Skip to content

feat(DEP0197): migrate util.types.isNativeErrorError.isError#157

Merged
brunocroh merged 14 commits intonodejs:mainfrom
brunocroh:feat/types-is-native-error
Sep 7, 2025
Merged

feat(DEP0197): migrate util.types.isNativeErrorError.isError#157
brunocroh merged 14 commits intonodejs:mainfrom
brunocroh:feat/types-is-native-error

Conversation

@brunocroh
Copy link
Member

@brunocroh brunocroh commented Aug 3, 2025

Closes #113

This PR depends on PR #151 being merged first.

Overview

This PR introduces a new TypeScript transformation that automatically migrates deprecated util.types.isNativeError usage to the modern Error.isError API.

Additional work

This implements one additional case for utils/src/ast-grep/remove-binding.ts. Previously, it failed to remove deep named imports, so I fixed this behaviour and added a new test to prevent regression

Previous behaviour:

input

const { types: { isNativeError, isMap } } = require("util");

result

const { isMap } = require("util");

New behaviour:

input

const { types: { isNativeError, isMap } } = require("util");

result

const { types: { isMap } } = require("util");

@brunocroh brunocroh changed the title Feat/types is native error feat(types-is-native-error): introduce Aug 3, 2025
@brunocroh brunocroh marked this pull request as draft August 3, 2025 18:01
@brunocroh brunocroh force-pushed the feat/types-is-native-error branch from c288f36 to ddce49b Compare August 4, 2025 19:01
Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

LGMT with rebase

@brunocroh brunocroh force-pushed the feat/types-is-native-error branch from ddce49b to d519ac2 Compare August 6, 2025 21:14
@brunocroh brunocroh marked this pull request as ready for review August 6, 2025 21:15
brunocroh and others added 2 commits August 6, 2025 19:21
Co-authored-by: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com>
Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

CI is green.

@AugustinMauroy AugustinMauroy requested a review from a team August 6, 2025 22:25
@brunocroh brunocroh requested a review from avivkeller August 13, 2025 07:34
@AugustinMauroy AugustinMauroy requested a review from a team August 13, 2025 09:08
Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

Looks pretty good. I think the if … return A else return A might be a mistake?

Annnd broken record: dynamic imports

Comment on lines 51 to 65
if (!propertyAccess) {
return {
path,
propertyAccess,
lastPropertyAccess,
depth: pathArr.length,
};
}

return {
path,
propertyAccess,
lastPropertyAccess,
depth: pathArr.length,
};
Copy link
Member

Choose a reason for hiding this comment

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

These are the same O.o


if (nodes.length === nodesToEdit.length) {
const result = removeBinding(
// @ts-ignore - ast-grep types are not fully compatible with JSSG types
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// @ts-ignore - ast-grep types are not fully compatible with JSSG types
// @ts-expect-error - ast-grep types are not fully compatible with JSSG types

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't necessary any more, so removed

brunocroh and others added 5 commits September 5, 2025 06:49
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
@brunocroh
Copy link
Member Author

Looks pretty good. I think the if … return A else return A might be a mistake?

Annnd broken record: dynamic imports

All done

Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

🙌

@brunocroh brunocroh merged commit 74ad7bf into nodejs:main Sep 7, 2025
6 checks passed
@JakobJingleheimer JakobJingleheimer added the dep:v24 Migration handles deprecation introduced in node v24 label Oct 18, 2025
@JakobJingleheimer JakobJingleheimer changed the title feat(types-is-native-error): introduce feat(DEP0197): migrate util.types.isNativeErrorError.isError Jan 17, 2026
@JakobJingleheimer JakobJingleheimer added this to the 22.x → 24.x milestone Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dep:v24 Migration handles deprecation introduced in node v24

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: handle util.types.isNativeError() depreciation

4 participants