Skip to content

Harden variable declarator validations - #17217

Merged
JLHwung merged 6 commits into
babel:mainfrom
JLHwung:harden-variable-declarator-validations
Apr 2, 2025
Merged

JLHwung merged 6 commits into
babel:mainfrom
JLHwung:harden-variable-declarator-validations

Conversation

@JLHwung

@JLHwung JLHwung commented Mar 31, 2025 •

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change? Yes
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#3075
Any Dependency Changes?
License MIT

This PR is sprung off from #17163. Here we applied more constraints on variable declarator validations in Babel 8.

@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Needs Docs labels Mar 31, 2025
@babel-bot

babel-bot commented Mar 31, 2025 •

Copy link
Copy Markdown
Collaborator

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

@nicolo-ribaudo

Copy link
Copy Markdown
Member

Does this play well with TypeScript's declare const a: number;?

@JLHwung

JLHwung commented Mar 31, 2025 •

Copy link
Copy Markdown
Contributor Author

Does this play well with TypeScript's declare const a: number;?

Good catch. Currently no. The VariableDeclaration does not accept declare as a builder parameter as builders generally don't take typescript parameters into account, so we should either: 1) accept declare as a builder parameter and respect that in the validator or 2) remove Identifier from the withoutInit validtor.

Co-authored-by: Nicolò Ribaudo <hello@nicr.dev>
@JLHwung

JLHwung commented Apr 2, 2025

Copy link
Copy Markdown
Contributor Author

Docs PR is ready: babel/website#3075 PTAL

@JLHwung
JLHwung merged commit 4d39e9d into babel:main Apr 2, 2025
@JLHwung
JLHwung deleted the harden-variable-declarator-validations branch April 2, 2025 18:43
@JLHwung JLHwung mentioned this pull request Apr 16, 2025
@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 Jul 3, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 3, 2025
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 PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants