Skip to content

Commit

Permalink
supress Babel 8 typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Dec 13, 2024
1 parent 864164f commit c2731bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/babel-generator/src/generators/expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function NewExpression(

this.print(node.typeArguments);
if (!process.env.BABEL_8_BREAKING) {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
this.print(node.typeParameters); // Legacy TS AST
}

Expand Down Expand Up @@ -189,6 +190,7 @@ export function OptionalCallExpression(
this.print(node.callee);

if (!process.env.BABEL_8_BREAKING) {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
this.print(node.typeParameters); // legacy TS AST
}

Expand All @@ -210,6 +212,7 @@ export function CallExpression(this: Printer, node: t.CallExpression) {

this.print(node.typeArguments); // Flow
if (!process.env.BABEL_8_BREAKING) {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
this.print(node.typeParameters); // legacy TS AST
}
this.token("(");
Expand Down
1 change: 1 addition & 0 deletions packages/babel-generator/src/generators/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function JSXOpeningElement(this: Printer, node: t.JSXOpeningElement) {
//@ts-ignore(Babel 7 vs Babel 8) Babel 8 AST
this.print(node.typeArguments);
} else {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
this.print(node.typeParameters); // Legacy TS AST
}

Expand Down
1 change: 1 addition & 0 deletions packages/babel-generator/src/generators/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ export function TSInstantiationExpression(
// @ts-ignore(Babel 7 vs Babel 8) Babel 8 AST
this.print(node.typeArguments);
} else {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
this.print(node.typeParameters);
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/babel-plugin-transform-typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ export default declare((api, opts: Options) => {
if (process.env.BABEL_8_BREAKING) {
path.node.typeArguments = null;
} else {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
path.node.typeParameters = null;
}
},
Expand All @@ -705,6 +706,7 @@ export default declare((api, opts: Options) => {
if (process.env.BABEL_8_BREAKING) {
path.node.typeArguments = null;
} else {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
path.node.typeParameters = null;
}
},
Expand All @@ -713,6 +715,7 @@ export default declare((api, opts: Options) => {
if (process.env.BABEL_8_BREAKING) {
path.node.typeArguments = null;
} else {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
path.node.typeParameters = null;
}
},
Expand All @@ -722,6 +725,7 @@ export default declare((api, opts: Options) => {
//@ts-ignore(Babel 7 vs Babel 8) Babel 8 AST
path.node.typeArguments = null;
} else {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
path.node.typeParameters = null;
}
},
Expand All @@ -731,6 +735,7 @@ export default declare((api, opts: Options) => {
// @ts-ignore(Babel 7 vs Babel 8) Babel 8 AST
path.node.typeArguments = null;
} else {
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
path.node.typeParameters = null;
}
},
Expand Down

0 comments on commit c2731bb

Please sign in to comment.