Skip to content

Commit

Permalink
Merge pull request #3680 from preactjs/fix-jsx-element
Browse files Browse the repository at this point in the history
undo jsx-element removal
  • Loading branch information
marvinhagemeister authored Aug 19, 2022
2 parents b7072ad + 0fd11bc commit 5362360
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export type ComponentProps<
: never;

export interface FunctionComponent<P = {}> {
(props: RenderableProps<P>, context?: any): ComponentChild;
(props: RenderableProps<P>, context?: any): VNode<any>;
displayName?: string;
defaultProps?: Partial<P>;
}
Expand Down
1 change: 1 addition & 0 deletions src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export namespace JSXInternal {
: never;
}[keyof IntrinsicElements]
| ComponentType<P>;
export interface Element extends VNode<any> {}
export type ElementClass = Component<any, any> | FunctionComponent<any>;

export interface ElementAttributesProperty {
Expand Down
31 changes: 16 additions & 15 deletions test/ts/preact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,22 @@ const UseOfComponentWithChildren = () => {
);
};

const DummyChildren: FunctionalComponent = ({ children }) => {
return children;
};

function ReturnChildren(props: { children: preact.ComponentChildren }) {
return props.children;
}

function TestUndefinedChildren() {
return (
<ReturnChildren>
<ReturnChildren>Hello</ReturnChildren>
</ReturnChildren>
);
}
// TODO: make this work
// const DummyChildren: FunctionalComponent = ({ children }) => {
// return children;
// };

// function ReturnChildren(props: { children: preact.ComponentChildren }) {
// return props.children;
// }

// function TestUndefinedChildren() {
// return (
// <ReturnChildren>
// <ReturnChildren>Hello</ReturnChildren>
// </ReturnChildren>
// );
// }

// using ref and or jsx
class ComponentUsingRef extends Component<any, any> {
Expand Down

0 comments on commit 5362360

Please sign in to comment.