Repository navigation
Add elaboration when call fails all overloads but succeeds against the implementation signature - #41001
Conversation
…e implementation signature
Nathan Shively-Sanders (sandersn)
left a comment
There was a problem hiding this comment.
Couple of questions about the technique you used.
I also wish there was some way to estimate how many times people will see this new error. Any ideas there?
| relatedInformation.length ? | ||
| relatedInformation.map(r => convertToDiagnosticRelatedInformation(r, newProgram, toPath)) : | ||
| emptyArray : | ||
| [] : |
There was a problem hiding this comment.
did we ever figure out what the performance impact of [] vs emptyArray is? Last I heard is that [] is better?
There was a problem hiding this comment.
...eh? In this case, it's just because we mutate relatedInformation in some places, so using a global singleton is bad.
| const candidate = getSignatureFromDeclaration(implDecl as FunctionLikeDeclaration); | ||
| const isSingleNonGenericCandidate = !candidate.typeParameters; | ||
| if (!!chooseOverload([candidate], assignableRelation, isSingleNonGenericCandidate)) { | ||
| addRelatedInfo(d, createDiagnosticForNode(implDecl, Diagnostics.The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible)); |
There was a problem hiding this comment.
does this mutate the related list? (and is that why you clone into related above?)
There was a problem hiding this comment.
addRelatedInfo, as the name implies, has always appended to the existing list.
Pretty often - almost any overload error where the overload being compiled against is actually in your source code (and thus has a body) rather than a library. |
Yeah, people on the VS Code team hit this, and it's a beginner mistake. If you don't hear about it much, it's because you bang your head on it for a bit and then figure it out. |
| !!! error TS2769: Overload 2 of 2, '(bar: number): number', gave the following error. | ||
| !!! error TS2769: Argument of type 'boolean' is not assignable to parameter of type 'number'. No newline at end of file | ||
| !!! error TS2769: Argument of type 'boolean' is not assignable to parameter of type 'number'. | ||
| !!! related TS2793 tests/cases/compiler/functionOverloads2.ts:3:10: The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible. No newline at end of file |
There was a problem hiding this comment.
😍
|
Causes crashes in Definitely Typed -- see types/agent-base for example. I'll file a bug. |
Fixes #4797