Skip to content
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

Cannot find module './App.vue' or its corresponding type declarations.ts(2307) #48651

Closed
jackyking-cn opened this issue Apr 12, 2022 · 10 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@jackyking-cn
Copy link

Bug Report

Cannot find module './App.vue' or its corresponding type declarations.ts(2307)
9db4477743614b5bb4081afac29de4c8
f80e7d9e60cb43ea805ca7da80cf4688

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

Visual Studio Code@1.66.1
typescript@4.6.3

⏯ Playground Link

πŸ’» Code

tsconfig.json:

{
  "extends": "@vue/tsconfig/tsconfig.web.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "exclude": ["src/**/__tests__/*", "src/**/*.spec.ts", "src/**/*.test.ts"],
  "compilerOptions": {
    "allowJs": true,
    "composite": true,
    "baseUrl": ".",
    "outDir": "./dist/",
    "paths": {
      "@/*": ["./src/*"]
    },
    "types": ["element-plus/global"]
  }
}

πŸ™ Actual behavior

πŸ™‚ Expected behavior

@jarrettmeyer
Copy link

I think this is a VSCode bug, not a TypeScript bug. I saw this problem for the first time yesterday on a working project. I can confirm that this bug appears on a TS/Vue project created with npm init vue. (Say "yes" to TypeScript and say "no" to everything else when prompted.) The only files with errors are *.vue files. The npm commands lint, typecheck, dev, and build all work as expected. The only problem is the red squiggle line in VSCode.

@xiaoxiangmoe
Copy link
Contributor

You should install TypeScript Vue Plugin and Vue Language Features.

@jackyking-cn
Copy link
Author

jackyking-cn commented Apr 12, 2022

I find this issues vuejs/language-tools#1173 ,this is problem of Voler.
But, I include others file extension, like *.sass , it’s still tip 2307.
So, typescript not support others file extension?

https://www.typescriptlang.org/zh/tsconfig#include

If a glob pattern doesn’t include a file extension, then only files with supported extensions are included (e.g. .ts, .tsx, and .d.ts by default, with .js and .jsx if allowJs is set to true).

I think this means typescript support others file extension.

@RyanCavanaugh RyanCavanaugh added the External Relates to another program, environment, or user action which we cannot control. label Apr 12, 2022
@RyanCavanaugh
Copy link
Member

It looks like this is a question rather than a bug report. This issue tracker is for tracking bugs and active work on TypeScript itself, rather than a general forum for programmers using TypeScript to get help or ask questions.

You can ask questions on sites like Stack Overflow. We are not able to provide one-on-one support on the issue tracker. Please read the issue template carefully - it has important information on what kinds of reports can be acted on here, as well as links to useful TypeScript resources. Thanks!

@jackyking-cn
Copy link
Author

Thanks everyone. let's wating Volar fix it.

@xjiabin
Copy link

xjiabin commented Oct 25, 2022

You should install TypeScript Vue Plugin and Vue Language Features.

Th. It works for me!

@MasterShi
Copy link

MasterShi commented Dec 2, 2022

create a file under the root of project dir and name it such like 'shims.d.ts' could solve

content:
declare module '*.vue' { import type { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> export default component }

@NguyenKyThinh94
Copy link

Still have same proplem with Volar

@riccardolardi
Copy link

I'm still having this issue using Sublime and the LSP-Volar package https://github.com/sublimelsp/LSP-volar

@abaumg
Copy link

abaumg commented Feb 9, 2023

You should install TypeScript Vue Plugin and Vue Language Features.

Please note that in the description of the TypeScript Vue Plugin extension, it says:

⚠️ It's recommended to use take over mode instead of this plugin.

So if you're using VS Code + Volar, you should enable the Takeover Mode instead of installing the extension. It is also mentioned in the Vue documentation: https://vuejs.org/guide/typescript/overview.html#volar-takeover-mode

(BTW, the identifier changed from johnsoncodehk.vscode-typescript-vue-plugin to vue.vscode-typescript-vue-plugin.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

9 participants