-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[regression - 5.4] Generated .d.ts
file contains invalid types
#57843
Comments
.d.ts
file contains invalid type names.d.ts
file contains invalid types
Update: This is a regression in TS5.4 In TS5.3 the emitted |
.d.ts
file contains invalid types.d.ts
file contains invalid types
I've got a repro repo for testing too.
Bisecting it looks like the first release that exhibited this bug was |
If you hadn't tried it yet, https://www.npmjs.com/package/every-ts can bisect further down from the nightly versions. |
Yup - 100% confirmed. |
I patched #57396 locally and it looks like it fixes the regression |
π Search Terms
error "generic type" "requires" "type argument(s)" declaration .d.ts emit
π Version & Regression Information
β― Playground Link
bug workbench link
π» Code
π Actual behavior
The code emitted for
repro.d.ts
isThis code has two type errors (on lines 2-6 and 7-11 respectively):
Note how the generated type uses
TwentyNine
on L2 andTwentyEight
on L7.These are the incorrect types to use (see below)
π Expected behavior
The types generate valid code with no semantic errors.
For example intellisense reports this type for
bar
which is validNote how this type instead uses
ThirtySix
on L2 andThirtyFive
on L7.Additional information about the issue
Sorry that this example is so goddamn disgusting to look at.
This is the name-mangled version of some real code from our codebase.
I tried to minimise it but it's all such an intermingled spaghetti mess that I wasn't able to figure out what things I could delete without changing the output.
For context - I am working on upgrading our codebase to TS5.4.
When I ran our typecheck CLI I got a number of errors across the codebase.
When I opened the files with errors - those errors didn't show up in the IDE.
I spent a while pulling my hair out trying to figure out why there was a discrepancy.
The error messages led me back to a monster file which makes use of some really ugly patterns of inferred types from
typeof
s to generate a lot of types. For reference the file itself is >3k LOC and the.d.ts
file it generates is >11k LOC. So so so many anonymous, inferred types.When I opened the
.d.ts
file it was filled with type errors. From what I can tell what's happening is that when you open the files with errors in the IDE then TS uses the.ts
source files for type checking and so it uses the "correct" type for everything. When we run our CLI to do the typecheck it uses project references and so it uses the.d.ts
output instead.Because the
.d.ts
output doesn't match the types TS infers from the.ts
file this causes the discrepancy between the reported errors.I think a most (if not all) of the errors in the
.d.ts
file are variations of the error shown by this repro but it's so hard to know as there are hundreds of them.Note: I didn't write this code and I hate that it exists. I am sorry.
The text was updated successfully, but these errors were encountered: