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

"overload signature is not compatible" shows up more than once in the LS #49916

Closed
jakebailey opened this issue Jul 15, 2022 · 5 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros
Milestone

Comments

@jakebailey
Copy link
Member

jakebailey commented Jul 15, 2022

Bug Report

🔎 Search Terms

overload signature is not compatible language server vs code vscode diagnostic problem error

🕗 Version & Regression Information

Probably #40094. But, old TS had one error in 3.3, then 2 in 3.5, then 7 in 4.1+, so this isn't just one PR.

⏯ Playground Link

// @strict: true
// @errors: 2394

export interface Push<T> {
    push(...values: T[]): void;
    /* @internal*/ readonly length: number;
}

export function append<TArray extends any[] | undefined, TValue extends NonNullable<TArray>[number] | undefined>(to: TArray, value: TValue): [undefined, undefined] extends [TArray, TValue] ? TArray : NonNullable<TArray>[number][];
export function append<T>(to: T[], value: T | undefined): T[];
export function append<T>(to: T[] | undefined, value: T): T[];
export function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined;
export function append<T>(to: Push<T>, value: T | undefined): void;
export function append<T>(to: T[], value: T | undefined): T[] | undefined {
    if (value === undefined) return to;
    if (to === undefined) return [value];
    to.push(value);
    return to;
}

Workbench Repro

Playground Link

🙁 Actual behavior

Many, many errors, but only in the LS.

image

🙂 Expected behavior

One error about overload signatures not being correct.

@jakebailey
Copy link
Member Author

The errors go away if you get rid of export on everything, and #40094 made the check always occur: https://github.com/microsoft/TypeScript/pull/40094/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8R32219

Which is probably the problem, though I am confused as to how this error is not suppressed for being duplicated. Or why all positions are the same when it's each individual overload that should be checked.

@jakebailey
Copy link
Member Author

Thankfully testable using fourslash (but not a compiler test):

Semantic Diagnostics for file '/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts':
/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts(8,17): error TS2394: This overload signature is not compatible with its implementation signature.
/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts(8,17): error TS2394: This overload signature is not compatible with its implementation signature.
/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts(8,17): error TS2394: This overload signature is not compatible with its implementation signature.
/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts(8,17): error TS2394: This overload signature is not compatible with its implementation signature.
/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts(8,17): error TS2394: This overload signature is not compatible with its implementation signature.
/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts(8,17): error TS2394: This overload signature is not compatible with its implementation signature.
/tests/cases/fourslash/overloadNotCompatibleErrorDuplication.ts(8,17): error TS2394: This overload signature is not compatible with its implementation signature.

@jakebailey jakebailey added the Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros label Jul 15, 2022
@typescript-bot

This comment was marked as outdated.

@jakebailey

This comment was marked as outdated.

@jakebailey jakebailey added this to the Backlog milestone Sep 21, 2022
@jakebailey jakebailey added the Bug A bug in TypeScript label Sep 21, 2022
@jakebailey
Copy link
Member Author

Turns out this was fixed by #50309 (which I think has enough test coverage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Has Repro This issue has compiler-backed repros: https://aka.ms/ts-repros
Projects
None yet
Development

No branches or pull requests

2 participants