Skip to content

Enable strictNullChecks for @babel/types#17609

Merged
nicolo-ribaudo merged 7 commits intobabel:mainfrom
liuxingbaoyu:strictNullChecks-types
Jan 27, 2026
Merged

Enable strictNullChecks for @babel/types#17609
nicolo-ribaudo merged 7 commits intobabel:mainfrom
liuxingbaoyu:strictNullChecks-types

Conversation

@liuxingbaoyu
Copy link
Member

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

@babel-bot
Copy link
Collaborator

babel-bot commented Nov 25, 2025

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

Comment on lines +152 to +154
expect(cloned.declarations[0].id.leadingComments[0].loc).toBe(undefined);
expect(cloned.declarations[0].id.innerComments[0].loc).toBe(undefined);
expect(cloned.declarations[0].id.trailingComments[0].loc).toBe(undefined);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a behavioral change, but it should be fine.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 26, 2025

Open in StackBlitz

commit: 73b10f3

@liuxingbaoyu liuxingbaoyu force-pushed the strictNullChecks-types branch from be1e8d4 to 9db6682 Compare November 28, 2025 12:42
@nicolo-ribaudo
Copy link
Member

Any chance you could rebase? :)

@liuxingbaoyu liuxingbaoyu force-pushed the strictNullChecks-types branch from 9db6682 to d27f8e9 Compare January 16, 2026 21:50
Comment on lines 623 to 627
if (!IS_STANDALONE) {
if (!new Error().stack.includes("regenerator")) {
if (!new Error().stack!.includes("regenerator")) {
throw error;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

regenerator has been archived, and we've forked it, so perhaps it's time to remove this check.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, agree. Separate PR though.

defineType("ExportAllDeclaration", {
builder: ["source"],
visitor: ["source", "attributes", "assertions"],
visitor: ["source", "assertions"],
Copy link
Member Author

Choose a reason for hiding this comment

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

A bug fix. :)

Copy link
Member

Choose a reason for hiding this comment

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

Mmm, shouldn't it be just attributes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, I got it backwards.

params,
body,
async,
//@ts-expect-error FIXME in Babel 8
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we add them?

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo Jan 16, 2026

Choose a reason for hiding this comment

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

Yeah we should probably add them to the arguments if they are required. Or give defaults where it makes sense (probably default to false for the booleans).

At least for arrowFunctionExpression, it'd be nice to have some custom logic that checks the type of the body and defines it.

Comment on lines 1331 to 1337
expression: {
// https://github.com/babel/babylon/issues/505
//
// NOTE: In the generated builder we compute the value of this field based
// on the body.
validate: assertValueType("boolean"),
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Can we remove this attribute?

Copy link
Member

Choose a reason for hiding this comment

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

It unfortunately is the simplest way to check if we are dealing with a shorthand arrow function or one with the full body, so I feat that at least direct users of the parser might be relying on it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked the parser, and it's only used in the estree plugin.
Also, it seems to simply check if body.type is BlockStatement.

Copy link
Member

Choose a reason for hiding this comment

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

Mh ok, let's do it in a new PR to get the breaking change changelog entry and document it in the migratio nguide.

@nicolo-ribaudo nicolo-ribaudo merged commit a2339a9 into babel:main Jan 27, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants