Closed
Description
TypeScript Version: 3.5.1
Search Terms:
- Tooltip
- Type resolution
- Emit
Code
TL;DR
Here are two video links that demonstrate the problem,
- Editing unrelated text causes resolution to fail, https://imgur.com/a/iXukNKS
- Order of resolution affects resolution success/failure, https://imgur.com/a/6H0eRqr
TODO Minimal repro
So, first, the set up,
- Clone https://github.com/AnyhowStep/tsql
- Checkout commit
6fcd75d9a9572c1c782db983c1c773282b37ce6a
npm install
- Open test/compile-time/input/table/as/long-chain.ts#L57
- Follow repro below (There's a video link below demonstrating repro)
The repro,
- Mouse over
aliasedTable
, resolves correctly - Mouse over
aliasedTable2
, resolves correctly - Type some random text
- Mouse over
aliasedTable2
, resolve toany
<-- Wtf? - Mouse over
aliasedTable
, resolve toany
<-- Wtf? - Delete the random text
- Mouse over
aliasedTable2
, resolve toany
<-- Wtf? - Mouse over
aliasedTable
, resolve toany
<-- Wtf?
Video link: https://imgur.com/a/iXukNKS
I tried to upload logs folowing instructions from #32086 (comment) but...
Expected behavior:
Type resolution should not flip-flop between correct results and any
Actual behavior:
Type resolution flip-flops between correct results and any
Playground Link:
TODO Minimal repro
Video link: https://imgur.com/a/iXukNKS
Related Issues:
Might be related to #32707
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Repro for microsoft/TypeScript#33067
AnyhowStep commentedon Aug 24, 2019
However, if you compile, the output will always emit correctly.
npm run test-compile-time
test/compile-time/actual-output/table/as/long-chain.d.ts
AnyhowStep commentedon Aug 24, 2019
This is also probably related,
#32573
Something about tsserver is probably caching some result or re-computing some result incorrectly =/
But tsc always starts from scratch (in this case) and doesn't have that problem
AnyhowStep commentedon Aug 24, 2019
Alternative repro,
Developer: Reload Window
aliasedTable2
first, resolves toany
aliasedTable
second, resolves toany
Developer: Reload Window
aliasedTable
first, resolves correctlyaliasedTable2
second, resolves correctlyVideo link: https://imgur.com/a/6H0eRqr
AnyhowStep commentedon Aug 24, 2019
Just speculating but this is how I would imagine a fix to be,
aliasedTable2
instantiationDepth
to zeroaliasedTable2
instantiationDepth
may changealiasedTable
aliasedTable2
'sinstantiationDepth
instantiationDepth
to zeroaliasedTable
instantiationDepth
may changealiasedTable
aliasedTable2
'sinstantiationDepth
instantiationDepth
may changealiasedTable2
Also speculating, this is what I imagine is happening right now,
aliasedTable2
instantiationDepth
to zeroaliasedTable2
instantiationDepth
may changealiasedTable
aliasedTable2
'sinstantiationDepth
aliasedTable
instantiationDepth
may changeany
aliasedTable
instantiationDepth
may changealiasedTable2
Then, when generating the tooltip for
aliasedTable
, it re-uses the earlier cached result.And that is why we see
any
when resolvingaliasedTable2
before resolvingaliasedTable
sandersn commentedon Jan 13, 2020
I tried the first repro and the Reload Window repro and couldn't get either to work with 3.8 or 3.5. Notably, I had to
npm run build
before the file had no errors, because otherwisedist
doesn't exist. That's the only difference from the instructions you gave.sandersn commentedon Jan 13, 2020
Ah, I watched the video and I see that it's not the whole type that becomes any;
columns[string]["mapper"]
just becomestm.Mapper<unknown, any>
instead oftm.Mapper<unknown, bigint>
I got the second repro to work, where you request the type of aliasedTable2 first.
I can't tell whether the repro works on 3.8 because the type is
tm.SafeMapper<bigint>
in both cases.sandersn commentedon Jan 13, 2020
I guess the next step is to minimise the 3.5 repro to eliminate the variability in Mapper vs SafeMapper.
sandersn commentedon Jan 13, 2020
Never mind, 3.8 is just better at retaining type aliases;
SafeMapper
is justMapper
with the first parameter fixed (which is the one without an error). This is either fixed in 3.8 or needs a different repro.