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
Improve the type definition of path.isX
#15661
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54975/ |
@@ -201,6 +210,7 @@ export function isForAwaitStatement(this: NodePath): boolean { | |||
return isForOfStatement(this.node, { await: true }); | |||
} | |||
|
|||
// TODO: Remove in Babel 8 | |||
export function isExistentialTypeParam(this: NodePath): void { | |||
throw new Error( | |||
"`path.isExistentialTypeParam` has been renamed to `path.isExistsTypeAnnotation()` in Babel 7.", |
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 remove it now?
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.
Yeah we can use something like
babel/packages/babel-core/src/index.ts
Lines 84 to 88 in 9ca034f
if (!process.env.BABEL_8_BREAKING) { | |
// For easier backward-compatibility, provide an API like the one we exposed in Babel 6. | |
if (!USE_ESM) { | |
// eslint-disable-next-line no-restricted-globals | |
exports.OptionManager = class OptionManager { |
@@ -26,66 +26,75 @@ import type * as t from "@babel/types"; | |||
const { isCompatTag } = react; | |||
import type { VirtualTypeAliases } from "./virtual-types"; | |||
|
|||
type Opts<Object> = Partial<{ |
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.
Nit, can you call this Obj
to avoid confusion with the global Object
constructor?
@@ -26,66 +26,75 @@ import type * as t from "@babel/types"; | |||
const { isCompatTag } = react; | |||
import type { VirtualTypeAliases } from "./virtual-types"; | |||
|
|||
type Opts<Object> = Partial<{ | |||
[Prop in keyof Object]: Object[Prop] extends t.Node | |||
? t.Node | Object[Prop] |
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 Object[Prop]
extends t.Node
, isn't this union just t.Node
?
Fixes #1, Fixes #2
Ref: #15549