Skip to content

@vue/compiler-core import @babel/types in type definition but missing in dependencies #6891

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

Closed
trim21 opened this issue Oct 16, 2022 · 3 comments

Comments

@trim21
Copy link

trim21 commented Oct 16, 2022

Vue version

3.2.41

Link to minimal reproduction

https://github.com/trim21/vue-compile-core-missing-deps

there is a vue type shim

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

Steps to reproduce

git clone https://github.com/trim21/vue-compile-core-missing-deps
cd vue-compile-core-missing-deps
npm i
npx tsc --noEmit

What is expected?

tsc type checking ok

What is actually happening?

[00:45:25] Starting compilation in watch mode...

node_modules/@babel/parser/typings/babel-parser.d.ts:14:23 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

14 ): ParseResult<import("@babel/types").File>;
                         ~~~~~~~~~~~~~~

node_modules/@babel/parser/typings/babel-parser.d.ts:22:23 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

22 ): ParseResult<import("@babel/types").Expression>;
                         ~~~~~~~~~~~~~~

node_modules/@vue/compiler-core/dist/compiler-core.d.ts:1:57 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

1 import type { BlockStatement as BlockStatement_2 } from '@babel/types';
                                                          ~~~~~~~~~~~~~~

node_modules/@vue/compiler-core/dist/compiler-core.d.ts:2:45 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

2 import type { Function as Function_2 } from '@babel/types';
                                              ~~~~~~~~~~~~~~

node_modules/@vue/compiler-core/dist/compiler-core.d.ts:4:33 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

4 import type { Identifier } from '@babel/types';
                                  ~~~~~~~~~~~~~~

node_modules/@vue/compiler-core/dist/compiler-core.d.ts:5:37 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

5 import type { Node as Node_3 } from '@babel/types';
                                      ~~~~~~~~~~~~~~

node_modules/@vue/compiler-core/dist/compiler-core.d.ts:6:37 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

6 import type { ObjectProperty } from '@babel/types';
                                      ~~~~~~~~~~~~~~

node_modules/@vue/compiler-core/dist/compiler-core.d.ts:8:30 - error TS2307: Cannot find module '@babel/types' or its corresponding type declarations.

8 import type { Program } from '@babel/types';
                               ~~~~~~~~~~~~~~

[00:45:27] Found 8 errors. Watching for file changes.

System Info

doesn't matter

Any additional comments?

This is fixed with @babel/types in deps.

@sxzz
Copy link
Member

sxzz commented Oct 16, 2022

It's by design I think. If you need TypeScript support then install it by yourself.


You can enable skipLibCheck in tsconfig

mcenkar added a commit to mcenkar/core-vue that referenced this issue Mar 15, 2024
fixes: vuejs#5625, vuejs#6891, vuejs#8917

Moved @babel/types from dev dependencies to normal dependencies. In this case
npm will correctly resolve dependency under configurations described in related
issues.
@mcenkar
Copy link

mcenkar commented Mar 15, 2024

I added PR #10533 solving issue. It seems to come back here a lot (already 3 issues: #5625, #8917, and this) and technically if compiler-core depends on library it should have it in dependencies (as in my PR).

Requiring from users adding dev dependencies of some of their dependencies creates confusion, and after some time you end up with a lot of dependencies where you don't know anymore if it's needed or was added to fix some missing transitive dep.

@haoqunjiang
Copy link
Member

See #10533 (comment)

@haoqunjiang haoqunjiang closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants