convert @babel/plugin-transform-react-jsx to typescript (#13221)
* babel-plugin-transform-react-jsx flowts rename * babel-plugin-transform-react-jsx flowts convert * babel-plugin-transform-react-jsx * babel-plugin-transform-react-jsx fix * make generate-tsconfig * yarn install * babel-plugin-transform-react-jsx remove unused typecast
This commit is contained in:
parent
7c9f618dfc
commit
379bc775ed
@ -28,6 +28,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "workspace:*",
|
||||
"@babel/helper-plugin-test-runner": "workspace:*"
|
||||
"@babel/helper-plugin-test-runner": "workspace:*",
|
||||
"@babel/traverse": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
|
||||
let pragmaFragSet = !!options.pragmaFrag;
|
||||
|
||||
if (file.ast.comments) {
|
||||
for (const comment of (file.ast.comments: Array<Object>)) {
|
||||
for (const comment of file.ast.comments) {
|
||||
const sourceMatches = JSX_SOURCE_ANNOTATION_REGEX.exec(
|
||||
comment.value,
|
||||
);
|
||||
@ -313,6 +313,7 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
|
||||
if (node.name === "this" && t.isReferenced(node, parent)) {
|
||||
return t.thisExpression();
|
||||
} else if (t.isValidIdentifier(node.name, false)) {
|
||||
// @ts-expect-error todo(flow->ts)
|
||||
node.type = "Identifier";
|
||||
} else {
|
||||
return t.stringLiteral(node.name);
|
||||
@ -416,7 +417,7 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
|
||||
const openingPath = path.get("openingElement");
|
||||
const args = [getTag(openingPath)];
|
||||
|
||||
let attribs = [];
|
||||
const attribsArray = [];
|
||||
const extracted = Object.create(null);
|
||||
|
||||
// for React.jsx, key, __source (dev), and __self (dev) is passed in as
|
||||
@ -443,17 +444,23 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
attribs.push(attr);
|
||||
attribsArray.push(attr);
|
||||
}
|
||||
} else {
|
||||
attribs.push(attr);
|
||||
attribsArray.push(attr);
|
||||
}
|
||||
}
|
||||
|
||||
const children = t.react.buildChildren(path.node);
|
||||
|
||||
if (attribs.length || children.length) {
|
||||
attribs = buildJSXOpeningElementAttributes(attribs, file, children);
|
||||
let attribs: t.ObjectExpression;
|
||||
|
||||
if (attribsArray.length || children.length) {
|
||||
attribs = buildJSXOpeningElementAttributes(
|
||||
attribsArray,
|
||||
file,
|
||||
children,
|
||||
);
|
||||
} else {
|
||||
// attributes should never be null
|
||||
attribs = t.objectExpression([]);
|
||||
@ -555,6 +562,7 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
|
||||
if (t.isIdentifier(tagExpr)) {
|
||||
tagName = tagExpr.name;
|
||||
} else if (t.isLiteral(tagExpr)) {
|
||||
// @ts-expect-error todo(flow->ts) value in missing for NullLiteral
|
||||
tagName = tagExpr.value;
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
"./packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/src/**/*.ts",
|
||||
"./packages/babel-plugin-proposal-async-do-expressions/src/**/*.ts",
|
||||
"./packages/babel-plugin-syntax-async-do-expressions/src/**/*.ts",
|
||||
"./packages/babel-plugin-transform-react-jsx/src/**/*.ts",
|
||||
"./packages/babel-template/src/**/*.ts",
|
||||
"./packages/babel-traverse/src/**/*.ts",
|
||||
"./packages/babel-types/src/**/*.ts"
|
||||
@ -100,6 +101,9 @@
|
||||
"@babel/plugin-syntax-async-do-expressions": [
|
||||
"./packages/babel-plugin-syntax-async-do-expressions/src"
|
||||
],
|
||||
"@babel/plugin-transform-react-jsx": [
|
||||
"./packages/babel-plugin-transform-react-jsx/src"
|
||||
],
|
||||
"@babel/template": [
|
||||
"./packages/babel-template/src"
|
||||
],
|
||||
|
||||
@ -643,6 +643,7 @@ __metadata:
|
||||
resolution: "@babel/helper-module-transforms@condition:BABEL_8_BREAKING?:workspace:^7.14.2#5131c1"
|
||||
dependencies:
|
||||
"@babel/helper-module-transforms-BABEL_8_BREAKING-false": "npm:@babel/helper-module-transforms@workspace:^7.14.2"
|
||||
checksum: 99b7a76ae03cc33a6d7a2e970aa72831e096f15bc2c58be10fb297e3fa411d9ba344cd0f93590c1b802a1b4450b7ea29db9aeeb7aeb7b2f9241e751c20a5079c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -2750,6 +2751,7 @@ __metadata:
|
||||
"@babel/helper-plugin-test-runner": "workspace:*"
|
||||
"@babel/helper-plugin-utils": "workspace:^7.13.0"
|
||||
"@babel/plugin-syntax-jsx": "workspace:^7.12.13"
|
||||
"@babel/traverse": "workspace:*"
|
||||
"@babel/types": "workspace:^7.13.12"
|
||||
peerDependencies:
|
||||
"@babel/core": ^7.0.0-0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user