-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TypeScript includes declaration merges from declaration file in typeRoots without import #20610
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
|
I see, then everything is as expected. Is this behavior documented somewhere, though? Personally I found it a bit unituitive. |
There is http://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types although we aren't doing a good job of specifying what "included" means. Imported modules don't need to be included, just global definitions. |
So does it then mean that the structure of the @types folder is irrelevant? By default every node_modules/@types/foobar/index.d.ts is included? I fooled myself into thinking that whether they are included or not would be controller by the import statements in your code, because the @types structure reflects the actual package names that you import. |
We normally automatically look through |
Gotcha, thanks |
TypeScript Version: 2.7.0-dev.201xxxxx
Context
I am trying to create a local type declaration file for winston-papertrail that adds a new property to winston.transports.Papertrail. There is a @types/winston but no @types/winston-papertrail. Requiring "winston-papertrail" should augment winston.transports to also contain this additional Papertrail property. My assumption was that types inside of 'typeRoots' do not take effect until after the corresponding import statement has been made.
I am able to make it work by doing the following:
Code
The main file is index.ts:
tsconfig.json:
types/winston-papertrail/index.d.ts:
Expected behavior:
The expected behavior is that the
Papertrail
property is NOT showing up in the autocompletion suggestions for properties on thewinston.transports
value since I haven't imported "winston-papertrail" yet.Actual behavior:
The
Papertrail
property is showing up in the autocompletion suggestions.The text was updated successfully, but these errors were encountered: