-
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
Use of the satisfies
keyword removes require
statements when TS compiler invoked programmatically
#51642
Comments
This happens subtly when the asserted type itself is invalid (I'm guessing there's a constraint violation or just missing type in this example); we bail out of |
@RyanCavanaugh Thanks for sorting this so quickly and I'm glad it was an easy fix. However I'm not sure why you say the asserted type is invalid. In my example the code does not have any compiler errors and the |
Yep, hence this part:
When the compiler is invoked that way, my understanding is that it doesn't disable type checking, but it does disable resolving references and any type errors that result are simply suppressed. |
@fatcerberus Thanks for taking the time to explain it to me. I guess the compiler couldn't resolve references even if it wanted to because it is being invoked with an out-of-context string of source code. What an interesting edge case. |
Just mentioning this also occurs in with ts-node when using |
Yeah, I'm pretty sure using TS in transpile mode doesn't actually disable type checking, it just suppresses all the type errors. It's kind of like setting |
Bug Report
Use of the
satisfies
keyword changes the output of the compiler. Vitally importantrequire
statements are missing. Does not appear to happen when usingtsc
but only when invoking the compiler programmatically as is done byts-loader
from the WebPack project.🔎 Search Terms
satisfies, webpack, ts-loader, 4.9
🕗 Version & Regression Information
This bug only occurs when using the
satisfies
keyword.⏯ Playground Link
Unable to reproduce with Playground so here is a repo showing the issue:
https://github.com/cjdell/typescript-satisfies-missing-modules-references-bug
Also another repo showing the original discovery of the bug including a working WebPack setup and
ts-loader
plugin:https://github.com/cjdell/ts-loader-satisfies-bug
💻 Code
Note: This is fully demonstrated in the above GitHub repo.
Output with
satisfies
:Output without
satisfies
:🙁 Actual behavior
As with above, using the
satisfies
keyword results in missingrequire
statements.🙂 Expected behavior
I expect the use of the
satisfies
keyword to have no effect on the compiler's outputted JavaScript.The text was updated successfully, but these errors were encountered: