Skip to content

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

Open

Description

@dunhor

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 {
                 ~~~~~~~~~~

Activity

  1. added
    bugSomething isn't working
    typescriptBugs/issues/feature asks for typescript generation
    on Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtypescriptBugs/issues/feature asks for typescript generation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions