-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
when importing d.ts file, it should have a better error message #4267
Comments
This is expected behaviour. There is no code to run in a Doing a namespace import, you are referencing types in that file, bringing them into the other file and referencing them. There is still no JavaScript emit from those files, but it brings those types into the type checking of another TypeScript file, and so is valid. What is the use case? The only "valid" use case is potentially having a |
|
I know there are few use cases for that situation. I just feel it's strange that valid typescript file can't be imported. I think running I met this situation on #4197 . I tried to apply |
I agree that it needs a better error message. Maybe you can provide some fake sample output of what you'd expect to happen and then it will be easier for us to implement it. |
I had an additional thought about the: import "something.d.ts"; This is the signal to the TS compiler to not drop the module from the emit because it has runtime side effects. This is theb not removing it from the emit, which is what occurs when it is a named import (because TypeScript realises it is types only and can be dropped). Deno then comes along, being told to load a file that didn't get emitted from the compiler, so it is a cache miss. I believe in TS 3.8 there is the a type only import, which I believe might make the use case work without using some other triple slash directive. |
@bartlomieju fixed this a while ago. We just emit an empty module for d.ts files now. Duplicate of #6746 which is closed |
404, Not found (I'm looking for a good starting place for *.jsx, skimming everything!) |
Documents move... updating comments in closed issues is usually not done. Here is the link though: https://deno.land/manual@v1.5.2/getting_started/typescript#using-external-type-definitions |
.d.ts
file can't be compiled when it is executed from CLI.Import without declaration cause same error.
some.ts
With declaration, no error.
The text was updated successfully, but these errors were encountered: