Skip to content

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

Closed
@shengslogar

Description

@shengslogar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions