Typescript: [ts] Could not find a declaration file for module in .js file (importing Vue ESM version)

Created on 7 Jun 2018  路  11Comments  路  Source: microsoft/TypeScript

51322 https://github.com/Microsoft/vscode/issues/51322#event-1668377362

VSCode Version: 1.24.0
OS Version: Fedora 28

Steps to Reproduce:

npm install vue
try to install the ESM module version of view:

import Vue from '../node_modules/vue/dist/vue.esm.browser.js';

and get error:

[ts]
Could not find a declaration file for module '../node_modules/vue/dist/vue.esm.browser.js'. '(various folders)/node_modules/vue/dist/vue.esm.browser.js' implicitly has an 'any' type.
  Try `npm install @types/vue` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue';`
module "(various folders)/node_modules/vue/dist/vue.esm.browser"

As this is a .js file, I assume it is an error that I now need to supply a declaration file? This just started to happen on the same file the moment after I updated to 1.24

Does this issue occur when all extensions are disabled?: Yes

Question

Most helpful comment

Still a problem for me at 1.24.1
Windows 10

All 11 comments

You might have better luck sharing this on StackOverflow. This is not a support forum, it is one for reporting compiler/language bugs and suggestions.
If you believe you are running into a compiler bug, please share a minimal repro project that demonstrates the issue you are running into and why you believe this is a compiler bug and not a declaration file issue or library usage problem.

I was told by a Microsoft employee on the vscode forum to post it here. Please see https://github.com/Microsoft/vscode/issues/51322#event-1668377362

I don't want any support, I would like to know why vscode is now asking me for something it was not in the previous version.

Might be related to (or even the same): https://github.com/Microsoft/TypeScript/issues/24781

Hi,

I was about to file a bug on VSCode Project but I found the original by @David-Else
I'm having the same problem. I'm getting error in my NodeJS files just after updating to VSCode 1.24 with TS 2.9. In my case I'm working on OSX 10.11.6.
Before updating VSCode was working fine. It could infer/find type defs for minio and a custom lib and intellisense was working just fine. But after the update it suddenly stopped working and I'm getting error messages such as:

[ts] Property 'bucketExists' does not exist on type 'Client'.

If I hover over the require I can read the next message:

[ts]
Could not find a declaration file for module 'minio'. '/<myProjectFolderPath>/node_modules/minio/dist/main/minio.js' implicitly has an 'any' type.
  Try `npm install @types/minio` if it exists or add a new declaration (.d.ts) file containing `declare module 'minio';`

Before the update VSCode was correctly resolving the type refs automatically and making Intellisense work like a charm. But now it's broken.

Here is the jsconfig.js file I have. I haven't changed anything on it. It was working fine before the update:

{
    "compilerOptions": {
        "target": "ES6",        
        "allowSyntheticDefaultImports": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "checkJs": true                  
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ]

}

Thank you in advance for any help/hint steps to follow.

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

It seemed to fix itself in 1.24.1

Still a problem for me at 1.24.1
Windows 10

I was wrong, it did not fix itself in 1.24.1! Fingers crossed for 1.25!!

Still the same, why a heck it treats _.js_ as _.ts_

We could use a repro here. The one posted by @mogarick has checkJs enabled and it's expected to see appropriate errors if checkJs is enabled.

Please log a new issue with repro steps if you are able to.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bgrieder picture bgrieder  路  3Comments

jbondc picture jbondc  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

siddjain picture siddjain  路  3Comments

seanzer picture seanzer  路  3Comments