-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
typings: remove deprecated and unused string methods from primordials #54090
base: main
Are you sure you want to change the base?
Conversation
this commit removes deprecated and unused string methods from the primordials module to clean up the codebase and improve maintainability. the removed methods are no longer used in the current node.js codebase and are considered deprecated. removed methods: - StringPrototypeTrimLeft - StringPrototypeTrimRight - StringPrototypeSup - StringPrototypeStrike - StringPrototypeSub - StringPrototypeSubstr - StringPrototypeSmall - StringPrototypeFontcolor - StringPrototypeFontsize - StringPrototypeFixed - StringPrototypeItalics - StringPrototypeAnchor - StringPrototypeBig - StringPrototypeBlink - StringPrototypeBold - RegExpPrototypeCompile
I don't really get this, those methods exist, I'd expect if someone opens a PR in the future adding them back, that might be accepted; ideally we would not land something that can be reverted immediately. Also, why would we remove those and keep e.g. |
@@ -343,7 +343,6 @@ declare namespace primordials { | |||
export import RegExp = globalThis.RegExp; | |||
export const RegExpPrototype: typeof RegExp.prototype | |||
export const RegExpPrototypeExec: UncurryThis<typeof RegExp.prototype.exec> | |||
export const RegExpPrototypeCompile: UncurryThis<typeof RegExp.prototype.compile> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's instead mark them as deprecated, keeping the types correct.
export const RegExpPrototypeCompile: UncurryThis<typeof RegExp.prototype.compile> | |
/** @deprecated A legacy feature for browser compatibility **/ | |
export const RegExpPrototypeCompile: UncurryThis<typeof RegExp.prototype.compile> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your concerns. I have a few questions based on your feedback @aduh95 :
- Does Node.js have a process for reviewing and removing deprecated methods in major release cycles?
- Your idea to mark these methods as deprecated is indeed practical, but eventually, deprecated methods need to be removed. Wouldn’t it be more effective to implement lint rules in the primordials.d.ts file to prevent the addition of deprecated methods?
I would appreciate your thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Node.js have a process for reviewing and removing deprecated methods in major release cycles?
Node.js has a deprecation cycle that's defined in
node/doc/contributing/collaborator-guide.md
Lines 487 to 495 in 27f1306
A _deprecation cycle_ is a major release during which an API has been in one of | |
the three Deprecation levels. Documentation-Only Deprecations can land in a | |
minor release. They can not change to a Runtime Deprecation until the next major | |
release. | |
No API can change to End-of-Life without going through a Runtime Deprecation | |
cycle. There is no rule that deprecated code must progress to End-of-Life. | |
Documentation-Only and Runtime Deprecations can remain in place for an unlimited | |
duration. |
However, the methods you list in the OP do not apply, because:
- they are not Node.js APIs, they are defined by the ECMAScript spec and implemented by V8.
- they are not deprecated by us.
- the file you're modifying is only used for internal development, and deprecation only apply to public APIs.
eventually, deprecated methods need to be removed
I don't think that's correct, a deprecated feature can stay around forever.
Wouldn’t it be more effective to implement lint rules in the
primordials.d.ts
file to prevent the addition of deprecated methods?
I very much doubt so, regardless if those methods are defined in primordials.d.ts
, they exist, and therefor can be used in .js
files. If you do add @deprecated
flag to them, IMO that would be more effective because folks who use an IDE with TS support would see those methods as underlined if they try to use it – if you remove it, it would only remove the autocompletion and the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is to actually delete these methods (or not add them in the first place) from the primordials
object. Then it would be correct to remove the typings.
From a look of the list it doesn't seem likely that we'll accept a PR that actually makes use of the deprecated methods, so I guess we should just...not accept a PR that adds them to the types files?
We do have existing usage of RegExpPrototypeTest to avoid performance regressions of RegExpPrototypeExec and silence the linter with |
This Pull Request (PR) aims to clean up the primordials module by removing methods that are deprecated and no longer used within the Node.js codebase. This update follows the latest JavaScript standards and helps to maintain consistency and improve the maintainability of the codebase.
Changes
The following methods have been removed from the primordials.d.ts file:
Reasons for Changes
Deprecated Status:
Codebase Cleanup:
Compatibility Issues: