Skip to content

Inconsistent error for merging an identical method and callback #1192

@LukeAbby

Description

@LukeAbby

For some reason stable TS accepts this:

interface Foo {
    foo(x: any): void;
    foo: (x: any) => void;
}

With no error.

However stable TS does NOT accept this:

interface Foo {
    foo: (x: any) => void;
    foo(x: any): void;
}

With the error Duplicate identifier 'foo'. twice.

Meanwhile TSGo does not accept either of these. I would not raise this as an issue if it weren't for two facts:

  • I observed this actually happening with real code; @types/chai and vitest declare containSubset(val: any, exp: any, msg?: string): void; and containSubset: (val: any, exp: any, msg?: string) => void; respectively
  • TSGo is aiming to be a 1:1 port so even weird behavior like this should be supported.

I would actually support revisiting these semantics such that either both are an error (like it is here) or neither are an error. I find the fact that order matters here surprising. If that is the decision I would like a clear answer so I can file an issue against packages with this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions