Skip to content

fix: Add missing dependency @babel/types#9924

Closed
elliottsj wants to merge 1 commit intobabel:masterfrom
elliottsj:add-missing-babel-types
Closed

fix: Add missing dependency @babel/types#9924
elliottsj wants to merge 1 commit intobabel:masterfrom
elliottsj:add-missing-babel-types

Conversation

@elliottsj
Copy link
Contributor

Q                       A
Fixed Issues? N/A
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link N/A
Any Dependency Changes? Yes
License MIT

This fixes an issue where '@babel/types' cannot be resolved when using
strict package managers like pnpm, e.g.

/path/to/project/node_modules/.registry.npmjs.org/@babel/parser/7.4.4/node_modules/@babel/parser/typings/babel-parser.d.ts
ERROR in /path/to/project/node_modules/.registry.npmjs.org/@babel/parser/7.4.4/node_modules/@babel/parser/typings/babel-parser.d.ts(11,71):
TS2307: Cannot find module '@babel/types'.

> Build error occurred
Error: > Build failed because of webpack errors
    at Object.build [as default] (/path/to/project/node_modules/.registry.npmjs.org/next/8.1.0_react-dom@16.8.6+react@16.8.6/node_modules/next/dist/build/index.js:192:15)

This fixes an issue where '@babel/types' cannot be resolved when using
strict package managers like pnpm, e.g.

    /path/to/project/node_modules/.registry.npmjs.org/@babel/parser/7.4.4/node_modules/@babel/parser/typings/babel-parser.d.ts
    ERROR in /path/to/project/node_modules/.registry.npmjs.org/@babel/parser/7.4.4/node_modules/@babel/parser/typings/babel-parser.d.ts(11,71):
    TS2307: Cannot find module '@babel/types'.

    > Build error occurred
    Error: > Build failed because of webpack errors
        at Object.build [as default] (/path/to/project/node_modules/.registry.npmjs.org/next/8.1.0_react-dom@16.8.6+react@16.8.6/node_modules/next/dist/build/index.js:192:15)
@loganfsmyth
Copy link
Member

Hmm, I don't think this is the right fix. The only place in the parser that uses @babel/types is the type definitions, so adding a whole extra dependency that isn't used at runtime isn't ideal.

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10748/

@elliottsj
Copy link
Contributor Author

elliottsj commented Apr 30, 2019

TypeScript depends on npm to install dependencies for type declarations, as described on https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#dependencies:

All dependencies are managed by npm. Make sure all the declaration packages you depend on are marked appropriately in the "dependencies" section in your package.json.

Although I have noticed that babel-parser.d.ts is the only declaration file in the babel repo. Maybe it makes sense to move it over to https://github.com/DefinitelyTyped/DefinitelyTyped?

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants