Open Andarist opened 1 year ago
an intersection is being created based on all signatures with the same type arguments arity
Is it that, or is it just picking the last overload, similar to what happens with Parameters
?
IIRC what Iβve seen when debugging this - itβs an intersection, itβs not picking a single matching signature.
I think that it makes sense per the second part of this comment: https://github.com/microsoft/TypeScript/pull/51695#discussion_r1035795803 . Itβs just that when mapping those signatures reportErrors
was always set to true and non-matching signatures were not rejected
I went back to recheck the implementation, "intersection" definitely caught my eye somewhere around this code but it seems that it was in some different parts.
So this isn't actually becoming an intersection, but the effect is kinda similar - it's an object type with multiple signatures (and more): https://github.dev/microsoft/TypeScript/blob/70d5cb28275d35e45a0f84aa981b45e6fb059160/src/compiler/checker.ts#L33667-L33679
@ahejlsberg any thoughts?
What would need to happen from the TypeScript team perspective for this change to be accepted? It seems to be a very reasonable improvement and it also addresses a couple other problems (linked above).
Bug Report
π Search Terms
instantiation expression, overload
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
This instantiation expression errors despite the fact that a matching signature exists.
π Expected behavior
It sounds likely that most people would assume that this should work similarly to how overloads are chosen - but instead an intersection is being created based on all signatures with the same type arguments arity.
originally reported by @herjiict here