-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
TypeScript Version: 3.7.0-dev.20191013
Search Terms: Could not find a declaration file for module, Javascript imports, Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, Node, RequireJS, Node Modules
Code
test2.js:
import Transmission from 'transmission' // A package written in JS with no @types package
const api = new Transmission()Expected behavior:
I am writing in a Javascript file I do not expect to get any warnings about missing Typescript types on my imported packages. If the source file was test2.ts I would expect this warning.
Actual behavior:
A warning is shown:
Could not find a declaration file for module 'transmission'. '/tmp/test-js/node_modules/transmission/lib/transmission.js' implicitly has an 'any' type.
Try `npm install @types/transmission` if it exists or add a new declaration (.d.ts) file containing `declare module 'transmission';`ts(7016)
This is an interesting interaction between the fact that VSCode (and other editors) use tsserver to generate annotations, autocompletion... Generally when writing Javascript in VSCode you are not nagged to put types anywhere (and don't even have to be aware tsserver is running) except for in this case when you import a package written in Javascript that does not have a @types package.
It seems this behavior was introduced mid last year: 16fc256
Playground Link: N/A because files are implicitly *.ts in the typescript playground.
Related Issues: #24749 atom/ide-typescript#144
