TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

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

Open jakebailey opened this issue 3 years ago • 4 comments

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 avatar Jul 15 '22 02:07 jakebailey

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 avatar Jul 15 '22 04:07 jakebailey

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 avatar Jul 15 '22 04:07 jakebailey

:wave: Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript.


Issue body code block by @jakebailey

:x: Failed: -

  • This overload signature is not compatible with its implementation signature.
Historical Information
Version Reproduction Outputs
4.3.2, 4.4.2, 4.5.2, 4.6.2, 4.7.2

:x: Failed: -

  • This overload signature is not compatible with its implementation signature.
  • This overload signature is not compatible with its implementation signature.
  • This overload signature is not compatible with its implementation signature.
  • This overload signature is not compatible with its implementation signature.
  • This overload signature is not compatible with its implementation signature.
  • This overload signature is not compatible with its implementation signature.
  • This overload signature is not compatible with its implementation signature.

typescript-bot avatar Jul 15 '22 23:07 typescript-bot

@typescript-bot bisect good v3.3.3 bad v3.5.1

jakebailey avatar Jul 15 '22 23:07 jakebailey

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

jakebailey avatar Jan 15 '23 05:01 jakebailey