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

[v2.1.2] Type checking fails when compilerOptions.skipLibCheck is false #4766

Closed
shengslogar opened this issue Aug 30, 2024 · 2 comments · Fixed by #4767
Closed

[v2.1.2] Type checking fails when compilerOptions.skipLibCheck is false #4766

shengslogar opened this issue Aug 30, 2024 · 2 comments · Fixed by #4767
Labels
bug Something isn't working

Comments

@shengslogar
Copy link

shengslogar commented Aug 30, 2024

Vue - Official extension or vue-tsc version

2.1.2

VSCode version

N/A

Vue version

3.4.38

TypeScript version

5.4.5

System Info

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.39 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.volta/tools/image/node/20.14.0/bin/node
    Yarn: 4.3.0 - ~/.volta/tools/image/yarn/4.3.0/bin/yarn
    npm: 10.7.0 - ~/.volta/tools/image/node/20.14.0/bin/npm
  Browsers:
    Chrome: 128.0.6613.86
    Safari: 17.6

package.json dependencies

{
  "dependencies": {
    "vue": "^3.4.29"
  },
  "devDependencies": {
    "@tsconfig/node20": "^20.1.4",
    "@types/node": "^20.14.5",
    "@vitejs/plugin-vue": "^5.0.5",
    "@vue/tsconfig": "^0.5.1",
    "npm-run-all2": "^6.2.0",
    "typescript": "~5.4.0",
    "vite": "^5.3.1",
    "vue-tsc": "^2.0.21"
  }
}

Steps to reproduce

  1. Follow Vue quickstart to create a new project with TypeScript (I ran yarn dlx create-vue@latest)
  2. Add "compilerOptions.skipLibCheck": false to tsconfig.app.json
  3. Run package.json type-check script (yarn type-check)

What is expected?

No errors and a success message, e.g ✨ Done in 1.14s..

What is actually happening?

Type errors coming out of node_modules/vue/dist/__globaltypes_3.4_false.d.ts:

yarn run v1.22.19
$ vue-tsc --build --force
node_modules/vue/dist/__globaltypes_3.4_false.d.ts:2:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

2 const __VLS_globalComponents = { ...{} as import('vue').GlobalComponents };
  ~~~~~

node_modules/vue/dist/__globaltypes_3.4_false.d.ts:2:32 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

2 const __VLS_globalComponents = { ...{} as import('vue').GlobalComponents };
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/vue/dist/__globaltypes_3.4_false.d.ts:2:57 - error TS2694: Namespace '"/Users/sheng/dev/vue-repro/node_modules/vue/dist/vue"' has no exported member 'GlobalComponents'.

2 const __VLS_globalComponents = { ...{} as import('vue').GlobalComponents };
                                                          ~~~~~~~~~~~~~~~~

node_modules/vue/dist/__globaltypes_3.4_false.d.ts:5:50 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

5 declare const __VLS_directiveBindingRestFields = { instance: null, oldValue: null, modifiers: null as any, dir: null as any };
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 4 errors.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Link to minimal reproduction

https://github.com/shengslogar/vuejs-language-tools-issue-4766

Any additional comments?

Since vue-cli configures projects to skipLibCheck: true by default (vuejs/vue-cli#5688), this is not a show-stopping bug, but still an unexpected one that only appears after upgrading from v2.0.29 to v2.1.0 and persists in v2.1.2.

@shengslogar shengslogar changed the title [v2.1.2] type-check fails when compilerOptions.skipLibCheck is false [v2.1.2] Type checking fails when compilerOptions.skipLibCheck is false Aug 30, 2024
@davidmatter davidmatter added bug Something isn't working and removed pending triage labels Aug 30, 2024
@ramseyfeng
Copy link

Is this issue be fixed?

@shengslogar
Copy link
Author

@ramseyfeng tagged v2.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants