Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#69365 Add type variables to SenderPort and…
Browse files Browse the repository at this point in the history
… ReceiverPort in react-elm-components by @akselw
  • Loading branch information
akselw authored Apr 16, 2024
1 parent 709bec4 commit 7f801fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions types/react-elm-components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ declare namespace Elm {
init: ({ node, flags }: { node: HTMLElement; flags: any }) => any;
}

interface SenderPort {
send: (data: any) => void;
interface SenderPort<Data> {
send: (data: Data) => void;
}
interface ReceiverPort {
subscribe: (callback: (value: any) => void) => void;
interface ReceiverPort<Value> {
subscribe: (callback: (value: Value) => void) => void;
}
interface Ports {
[x: string]: SenderPort | ReceiverPort;
[x: string]: SenderPort<any> | ReceiverPort<any>;
}
}

Expand Down
7 changes: 6 additions & 1 deletion types/react-elm-components/react-elm-components-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ function App() {
}

function AppWithPorts() {
return <Elm src={Elm19Mock.main} ports={(ports: Record<string, any>) => {}} />;
return (
<Elm
src={Elm19Mock.main}
ports={(ports: Record<string, Elm.SenderPort<{ value: number }> | Elm.ReceiverPort<string>>) => {}}
/>
);
}

function AppWithFlags() {
Expand Down

0 comments on commit 7f801fd

Please sign in to comment.