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

Restore @babel/types support for old TS versions #12521

Merged
merged 2 commits into from
Dec 17, 2020

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Dec 17, 2020

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

This PR swaps lib/index.d.ts and lib/index-ts3.7.d.ts in @babel/types. By doning so, older TS version that don't support the typesVersion option in package.json (it has been introduced in 3.1, but it seems not to work correctly in 3.2) will still get a working .d.ts file.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: typescript pkg: types i: regression labels Dec 17, 2020
@babel-bot
Copy link
Collaborator

babel-bot commented Dec 17, 2020

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

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a8143af:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@zxbodya
Copy link
Contributor

zxbodya commented Dec 17, 2020

might be a bit more light weight option to try - would it fix the problem if we just add types field pointing to legacy types(I think that is supported in old versions), and typesVersion with proper rules for newer versions already supporting it?

@nicolo-ribaudo
Copy link
Member Author

Oh that's a good idea

@zxbodya
Copy link
Contributor

zxbodya commented Dec 17, 2020

Oh that's a good idea

just tried it locally with typescript 3.1 - it works 😄

@nicolo-ribaudo
Copy link
Member Author

Updated to use types. I still renamed index-ts3.7.d.ts to index-legacy.d.ts, since the types it contains are not compatible with TS 3.7.

"<3.7": {
"lib/index.d.ts": [
"lib/index-ts3.7.d.ts"
">=3.7": {
Copy link
Contributor

@zxbodya zxbodya Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be < ?

Copy link
Member Author

@nicolo-ribaudo nicolo-ribaudo Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No: types points to the index-legacy.d.ts file for old TS versions. For new TS versions, (>= 3.7), we remap it back to index.d.ts.

@nicolo-ribaudo nicolo-ribaudo merged commit b9deeb4 into babel:main Dec 17, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the fix-types-ts-regression branch December 17, 2020 17:34
@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 Mar 19, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: types PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@babel/types 7.12.11 causes syntax error on TypeScript 3.2.4
5 participants