-
Notifications
You must be signed in to change notification settings - Fork 12.8k
ignoring custom typescript dts type definition files for javascript modules #39709
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
Comments
This sounds like a configuration error, not a bug. We can investigate if this is reduced to just a set of files that clearly demonstrates a defect |
Please see the example repository I linked in the first reproduction step. That is a pretty minimal project that demonstrates the issue. That also happens to demonstrate this issue: #35296. If this is a configuration issue, I'd love if you can show me where my configuration error is. Note that the project builds and runs just fine from the command line. The problem is that VS Code does not use the definition files in the |
@RyanCavanaugh what more information do you need for this issue? |
@RyanCavanaugh I don't think it is a configuration error, but I don't know the degree to which it's in scope. The basic scenario is a codebase with project references, where one project dependency has That means that the depending project sees the TypeScript-generated @restjohn, can you confirm that that's what you're seeing? I guess one workaround is to have your build scripts re-inject the One thing we could potentially do is copy corresponding |
Thanks for your response @DanielRosenwasser. Your description of the symptoms seems correct on the surface, though I reiterate that the project builds from the command line with If you examine the project in the linked repository, you'll see that the build script does what you say and injects the Additionally, you'll see from my comments in the linked related issue that the workaround of copying |
Is there any progress on this. I have two files:
tsc ignores the source file file.d.ts, and creates a new file.d.ts with the contents "export {};" Subsequently, when ng build runs, it claims that "import * as X from 'file'" doesn't export anything because (I assume) the tsc generated file.d.ts is always empty with "export {};". |
The common thread here is that |
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Uh oh!
There was an error while loading. Please reload this page.
TS Template added by @mjbvz
TypeScript Version: 3.9.7
Search Terms
Issue Type: Bug
test/legacy.test.ts
file.Expected result
VS Code should not report any errors in
test/legacy.test.ts
.Actual result
VS Code applies an error annotation where the file references the
legacy.FooOptions
type:Namespace '"/<path_omitted>/typescript_custom_dts_issue/src/legacy"' has no exported member 'FooOptions'.ts(2694)
.The
FooOptions
type is declared in thesrc/legacy.d.ts
custom type definition file. The NPM scriptbuild:copy_types
copies that custom type declaration file to thelib
directory, which is theoutDir
configured insrc/tsconfig.json
. VS Code appears to ignore that type definition file. Note that importing thelegacy
module in the test file using../src/legacy
removes the error annotation, but the test generates a runtime error that the module../src/legacy
cannot be found because of course Node cannot load a.ts
TypeScript module.I thought perhaps source maps might be causing VS Code to ignore the definition file in the
lib
directory, but deleting the source maps and reloading the project did not resolve the issue. Could this have something to do with VS Code attempting to account for the project reference fromtest/tsconfig.json
tosrc/tsconfig.json
?I have also used the Insider version of VS Code to test and reproduce this issue.
VS Code version: Code 1.47.2 (17299e413d5590b14ab0340ea477cdd86ff13daf, 2020-07-15T18:18:50.054Z)
OS version: Darwin x64 19.5.0
System Info
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Extensions (47)
The text was updated successfully, but these errors were encountered: