Skip to content

Commit

Permalink
TS: Add key to all jsx elements (#1887)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister authored Aug 20, 2019
1 parent 372c62f commit d423e0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export namespace JSXInternal {
? Defaultize<Props, Defaults>
: Props;

interface IntrinsicAttributes {
key?: any;
}

interface Element extends preact.VNode<any> {
}

Expand Down
8 changes: 8 additions & 0 deletions test/ts/Component-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ class StaticComponent extends Component<SimpleComponentProps, SimpleState> {
}
}

function MapperItem(props: { foo: number }) {
return <div />;
}

function Mapper() {
return [1, 2, 3].map(x => <MapperItem foo={x} key={x}/>)
}

describe("Component", () => {
const component = new SimpleComponent({ initialName: "da name" });

Expand Down

0 comments on commit d423e0c

Please sign in to comment.