From d23c3ca10b392a3b2ca7191638b20c00e32d3202 Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Thu, 1 Feb 2018 03:03:30 -0800 Subject: [PATCH] Rename `Ast` to a more appropriate `BabelNode` in the babel flow type Summary: An Ast consists of `Node` elements and the one Babel uses is specific to Babel (incompatible with Astree spec by default) so `BabelNode` seems more appropriate. Keeping the other `ast` names for now to reduce the footprint of this diff. Also makes sure `babel-core` properly exports the same node type as what the api returns making fixes to this type in the future easier to implement. Reviewed By: davidaurelio Differential Revision: D6834291 fbshipit-source-id: 4cb0eb2ee280a4988071b8412539edfad12cf56f --- flow-typed/babel.js.flow | 11 +++++------ packages/metro/src/Bundler/util.js | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flow-typed/babel.js.flow b/flow-typed/babel.js.flow index 7775a30c..4bda3054 100644 --- a/flow-typed/babel.js.flow +++ b/flow-typed/babel.js.flow @@ -102,10 +102,10 @@ type _TransformOptions = __TransformOptions & { env?: {[key: string]: __TransformOptions}, }; -type Ast = {}; +type BabelNode = {}; type TransformResult = { - ast: Ast, + ast: BabelNode, code: ?string, ignored: boolean, map: ?_BabelSourceMap, @@ -123,14 +123,13 @@ type BabelTypes = {[key: string]: Function}; declare module 'babel-core' { declare type Plugins = _Plugins; declare type BabelSourceMap = _BabelSourceMap; - declare type Ast = {}; + declare type Ast = BabelNode; declare type TransformOptions = _TransformOptions; declare var transform: TransformSync /*( code: string, options?: _TransformOptions, ): TransformResult*/; declare function traverse( - ast: Ast, ast: BabelNode, visitor: BabelVisitor, scope?: ?Object, @@ -140,7 +139,7 @@ declare module 'babel-core' { declare var types: BabelTypes; declare var transformFile: TransformFile; declare var transformFromAst: TransformFromAst /*( - ast: Ast, + ast: BabelNode, code?: ?string, babelOptions?: _TransformOptions, ): TransformResult*/; @@ -157,7 +156,7 @@ type _BabelSourceMapSegment = { declare module 'babel-generator' { declare export type BabelSourceMapSegment = _BabelSourceMapSegment; declare export default ( - ast: Ast, + ast: BabelNode, options?: GeneratorOptions, code?: string | {[string]: string}, ) => GeneratorResult diff --git a/packages/metro/src/Bundler/util.js b/packages/metro/src/Bundler/util.js index f086ebca..8cbbe82b 100644 --- a/packages/metro/src/Bundler/util.js +++ b/packages/metro/src/Bundler/util.js @@ -17,6 +17,7 @@ const {babelTypes} = require('../babel-bridge'); import type {AssetDataWithoutFiles} from '../Assets'; import type {ModuleTransportLike} from '../shared/types.flow'; +import type {Ast} from '@babel/core'; // Structure of the object: dir.name.scale = asset export type RemoteFileMap = {