diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e2d4240257..3160c30b5e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -84,7 +84,7 @@ module.exports = { ], excludedFiles: [ // @babel/register is the require() hook, so it will always be CJS-based - "packages/babel-register/**/*.js", + "packages/babel-register/**/*.{js,ts}", ], rules: { "no-restricted-globals": ["error", ...cjsGlobals], diff --git a/Gulpfile.mjs b/Gulpfile.mjs index bffce65ecf..ba431b72cc 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -61,7 +61,7 @@ function mapSrcToLib(srcPath) { function mapToDts(packageName) { return packageName.replace( /(?<=\\|\/|^)(packages|eslint|codemods)(?=\\|\/)/, - "dts" + "dts/$1" ); } diff --git a/codemods/babel-plugin-codemod-object-assign-to-object-spread/src/index.js b/codemods/babel-plugin-codemod-object-assign-to-object-spread/src/index.ts similarity index 100% rename from codemods/babel-plugin-codemod-object-assign-to-object-spread/src/index.js rename to codemods/babel-plugin-codemod-object-assign-to-object-spread/src/index.ts diff --git a/codemods/babel-plugin-codemod-optional-catch-binding/src/index.js b/codemods/babel-plugin-codemod-optional-catch-binding/src/index.ts similarity index 100% rename from codemods/babel-plugin-codemod-optional-catch-binding/src/index.js rename to codemods/babel-plugin-codemod-optional-catch-binding/src/index.ts diff --git a/eslint/babel-eslint-plugin-development-internal/src/index.js b/eslint/babel-eslint-plugin-development-internal/src/index.ts similarity index 100% rename from eslint/babel-eslint-plugin-development-internal/src/index.js rename to eslint/babel-eslint-plugin-development-internal/src/index.ts diff --git a/eslint/babel-eslint-plugin-development-internal/src/rules/dry-error-messages.js b/eslint/babel-eslint-plugin-development-internal/src/rules/dry-error-messages.ts similarity index 100% rename from eslint/babel-eslint-plugin-development-internal/src/rules/dry-error-messages.js rename to eslint/babel-eslint-plugin-development-internal/src/rules/dry-error-messages.ts diff --git a/eslint/babel-eslint-plugin-development-internal/src/rules/report-error-message-format.js b/eslint/babel-eslint-plugin-development-internal/src/rules/report-error-message-format.ts similarity index 100% rename from eslint/babel-eslint-plugin-development-internal/src/rules/report-error-message-format.js rename to eslint/babel-eslint-plugin-development-internal/src/rules/report-error-message-format.ts diff --git a/eslint/babel-eslint-plugin-development/src/index.js b/eslint/babel-eslint-plugin-development/src/index.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/index.js rename to eslint/babel-eslint-plugin-development/src/index.ts diff --git a/eslint/babel-eslint-plugin-development/src/rules/no-deprecated-clone.js b/eslint/babel-eslint-plugin-development/src/rules/no-deprecated-clone.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/rules/no-deprecated-clone.js rename to eslint/babel-eslint-plugin-development/src/rules/no-deprecated-clone.ts diff --git a/eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.js b/eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.js rename to eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.ts diff --git a/eslint/babel-eslint-plugin-development/src/rules/plugin-name.js b/eslint/babel-eslint-plugin-development/src/rules/plugin-name.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/rules/plugin-name.js rename to eslint/babel-eslint-plugin-development/src/rules/plugin-name.ts diff --git a/eslint/babel-eslint-plugin-development/src/utils/get-export-name.js b/eslint/babel-eslint-plugin-development/src/utils/get-export-name.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/utils/get-export-name.js rename to eslint/babel-eslint-plugin-development/src/utils/get-export-name.ts diff --git a/eslint/babel-eslint-plugin-development/src/utils/get-reference-origin.js b/eslint/babel-eslint-plugin-development/src/utils/get-reference-origin.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/utils/get-reference-origin.js rename to eslint/babel-eslint-plugin-development/src/utils/get-reference-origin.ts diff --git a/eslint/babel-eslint-plugin-development/src/utils/is-babel-plugin-factory.js b/eslint/babel-eslint-plugin-development/src/utils/is-babel-plugin-factory.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/utils/is-babel-plugin-factory.js rename to eslint/babel-eslint-plugin-development/src/utils/is-babel-plugin-factory.ts diff --git a/eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.js b/eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.ts similarity index 100% rename from eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.js rename to eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.ts diff --git a/eslint/babel-eslint-plugin/src/index.js b/eslint/babel-eslint-plugin/src/index.ts similarity index 100% rename from eslint/babel-eslint-plugin/src/index.js rename to eslint/babel-eslint-plugin/src/index.ts diff --git a/eslint/babel-eslint-plugin/src/rules/new-cap.js b/eslint/babel-eslint-plugin/src/rules/new-cap.ts similarity index 100% rename from eslint/babel-eslint-plugin/src/rules/new-cap.js rename to eslint/babel-eslint-plugin/src/rules/new-cap.ts diff --git a/eslint/babel-eslint-plugin/src/rules/no-invalid-this.js b/eslint/babel-eslint-plugin/src/rules/no-invalid-this.ts similarity index 100% rename from eslint/babel-eslint-plugin/src/rules/no-invalid-this.js rename to eslint/babel-eslint-plugin/src/rules/no-invalid-this.ts diff --git a/eslint/babel-eslint-plugin/src/rules/no-unused-expressions.js b/eslint/babel-eslint-plugin/src/rules/no-unused-expressions.ts similarity index 100% rename from eslint/babel-eslint-plugin/src/rules/no-unused-expressions.js rename to eslint/babel-eslint-plugin/src/rules/no-unused-expressions.ts diff --git a/eslint/babel-eslint-plugin/src/rules/object-curly-spacing.js b/eslint/babel-eslint-plugin/src/rules/object-curly-spacing.ts similarity index 100% rename from eslint/babel-eslint-plugin/src/rules/object-curly-spacing.js rename to eslint/babel-eslint-plugin/src/rules/object-curly-spacing.ts diff --git a/eslint/babel-eslint-plugin/src/rules/semi.js b/eslint/babel-eslint-plugin/src/rules/semi.ts similarity index 98% rename from eslint/babel-eslint-plugin/src/rules/semi.js rename to eslint/babel-eslint-plugin/src/rules/semi.ts index 5c4fa9cfea..1d96632e68 100644 --- a/eslint/babel-eslint-plugin/src/rules/semi.js +++ b/eslint/babel-eslint-plugin/src/rules/semi.ts @@ -47,7 +47,7 @@ function isOneLinerBlock(context, node) { ); } -function report(context, node, missing) { +function report(context, node, missing?) { const lastToken = context.getSourceCode().getLastToken(node); let message, diff --git a/packages/babel-core/src/config/plugin.ts b/packages/babel-core/src/config/plugin.ts index 2f958faa70..1ac360fc8f 100644 --- a/packages/babel-core/src/config/plugin.ts +++ b/packages/babel-core/src/config/plugin.ts @@ -2,13 +2,13 @@ import type { PluginObject } from "./validation/plugins"; export default class Plugin { key: string | undefined | null; - manipulateOptions: ((options: unknown, parserOpts: unknown) => void) | void; - post: Function | void; - pre: Function | void; + manipulateOptions?: (options: unknown, parserOpts: unknown) => void; + post?: Function; + pre?: Function; visitor: {}; - parserOverride: Function | void; - generatorOverride: Function | void; + parserOverride?: Function; + generatorOverride?: Function; options: {}; diff --git a/packages/babel-generator/src/buffer.ts b/packages/babel-generator/src/buffer.ts index 50e393306a..cbbaef52e0 100644 --- a/packages/babel-generator/src/buffer.ts +++ b/packages/babel-generator/src/buffer.ts @@ -38,7 +38,7 @@ export default class Buffer { * Get the final string output from the buffer, along with the sourcemap if one exists. */ - get(): any { + get() { this._flush(); const map = this._map; diff --git a/packages/babel-generator/src/generators/jsx.ts b/packages/babel-generator/src/generators/jsx.ts index c265fb5570..0bb50ff781 100644 --- a/packages/babel-generator/src/generators/jsx.ts +++ b/packages/babel-generator/src/generators/jsx.ts @@ -67,7 +67,7 @@ export function JSXElement(this: Printer, node: t.JSXElement) { if (open.selfClosing) return; this.indent(); - for (const child of node.children as Array) { + for (const child of node.children) { this.print(child, node); } this.dedent(); @@ -109,7 +109,7 @@ export function JSXFragment(this: Printer, node: t.JSXFragment) { this.print(node.openingFragment, node); this.indent(); - for (const child of node.children as Array) { + for (const child of node.children) { this.print(child, node); } this.dedent(); diff --git a/packages/babel-generator/src/generators/statements.ts b/packages/babel-generator/src/generators/statements.ts index 981234adf5..3150857fee 100644 --- a/packages/babel-generator/src/generators/statements.ts +++ b/packages/babel-generator/src/generators/statements.ts @@ -267,7 +267,7 @@ export function VariableDeclaration( let hasInits = false; // don't add whitespace to loop heads if (!isFor(parent)) { - for (const declar of node.declarations as Array) { + for (const declar of node.declarations) { if (declar.init) { // has an init so let's split it up over multiple lines hasInits = true; diff --git a/packages/babel-generator/src/index.ts b/packages/babel-generator/src/index.ts index 5346c24460..104f8325bc 100644 --- a/packages/babel-generator/src/index.ts +++ b/packages/babel-generator/src/index.ts @@ -246,7 +246,7 @@ export default function generate( ast: t.Node, opts?: GeneratorOptions, code?: string | { [filename: string]: string }, -): any { +) { const gen = new Generator(ast, opts, code); return gen.generate(); } diff --git a/packages/babel-generator/src/printer.ts b/packages/babel-generator/src/printer.ts index b27bfa0395..bbdcc5b1ba 100644 --- a/packages/babel-generator/src/printer.ts +++ b/packages/babel-generator/src/printer.ts @@ -375,7 +375,7 @@ class Printer { * `undefined` will be returned and not `foo` due to the terminator. */ - startTerminatorless(isLabel: boolean = false): any { + startTerminatorless(isLabel: boolean = false) { if (isLabel) { this._noLineTerminator = true; return null; diff --git a/packages/babel-helper-builder-binary-assignment-operator-visitor/src/index.js b/packages/babel-helper-builder-binary-assignment-operator-visitor/src/index.ts similarity index 78% rename from packages/babel-helper-builder-binary-assignment-operator-visitor/src/index.js rename to packages/babel-helper-builder-binary-assignment-operator-visitor/src/index.ts index 951accfbe6..c498d70369 100644 --- a/packages/babel-helper-builder-binary-assignment-operator-visitor/src/index.js +++ b/packages/babel-helper-builder-binary-assignment-operator-visitor/src/index.ts @@ -1,15 +1,17 @@ import explode from "@babel/helper-explode-assignable-expression"; import { assignmentExpression, sequenceExpression } from "@babel/types"; +import type { Visitor } from "@babel/traverse"; -export default function (opts: { build: Function, operator: string }): Object { +export default function (opts: { build: Function; operator: string }) { const { build, operator } = opts; - return { + const visitor: Visitor = { AssignmentExpression(path) { const { node, scope } = path; if (node.operator !== operator + "=") return; const nodes = []; + // @ts-expect-error todo(flow->ts) const exploded = explode(node.left, nodes, this, scope); nodes.push( assignmentExpression( @@ -28,4 +30,5 @@ export default function (opts: { build: Function, operator: string }): Object { } }, }; + return visitor; } diff --git a/packages/babel-helper-builder-react-jsx/package.json b/packages/babel-helper-builder-react-jsx/package.json index 7455f39c8e..12c5d642f2 100644 --- a/packages/babel-helper-builder-react-jsx/package.json +++ b/packages/babel-helper-builder-react-jsx/package.json @@ -17,6 +17,9 @@ "@babel/helper-annotate-as-pure": "workspace:^", "@babel/types": "workspace:^" }, + "devDependencies": { + "@babel/traverse": "workspace:^" + }, "engines": { "node": ">=6.9.0" }, diff --git a/packages/babel-helper-builder-react-jsx/src/index.js b/packages/babel-helper-builder-react-jsx/src/index.ts similarity index 93% rename from packages/babel-helper-builder-react-jsx/src/index.js rename to packages/babel-helper-builder-react-jsx/src/index.ts index b8c54f2867..e9f436afb6 100644 --- a/packages/babel-helper-builder-react-jsx/src/index.js +++ b/packages/babel-helper-builder-react-jsx/src/index.ts @@ -24,17 +24,19 @@ import { thisExpression, } from "@babel/types"; import annotateAsPure from "@babel/helper-annotate-as-pure"; +import type { Visitor } from "@babel/traverse"; type ElementState = { - tagExpr: Object, // tag node - tagName: ?string, // raw string tag name - args: Array, // array of call arguments - call?: Object, // optional call property that can be set to override the call expression returned - pure: boolean, // true if the element can be marked with a #__PURE__ annotation + tagExpr: any; // tag node, + tagName: string | undefined | null; // raw string tag name, + args: Array; // array of call arguments, + call?: any; // optional call property that can be set to override the call expression returned, + pure: boolean; // true if the element can be marked with a #__PURE__ annotation + callee?: any; }; export default function (opts) { - const visitor = {}; + const visitor: Visitor = {}; visitor.JSXNamespacedName = function (path) { if (opts.throwIfNamespace) { @@ -81,6 +83,7 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`, if (node.name === "this" && isReferenced(node, parent)) { return thisExpression(); } else if (isValidIdentifier(node.name, false)) { + // @ts-expect-error todo(flow->ts) avoid type unsafe mutations node.type = "Identifier"; } else { return stringLiteral(node.name); @@ -152,6 +155,7 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`, if (isIdentifier(tagExpr)) { tagName = tagExpr.name; } else if (isLiteral(tagExpr)) { + // @ts-expect-error todo(flow->ts) NullLiteral tagName = tagExpr.value; } diff --git a/packages/babel-helper-create-class-features-plugin/src/index.ts b/packages/babel-helper-create-class-features-plugin/src/index.ts index df7046213e..6e242a58c7 100644 --- a/packages/babel-helper-create-class-features-plugin/src/index.ts +++ b/packages/babel-helper-create-class-features-plugin/src/index.ts @@ -19,6 +19,7 @@ import { isLoose, } from "./features"; import { assertFieldTransformed } from "./typescript"; +import type { ParserOptions } from "@babel/parser"; export { FEATURES, enableFeature, injectInitialization }; @@ -38,7 +39,7 @@ interface Options { feature: number; loose?: boolean; // same as PluginObject.manipulateOptions - manipulateOptions: (options: unknown, parserOpts: unknown) => void; + manipulateOptions: (options: unknown, parserOpts: ParserOptions) => void; // TODO(flow->ts): change to babel api api?: { assumption: (key?: string) => boolean | undefined }; } diff --git a/packages/babel-helper-define-map/src/index.js b/packages/babel-helper-define-map/src/index.ts similarity index 87% rename from packages/babel-helper-define-map/src/index.js rename to packages/babel-helper-define-map/src/index.ts index 60c69cbf91..591cd78193 100644 --- a/packages/babel-helper-define-map/src/index.js +++ b/packages/babel-helper-define-map/src/index.ts @@ -18,7 +18,7 @@ import { toKeyAlias, } from "@babel/types"; -function toKind(node: Object) { +function toKind(node: any) { if (isClassMethod(node) || isObjectMethod(node)) { if (node.kind === "get" || node.kind === "set") { return node.kind; @@ -30,18 +30,12 @@ function toKind(node: Object) { const has = Function.prototype.call.bind(Object.prototype.hasOwnProperty); -export function push( - mutatorMap: Object, - node: Object, - kind: string, - file, - scope?, -): Object { +export function push(mutatorMap: any, node: any, kind: string, file, scope?) { const alias = toKeyAlias(node); // - let map = {}; + let map = {} as any; if (has(mutatorMap, alias)) map = mutatorMap[alias]; mutatorMap[alias] = map; @@ -79,6 +73,7 @@ export function push( } else if (isObjectMethod(node) || isClassMethod(node)) { value = functionExpression( null, + // @ts-expect-error todo(flow->ts) TSParameterProperty is not assignable to parameter of type 'Identifier | RestElement | Pattern'. node.params, node.body, node.generator, @@ -110,7 +105,7 @@ export function push( return map; } -export function hasComputed(mutatorMap: Object): boolean { +export function hasComputed(mutatorMap: any): boolean { for (const key of Object.keys(mutatorMap)) { if (mutatorMap[key]._computed) { return true; @@ -119,7 +114,7 @@ export function hasComputed(mutatorMap: Object): boolean { return false; } -export function toComputedObjectFromClass(obj: Object): Object { +export function toComputedObjectFromClass(obj: any) { const objExpr = arrayExpression([]); for (let i = 0; i < obj.properties.length; i++) { @@ -134,7 +129,7 @@ export function toComputedObjectFromClass(obj: Object): Object { return objExpr; } -export function toClassObject(mutatorMap: Object): Object { +export function toClassObject(mutatorMap: any) { const objExpr = objectExpression([]); Object.keys(mutatorMap).forEach(function (mutatorMapKey) { @@ -160,7 +155,7 @@ export function toClassObject(mutatorMap: Object): Object { return objExpr; } -export function toDefineObject(mutatorMap: Object): Object { +export function toDefineObject(mutatorMap: any) { Object.keys(mutatorMap).forEach(function (key) { const map = mutatorMap[key]; if (map.value) map.writable = booleanLiteral(true); diff --git a/packages/babel-helper-module-transforms/src/normalize-and-load-metadata.ts b/packages/babel-helper-module-transforms/src/normalize-and-load-metadata.ts index 35e1b02b17..0fac804b8f 100644 --- a/packages/babel-helper-module-transforms/src/normalize-and-load-metadata.ts +++ b/packages/babel-helper-module-transforms/src/normalize-and-load-metadata.ts @@ -482,8 +482,7 @@ function getLocalExportMetadata( (initializeReexports || !child.node.source) ) { if (child.node.declaration) { - // todo: flow->ts babel-types node field types - const declaration = child.get("declaration") as NodePath; + const declaration = child.get("declaration"); const ids = declaration.getOuterBindingIdentifierPaths(); Object.keys(ids).forEach(name => { if (name === "__esModule") { diff --git a/packages/babel-helper-plugin-test-runner/src/index.js b/packages/babel-helper-plugin-test-runner/src/index.ts similarity index 100% rename from packages/babel-helper-plugin-test-runner/src/index.js rename to packages/babel-helper-plugin-test-runner/src/index.ts diff --git a/packages/babel-helper-plugin-utils/src/index.js b/packages/babel-helper-plugin-utils/src/index.ts similarity index 82% rename from packages/babel-helper-plugin-utils/src/index.js rename to packages/babel-helper-plugin-utils/src/index.ts index 5347c2470f..53c7caaa0f 100644 --- a/packages/babel-helper-plugin-utils/src/index.js +++ b/packages/babel-helper-plugin-utils/src/index.ts @@ -1,4 +1,19 @@ -export function declare(builder) { +export function declare< + Args extends + | [any] + | [any, any?] + | [any, any?, any?] + | [any, any] + | [any, any, any?] + | [any, any, any], + Builder extends (...args: Args) => any, +>( + builder: Builder, + // todo(flow->ts) maybe add stricter type for returned function + // reason any is there to not expose exact implementation details in type + // example of issue with this packages/babel-preset-typescript/src/index.ts +): Builder extends (...args: infer A) => any ? (...args: A) => any : never { + // @ts-ignore return (api, options, dirname) => { let clonedApi; @@ -10,6 +25,7 @@ export function declare(builder) { clonedApi[name] = apiPolyfills[name](clonedApi); } + // @ts-ignore return builder(clonedApi ?? api, options || {}, dirname); }; } @@ -101,12 +117,9 @@ function throwVersionError(range, version) { Error.stackTraceLimit = limit; } - throw Object.assign( - err, - ({ - code: "BABEL_VERSION_UNSUPPORTED", - version, - range, - }: any), - ); + throw Object.assign(err, { + code: "BABEL_VERSION_UNSUPPORTED", + version, + range, + } as any); } diff --git a/packages/babel-helper-remap-async-to-generator/src/index.js b/packages/babel-helper-remap-async-to-generator/src/index.ts similarity index 96% rename from packages/babel-helper-remap-async-to-generator/src/index.js rename to packages/babel-helper-remap-async-to-generator/src/index.ts index 88197fdcf5..47926f221d 100644 --- a/packages/babel-helper-remap-async-to-generator/src/index.js +++ b/packages/babel-helper-remap-async-to-generator/src/index.ts @@ -30,8 +30,11 @@ const awaitVisitor = { }; export default function ( - path: NodePath, - helpers: { wrapAsync: Object, wrapAwait: Object }, + path: NodePath, + helpers: { + wrapAsync: any; + wrapAwait?: any; + }, noNewArrows?: boolean, ) { path.traverse(awaitVisitor, { diff --git a/packages/babel-helper-wrap-function/src/index.js b/packages/babel-helper-wrap-function/src/index.ts similarity index 85% rename from packages/babel-helper-wrap-function/src/index.js rename to packages/babel-helper-wrap-function/src/index.ts index eac5c924f5..2c87622567 100644 --- a/packages/babel-helper-wrap-function/src/index.js +++ b/packages/babel-helper-wrap-function/src/index.ts @@ -9,6 +9,7 @@ import { isRestElement, returnStatement, } from "@babel/types"; +import type * as t from "@babel/types"; const buildAnonymousExpressionWrapper = template.expression(` (function () { @@ -37,7 +38,10 @@ const buildDeclarationWrapper = template(` } `); -function classOrObjectMethod(path: NodePath, callId: Object) { +function classOrObjectMethod( + path: NodePath, + callId: any, +) { const node = path.node; const body = node.body; @@ -57,12 +61,12 @@ function classOrObjectMethod(path: NodePath, callId: Object) { node.generator = false; // Unwrap the wrapper IIFE's environment so super and this and such still work. - path - .get("body.body.0.argument.callee.arguments.0") - .unwrapFunctionEnvironment(); + ( + path.get("body.body.0.argument.callee.arguments.0") as NodePath + ).unwrapFunctionEnvironment(); } -function plainFunction(path: NodePath, callId: Object, noNewArrows: boolean) { +function plainFunction(path: NodePath, callId: any, noNewArrows: boolean) { const node = path.node; const isDeclaration = path.isFunctionDeclaration(); const functionId = node.id; @@ -109,6 +113,7 @@ function plainFunction(path: NodePath, callId: Object, noNewArrows: boolean) { path.replaceWith(container[0]); path.insertAfter(container[1]); } else { + // @ts-expect-error todo(flow->ts) separate `wrapper` for `isDeclaration` and `else` branches const retFunction = container.callee.body.body[1].argument; if (!functionId) { nameFunction({ @@ -120,6 +125,7 @@ function plainFunction(path: NodePath, callId: Object, noNewArrows: boolean) { if (!retFunction || retFunction.id || node.params.length) { // we have an inferred function id or params so we need this wrapper + // @ts-expect-error todo(flow->ts) separate `wrapper` for `isDeclaration` and `else` branches path.replaceWith(container); } else { // we can omit this wrapper as the conditions it protects for do not apply @@ -130,7 +136,7 @@ function plainFunction(path: NodePath, callId: Object, noNewArrows: boolean) { export default function wrapFunction( path: NodePath, - callId: Object, + callId: any, // TODO(Babel 8): Consider defaulting to false for spec compliancy noNewArrows: boolean = true, ) { diff --git a/packages/babel-node/src/_babel-node.js b/packages/babel-node/src/_babel-node.ts similarity index 94% rename from packages/babel-node/src/_babel-node.js rename to packages/babel-node/src/_babel-node.ts index 7331d99943..3e2fee2b3e 100644 --- a/packages/babel-node/src/_babel-node.js +++ b/packages/babel-node/src/_babel-node.ts @@ -67,6 +67,7 @@ program.option( program.option("-w, --plugins [string]", "", collect); program.option("-b, --presets [string]", "", collect); +declare const PACKAGE_JSON: { name: string; version: string }; program.version(PACKAGE_JSON.version); program.usage("[options] [ -e script | script.js ] [arguments]"); program.parse(process.argv); @@ -144,17 +145,26 @@ if (program.eval || program.print) { let code = program.eval; if (!code || code === true) code = program.print; + // @ts-expect-error todo(flow->ts) global.__filename = "[eval]"; + // @ts-expect-error todo(flow->ts) global.__dirname = process.cwd(); + // @ts-expect-error todo(flow->ts) const module = new Module(global.__filename); + // @ts-expect-error todo(flow->ts) module.filename = global.__filename; + // @ts-expect-error todo(flow->ts) module.paths = Module._nodeModulePaths(global.__dirname); + // @ts-expect-error todo(flow->ts) global.exports = module.exports; + // @ts-expect-error todo(flow->ts) global.module = module; + // @ts-expect-error todo(flow->ts) global.require = module.require.bind(module); + // @ts-expect-error todo(flow->ts) const result = _eval(code, global.__filename); if (program.print) { const output = typeof result === "string" ? result : inspect(result); diff --git a/packages/babel-node/src/babel-node.js b/packages/babel-node/src/babel-node.ts similarity index 100% rename from packages/babel-node/src/babel-node.js rename to packages/babel-node/src/babel-node.ts diff --git a/packages/babel-plugin-external-helpers/src/index.js b/packages/babel-plugin-external-helpers/src/index.ts similarity index 100% rename from packages/babel-plugin-external-helpers/src/index.js rename to packages/babel-plugin-external-helpers/src/index.ts diff --git a/packages/babel-plugin-proposal-async-generator-functions/src/for-await.js b/packages/babel-plugin-proposal-async-generator-functions/src/for-await.ts similarity index 96% rename from packages/babel-plugin-proposal-async-generator-functions/src/for-await.js rename to packages/babel-plugin-proposal-async-generator-functions/src/for-await.ts index 16f08dca15..163eb5f6f3 100644 --- a/packages/babel-plugin-proposal-async-generator-functions/src/for-await.js +++ b/packages/babel-plugin-proposal-async-generator-functions/src/for-await.ts @@ -61,6 +61,7 @@ export default function (path, { getAsyncIterator }) { }); // remove async function wrapper + // @ts-expect-error todo(flow->ts) improve type annotation for buildForAwait template = template.body.body; const isLabeledParent = t.isLabeledStatement(parent); diff --git a/packages/babel-plugin-proposal-async-generator-functions/src/index.js b/packages/babel-plugin-proposal-async-generator-functions/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-async-generator-functions/src/index.js rename to packages/babel-plugin-proposal-async-generator-functions/src/index.ts diff --git a/packages/babel-plugin-proposal-class-properties/src/index.js b/packages/babel-plugin-proposal-class-properties/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-class-properties/src/index.js rename to packages/babel-plugin-proposal-class-properties/src/index.ts diff --git a/packages/babel-plugin-proposal-class-static-block/package.json b/packages/babel-plugin-proposal-class-static-block/package.json index 51be46c443..cf678a74cb 100644 --- a/packages/babel-plugin-proposal-class-static-block/package.json +++ b/packages/babel-plugin-proposal-class-static-block/package.json @@ -28,7 +28,9 @@ }, "devDependencies": { "@babel/core": "workspace:^", - "@babel/helper-plugin-test-runner": "workspace:^" + "@babel/helper-plugin-test-runner": "workspace:^", + "@babel/traverse": "workspace:^", + "@babel/types": "workspace:^" }, "homepage": "https://babel.dev/docs/en/next/babel-plugin-proposal-class-static-block", "engines": { diff --git a/packages/babel-plugin-proposal-class-static-block/src/index.js b/packages/babel-plugin-proposal-class-static-block/src/index.ts similarity index 83% rename from packages/babel-plugin-proposal-class-static-block/src/index.js rename to packages/babel-plugin-proposal-class-static-block/src/index.ts index 5bc560fc77..ff43aa8cf5 100644 --- a/packages/babel-plugin-proposal-class-static-block/src/index.js +++ b/packages/babel-plugin-proposal-class-static-block/src/index.ts @@ -6,11 +6,13 @@ import { FEATURES, } from "@babel/helper-create-class-features-plugin"; +import type * as t from "@babel/types"; +import type { NodePath } from "@babel/traverse"; /** * Generate a uid that is not in `denyList` * * @param {*} scope - * @param {Set} a deny list that the generated uid should avoid + * @param {Set} denyList a deny list that the generated uid should avoid * @returns */ function generateUid(scope, denyList: Set) { @@ -41,9 +43,9 @@ export default declare(({ types: t, template, assertVersion }) => { // Run on ClassBody and not on class so that if @babel/helper-create-class-features-plugin // is enabled it can generte optimized output without passing from the intermediate // private fields representation. - ClassBody(classBody: NodePath) { + ClassBody(classBody: NodePath) { const { scope } = classBody; - const privateNames = new Set(); + const privateNames = new Set(); const body = classBody.get("body"); for (const path of body) { if (path.isPrivate()) { @@ -60,7 +62,9 @@ export default declare(({ types: t, template, assertVersion }) => { path.replaceWith( t.classPrivateProperty( staticBlockRef, - template.expression.ast`(() => { ${path.node.body} })()`, + template.expression.ast`(() => { ${ + (path.node as t.StaticBlock).body + } })()`, [], /* static */ true, ), diff --git a/packages/babel-plugin-proposal-decorators/package.json b/packages/babel-plugin-proposal-decorators/package.json index fea778a988..2173a299e3 100644 --- a/packages/babel-plugin-proposal-decorators/package.json +++ b/packages/babel-plugin-proposal-decorators/package.json @@ -30,6 +30,7 @@ "devDependencies": { "@babel/core": "workspace:^", "@babel/helper-plugin-test-runner": "workspace:^", + "@babel/traverse": "workspace:^", "babel-plugin-polyfill-es-shims": "^0.6.0", "object.getownpropertydescriptors": "^2.1.1" }, diff --git a/packages/babel-plugin-proposal-decorators/src/index.js b/packages/babel-plugin-proposal-decorators/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-decorators/src/index.js rename to packages/babel-plugin-proposal-decorators/src/index.ts diff --git a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js b/packages/babel-plugin-proposal-decorators/src/transformer-legacy.ts similarity index 90% rename from packages/babel-plugin-proposal-decorators/src/transformer-legacy.js rename to packages/babel-plugin-proposal-decorators/src/transformer-legacy.ts index 5b8dd8d202..ca16608bbb 100644 --- a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js +++ b/packages/babel-plugin-proposal-decorators/src/transformer-legacy.ts @@ -1,18 +1,19 @@ // Fork of https://github.com/loganfsmyth/babel-plugin-proposal-decorators-legacy import { template, types as t } from "@babel/core"; +import type { Visitor } from "@babel/traverse"; const buildClassDecorator = template(` DECORATOR(CLASS_REF = INNER) || CLASS_REF; -`); +`) as (replacements: { DECORATOR; CLASS_REF; INNER }) => t.ExpressionStatement; const buildClassPrototype = template(` CLASS_REF.prototype; -`); +`) as (replacements: { CLASS_REF }) => t.ExpressionStatement; const buildGetDescriptor = template(` Object.getOwnPropertyDescriptor(TARGET, PROPERTY); -`); +`) as (replacements: { TARGET; PROPERTY }) => t.ExpressionStatement; const buildGetObjectInitializer = template(` (TEMP = Object.getOwnPropertyDescriptor(TARGET, PROPERTY), (TEMP = TEMP ? TEMP.value : undefined), { @@ -23,7 +24,7 @@ const buildGetObjectInitializer = template(` return TEMP; } }) -`); +`) as (replacements: { TEMP; TARGET; PROPERTY }) => t.ExpressionStatement; const WARNING_CALLS = new WeakSet(); @@ -241,6 +242,7 @@ export default { replacement, t.exportNamedDeclaration(null, [ t.exportSpecifier( + // @ts-expect-error todo(flow->ts) might be add more specific return type for decoratedClassToExpression t.cloneNode(replacement.declarations[0].id), t.identifier("default"), ), @@ -263,7 +265,7 @@ export default { // class decorators, and a second pass to process method decorators. const decoratedClass = applyEnsureOrdering(path) || - applyClassDecorators(path, state) || + applyClassDecorators(path) || applyMethodDecorators(path, state); if (decoratedClass) path.replaceWith(decoratedClass); @@ -280,12 +282,17 @@ export default { path.replaceWith( t.callExpression(state.addHelper("initializerDefineProperty"), [ + // @ts-expect-error todo(flow->ts) typesafe NodePath.get t.cloneNode(path.get("left.object").node), t.stringLiteral( + // @ts-expect-error todo(flow->ts) typesafe NodePath.get path.get("left.property").node.name || + // @ts-expect-error todo(flow->ts) typesafe NodePath.get path.get("left.property").node.value, ), + // @ts-expect-error todo(flow->ts) t.cloneNode(path.get("right.arguments")[0].node), + // @ts-expect-error todo(flow->ts) t.cloneNode(path.get("right.arguments")[1].node), ]), ); @@ -297,6 +304,7 @@ export default { // If the class properties plugin isn't enabled, this line will add an unused helper // to the code. It's not ideal, but it's ok since the configuration is not valid anyway. + // @ts-expect-error todo(flow->ts) check that `callee` is Identifier if (path.node.callee.name !== state.addHelper("defineProperty").name) { return; } @@ -305,9 +313,11 @@ export default { t.callExpression(state.addHelper("initializerDefineProperty"), [ t.cloneNode(path.get("arguments")[0].node), t.cloneNode(path.get("arguments")[1].node), + // @ts-expect-error todo(flow->ts) t.cloneNode(path.get("arguments.2.arguments")[0].node), + // @ts-expect-error todo(flow->ts) t.cloneNode(path.get("arguments.2.arguments")[1].node), ]), ); }, -}; +} as Visitor; diff --git a/packages/babel-plugin-proposal-do-expressions/src/index.js b/packages/babel-plugin-proposal-do-expressions/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-do-expressions/src/index.js rename to packages/babel-plugin-proposal-do-expressions/src/index.ts diff --git a/packages/babel-plugin-proposal-dynamic-import/src/index.js b/packages/babel-plugin-proposal-dynamic-import/src/index.ts similarity index 94% rename from packages/babel-plugin-proposal-dynamic-import/src/index.js rename to packages/babel-plugin-proposal-dynamic-import/src/index.ts index a9f9285fa8..2a499d1bfe 100644 --- a/packages/babel-plugin-proposal-dynamic-import/src/index.js +++ b/packages/babel-plugin-proposal-dynamic-import/src/index.ts @@ -16,6 +16,8 @@ the @babel/plugin-syntax-dynamic-import plugin and let your bundler handle dynamic imports. `; +declare const PACKAGE_JSON: { name: string; version: string }; + export default declare(api => { api.assertVersion(7); diff --git a/packages/babel-plugin-proposal-export-default-from/src/index.js b/packages/babel-plugin-proposal-export-default-from/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-export-default-from/src/index.js rename to packages/babel-plugin-proposal-export-default-from/src/index.ts diff --git a/packages/babel-plugin-proposal-export-namespace-from/src/index.js b/packages/babel-plugin-proposal-export-namespace-from/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-export-namespace-from/src/index.js rename to packages/babel-plugin-proposal-export-namespace-from/src/index.ts diff --git a/packages/babel-plugin-proposal-function-bind/src/index.js b/packages/babel-plugin-proposal-function-bind/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-function-bind/src/index.js rename to packages/babel-plugin-proposal-function-bind/src/index.ts diff --git a/packages/babel-plugin-proposal-function-sent/src/index.js b/packages/babel-plugin-proposal-function-sent/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-function-sent/src/index.js rename to packages/babel-plugin-proposal-function-sent/src/index.ts diff --git a/packages/babel-plugin-proposal-json-strings/src/index.js b/packages/babel-plugin-proposal-json-strings/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-json-strings/src/index.js rename to packages/babel-plugin-proposal-json-strings/src/index.ts diff --git a/packages/babel-plugin-proposal-logical-assignment-operators/src/index.js b/packages/babel-plugin-proposal-logical-assignment-operators/src/index.ts similarity index 94% rename from packages/babel-plugin-proposal-logical-assignment-operators/src/index.js rename to packages/babel-plugin-proposal-logical-assignment-operators/src/index.ts index dd5ea53681..da1eeaea35 100644 --- a/packages/babel-plugin-proposal-logical-assignment-operators/src/index.js +++ b/packages/babel-plugin-proposal-logical-assignment-operators/src/index.ts @@ -34,6 +34,7 @@ export default declare(api => { lhs.property = t.assignmentExpression( "=", t.cloneNode(memo), + // @ts-expect-error todo(flow->ts): property can be t.PrivateName property, ); } diff --git a/packages/babel-plugin-proposal-nullish-coalescing-operator/src/index.js b/packages/babel-plugin-proposal-nullish-coalescing-operator/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-nullish-coalescing-operator/src/index.js rename to packages/babel-plugin-proposal-nullish-coalescing-operator/src/index.ts diff --git a/packages/babel-plugin-proposal-numeric-separator/package.json b/packages/babel-plugin-proposal-numeric-separator/package.json index cf3c955843..3a74a449fb 100644 --- a/packages/babel-plugin-proposal-numeric-separator/package.json +++ b/packages/babel-plugin-proposal-numeric-separator/package.json @@ -25,7 +25,9 @@ }, "devDependencies": { "@babel/core": "workspace:^", - "@babel/helper-plugin-test-runner": "workspace:^" + "@babel/helper-plugin-test-runner": "workspace:^", + "@babel/traverse": "workspace:^", + "@babel/types": "workspace:^" }, "engines": { "node": ">=6.9.0" diff --git a/packages/babel-plugin-proposal-numeric-separator/src/index.js b/packages/babel-plugin-proposal-numeric-separator/src/index.ts similarity index 74% rename from packages/babel-plugin-proposal-numeric-separator/src/index.js rename to packages/babel-plugin-proposal-numeric-separator/src/index.ts index 3fc6c4a405..dfa9943255 100644 --- a/packages/babel-plugin-proposal-numeric-separator/src/index.js +++ b/packages/babel-plugin-proposal-numeric-separator/src/index.ts @@ -1,5 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxNumericSeparator from "@babel/plugin-syntax-numeric-separator"; +import type { NodePath } from "@babel/traverse"; +import type * as t from "@babel/types"; /** * Given a bigIntLiteral or NumericLiteral, remove numeric @@ -7,9 +9,11 @@ import syntaxNumericSeparator from "@babel/plugin-syntax-numeric-separator"; * * @param {NodePath} { node }: A Babel AST node path */ -function remover({ node }: NodePath) { +function remover({ node }: NodePath) { const { extra } = node; + // @ts-expect-error todo(flow->ts) if (extra?.raw?.includes("_")) { + // @ts-expect-error todo(flow->ts) extra.raw = extra.raw.replace(/_/g, ""); } } diff --git a/packages/babel-plugin-proposal-optional-catch-binding/src/index.js b/packages/babel-plugin-proposal-optional-catch-binding/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-optional-catch-binding/src/index.js rename to packages/babel-plugin-proposal-optional-catch-binding/src/index.ts diff --git a/packages/babel-plugin-proposal-optional-chaining/package.json b/packages/babel-plugin-proposal-optional-chaining/package.json index 570f7a8ef2..2498966ec0 100644 --- a/packages/babel-plugin-proposal-optional-chaining/package.json +++ b/packages/babel-plugin-proposal-optional-chaining/package.json @@ -27,7 +27,8 @@ "devDependencies": { "@babel/core": "workspace:^", "@babel/helper-plugin-test-runner": "workspace:^", - "@babel/plugin-transform-block-scoping": "workspace:^" + "@babel/plugin-transform-block-scoping": "workspace:^", + "@babel/traverse": "workspace:^" }, "engines": { "node": ">=6.9.0" diff --git a/packages/babel-plugin-proposal-optional-chaining/src/index.js b/packages/babel-plugin-proposal-optional-chaining/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-optional-chaining/src/index.js rename to packages/babel-plugin-proposal-optional-chaining/src/index.ts diff --git a/packages/babel-plugin-proposal-optional-chaining/src/transform.js b/packages/babel-plugin-proposal-optional-chaining/src/transform.ts similarity index 92% rename from packages/babel-plugin-proposal-optional-chaining/src/transform.js rename to packages/babel-plugin-proposal-optional-chaining/src/transform.ts index 05ae81bdb4..5ba92765f1 100644 --- a/packages/babel-plugin-proposal-optional-chaining/src/transform.js +++ b/packages/babel-plugin-proposal-optional-chaining/src/transform.ts @@ -1,4 +1,5 @@ import { types as t, template } from "@babel/core"; +import type { NodePath } from "@babel/traverse"; import { skipTransparentExprWrapperNodes, skipTransparentExprWrappers, @@ -48,7 +49,7 @@ export function transform( { pureGetters, noDocumentAll, - }: { pureGetters: boolean, noDocumentAll: boolean }, + }: { pureGetters: boolean; noDocumentAll: boolean }, ) { const { scope } = path; // maybeWrapped points to the outermost transparent expression wrapper @@ -69,7 +70,7 @@ export function transform( // Replace `function (a, x = a.b?.c) {}` to `function (a, x = (() => a.b?.c)() ){}` // so the temporary variable can be injected in correct scope if (scope.path.isPattern() && needsMemoize(optionalPath)) { - path.replaceWith(template.ast`(() => ${path.node})()`); + path.replaceWith(template.ast`(() => ${path.node})()` as t.Statement); // The injected optional chain will be queued and eventually transformed when visited return; } @@ -83,15 +84,19 @@ export function transform( } if (optionalPath.isOptionalMemberExpression()) { + // @ts-expect-error todo(flow->ts) avoid changing more type optionalPath.node.type = "MemberExpression"; + // @ts-expect-error todo(flow->ts) optionalPath = skipTransparentExprWrappers(optionalPath.get("object")); } else if (optionalPath.isOptionalCallExpression()) { + // @ts-expect-error todo(flow->ts) avoid changing more type optionalPath.node.type = "CallExpression"; + // @ts-expect-error todo(flow->ts) optionalPath = skipTransparentExprWrappers(optionalPath.get("callee")); } } - let replacementPath = path; + let replacementPath: NodePath = path; if (parentPath.isUnaryExpression({ operator: "delete" })) { replacementPath = parentPath; isDeleteOperation = true; @@ -145,7 +150,7 @@ export function transform( // Otherwise, we need to memoize the context object, and change the call into a Function#call. // `a.?b.?()` translates roughly to `(_b = _a.b) != null && _b.call(_a)` const { object } = chain; - let context = scope.maybeGenerateMemoised(object); + let context: t.Expression = scope.maybeGenerateMemoised(object); if (context) { chain.object = t.assignmentExpression("=", context, object); } else if (t.isSuper(object)) { @@ -194,6 +199,7 @@ export function transform( t.logicalExpression("&&", nonNullishCheck, replacement), ); replacementPath = skipTransparentExprWrappers( + // @ts-expect-error todo(flow->ts) replacementPath.get("right"), ); } else { @@ -207,6 +213,7 @@ export function transform( t.conditionalExpression(nullishCheck, returnValue, replacement), ); replacementPath = skipTransparentExprWrappers( + // @ts-expect-error todo(flow->ts) replacementPath.get("alternate"), ); } diff --git a/packages/babel-plugin-proposal-optional-chaining/src/util.js b/packages/babel-plugin-proposal-optional-chaining/src/util.ts similarity index 95% rename from packages/babel-plugin-proposal-optional-chaining/src/util.js rename to packages/babel-plugin-proposal-optional-chaining/src/util.ts index 7f98ccb2fc..4bb72bc55b 100644 --- a/packages/babel-plugin-proposal-optional-chaining/src/util.js +++ b/packages/babel-plugin-proposal-optional-chaining/src/util.ts @@ -1,3 +1,4 @@ +import type { NodePath } from "@babel/traverse"; import { isTransparentExprWrapper } from "@babel/helper-skip-transparent-expression-wrappers"; /** * Test if a NodePath will be cast to boolean when evaluated. @@ -58,7 +59,7 @@ export function willPathCastToBoolean(path: NodePath): boolean { export function findOutermostTransparentParent(path: NodePath): NodePath { let maybeWrapped = path; path.findParent(p => { - if (!isTransparentExprWrapper(p)) return true; + if (!isTransparentExprWrapper(p.node)) return true; maybeWrapped = p; }); return maybeWrapped; diff --git a/packages/babel-plugin-proposal-partial-application/src/index.js b/packages/babel-plugin-proposal-partial-application/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-partial-application/src/index.js rename to packages/babel-plugin-proposal-partial-application/src/index.ts diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/buildOptimizedSequenceExpression.js b/packages/babel-plugin-proposal-pipeline-operator/src/buildOptimizedSequenceExpression.ts similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/src/buildOptimizedSequenceExpression.js rename to packages/babel-plugin-proposal-pipeline-operator/src/buildOptimizedSequenceExpression.ts diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/fsharpVisitor.js b/packages/babel-plugin-proposal-pipeline-operator/src/fsharpVisitor.ts similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/src/fsharpVisitor.js rename to packages/babel-plugin-proposal-pipeline-operator/src/fsharpVisitor.ts diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/hackVisitor.js b/packages/babel-plugin-proposal-pipeline-operator/src/hackVisitor.ts similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/src/hackVisitor.js rename to packages/babel-plugin-proposal-pipeline-operator/src/hackVisitor.ts diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/index.js b/packages/babel-plugin-proposal-pipeline-operator/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/src/index.js rename to packages/babel-plugin-proposal-pipeline-operator/src/index.ts diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/minimalVisitor.js b/packages/babel-plugin-proposal-pipeline-operator/src/minimalVisitor.ts similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/src/minimalVisitor.js rename to packages/babel-plugin-proposal-pipeline-operator/src/minimalVisitor.ts diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/smartVisitor.js b/packages/babel-plugin-proposal-pipeline-operator/src/smartVisitor.ts similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/src/smartVisitor.js rename to packages/babel-plugin-proposal-pipeline-operator/src/smartVisitor.ts diff --git a/packages/babel-plugin-proposal-private-methods/src/index.js b/packages/babel-plugin-proposal-private-methods/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-private-methods/src/index.js rename to packages/babel-plugin-proposal-private-methods/src/index.ts diff --git a/packages/babel-plugin-proposal-private-property-in-object/src/index.js b/packages/babel-plugin-proposal-private-property-in-object/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-private-property-in-object/src/index.js rename to packages/babel-plugin-proposal-private-property-in-object/src/index.ts diff --git a/packages/babel-plugin-proposal-record-and-tuple/src/index.js b/packages/babel-plugin-proposal-record-and-tuple/src/index.ts similarity index 97% rename from packages/babel-plugin-proposal-record-and-tuple/src/index.js rename to packages/babel-plugin-proposal-record-and-tuple/src/index.ts index 0a63de2e31..ac57361166 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/src/index.js +++ b/packages/babel-plugin-proposal-record-and-tuple/src/index.ts @@ -20,6 +20,7 @@ import { types as t } from "@babel/core"; import { addNamed, isModule } from "@babel/helper-module-imports"; import { OptionValidator } from "@babel/helper-validator-option"; +declare const PACKAGE_JSON: { name: string; version: string }; const v = new OptionValidator(PACKAGE_JSON.name); export default declare((api, options) => { diff --git a/packages/babel-plugin-proposal-throw-expressions/src/index.js b/packages/babel-plugin-proposal-throw-expressions/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-throw-expressions/src/index.js rename to packages/babel-plugin-proposal-throw-expressions/src/index.ts diff --git a/packages/babel-plugin-proposal-unicode-property-regex/src/index.js b/packages/babel-plugin-proposal-unicode-property-regex/src/index.ts similarity index 100% rename from packages/babel-plugin-proposal-unicode-property-regex/src/index.js rename to packages/babel-plugin-proposal-unicode-property-regex/src/index.ts diff --git a/packages/babel-plugin-syntax-decimal/src/index.js b/packages/babel-plugin-syntax-decimal/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-decimal/src/index.js rename to packages/babel-plugin-syntax-decimal/src/index.ts diff --git a/packages/babel-plugin-syntax-decorators/src/index.js b/packages/babel-plugin-syntax-decorators/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-decorators/src/index.js rename to packages/babel-plugin-syntax-decorators/src/index.ts diff --git a/packages/babel-plugin-syntax-do-expressions/src/index.js b/packages/babel-plugin-syntax-do-expressions/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-do-expressions/src/index.js rename to packages/babel-plugin-syntax-do-expressions/src/index.ts diff --git a/packages/babel-plugin-syntax-export-default-from/src/index.js b/packages/babel-plugin-syntax-export-default-from/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-export-default-from/src/index.js rename to packages/babel-plugin-syntax-export-default-from/src/index.ts diff --git a/packages/babel-plugin-syntax-flow/src/index.js b/packages/babel-plugin-syntax-flow/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-flow/src/index.js rename to packages/babel-plugin-syntax-flow/src/index.ts diff --git a/packages/babel-plugin-syntax-function-bind/src/index.js b/packages/babel-plugin-syntax-function-bind/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-function-bind/src/index.js rename to packages/babel-plugin-syntax-function-bind/src/index.ts diff --git a/packages/babel-plugin-syntax-function-sent/src/index.js b/packages/babel-plugin-syntax-function-sent/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-function-sent/src/index.js rename to packages/babel-plugin-syntax-function-sent/src/index.ts diff --git a/packages/babel-plugin-syntax-import-assertions/src/index.js b/packages/babel-plugin-syntax-import-assertions/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-import-assertions/src/index.js rename to packages/babel-plugin-syntax-import-assertions/src/index.ts diff --git a/packages/babel-plugin-syntax-jsx/src/index.js b/packages/babel-plugin-syntax-jsx/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-jsx/src/index.js rename to packages/babel-plugin-syntax-jsx/src/index.ts diff --git a/packages/babel-plugin-syntax-module-blocks/src/index.js b/packages/babel-plugin-syntax-module-blocks/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-module-blocks/src/index.js rename to packages/babel-plugin-syntax-module-blocks/src/index.ts diff --git a/packages/babel-plugin-syntax-partial-application/src/index.js b/packages/babel-plugin-syntax-partial-application/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-partial-application/src/index.js rename to packages/babel-plugin-syntax-partial-application/src/index.ts diff --git a/packages/babel-plugin-syntax-pipeline-operator/src/index.js b/packages/babel-plugin-syntax-pipeline-operator/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-pipeline-operator/src/index.js rename to packages/babel-plugin-syntax-pipeline-operator/src/index.ts diff --git a/packages/babel-plugin-syntax-record-and-tuple/src/index.js b/packages/babel-plugin-syntax-record-and-tuple/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-record-and-tuple/src/index.js rename to packages/babel-plugin-syntax-record-and-tuple/src/index.ts diff --git a/packages/babel-plugin-syntax-throw-expressions/src/index.js b/packages/babel-plugin-syntax-throw-expressions/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-throw-expressions/src/index.js rename to packages/babel-plugin-syntax-throw-expressions/src/index.ts diff --git a/packages/babel-plugin-syntax-typescript/src/index.js b/packages/babel-plugin-syntax-typescript/src/index.ts similarity index 100% rename from packages/babel-plugin-syntax-typescript/src/index.js rename to packages/babel-plugin-syntax-typescript/src/index.ts diff --git a/packages/babel-plugin-transform-arrow-functions/package.json b/packages/babel-plugin-transform-arrow-functions/package.json index a2d74f1c89..f760580a42 100644 --- a/packages/babel-plugin-transform-arrow-functions/package.json +++ b/packages/babel-plugin-transform-arrow-functions/package.json @@ -25,7 +25,8 @@ "devDependencies": { "@babel/core": "workspace:^", "@babel/helper-plugin-test-runner": "workspace:^", - "@babel/traverse": "workspace:^" + "@babel/traverse": "workspace:^", + "@babel/types": "workspace:^" }, "engines": { "node": ">=6.9.0" diff --git a/packages/babel-plugin-transform-arrow-functions/src/index.js b/packages/babel-plugin-transform-arrow-functions/src/index.ts similarity index 84% rename from packages/babel-plugin-transform-arrow-functions/src/index.js rename to packages/babel-plugin-transform-arrow-functions/src/index.ts index 98ac9f4d62..4138442337 100644 --- a/packages/babel-plugin-transform-arrow-functions/src/index.js +++ b/packages/babel-plugin-transform-arrow-functions/src/index.ts @@ -1,5 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; -import type NodePath from "@babel/traverse"; +import type { NodePath } from "@babel/traverse"; +import type * as t from "@babel/types"; export default declare((api, options) => { api.assertVersion(7); @@ -10,9 +11,7 @@ export default declare((api, options) => { name: "transform-arrow-functions", visitor: { - ArrowFunctionExpression( - path: NodePath, - ) { + ArrowFunctionExpression(path: NodePath) { // In some conversion cases, it may have already been converted to a function while this callback // was queued up. if (!path.isArrowFunctionExpression()) return; diff --git a/packages/babel-plugin-transform-async-to-generator/src/index.js b/packages/babel-plugin-transform-async-to-generator/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-async-to-generator/src/index.js rename to packages/babel-plugin-transform-async-to-generator/src/index.ts diff --git a/packages/babel-plugin-transform-block-scoped-functions/src/index.js b/packages/babel-plugin-transform-block-scoped-functions/src/index.ts similarity index 91% rename from packages/babel-plugin-transform-block-scoped-functions/src/index.js rename to packages/babel-plugin-transform-block-scoped-functions/src/index.ts index 79b9b27e2b..1e39245223 100644 --- a/packages/babel-plugin-transform-block-scoped-functions/src/index.js +++ b/packages/babel-plugin-transform-block-scoped-functions/src/index.ts @@ -5,7 +5,7 @@ export default declare(api => { api.assertVersion(7); function statementList(key, path) { - const paths: Array = path.get(key); + const paths = path.get(key); for (const path of paths) { const func = path.node; @@ -16,6 +16,7 @@ export default declare(api => { ]); // hoist it up above everything else + // @ts-expect-error todo(flow->ts): avoid mutations declar._blockHoist = 2; // todo: name this diff --git a/packages/babel-plugin-transform-block-scoping/src/index.ts b/packages/babel-plugin-transform-block-scoping/src/index.ts index f3ffbef6d0..a57ad115c1 100644 --- a/packages/babel-plugin-transform-block-scoping/src/index.ts +++ b/packages/babel-plugin-transform-block-scoping/src/index.ts @@ -920,7 +920,7 @@ class BlockScoping { * later on. */ - checkLoop(): any { + checkLoop() { const state: LoopVisitorState = { hasBreakContinue: false, ignoreLabeless: false, diff --git a/packages/babel-plugin-transform-computed-properties/src/index.js b/packages/babel-plugin-transform-computed-properties/src/index.ts similarity index 94% rename from packages/babel-plugin-transform-computed-properties/src/index.js rename to packages/babel-plugin-transform-computed-properties/src/index.ts index 9fa5c5c964..e523cd5e88 100644 --- a/packages/babel-plugin-transform-computed-properties/src/index.js +++ b/packages/babel-plugin-transform-computed-properties/src/index.ts @@ -32,7 +32,7 @@ export default declare((api, options) => { function pushAssign(objId, prop, body) { if (prop.kind === "get" && prop.kind === "set") { - pushMutatorDefine(objId, prop, body); + pushMutatorDefine(objId, prop); } else { body.push( t.expressionStatement( @@ -43,6 +43,7 @@ export default declare((api, options) => { prop.key, prop.computed || t.isLiteral(prop.key), ), + // @ts-expect-error todo(flow->ts): double-check type error getValue(prop), ), ), @@ -65,12 +66,12 @@ export default declare((api, options) => { } body.push( - ...buildMutatorMapAssign({ + ...(buildMutatorMapAssign({ MUTATOR_MAP_REF: getMutatorId(), KEY: t.cloneNode(key), VALUE: getValue(prop), KIND: t.identifier(prop.kind), - }), + }) as t.Statement[]), ); } @@ -122,7 +123,7 @@ export default declare((api, options) => { exit(path, state) { const { node, parent, scope } = path; let hasComputed = false; - for (const prop of (node.properties: Array)) { + for (const prop of node.properties) { hasComputed = prop.computed === true; if (hasComputed) break; } @@ -194,6 +195,7 @@ export default declare((api, options) => { ); } + // @ts-expect-error todo(flow->ts) `void` should not be used as variable if (single) { path.replaceWith(single); } else { diff --git a/packages/babel-plugin-transform-destructuring/package.json b/packages/babel-plugin-transform-destructuring/package.json index 9c3b9a5f74..531df29ad6 100644 --- a/packages/babel-plugin-transform-destructuring/package.json +++ b/packages/babel-plugin-transform-destructuring/package.json @@ -24,7 +24,8 @@ }, "devDependencies": { "@babel/core": "workspace:^", - "@babel/helper-plugin-test-runner": "workspace:^" + "@babel/helper-plugin-test-runner": "workspace:^", + "@babel/traverse": "workspace:^" }, "engines": { "node": ">=6.9.0" diff --git a/packages/babel-plugin-transform-destructuring/src/index.js b/packages/babel-plugin-transform-destructuring/src/index.ts similarity index 96% rename from packages/babel-plugin-transform-destructuring/src/index.js rename to packages/babel-plugin-transform-destructuring/src/index.ts index 7af938dbeb..959e8fbf2e 100644 --- a/packages/babel-plugin-transform-destructuring/src/index.js +++ b/packages/babel-plugin-transform-destructuring/src/index.ts @@ -1,5 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; +import type { Scope } from "@babel/traverse"; export default declare((api, options) => { api.assertVersion(7); @@ -23,7 +24,7 @@ export default declare((api, options) => { */ function variableDeclarationHasPattern(node) { - for (const declar of (node.declarations: Array)) { + for (const declar of node.declarations) { if (t.isPattern(declar.id)) { return true; } @@ -36,7 +37,7 @@ export default declare((api, options) => { */ function hasRest(pattern) { - for (const elem of (pattern.elements: Array)) { + for (const elem of pattern.elements) { if (t.isRestElement(elem)) { return true; } @@ -49,7 +50,7 @@ export default declare((api, options) => { */ function hasObjectRest(pattern) { - for (const elem of (pattern.properties: Array)) { + for (const elem of pattern.properties) { if (t.isRestElement(elem)) { return true; } @@ -77,6 +78,15 @@ export default declare((api, options) => { }; class DestructuringTransformer { + private blockHoist: any; + private operator: any; + arrays: any; + private nodes: any; + private scope: Scope; + private kind: any; + private iterableIsArray: any; + private arrayLikeIsIterable: any; + private addHelper: any; constructor(opts) { this.blockHoist = opts.blockHoist; this.operator = opts.operator; @@ -118,6 +128,7 @@ export default declare((api, options) => { const declar = t.variableDeclaration("var", [ t.variableDeclarator(t.cloneNode(id), t.cloneNode(init)), ]); + // @ts-expect-error todo(flow->ts): avoid mutations declar._blockHoist = this.blockHoist; return declar; } @@ -135,7 +146,7 @@ export default declare((api, options) => { } } - toArray(node, count) { + toArray(node, count?) { if ( this.iterableIsArray || (t.isIdentifier(node) && this.arrays[node.name]) @@ -208,6 +219,7 @@ export default declare((api, options) => { keys.push(t.cloneNode(key)); hasTemplateLiteral = true; } else if (t.isLiteral(key)) { + // @ts-expect-error todo(flow->ts) NullLiteral keys.push(t.stringLiteral(String(key.value))); } else { keys.push(t.cloneNode(key)); @@ -222,7 +234,7 @@ export default declare((api, options) => { t.cloneNode(objRef), ]); } else { - let keyExpression = t.arrayExpression(keys); + let keyExpression: t.Expression = t.arrayExpression(keys); if (!allLiteral) { keyExpression = t.callExpression( @@ -342,7 +354,7 @@ export default declare((api, options) => { return false; } - for (const elem of (pattern.elements: Array)) { + for (const elem of pattern.elements) { // deopt on holes if (!elem) return false; @@ -350,7 +362,7 @@ export default declare((api, options) => { if (t.isMemberExpression(elem)) return false; } - for (const elem of (arr.elements: Array)) { + for (const elem of arr.elements) { // deopt on spread elements if (t.isSpreadElement(elem)) return false; diff --git a/packages/babel-plugin-transform-dotall-regex/src/index.js b/packages/babel-plugin-transform-dotall-regex/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-dotall-regex/src/index.js rename to packages/babel-plugin-transform-dotall-regex/src/index.ts diff --git a/packages/babel-plugin-transform-duplicate-keys/src/index.js b/packages/babel-plugin-transform-duplicate-keys/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-duplicate-keys/src/index.js rename to packages/babel-plugin-transform-duplicate-keys/src/index.ts diff --git a/packages/babel-plugin-transform-exponentiation-operator/src/index.js b/packages/babel-plugin-transform-exponentiation-operator/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-exponentiation-operator/src/index.js rename to packages/babel-plugin-transform-exponentiation-operator/src/index.ts diff --git a/packages/babel-plugin-transform-flow-comments/src/index.js b/packages/babel-plugin-transform-flow-comments/src/index.ts similarity index 98% rename from packages/babel-plugin-transform-flow-comments/src/index.js rename to packages/babel-plugin-transform-flow-comments/src/index.ts index db926052c3..d1190fefe0 100644 --- a/packages/babel-plugin-transform-flow-comments/src/index.js +++ b/packages/babel-plugin-transform-flow-comments/src/index.ts @@ -19,6 +19,13 @@ export default declare(api => { optional = false, comments = generateComment(ofPath, optional), keepType = false, + }: { + ofPath?; + toPath?; + where?: string; + optional?; + comments?; + keepType?; }) { if (!toPath?.node) { toPath = ofPath.getPrevSibling(); @@ -67,7 +74,7 @@ export default declare(api => { }); } - function generateComment(path, optional) { + function generateComment(path, optional?) { let comment = path .getSource() .replace(/\*-\//g, "*-ESCAPED/") diff --git a/packages/babel-plugin-transform-flow-strip-types/src/index.js b/packages/babel-plugin-transform-flow-strip-types/src/index.ts similarity index 98% rename from packages/babel-plugin-transform-flow-strip-types/src/index.js rename to packages/babel-plugin-transform-flow-strip-types/src/index.ts index 5d293ae474..6b5ec02a25 100644 --- a/packages/babel-plugin-transform-flow-strip-types/src/index.js +++ b/packages/babel-plugin-transform-flow-strip-types/src/index.ts @@ -33,7 +33,7 @@ export default declare((api, opts) => { let directiveFound = false; if (comments) { - for (const comment of (comments: Array)) { + for (const comment of comments) { if (FLOW_DIRECTIVE.test(comment.value)) { directiveFound = true; diff --git a/packages/babel-plugin-transform-for-of/src/index.js b/packages/babel-plugin-transform-for-of/src/index.ts similarity index 98% rename from packages/babel-plugin-transform-for-of/src/index.js rename to packages/babel-plugin-transform-for-of/src/index.ts index 882ff9b82b..91d99c4880 100644 --- a/packages/babel-plugin-transform-for-of/src/index.js +++ b/packages/babel-plugin-transform-for-of/src/index.ts @@ -157,7 +157,7 @@ export default declare((api, options) => { KEY: iterationKey, NAME: right, ARR: node.right, - }); + }) as t.For; t.inherits(loop, node); t.ensureBlock(loop); @@ -171,8 +171,10 @@ export default declare((api, options) => { const left = node.left; if (t.isVariableDeclaration(left)) { left.declarations[0].init = iterationValue; + // @ts-expect-error todo(flow->ts): loop.body.body.unshift(left); } else { + // @ts-expect-error todo(flow->ts): loop.body.body.unshift( t.expressionStatement( t.assignmentExpression("=", left, iterationValue), diff --git a/packages/babel-plugin-transform-for-of/src/no-helper-implementation.js b/packages/babel-plugin-transform-for-of/src/no-helper-implementation.ts similarity index 99% rename from packages/babel-plugin-transform-for-of/src/no-helper-implementation.js rename to packages/babel-plugin-transform-for-of/src/no-helper-implementation.ts index c867a5d096..d84143b6e3 100644 --- a/packages/babel-plugin-transform-for-of/src/no-helper-implementation.js +++ b/packages/babel-plugin-transform-for-of/src/no-helper-implementation.ts @@ -115,7 +115,7 @@ function pushComputedPropsLoose(path, file) { INDEX: scope.generateUidIdentifier("i"), ID: id, INTERMEDIATE: intermediate, - }); + }) as t.Statement; // const isLabeledParent = t.isLabeledStatement(parent); diff --git a/packages/babel-plugin-transform-function-name/src/index.js b/packages/babel-plugin-transform-function-name/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-function-name/src/index.js rename to packages/babel-plugin-transform-function-name/src/index.ts diff --git a/packages/babel-plugin-transform-instanceof/src/index.js b/packages/babel-plugin-transform-instanceof/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-instanceof/src/index.js rename to packages/babel-plugin-transform-instanceof/src/index.ts diff --git a/packages/babel-plugin-transform-jscript/src/index.js b/packages/babel-plugin-transform-jscript/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-jscript/src/index.js rename to packages/babel-plugin-transform-jscript/src/index.ts diff --git a/packages/babel-plugin-transform-literals/src/index.js b/packages/babel-plugin-transform-literals/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-literals/src/index.js rename to packages/babel-plugin-transform-literals/src/index.ts diff --git a/packages/babel-plugin-transform-member-expression-literals/src/index.js b/packages/babel-plugin-transform-member-expression-literals/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-member-expression-literals/src/index.js rename to packages/babel-plugin-transform-member-expression-literals/src/index.ts diff --git a/packages/babel-plugin-transform-modules-amd/src/index.js b/packages/babel-plugin-transform-modules-amd/src/index.ts similarity index 97% rename from packages/babel-plugin-transform-modules-amd/src/index.js rename to packages/babel-plugin-transform-modules-amd/src/index.ts index 737ef30a14..71b0b7585c 100644 --- a/packages/babel-plugin-transform-modules-amd/src/index.js +++ b/packages/babel-plugin-transform-modules-amd/src/index.ts @@ -70,7 +70,7 @@ export default declare((api, options) => { state.rejectId = rejectId; } - let result = t.identifier("imported"); + let result: t.Node = t.identifier("imported"); if (!noInterop) result = wrapInterop(path, result, "namespace"); path.replaceWith( @@ -105,6 +105,7 @@ export default declare((api, options) => { } let moduleName = getModuleName(this.file.opts, options); + // @ts-expect-error todo(flow->ts): do not reuse variables if (moduleName) moduleName = t.stringLiteral(moduleName); const { meta, headers } = rewriteModuleStatementsAndPrepareHeader( diff --git a/packages/babel-plugin-transform-modules-commonjs/src/index.js b/packages/babel-plugin-transform-modules-commonjs/src/index.ts similarity index 99% rename from packages/babel-plugin-transform-modules-commonjs/src/index.js rename to packages/babel-plugin-transform-modules-commonjs/src/index.ts index e33768c1cc..c142c2d230 100644 --- a/packages/babel-plugin-transform-modules-commonjs/src/index.js +++ b/packages/babel-plugin-transform-modules-commonjs/src/index.ts @@ -169,6 +169,7 @@ export default declare((api, options) => { } let moduleName = getModuleName(this.file.opts, options); + // @ts-expect-error todo(flow->ts): do not reuse variables if (moduleName) moduleName = t.stringLiteral(moduleName); const { meta, headers } = rewriteModuleStatementsAndPrepareHeader( diff --git a/packages/babel-plugin-transform-modules-systemjs/src/index.js b/packages/babel-plugin-transform-modules-systemjs/src/index.ts similarity index 98% rename from packages/babel-plugin-transform-modules-systemjs/src/index.js rename to packages/babel-plugin-transform-modules-systemjs/src/index.ts index b9407d8c1e..6a573f487b 100644 --- a/packages/babel-plugin-transform-modules-systemjs/src/index.js +++ b/packages/babel-plugin-transform-modules-systemjs/src/index.ts @@ -37,7 +37,7 @@ ERROR: Dynamic import() transformation must be enabled using the //todo: use getExportSpecifierName in `helper-module-transforms` when this library is refactored to NodePath usage. export function getExportSpecifierName( - node: Node, + node: t.Node, stringSpecifiers: Set, ): string { if (node.type === "Identifier") { @@ -61,15 +61,14 @@ export function getExportSpecifierName( } } -type PluginState = {| - contextIdent: string, - +type PluginState = { + contextIdent: string; // List of names that should only be printed as string literals. // i.e. `import { "any unicode" as foo } from "some-module"` // `stringSpecifiers` is Set(1) ["any unicode"] // In most cases `stringSpecifiers` is an empty Set - stringSpecifiers: Set, -|}; + stringSpecifiers: Set; +}; function constructExportCall( path, @@ -333,7 +332,7 @@ export default declare((api, options) => { const exportNames = []; const exportValues = []; - const body: Array = path.get("body"); + const body: Array = path.get("body"); for (const path of body) { if (path.isFunctionDeclaration()) { @@ -563,6 +562,7 @@ export default declare((api, options) => { }); let moduleName = getModuleName(this.file.opts, options); + // @ts-expect-error todo(flow->ts): do not reuse variables if (moduleName) moduleName = t.stringLiteral(moduleName); hoistVariables( diff --git a/packages/babel-plugin-transform-modules-umd/src/index.js b/packages/babel-plugin-transform-modules-umd/src/index.ts similarity index 98% rename from packages/babel-plugin-transform-modules-umd/src/index.js rename to packages/babel-plugin-transform-modules-umd/src/index.ts index 37a244b56c..ff8ef645f3 100644 --- a/packages/babel-plugin-transform-modules-umd/src/index.js +++ b/packages/babel-plugin-transform-modules-umd/src/index.ts @@ -147,6 +147,7 @@ export default declare((api, options) => { const browserGlobals = globals || {}; let moduleName = getModuleName(this.file.opts, options); + // @ts-expect-error todo(flow->ts): do not reuse variables if (moduleName) moduleName = t.stringLiteral(moduleName); const { meta, headers } = rewriteModuleStatementsAndPrepareHeader( @@ -202,6 +203,7 @@ export default declare((api, options) => { interop, ), ); + // @ts-expect-error todo(flow->ts) header.loc = meta.loc; headers.push(header); } diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/src/index.js b/packages/babel-plugin-transform-named-capturing-groups-regex/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-named-capturing-groups-regex/src/index.js rename to packages/babel-plugin-transform-named-capturing-groups-regex/src/index.ts diff --git a/packages/babel-plugin-transform-new-target/src/index.js b/packages/babel-plugin-transform-new-target/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-new-target/src/index.js rename to packages/babel-plugin-transform-new-target/src/index.ts diff --git a/packages/babel-plugin-transform-object-assign/src/index.js b/packages/babel-plugin-transform-object-assign/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-object-assign/src/index.js rename to packages/babel-plugin-transform-object-assign/src/index.ts diff --git a/packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.js b/packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.js rename to packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/index.ts diff --git a/packages/babel-plugin-transform-object-super/src/index.js b/packages/babel-plugin-transform-object-super/src/index.ts similarity index 96% rename from packages/babel-plugin-transform-object-super/src/index.js rename to packages/babel-plugin-transform-object-super/src/index.ts index c810a49d22..b375f575f9 100644 --- a/packages/babel-plugin-transform-object-super/src/index.js +++ b/packages/babel-plugin-transform-object-super/src/index.ts @@ -3,6 +3,7 @@ import ReplaceSupers from "@babel/helper-replace-supers"; import { types as t } from "@babel/core"; function replacePropertySuper(path, getObjectRef, file) { + // @ts-expect-error todo(flow->ts): const replaceSupers = new ReplaceSupers({ getObjectRef: getObjectRef, methodPath: path, diff --git a/packages/babel-plugin-transform-parameters/src/index.js b/packages/babel-plugin-transform-parameters/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-parameters/src/index.js rename to packages/babel-plugin-transform-parameters/src/index.ts diff --git a/packages/babel-plugin-transform-parameters/src/params.js b/packages/babel-plugin-transform-parameters/src/params.ts similarity index 99% rename from packages/babel-plugin-transform-parameters/src/params.js rename to packages/babel-plugin-transform-parameters/src/params.ts index aac3e64bb4..d9bfd15af9 100644 --- a/packages/babel-plugin-transform-parameters/src/params.js +++ b/packages/babel-plugin-transform-parameters/src/params.ts @@ -45,8 +45,8 @@ const iifeVisitor = { export default function convertFunctionParams( path, ignoreFunctionLength, - shouldTransformParam, - replaceRestElement, + shouldTransformParam?, + replaceRestElement?, ) { const params = path.get("params"); diff --git a/packages/babel-plugin-transform-parameters/src/rest.js b/packages/babel-plugin-transform-parameters/src/rest.ts similarity index 99% rename from packages/babel-plugin-transform-parameters/src/rest.js rename to packages/babel-plugin-transform-parameters/src/rest.ts index 2d2f422d3c..196c11f82d 100644 --- a/packages/babel-plugin-transform-parameters/src/rest.js +++ b/packages/babel-plugin-transform-parameters/src/rest.ts @@ -289,7 +289,7 @@ export default function convertFunctionRest(path) { // There are only "shorthand" references if (!state.deopted && !state.references.length) { - for (const { path, cause } of (state.candidates: Array)) { + for (const { path, cause } of state.candidates) { const clonedArgsId = t.cloneNode(argsId); switch (cause) { case "indexGetter": diff --git a/packages/babel-plugin-transform-property-literals/src/index.js b/packages/babel-plugin-transform-property-literals/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-property-literals/src/index.js rename to packages/babel-plugin-transform-property-literals/src/index.ts diff --git a/packages/babel-plugin-transform-property-mutators/src/index.js b/packages/babel-plugin-transform-property-mutators/src/index.ts similarity index 95% rename from packages/babel-plugin-transform-property-mutators/src/index.js rename to packages/babel-plugin-transform-property-mutators/src/index.ts index ee419c7e44..3ed962f38f 100644 --- a/packages/babel-plugin-transform-property-mutators/src/index.js +++ b/packages/babel-plugin-transform-property-mutators/src/index.ts @@ -12,7 +12,7 @@ export default declare(api => { ObjectExpression(path, file) { const { node } = path; let hasAny = false; - for (const prop of (node.properties: Array)) { + for (const prop of node.properties) { if (prop.kind === "get" || prop.kind === "set") { hasAny = true; break; diff --git a/packages/babel-plugin-transform-proto-to-assign/src/index.js b/packages/babel-plugin-transform-proto-to-assign/src/index.ts similarity index 88% rename from packages/babel-plugin-transform-proto-to-assign/src/index.js rename to packages/babel-plugin-transform-proto-to-assign/src/index.ts index 2c2a111df2..7a78893091 100644 --- a/packages/babel-plugin-transform-proto-to-assign/src/index.js +++ b/packages/babel-plugin-transform-proto-to-assign/src/index.ts @@ -12,6 +12,7 @@ export default declare(api => { const left = node.left; return ( t.isMemberExpression(left) && + // @ts-expect-error todo(flow->ts): property can be t.PrivateName t.isLiteral(t.toComputedKey(left, left.property), { value: "__proto__" }) ); } @@ -56,7 +57,12 @@ export default declare(api => { if (isProtoAssignmentExpression(expr)) { path.replaceWith( - buildDefaultsCallExpression(expr, expr.left.object, file), + buildDefaultsCallExpression( + expr, + // todo(flow->ts) isProtoAssignmentExpression actually checks that + (expr.left as t.MemberExpression).object, + file, + ), ); } }, diff --git a/packages/babel-plugin-transform-react-constant-elements/src/index.js b/packages/babel-plugin-transform-react-constant-elements/src/index.ts similarity index 98% rename from packages/babel-plugin-transform-react-constant-elements/src/index.js rename to packages/babel-plugin-transform-react-constant-elements/src/index.ts index 873b15a4d4..2beafc4965 100644 --- a/packages/babel-plugin-transform-react-constant-elements/src/index.js +++ b/packages/babel-plugin-transform-react-constant-elements/src/index.ts @@ -249,7 +249,8 @@ export default declare((api, options) => { const id = path.scope.generateUidBasedOnNode(name); targetScope.push({ id: t.identifier(id) }); - let replacement = template.expression.ast` + let replacement: t.Expression | t.JSXExpressionContainer = template + .expression.ast` ${t.identifier(id)} || (${t.identifier(id)} = ${path.node}) `; if ( diff --git a/packages/babel-plugin-transform-react-display-name/src/index.js b/packages/babel-plugin-transform-react-display-name/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-react-display-name/src/index.js rename to packages/babel-plugin-transform-react-display-name/src/index.ts diff --git a/packages/babel-plugin-transform-react-inline-elements/src/index.js b/packages/babel-plugin-transform-react-inline-elements/src/index.ts similarity index 93% rename from packages/babel-plugin-transform-react-inline-elements/src/index.js rename to packages/babel-plugin-transform-react-inline-elements/src/index.ts index 925d46032c..46199b940b 100644 --- a/packages/babel-plugin-transform-react-inline-elements/src/index.js +++ b/packages/babel-plugin-transform-react-inline-elements/src/index.ts @@ -48,9 +48,11 @@ export default declare(api => { let hasKey = false; if (t.isObjectExpression(props)) { const keyIndex = props.properties.findIndex(prop => + // @ts-expect-error todo(flow->ts) key does not exist on SpeadElement t.isIdentifier(prop.key, { name: "key" }), ); if (keyIndex > -1) { + // @ts-expect-error todo(flow->ts) value does not exist on ObjectMethod state.args.splice(2, 0, props.properties[keyIndex].value); props.properties.splice(keyIndex, 1); hasKey = true; diff --git a/packages/babel-plugin-transform-react-jsx-compat/src/index.js b/packages/babel-plugin-transform-react-jsx-compat/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-react-jsx-compat/src/index.js rename to packages/babel-plugin-transform-react-jsx-compat/src/index.ts diff --git a/packages/babel-plugin-transform-react-jsx-development/src/index.js b/packages/babel-plugin-transform-react-jsx-development/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-react-jsx-development/src/index.js rename to packages/babel-plugin-transform-react-jsx-development/src/index.ts diff --git a/packages/babel-plugin-transform-react-jsx-self/src/index.js b/packages/babel-plugin-transform-react-jsx-self/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-react-jsx-self/src/index.js rename to packages/babel-plugin-transform-react-jsx-self/src/index.ts diff --git a/packages/babel-plugin-transform-react-jsx-source/src/index.js b/packages/babel-plugin-transform-react-jsx-source/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-react-jsx-source/src/index.js rename to packages/babel-plugin-transform-react-jsx-source/src/index.ts diff --git a/packages/babel-plugin-transform-react-pure-annotations/src/index.js b/packages/babel-plugin-transform-react-pure-annotations/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-react-pure-annotations/src/index.js rename to packages/babel-plugin-transform-react-pure-annotations/src/index.ts diff --git a/packages/babel-plugin-transform-regenerator/src/index.js b/packages/babel-plugin-transform-regenerator/src/index.ts similarity index 63% rename from packages/babel-plugin-transform-regenerator/src/index.js rename to packages/babel-plugin-transform-regenerator/src/index.ts index 3c776e3d8f..a9af30f526 100644 --- a/packages/babel-plugin-transform-regenerator/src/index.js +++ b/packages/babel-plugin-transform-regenerator/src/index.ts @@ -1,2 +1,3 @@ +// eslint-disable-next-line @babel/development/plugin-name import regeneratorTransform from "regenerator-transform"; export default regeneratorTransform.default; diff --git a/packages/babel-plugin-transform-reserved-words/src/index.js b/packages/babel-plugin-transform-reserved-words/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-reserved-words/src/index.js rename to packages/babel-plugin-transform-reserved-words/src/index.ts diff --git a/packages/babel-plugin-transform-shorthand-properties/src/index.js b/packages/babel-plugin-transform-shorthand-properties/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-shorthand-properties/src/index.js rename to packages/babel-plugin-transform-shorthand-properties/src/index.ts diff --git a/packages/babel-plugin-transform-spread/src/index.ts b/packages/babel-plugin-transform-spread/src/index.ts index ee3ed8bbcd..ec68db00ff 100644 --- a/packages/babel-plugin-transform-spread/src/index.ts +++ b/packages/babel-plugin-transform-spread/src/index.ts @@ -167,7 +167,7 @@ export default declare((api, options) => { const callee = calleePath.node as t.MemberExpression; - if (calleePath.isMemberExpression()) { + if (t.isMemberExpression(callee)) { const temp = scope.maybeGenerateMemoised(callee.object); if (temp) { callee.object = t.assignmentExpression("=", temp, callee.object); diff --git a/packages/babel-plugin-transform-sticky-regex/src/index.js b/packages/babel-plugin-transform-sticky-regex/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-sticky-regex/src/index.js rename to packages/babel-plugin-transform-sticky-regex/src/index.ts diff --git a/packages/babel-plugin-transform-strict-mode/src/index.js b/packages/babel-plugin-transform-strict-mode/src/index.ts similarity index 87% rename from packages/babel-plugin-transform-strict-mode/src/index.js rename to packages/babel-plugin-transform-strict-mode/src/index.ts index 9be2ae2f15..8f3ae8b024 100644 --- a/packages/babel-plugin-transform-strict-mode/src/index.js +++ b/packages/babel-plugin-transform-strict-mode/src/index.ts @@ -11,7 +11,7 @@ export default declare(api => { Program(path) { const { node } = path; - for (const directive of (node.directives: Array)) { + for (const directive of node.directives) { if (directive.value.value === "use strict") return; } diff --git a/packages/babel-plugin-transform-template-literals/src/index.js b/packages/babel-plugin-transform-template-literals/src/index.ts similarity index 97% rename from packages/babel-plugin-transform-template-literals/src/index.js rename to packages/babel-plugin-transform-template-literals/src/index.ts index 5b588900d3..d3fdc6e678 100644 --- a/packages/babel-plugin-transform-template-literals/src/index.js +++ b/packages/babel-plugin-transform-template-literals/src/index.ts @@ -61,7 +61,7 @@ export default declare((api, options) => { // Flag variable to check if contents of strings and raw are equal let isStringsRawEqual = true; - for (const elem of (quasi.quasis: Array)) { + for (const elem of quasi.quasis) { const { raw, cooked } = elem.value; const value = cooked == null @@ -103,7 +103,7 @@ export default declare((api, options) => { const expressions = path.get("expressions"); let index = 0; - for (const elem of (path.node.quasis: Array)) { + for (const elem of path.node.quasis) { if (elem.value.cooked) { nodes.push(t.stringLiteral(elem.value.cooked)); } diff --git a/packages/babel-plugin-transform-typeof-symbol/src/index.js b/packages/babel-plugin-transform-typeof-symbol/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-typeof-symbol/src/index.js rename to packages/babel-plugin-transform-typeof-symbol/src/index.ts diff --git a/packages/babel-plugin-transform-unicode-escapes/src/index.js b/packages/babel-plugin-transform-unicode-escapes/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-unicode-escapes/src/index.js rename to packages/babel-plugin-transform-unicode-escapes/src/index.ts diff --git a/packages/babel-plugin-transform-unicode-regex/src/index.js b/packages/babel-plugin-transform-unicode-regex/src/index.ts similarity index 100% rename from packages/babel-plugin-transform-unicode-regex/src/index.js rename to packages/babel-plugin-transform-unicode-regex/src/index.ts diff --git a/packages/babel-preset-env/package.json b/packages/babel-preset-env/package.json index d70ab28728..5fe461c19b 100644 --- a/packages/babel-preset-env/package.json +++ b/packages/babel-preset-env/package.json @@ -97,7 +97,8 @@ "devDependencies": { "@babel/core": "workspace:^", "@babel/core-7.12": "npm:@babel/core@7.12.9", - "@babel/helper-plugin-test-runner": "workspace:^" + "@babel/helper-plugin-test-runner": "workspace:^", + "@babel/traverse": "workspace:^" }, "engines": { "node": ">=6.9.0" diff --git a/packages/babel-preset-env/src/index.ts b/packages/babel-preset-env/src/index.ts index 86de8f790f..53bf3998fc 100644 --- a/packages/babel-preset-env/src/index.ts +++ b/packages/babel-preset-env/src/index.ts @@ -336,7 +336,7 @@ option \`forceAllTransforms: true\` instead. ? forceAllTransforms : forceAllTransforms || hasUglifyTarget ) - ? {} + ? ({} as Targets) : targets; const include = transformIncludesAndExcludes(optionsInclude); diff --git a/packages/babel-preset-flow/src/index.js b/packages/babel-preset-flow/src/index.ts similarity index 100% rename from packages/babel-preset-flow/src/index.js rename to packages/babel-preset-flow/src/index.ts diff --git a/packages/babel-preset-flow/src/normalize-options.js b/packages/babel-preset-flow/src/normalize-options.ts similarity index 92% rename from packages/babel-preset-flow/src/normalize-options.js rename to packages/babel-preset-flow/src/normalize-options.ts index 9d79c4395b..77da4803a5 100644 --- a/packages/babel-preset-flow/src/normalize-options.js +++ b/packages/babel-preset-flow/src/normalize-options.ts @@ -1,7 +1,7 @@ import { OptionValidator } from "@babel/helper-validator-option"; const v = new OptionValidator("@babel/preset-flow"); -export default function normalizeOptions(options = {}) { +export default function normalizeOptions(options: any = {}) { let { all } = options; const { allowDeclareFields } = options; diff --git a/packages/babel-preset-react/src/index.js b/packages/babel-preset-react/src/index.ts similarity index 100% rename from packages/babel-preset-react/src/index.js rename to packages/babel-preset-react/src/index.ts diff --git a/packages/babel-preset-react/src/normalize-options.js b/packages/babel-preset-react/src/normalize-options.ts similarity index 98% rename from packages/babel-preset-react/src/normalize-options.js rename to packages/babel-preset-react/src/normalize-options.ts index 9061f07276..fcf4bfaa57 100644 --- a/packages/babel-preset-react/src/normalize-options.js +++ b/packages/babel-preset-react/src/normalize-options.ts @@ -4,7 +4,7 @@ import { } from "@babel/helper-validator-option"; const v = new OptionValidator("@babel/preset-react"); -export default function normalizeOptions(options = {}) { +export default function normalizeOptions(options: any = {}) { if (process.env.BABEL_8_BREAKING) { if ("useSpread" in options) { throw new Error( diff --git a/packages/babel-preset-typescript/src/index.js b/packages/babel-preset-typescript/src/index.ts similarity index 100% rename from packages/babel-preset-typescript/src/index.js rename to packages/babel-preset-typescript/src/index.ts diff --git a/packages/babel-preset-typescript/src/normalize-options.js b/packages/babel-preset-typescript/src/normalize-options.ts similarity index 97% rename from packages/babel-preset-typescript/src/normalize-options.js rename to packages/babel-preset-typescript/src/normalize-options.ts index 9d93723a58..419c18adb9 100644 --- a/packages/babel-preset-typescript/src/normalize-options.js +++ b/packages/babel-preset-typescript/src/normalize-options.ts @@ -1,7 +1,7 @@ import { OptionValidator } from "@babel/helper-validator-option"; const v = new OptionValidator("@babel/preset-typescript"); -export default function normalizeOptions(options = {}) { +export default function normalizeOptions(options = {} as any) { let { allowNamespaces = true, jsxPragma, onlyRemoveTypeImports } = options; const TopLevelOptions = { diff --git a/packages/babel-register/src/browser.js b/packages/babel-register/src/browser.ts similarity index 100% rename from packages/babel-register/src/browser.js rename to packages/babel-register/src/browser.ts diff --git a/packages/babel-register/src/cache.js b/packages/babel-register/src/cache.ts similarity index 98% rename from packages/babel-register/src/cache.js rename to packages/babel-register/src/cache.ts index 8e3f812b3d..80495ae782 100644 --- a/packages/babel-register/src/cache.js +++ b/packages/babel-register/src/cache.ts @@ -11,7 +11,7 @@ const DEFAULT_FILENAME = path.join( `.babel.${babel.version}.${babel.getEnv()}.json`, ); const FILENAME: string = process.env.BABEL_CACHE_PATH || DEFAULT_FILENAME; -let data: Object = {}; +let data: any = {}; let cacheDirty = false; @@ -112,7 +112,7 @@ due to a permission issue. Cache is disabled.`, * Retrieve data from cache. */ -export function get(): Object { +export function get(): any { return data; } diff --git a/packages/babel-register/src/node.js b/packages/babel-register/src/node.ts similarity index 91% rename from packages/babel-register/src/node.js rename to packages/babel-register/src/node.ts index 6d627a6574..f7990885f0 100644 --- a/packages/babel-register/src/node.js +++ b/packages/babel-register/src/node.ts @@ -9,7 +9,7 @@ import path from "path"; import Module from "module"; const maps = {}; -let transformOpts = {}; +let transformOpts: any = {}; let piratesRevert = null; function installSourceMapSupport() { @@ -52,7 +52,7 @@ function compile(code, filename) { let cacheKey = `${JSON.stringify(opts)}:${babel.version}`; - const env = babel.getEnv(false); + const env = babel.getEnv(""); if (env) cacheKey += `:${env}`; @@ -87,18 +87,22 @@ function compile(code, filename) { } let compiling = false; +// @ts-expect-error field is missing in type definitions const internalModuleCache = Module._cache; function compileHook(code, filename) { if (compiling) return code; + // @ts-expect-error field is missing in type definitions const globalModuleCache = Module._cache; try { compiling = true; + // @ts-expect-error field is missing in type definitions Module._cache = internalModuleCache; return compile(code, filename); } finally { compiling = false; + // @ts-expect-error field is missing in type definitions Module._cache = globalModuleCache; } } @@ -116,7 +120,7 @@ function escapeRegExp(string) { return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&"); } -export default function register(opts?: Object = {}) { +export default function register(opts: any = {}) { // Clone to avoid mutating the arguments object with the 'delete's below. opts = { ...opts, diff --git a/packages/babel-register/src/nodeWrapper.js b/packages/babel-register/src/nodeWrapper.ts similarity index 94% rename from packages/babel-register/src/nodeWrapper.js rename to packages/babel-register/src/nodeWrapper.ts index 13a7157b0d..1839dfc7e4 100644 --- a/packages/babel-register/src/nodeWrapper.js +++ b/packages/babel-register/src/nodeWrapper.ts @@ -5,6 +5,7 @@ * and allows register to transform these modules if they are loaded externally. */ +// @ts-ignore todo(flow->ts) convert to esm const Module = require("module"); const globalModuleCache = Module._cache; diff --git a/packages/babel-standalone/src/preset-stage-3.ts b/packages/babel-standalone/src/preset-stage-3.ts index b7d84d0251..d8a8bfcb46 100644 --- a/packages/babel-standalone/src/preset-stage-3.ts +++ b/packages/babel-standalone/src/preset-stage-3.ts @@ -1,7 +1,8 @@ import * as babelPlugins from "./generated/plugins"; export default (_: any, { loose = false } = {}) => { - const plugins = [ + // todo(flow->ts) improve types + const plugins: any[] = [ babelPlugins.syntaxImportAssertions, babelPlugins.proposalClassStaticBlock, ]; diff --git a/packages/babel-traverse/src/path/evaluation.ts b/packages/babel-traverse/src/path/evaluation.ts index de673dd007..89541ccd78 100644 --- a/packages/babel-traverse/src/path/evaluation.ts +++ b/packages/babel-traverse/src/path/evaluation.ts @@ -139,8 +139,8 @@ function _evaluate(path: NodePath, state) { path.isMemberExpression() && !path.parentPath.isCallExpression({ callee: path.node }) ) { - const property = path.get("property") as NodePath; - const object = path.get("object") as NodePath; + const property = path.get("property"); + const object = path.get("object"); if (object.isLiteral() && property.isIdentifier()) { // @ts-expect-error todo(flow->ts): instead of typeof - would it be better to check type of ast node? @@ -353,8 +353,7 @@ function _evaluate(path: NodePath, state) { if (callee.isMemberExpression()) { const object = callee.get("object"); - // todo: improve babel-types - const property = callee.get("property") as NodePath; + const property = callee.get("property"); // Math.min(1, 2) if ( diff --git a/packages/babel-traverse/src/scope/index.ts b/packages/babel-traverse/src/scope/index.ts index 056dc22078..93aa941016 100644 --- a/packages/babel-traverse/src/scope/index.ts +++ b/packages/babel-traverse/src/scope/index.ts @@ -1091,7 +1091,7 @@ export default class Scope { * Walks the scope tree and gathers all declarations of `kind`. */ - getAllBindingsOfKind(...kinds: string[]): any { + getAllBindingsOfKind(...kinds: string[]): Record { const ids = Object.create(null); for (const kind of kinds) { diff --git a/scripts/generators/tsconfig.js b/scripts/generators/tsconfig.js index 413f4e3e75..974170cc4c 100644 --- a/scripts/generators/tsconfig.js +++ b/scripts/generators/tsconfig.js @@ -16,7 +16,12 @@ function getTsPkgs(subRoot) { dir: path.resolve(root, subRoot, name), relative: `./${subRoot}/${name}`, })) - .filter(({ dir }) => fs.existsSync(path.join(dir, "src", "index.ts"))); + .filter( + ({ dir }) => + // babel-register is special-cased because its entry point is a js file + dir.includes("babel-register") || + fs.existsSync(path.join(dir, "src", "index.ts")) + ); } const tsPkgs = [ diff --git a/tsconfig.json b/tsconfig.json index edf6a89408..2ba274f749 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,12 @@ "./packages/babel-core/src/**/*.ts", "./packages/babel-generator/src/**/*.ts", "./packages/babel-helper-annotate-as-pure/src/**/*.ts", + "./packages/babel-helper-builder-binary-assignment-operator-visitor/src/**/*.ts", + "./packages/babel-helper-builder-react-jsx/src/**/*.ts", "./packages/babel-helper-compilation-targets/src/**/*.ts", "./packages/babel-helper-create-class-features-plugin/src/**/*.ts", "./packages/babel-helper-create-regexp-features-plugin/src/**/*.ts", + "./packages/babel-helper-define-map/src/**/*.ts", "./packages/babel-helper-explode-assignable-expression/src/**/*.ts", "./packages/babel-helper-fixtures/src/**/*.ts", "./packages/babel-helper-function-name/src/**/*.ts", @@ -18,6 +21,9 @@ "./packages/babel-helper-module-imports/src/**/*.ts", "./packages/babel-helper-module-transforms/src/**/*.ts", "./packages/babel-helper-optimise-call-expression/src/**/*.ts", + "./packages/babel-helper-plugin-test-runner/src/**/*.ts", + "./packages/babel-helper-plugin-utils/src/**/*.ts", + "./packages/babel-helper-remap-async-to-generator/src/**/*.ts", "./packages/babel-helper-replace-supers/src/**/*.ts", "./packages/babel-helper-simple-access/src/**/*.ts", "./packages/babel-helper-skip-transparent-expression-wrappers/src/**/*.ts", @@ -25,24 +31,119 @@ "./packages/babel-helper-transform-fixture-test-runner/src/**/*.ts", "./packages/babel-helper-validator-identifier/src/**/*.ts", "./packages/babel-helper-validator-option/src/**/*.ts", + "./packages/babel-helper-wrap-function/src/**/*.ts", "./packages/babel-helpers/src/**/*.ts", "./packages/babel-highlight/src/**/*.ts", "./packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression/src/**/*.ts", "./packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/src/**/*.ts", + "./packages/babel-plugin-external-helpers/src/**/*.ts", "./packages/babel-plugin-proposal-async-do-expressions/src/**/*.ts", + "./packages/babel-plugin-proposal-async-generator-functions/src/**/*.ts", + "./packages/babel-plugin-proposal-class-properties/src/**/*.ts", + "./packages/babel-plugin-proposal-class-static-block/src/**/*.ts", + "./packages/babel-plugin-proposal-decorators/src/**/*.ts", + "./packages/babel-plugin-proposal-do-expressions/src/**/*.ts", + "./packages/babel-plugin-proposal-dynamic-import/src/**/*.ts", + "./packages/babel-plugin-proposal-export-default-from/src/**/*.ts", + "./packages/babel-plugin-proposal-export-namespace-from/src/**/*.ts", + "./packages/babel-plugin-proposal-function-bind/src/**/*.ts", + "./packages/babel-plugin-proposal-function-sent/src/**/*.ts", + "./packages/babel-plugin-proposal-json-strings/src/**/*.ts", + "./packages/babel-plugin-proposal-logical-assignment-operators/src/**/*.ts", + "./packages/babel-plugin-proposal-nullish-coalescing-operator/src/**/*.ts", + "./packages/babel-plugin-proposal-numeric-separator/src/**/*.ts", "./packages/babel-plugin-proposal-object-rest-spread/src/**/*.ts", + "./packages/babel-plugin-proposal-optional-catch-binding/src/**/*.ts", + "./packages/babel-plugin-proposal-optional-chaining/src/**/*.ts", + "./packages/babel-plugin-proposal-partial-application/src/**/*.ts", + "./packages/babel-plugin-proposal-pipeline-operator/src/**/*.ts", + "./packages/babel-plugin-proposal-private-methods/src/**/*.ts", + "./packages/babel-plugin-proposal-private-property-in-object/src/**/*.ts", + "./packages/babel-plugin-proposal-record-and-tuple/src/**/*.ts", + "./packages/babel-plugin-proposal-throw-expressions/src/**/*.ts", + "./packages/babel-plugin-proposal-unicode-property-regex/src/**/*.ts", "./packages/babel-plugin-syntax-async-do-expressions/src/**/*.ts", + "./packages/babel-plugin-syntax-decimal/src/**/*.ts", + "./packages/babel-plugin-syntax-decorators/src/**/*.ts", + "./packages/babel-plugin-syntax-do-expressions/src/**/*.ts", + "./packages/babel-plugin-syntax-export-default-from/src/**/*.ts", + "./packages/babel-plugin-syntax-flow/src/**/*.ts", + "./packages/babel-plugin-syntax-function-bind/src/**/*.ts", + "./packages/babel-plugin-syntax-function-sent/src/**/*.ts", + "./packages/babel-plugin-syntax-import-assertions/src/**/*.ts", + "./packages/babel-plugin-syntax-jsx/src/**/*.ts", + "./packages/babel-plugin-syntax-module-blocks/src/**/*.ts", + "./packages/babel-plugin-syntax-partial-application/src/**/*.ts", + "./packages/babel-plugin-syntax-pipeline-operator/src/**/*.ts", + "./packages/babel-plugin-syntax-record-and-tuple/src/**/*.ts", + "./packages/babel-plugin-syntax-throw-expressions/src/**/*.ts", + "./packages/babel-plugin-syntax-typescript/src/**/*.ts", + "./packages/babel-plugin-transform-arrow-functions/src/**/*.ts", + "./packages/babel-plugin-transform-async-to-generator/src/**/*.ts", + "./packages/babel-plugin-transform-block-scoped-functions/src/**/*.ts", "./packages/babel-plugin-transform-block-scoping/src/**/*.ts", "./packages/babel-plugin-transform-classes/src/**/*.ts", + "./packages/babel-plugin-transform-computed-properties/src/**/*.ts", + "./packages/babel-plugin-transform-destructuring/src/**/*.ts", + "./packages/babel-plugin-transform-dotall-regex/src/**/*.ts", + "./packages/babel-plugin-transform-duplicate-keys/src/**/*.ts", + "./packages/babel-plugin-transform-exponentiation-operator/src/**/*.ts", + "./packages/babel-plugin-transform-flow-comments/src/**/*.ts", + "./packages/babel-plugin-transform-flow-strip-types/src/**/*.ts", + "./packages/babel-plugin-transform-for-of/src/**/*.ts", + "./packages/babel-plugin-transform-function-name/src/**/*.ts", + "./packages/babel-plugin-transform-instanceof/src/**/*.ts", + "./packages/babel-plugin-transform-jscript/src/**/*.ts", + "./packages/babel-plugin-transform-literals/src/**/*.ts", + "./packages/babel-plugin-transform-member-expression-literals/src/**/*.ts", + "./packages/babel-plugin-transform-modules-amd/src/**/*.ts", + "./packages/babel-plugin-transform-modules-commonjs/src/**/*.ts", + "./packages/babel-plugin-transform-modules-systemjs/src/**/*.ts", + "./packages/babel-plugin-transform-modules-umd/src/**/*.ts", + "./packages/babel-plugin-transform-named-capturing-groups-regex/src/**/*.ts", + "./packages/babel-plugin-transform-new-target/src/**/*.ts", + "./packages/babel-plugin-transform-object-assign/src/**/*.ts", + "./packages/babel-plugin-transform-object-set-prototype-of-to-assign/src/**/*.ts", + "./packages/babel-plugin-transform-object-super/src/**/*.ts", + "./packages/babel-plugin-transform-parameters/src/**/*.ts", + "./packages/babel-plugin-transform-property-literals/src/**/*.ts", + "./packages/babel-plugin-transform-property-mutators/src/**/*.ts", + "./packages/babel-plugin-transform-proto-to-assign/src/**/*.ts", + "./packages/babel-plugin-transform-react-constant-elements/src/**/*.ts", + "./packages/babel-plugin-transform-react-display-name/src/**/*.ts", + "./packages/babel-plugin-transform-react-inline-elements/src/**/*.ts", "./packages/babel-plugin-transform-react-jsx/src/**/*.ts", + "./packages/babel-plugin-transform-react-jsx-compat/src/**/*.ts", + "./packages/babel-plugin-transform-react-jsx-development/src/**/*.ts", + "./packages/babel-plugin-transform-react-jsx-self/src/**/*.ts", + "./packages/babel-plugin-transform-react-jsx-source/src/**/*.ts", + "./packages/babel-plugin-transform-react-pure-annotations/src/**/*.ts", + "./packages/babel-plugin-transform-regenerator/src/**/*.ts", + "./packages/babel-plugin-transform-reserved-words/src/**/*.ts", "./packages/babel-plugin-transform-runtime/src/**/*.ts", + "./packages/babel-plugin-transform-shorthand-properties/src/**/*.ts", "./packages/babel-plugin-transform-spread/src/**/*.ts", + "./packages/babel-plugin-transform-sticky-regex/src/**/*.ts", + "./packages/babel-plugin-transform-strict-mode/src/**/*.ts", + "./packages/babel-plugin-transform-template-literals/src/**/*.ts", + "./packages/babel-plugin-transform-typeof-symbol/src/**/*.ts", "./packages/babel-plugin-transform-typescript/src/**/*.ts", + "./packages/babel-plugin-transform-unicode-escapes/src/**/*.ts", + "./packages/babel-plugin-transform-unicode-regex/src/**/*.ts", "./packages/babel-preset-env/src/**/*.ts", + "./packages/babel-preset-flow/src/**/*.ts", + "./packages/babel-preset-react/src/**/*.ts", + "./packages/babel-preset-typescript/src/**/*.ts", + "./packages/babel-register/src/**/*.ts", "./packages/babel-standalone/src/**/*.ts", "./packages/babel-template/src/**/*.ts", "./packages/babel-traverse/src/**/*.ts", - "./packages/babel-types/src/**/*.ts" + "./packages/babel-types/src/**/*.ts", + "./eslint/babel-eslint-plugin/src/**/*.ts", + "./eslint/babel-eslint-plugin-development/src/**/*.ts", + "./eslint/babel-eslint-plugin-development-internal/src/**/*.ts", + "./codemods/babel-plugin-codemod-object-assign-to-object-spread/src/**/*.ts", + "./codemods/babel-plugin-codemod-optional-catch-binding/src/**/*.ts" ], "compilerOptions": { "paths": { @@ -58,6 +159,12 @@ "@babel/helper-annotate-as-pure": [ "./packages/babel-helper-annotate-as-pure/src" ], + "@babel/helper-builder-binary-assignment-operator-visitor": [ + "./packages/babel-helper-builder-binary-assignment-operator-visitor/src" + ], + "@babel/helper-builder-react-jsx": [ + "./packages/babel-helper-builder-react-jsx/src" + ], "@babel/helper-compilation-targets": [ "./packages/babel-helper-compilation-targets/src" ], @@ -67,6 +174,9 @@ "@babel/helper-create-regexp-features-plugin": [ "./packages/babel-helper-create-regexp-features-plugin/src" ], + "@babel/helper-define-map": [ + "./packages/babel-helper-define-map/src" + ], "@babel/helper-explode-assignable-expression": [ "./packages/babel-helper-explode-assignable-expression/src" ], @@ -94,6 +204,15 @@ "@babel/helper-optimise-call-expression": [ "./packages/babel-helper-optimise-call-expression/src" ], + "@babel/helper-plugin-test-runner": [ + "./packages/babel-helper-plugin-test-runner/src" + ], + "@babel/helper-plugin-utils": [ + "./packages/babel-helper-plugin-utils/src" + ], + "@babel/helper-remap-async-to-generator": [ + "./packages/babel-helper-remap-async-to-generator/src" + ], "@babel/helper-replace-supers": [ "./packages/babel-helper-replace-supers/src" ], @@ -115,6 +234,9 @@ "@babel/helper-validator-option": [ "./packages/babel-helper-validator-option/src" ], + "@babel/helper-wrap-function": [ + "./packages/babel-helper-wrap-function/src" + ], "@babel/helpers": [ "./packages/babel-helpers/src" ], @@ -127,36 +249,303 @@ "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": [ "./packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/src" ], + "@babel/plugin-external-helpers": [ + "./packages/babel-plugin-external-helpers/src" + ], "@babel/plugin-proposal-async-do-expressions": [ "./packages/babel-plugin-proposal-async-do-expressions/src" ], + "@babel/plugin-proposal-async-generator-functions": [ + "./packages/babel-plugin-proposal-async-generator-functions/src" + ], + "@babel/plugin-proposal-class-properties": [ + "./packages/babel-plugin-proposal-class-properties/src" + ], + "@babel/plugin-proposal-class-static-block": [ + "./packages/babel-plugin-proposal-class-static-block/src" + ], + "@babel/plugin-proposal-decorators": [ + "./packages/babel-plugin-proposal-decorators/src" + ], + "@babel/plugin-proposal-do-expressions": [ + "./packages/babel-plugin-proposal-do-expressions/src" + ], + "@babel/plugin-proposal-dynamic-import": [ + "./packages/babel-plugin-proposal-dynamic-import/src" + ], + "@babel/plugin-proposal-export-default-from": [ + "./packages/babel-plugin-proposal-export-default-from/src" + ], + "@babel/plugin-proposal-export-namespace-from": [ + "./packages/babel-plugin-proposal-export-namespace-from/src" + ], + "@babel/plugin-proposal-function-bind": [ + "./packages/babel-plugin-proposal-function-bind/src" + ], + "@babel/plugin-proposal-function-sent": [ + "./packages/babel-plugin-proposal-function-sent/src" + ], + "@babel/plugin-proposal-json-strings": [ + "./packages/babel-plugin-proposal-json-strings/src" + ], + "@babel/plugin-proposal-logical-assignment-operators": [ + "./packages/babel-plugin-proposal-logical-assignment-operators/src" + ], + "@babel/plugin-proposal-nullish-coalescing-operator": [ + "./packages/babel-plugin-proposal-nullish-coalescing-operator/src" + ], + "@babel/plugin-proposal-numeric-separator": [ + "./packages/babel-plugin-proposal-numeric-separator/src" + ], "@babel/plugin-proposal-object-rest-spread": [ "./packages/babel-plugin-proposal-object-rest-spread/src" ], + "@babel/plugin-proposal-optional-catch-binding": [ + "./packages/babel-plugin-proposal-optional-catch-binding/src" + ], + "@babel/plugin-proposal-optional-chaining": [ + "./packages/babel-plugin-proposal-optional-chaining/src" + ], + "@babel/plugin-proposal-partial-application": [ + "./packages/babel-plugin-proposal-partial-application/src" + ], + "@babel/plugin-proposal-pipeline-operator": [ + "./packages/babel-plugin-proposal-pipeline-operator/src" + ], + "@babel/plugin-proposal-private-methods": [ + "./packages/babel-plugin-proposal-private-methods/src" + ], + "@babel/plugin-proposal-private-property-in-object": [ + "./packages/babel-plugin-proposal-private-property-in-object/src" + ], + "@babel/plugin-proposal-record-and-tuple": [ + "./packages/babel-plugin-proposal-record-and-tuple/src" + ], + "@babel/plugin-proposal-throw-expressions": [ + "./packages/babel-plugin-proposal-throw-expressions/src" + ], + "@babel/plugin-proposal-unicode-property-regex": [ + "./packages/babel-plugin-proposal-unicode-property-regex/src" + ], "@babel/plugin-syntax-async-do-expressions": [ "./packages/babel-plugin-syntax-async-do-expressions/src" ], + "@babel/plugin-syntax-decimal": [ + "./packages/babel-plugin-syntax-decimal/src" + ], + "@babel/plugin-syntax-decorators": [ + "./packages/babel-plugin-syntax-decorators/src" + ], + "@babel/plugin-syntax-do-expressions": [ + "./packages/babel-plugin-syntax-do-expressions/src" + ], + "@babel/plugin-syntax-export-default-from": [ + "./packages/babel-plugin-syntax-export-default-from/src" + ], + "@babel/plugin-syntax-flow": [ + "./packages/babel-plugin-syntax-flow/src" + ], + "@babel/plugin-syntax-function-bind": [ + "./packages/babel-plugin-syntax-function-bind/src" + ], + "@babel/plugin-syntax-function-sent": [ + "./packages/babel-plugin-syntax-function-sent/src" + ], + "@babel/plugin-syntax-import-assertions": [ + "./packages/babel-plugin-syntax-import-assertions/src" + ], + "@babel/plugin-syntax-jsx": [ + "./packages/babel-plugin-syntax-jsx/src" + ], + "@babel/plugin-syntax-module-blocks": [ + "./packages/babel-plugin-syntax-module-blocks/src" + ], + "@babel/plugin-syntax-partial-application": [ + "./packages/babel-plugin-syntax-partial-application/src" + ], + "@babel/plugin-syntax-pipeline-operator": [ + "./packages/babel-plugin-syntax-pipeline-operator/src" + ], + "@babel/plugin-syntax-record-and-tuple": [ + "./packages/babel-plugin-syntax-record-and-tuple/src" + ], + "@babel/plugin-syntax-throw-expressions": [ + "./packages/babel-plugin-syntax-throw-expressions/src" + ], + "@babel/plugin-syntax-typescript": [ + "./packages/babel-plugin-syntax-typescript/src" + ], + "@babel/plugin-transform-arrow-functions": [ + "./packages/babel-plugin-transform-arrow-functions/src" + ], + "@babel/plugin-transform-async-to-generator": [ + "./packages/babel-plugin-transform-async-to-generator/src" + ], + "@babel/plugin-transform-block-scoped-functions": [ + "./packages/babel-plugin-transform-block-scoped-functions/src" + ], "@babel/plugin-transform-block-scoping": [ "./packages/babel-plugin-transform-block-scoping/src" ], "@babel/plugin-transform-classes": [ "./packages/babel-plugin-transform-classes/src" ], + "@babel/plugin-transform-computed-properties": [ + "./packages/babel-plugin-transform-computed-properties/src" + ], + "@babel/plugin-transform-destructuring": [ + "./packages/babel-plugin-transform-destructuring/src" + ], + "@babel/plugin-transform-dotall-regex": [ + "./packages/babel-plugin-transform-dotall-regex/src" + ], + "@babel/plugin-transform-duplicate-keys": [ + "./packages/babel-plugin-transform-duplicate-keys/src" + ], + "@babel/plugin-transform-exponentiation-operator": [ + "./packages/babel-plugin-transform-exponentiation-operator/src" + ], + "@babel/plugin-transform-flow-comments": [ + "./packages/babel-plugin-transform-flow-comments/src" + ], + "@babel/plugin-transform-flow-strip-types": [ + "./packages/babel-plugin-transform-flow-strip-types/src" + ], + "@babel/plugin-transform-for-of": [ + "./packages/babel-plugin-transform-for-of/src" + ], + "@babel/plugin-transform-function-name": [ + "./packages/babel-plugin-transform-function-name/src" + ], + "@babel/plugin-transform-instanceof": [ + "./packages/babel-plugin-transform-instanceof/src" + ], + "@babel/plugin-transform-jscript": [ + "./packages/babel-plugin-transform-jscript/src" + ], + "@babel/plugin-transform-literals": [ + "./packages/babel-plugin-transform-literals/src" + ], + "@babel/plugin-transform-member-expression-literals": [ + "./packages/babel-plugin-transform-member-expression-literals/src" + ], + "@babel/plugin-transform-modules-amd": [ + "./packages/babel-plugin-transform-modules-amd/src" + ], + "@babel/plugin-transform-modules-commonjs": [ + "./packages/babel-plugin-transform-modules-commonjs/src" + ], + "@babel/plugin-transform-modules-systemjs": [ + "./packages/babel-plugin-transform-modules-systemjs/src" + ], + "@babel/plugin-transform-modules-umd": [ + "./packages/babel-plugin-transform-modules-umd/src" + ], + "@babel/plugin-transform-named-capturing-groups-regex": [ + "./packages/babel-plugin-transform-named-capturing-groups-regex/src" + ], + "@babel/plugin-transform-new-target": [ + "./packages/babel-plugin-transform-new-target/src" + ], + "@babel/plugin-transform-object-assign": [ + "./packages/babel-plugin-transform-object-assign/src" + ], + "@babel/plugin-transform-object-set-prototype-of-to-assign": [ + "./packages/babel-plugin-transform-object-set-prototype-of-to-assign/src" + ], + "@babel/plugin-transform-object-super": [ + "./packages/babel-plugin-transform-object-super/src" + ], + "@babel/plugin-transform-parameters": [ + "./packages/babel-plugin-transform-parameters/src" + ], + "@babel/plugin-transform-property-literals": [ + "./packages/babel-plugin-transform-property-literals/src" + ], + "@babel/plugin-transform-property-mutators": [ + "./packages/babel-plugin-transform-property-mutators/src" + ], + "@babel/plugin-transform-proto-to-assign": [ + "./packages/babel-plugin-transform-proto-to-assign/src" + ], + "@babel/plugin-transform-react-constant-elements": [ + "./packages/babel-plugin-transform-react-constant-elements/src" + ], + "@babel/plugin-transform-react-display-name": [ + "./packages/babel-plugin-transform-react-display-name/src" + ], + "@babel/plugin-transform-react-inline-elements": [ + "./packages/babel-plugin-transform-react-inline-elements/src" + ], "@babel/plugin-transform-react-jsx": [ "./packages/babel-plugin-transform-react-jsx/src" ], + "@babel/plugin-transform-react-jsx-compat": [ + "./packages/babel-plugin-transform-react-jsx-compat/src" + ], + "@babel/plugin-transform-react-jsx-development": [ + "./packages/babel-plugin-transform-react-jsx-development/src" + ], + "@babel/plugin-transform-react-jsx-self": [ + "./packages/babel-plugin-transform-react-jsx-self/src" + ], + "@babel/plugin-transform-react-jsx-source": [ + "./packages/babel-plugin-transform-react-jsx-source/src" + ], + "@babel/plugin-transform-react-pure-annotations": [ + "./packages/babel-plugin-transform-react-pure-annotations/src" + ], + "@babel/plugin-transform-regenerator": [ + "./packages/babel-plugin-transform-regenerator/src" + ], + "@babel/plugin-transform-reserved-words": [ + "./packages/babel-plugin-transform-reserved-words/src" + ], "@babel/plugin-transform-runtime": [ "./packages/babel-plugin-transform-runtime/src" ], + "@babel/plugin-transform-shorthand-properties": [ + "./packages/babel-plugin-transform-shorthand-properties/src" + ], "@babel/plugin-transform-spread": [ "./packages/babel-plugin-transform-spread/src" ], + "@babel/plugin-transform-sticky-regex": [ + "./packages/babel-plugin-transform-sticky-regex/src" + ], + "@babel/plugin-transform-strict-mode": [ + "./packages/babel-plugin-transform-strict-mode/src" + ], + "@babel/plugin-transform-template-literals": [ + "./packages/babel-plugin-transform-template-literals/src" + ], + "@babel/plugin-transform-typeof-symbol": [ + "./packages/babel-plugin-transform-typeof-symbol/src" + ], "@babel/plugin-transform-typescript": [ "./packages/babel-plugin-transform-typescript/src" ], + "@babel/plugin-transform-unicode-escapes": [ + "./packages/babel-plugin-transform-unicode-escapes/src" + ], + "@babel/plugin-transform-unicode-regex": [ + "./packages/babel-plugin-transform-unicode-regex/src" + ], "@babel/preset-env": [ "./packages/babel-preset-env/src" ], + "@babel/preset-flow": [ + "./packages/babel-preset-flow/src" + ], + "@babel/preset-react": [ + "./packages/babel-preset-react/src" + ], + "@babel/preset-typescript": [ + "./packages/babel-preset-typescript/src" + ], + "@babel/register": [ + "./packages/babel-register/src" + ], "@babel/standalone": [ "./packages/babel-standalone/src" ], @@ -168,6 +557,21 @@ ], "@babel/types": [ "./packages/babel-types/src" + ], + "@babel/eslint-plugin": [ + "./eslint/babel-eslint-plugin/src" + ], + "@babel/eslint-plugin-development": [ + "./eslint/babel-eslint-plugin-development/src" + ], + "@babel/eslint-plugin-development-internal": [ + "./eslint/babel-eslint-plugin-development-internal/src" + ], + "@babel/plugin-codemod-object-assign-to-object-spread": [ + "./codemods/babel-plugin-codemod-object-assign-to-object-spread/src" + ], + "@babel/plugin-codemod-optional-catch-binding": [ + "./codemods/babel-plugin-codemod-optional-catch-binding/src" ] } } diff --git a/yarn.lock b/yarn.lock index 6f16fac72c..8a82ef2fe0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -466,6 +466,7 @@ __metadata: resolution: "@babel/helper-builder-react-jsx@workspace:packages/babel-helper-builder-react-jsx" dependencies: "@babel/helper-annotate-as-pure": "workspace:^" + "@babel/traverse": "workspace:^" "@babel/types": "workspace:^" languageName: unknown linkType: soft @@ -1231,6 +1232,8 @@ __metadata: "@babel/helper-plugin-test-runner": "workspace:^" "@babel/helper-plugin-utils": "workspace:^" "@babel/plugin-syntax-class-static-block": ^7.14.5 + "@babel/traverse": "workspace:^" + "@babel/types": "workspace:^" peerDependencies: "@babel/core": ^7.12.0 languageName: unknown @@ -1245,6 +1248,7 @@ __metadata: "@babel/helper-plugin-test-runner": "workspace:^" "@babel/helper-plugin-utils": "workspace:^" "@babel/plugin-syntax-decorators": "workspace:^" + "@babel/traverse": "workspace:^" babel-plugin-polyfill-es-shims: ^0.6.0 object.getownpropertydescriptors: ^2.1.1 peerDependencies: @@ -1452,6 +1456,8 @@ __metadata: "@babel/helper-plugin-test-runner": "workspace:^" "@babel/helper-plugin-utils": "workspace:^" "@babel/plugin-syntax-numeric-separator": ^7.10.4 + "@babel/traverse": "workspace:^" + "@babel/types": "workspace:^" peerDependencies: "@babel/core": ^7.0.0-0 languageName: unknown @@ -1537,6 +1543,7 @@ __metadata: "@babel/helper-skip-transparent-expression-wrappers": "workspace:^" "@babel/plugin-syntax-optional-chaining": ^7.8.3 "@babel/plugin-transform-block-scoping": "workspace:^" + "@babel/traverse": "workspace:^" peerDependencies: "@babel/core": ^7.0.0-0 languageName: unknown @@ -2067,6 +2074,7 @@ __metadata: "@babel/helper-plugin-test-runner": "workspace:^" "@babel/helper-plugin-utils": "workspace:^" "@babel/traverse": "workspace:^" + "@babel/types": "workspace:^" peerDependencies: "@babel/core": ^7.0.0-0 languageName: unknown @@ -2223,6 +2231,7 @@ __metadata: "@babel/core": "workspace:^" "@babel/helper-plugin-test-runner": "workspace:^" "@babel/helper-plugin-utils": "workspace:^" + "@babel/traverse": "workspace:^" peerDependencies: "@babel/core": ^7.0.0-0 languageName: unknown @@ -3316,6 +3325,7 @@ __metadata: "@babel/plugin-transform-unicode-escapes": "workspace:^" "@babel/plugin-transform-unicode-regex": "workspace:^" "@babel/preset-modules": ^0.1.5 + "@babel/traverse": "workspace:^" "@babel/types": "workspace:^" babel-plugin-polyfill-corejs2: ^0.3.0 babel-plugin-polyfill-corejs3: ^0.4.0