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
Provide plugin/preset typings from plugin-utils #14499
Merged
nicolo-ribaudo
merged 22 commits into
babel:main
from
JLHwung:expose-plugin-preset-api-types
Apr 29, 2022
Merged
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cf26c37
type: refine assumptions interface
JLHwung dd73f4c
fix: use UidIdentifier when partial callee is not identifier
JLHwung 7a21c70
perf: scan object properties in one pass
JLHwung 11c80b9
fix: support private name in member proeprty
JLHwung 1a016a2
fix: add pipeline operator to BinaryOperators
JLHwung dc43dd0
typings: fix GeneratorOptions
JLHwung 046daab
update babel parser typings
JLHwung 8ef9dd2
fix: add predicate to @babel/types
JLHwung 381fd18
typings: export Plugin/Preset related types
JLHwung 99d3abd
feat: add declarePreset method and refine declare types
JLHwung beda280
use helper-plugin-utils in named-capturing-groups
JLHwung c20d40b
fix typing issues
JLHwung e82aa35
Update packages/babel-core/src/config/validation/plugins.ts
JLHwung d39e051
Update packages/babel-plugin-proposal-nullish-coalescing-operator/src…
JLHwung cc42fdf
Update packages/babel-helper-plugin-utils/src/index.ts
JLHwung cd4cdf2
simplify declare/declarePreset
JLHwung 032ebf4
improve decorator 2021-12 transformer typings
JLHwung 84153ee
Do not expose plugin state
JLHwung dd42d4f
bump typescript to 4.6.3
JLHwung e2106bf
fix AssumptionFunction return type
JLHwung b0fd195
misc
JLHwung 6c2d2d9
noNewArrows defaults to true
JLHwung File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { declare } from "@babel/helper-plugin-utils"; | ||
import { transform } from "@babel/plugin-proposal-optional-chaining"; | ||
import { shouldTransform } from "./util"; | ||
import type { NodePath } from "@babel/traverse"; | ||
import type * as t from "@babel/types"; | ||
|
||
export default declare(api => { | ||
api.assertVersion(7); | ||
|
@@ -12,7 +14,9 @@ export default declare(api => { | |
name: "bugfix-v8-spread-parameters-in-optional-chaining", | ||
|
||
visitor: { | ||
"OptionalCallExpression|OptionalMemberExpression"(path) { | ||
"OptionalCallExpression|OptionalMemberExpression"( | ||
path: NodePath<t.OptionalCallExpression | t.OptionalMemberExpression>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still have to manually annotate the input of the multiple-type selection visitors. |
||
) { | ||
if (shouldTransform(path)) { | ||
transform(path, { noDocumentAll, pureGetters }); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Technically a plugin could be used with an old
@babel/core
version that doesn't know about a new assumption and thus returns undefined.We could annotate this as
(name: AssumptionName) => boolean | void
: it's fine (and more helpful) if the parameter is more restrictive, but the return type should cover all the possibilities to avoid possible bugs caused by assuming that it's always a boolean.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.
If we stick to the principle that an assumption always introduce certain non-spec constraints, I would not oppose to make it always return
false
for unknown assumptions. Otherwise plugins has to cast.assumption(name)
to boolean by themselves.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.
Well, there is at least
noNewArrow
that doesapi.assumption("noNewArrow") ?? true
, so "just return false" doesn't work.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.
Don't we want to default it to
false
in Babel 8? 🙂