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
This commit is contained in:
Peter van der Zee 2018-02-01 03:03:30 -08:00 committed by Facebook Github Bot
parent 7fcff0a976
commit d23c3ca10b
2 changed files with 6 additions and 6 deletions

View File

@ -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<State>(
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

View File

@ -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 = {