Conditionally Mapped Type Leads to Confusing ts(2345) Error Message #40550
Labels
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version:
3.9.6
4.1.0-dev.20200914
Search Terms:
2345
conditional
Code
You can find this gnarly type here:
TypeScript/tests/cases/conformance/types/conditional/conditionalTypes2.ts
Line 227 in 94d4023
The following consuming/using code correctly generates
ts(2345)
errors for the last two lines:Expected behavior:
In
[email protected]
&[email protected]
(and a few earlier versions I tried) the error message for both lines is:Actual behavior:
In
typescript@^3.9.6
this is reported for both lines:That's correct (nice even!) for the
callA()
line, but it's confusing for thecallB()
line.(This reproduction is a single file that can run into this problem... it's not how I ran into it. I had a
ts.Program
with many 10s of*.ts
files in the same compilation and the message was referring to some type that made no sense in the source file that was giving me the error.)Playground Link:
https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAXAngBwQcRIgCjA9ujCgHJQC2IAzgPIBmAKmiADwMA08AStYjAJZhEDfE3QA+eAF54AbwCwAKACQAbQDS8fgDt4AaxDJ8deAwC6ALlMaz8EAA9EIbcCrdeAoSLEIA-PE0rbRAANxAYAG4lAF9VAyMTcyjFJR0nGDooMAQAQTklZTgARysqPh0Ac2TlbQBXciD6gCNw6rKYUvLtKpjU7XTM7PgAIXyVYs6Bbuq68l9G8hbIgvb5+HbK5OilJVBIWAQ6Wu0hfnxdMCgICByACm0KECssXAIiUkfaRmYWHM4N7riACUVhC+H4wGSe2gcHgRxOiDOFyuEGG90ez2weEI4Q+lC+PhYPCKtX4cGALGG4n+XQqwNB4MhO0UYHOZXgqDe0ngACIqPhKOpDDzkpdrndOYQgRF4AB6WVIKi3ABMAGYACwAViBSjFqNuktQ0rlCsQSrVWp1iiAA
Related Issues:
I found reference to the gnarly type above in #32608 & #33568.
It looks to be the same "monster" as you see in #29505 too.
The text was updated successfully, but these errors were encountered: