Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript interfaces that "extend" another interface and overload a function on the base interface causes a tsc error #114

Open
dunhor opened this issue Aug 20, 2021 · 0 comments
Labels
bug Something isn't working typescript Bugs/issues/feature asks for typescript generation

Comments

@dunhor
Copy link
Member

dunhor commented Aug 20, 2021

E.g. the definition of IWebSocket gets generated as:

    interface IWebSocket extends Windows.Foundation.IClosable {
        readonly outputStream: Windows.Storage.Streams.IOutputStream;
        connectAsync(uri: Windows.Foundation.Uri): Windows.Foundation.WinRTPromise<void, void>;
        setRequestHeader(headerName: string, headerValue: string): void;
        close(code: number, reason: string): void;
        addEventListener(type: "closed", listener: Windows.Foundation.TypedEventHandler<Windows.Networking.Sockets.IWebSocket, Windows.Networking.Sockets.WebSocketClosedEventArgs>): void;
        removeEventListener(type: "closed", listener: Windows.Foundation.TypedEventHandler<Windows.Networking.Sockets.IWebSocket, Windows.Networking.Sockets.WebSocketClosedEventArgs>): void;
    }

Which produces the following error because IClosable declares the function close(): void

windows/WinRTTurboModule/Generated Files/types/Windows.Networking.Sockets.d.ts:65:15 - error TS2430: Interface 'IWebSocket' incorrectly extends interface 'IClosable'.
  Types of property 'close' are incompatible.
    Type '(code: number, reason: string) => void' is not assignable to type '() => void'.

65     interface IWebSocket extends Windows.Foundation.IClosable {
                 ~~~~~~~~~~
@dunhor dunhor added bug Something isn't working typescript Bugs/issues/feature asks for typescript generation labels Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript Bugs/issues/feature asks for typescript generation
Projects
None yet
Development

No branches or pull requests

1 participant