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 traverse typings #14648
Improve traverse typings #14648
Changes from all commits
6d42e2e
15279e7
b4cad86
3f5cebe
4258928
68137e3
382ba1e
f9c0457
3551433
a209629
d6ec941
038eb2c
a504cec
fc97108
6b3ae16
3e9f7fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ export default function splitExportDeclaration( | |
} | ||
|
||
const updatedDeclaration = standaloneDeclaration | ||
? declaration | ||
? declaration.node | ||
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. This looks like a bugfix, did it change any observable behavior? 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. This is not a bug fix. replaceWith<R extends t.Node>(
this: NodePath,
replacementPath: R | NodePath<R>,
): [NodePath<R>] does not support |
||
: variableDeclaration("var", [ | ||
variableDeclarator( | ||
cloneNode(id), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,14 +33,16 @@ type Module = { | |
}; | ||
|
||
if (!process.env.BABEL_8_BREAKING) { | ||
// Introduced in Node.js 8 | ||
// Introduced in Node.js 10 | ||
if (!assert.rejects) { | ||
assert.rejects = async function (block, validateError) { | ||
try { | ||
await block(); | ||
await (typeof block === "function" ? block() : block); | ||
return Promise.reject(new Error("Promise not rejected")); | ||
} catch (error) { | ||
if (!validateError(error)) { | ||
// @ts-ignore Fixme: validateError can be a string | object | ||
// see https://nodejs.org/api/assert.html#assertrejectsasyncfn-error-message | ||
if (typeof validateError === "function" && !validateError(error)) { | ||
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. TS caught some bugs in our polyfill. We can fix this in a separate PR or leave it as-is. 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. It works well enough for what we need 😛 |
||
return Promise.reject( | ||
new Error("Promise rejected with invalid error"), | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -540,7 +540,7 @@ export default declare((api, opts: Options) => { | |
}, | ||
|
||
// taken from transform-destructuring/src/index.js#visitor | ||
ForXStatement(path) { | ||
ForXStatement(path: NodePath<t.ForXStatement>) { | ||
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. Shouldn't this be automatically inferred given the visitor name? 🤔 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. Yes, TS already inferred the |
||
const { node, scope } = path; | ||
const leftPath = path.get("left"); | ||
const left = node.left; | ||
|
@@ -558,7 +558,7 @@ export default declare((api, opts: Options) => { | |
]); | ||
|
||
path.ensureBlock(); | ||
const body = node.body as t.BlockStatement; | ||
const body = path.node.body; | ||
|
||
if (body.body.length === 0 && path.isCompletionRecord()) { | ||
body.body.unshift( | ||
|
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 have reverted some changes suggested before since
getLastStatement
does accept a BreakStatement, it will return the statement itself as the "last statement".