From 4403f811026fde8a090c87b989ce3a6d748430ef Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Fri, 12 Jan 2018 04:09:45 -0800 Subject: [PATCH] Rename `BabelRawMapping` to `BabelSourceMapSegment` Reviewed By: mjesun Differential Revision: D6702880 fbshipit-source-id: 4c800ef9571bcfed6f3ed8e39d0002a94bd9190f --- flow-typed/babel.js.flow | 6 +++--- packages/metro-source-map/src/source-map.js | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/flow-typed/babel.js.flow b/flow-typed/babel.js.flow index d6bbab44..e33606b3 100644 --- a/flow-typed/babel.js.flow +++ b/flow-typed/babel.js.flow @@ -114,7 +114,7 @@ type TransformResult = { type GeneratorResult = { code: string, map: ?_BabelSourceMap, - rawMappings: ?Array<_RawMapping>, + rawMappings: ?Array<_BabelSourceMapSegment>, }; type VisitFn = (path: Object, state: State) => any; @@ -146,7 +146,7 @@ declare module 'babel-core' { ): TransformResult; } -type _RawMapping = { +type _BabelSourceMapSegment = { generated: {column: number, line: number}, name?: string, original?: {column: number, line: number}, @@ -155,7 +155,7 @@ type _RawMapping = { // https://github.com/babel/babel/tree/master/packages/babel-generator declare module 'babel-generator' { - declare export type RawMapping = _RawMapping; + declare export type BabelSourceMapSegment = _BabelSourceMapSegment; declare export default ( ast: Ast, options?: GeneratorOptions, diff --git a/packages/metro-source-map/src/source-map.js b/packages/metro-source-map/src/source-map.js index 55d4c0d6..78aba2a0 100644 --- a/packages/metro-source-map/src/source-map.js +++ b/packages/metro-source-map/src/source-map.js @@ -16,7 +16,7 @@ const Generator = require('./Generator'); const SourceMap = require('source-map'); import type {BabelSourceMap} from 'babel-core'; -import type {RawMapping as BabelRawMapping} from 'babel-generator'; +import type {BabelSourceMapSegment} from 'babel-generator'; import type {RawMapping as UnknownSourceMapMappingType} from 'source-map'; export type UnknownSourceMapMappingTypes = Array; @@ -89,7 +89,9 @@ function fromRawMappings( * Transforms a standard source map object into a Raw Mappings object, to be * used across the bundler. */ -function toRawMappings(sourceMap: BabelSourceMap): Array { +function toRawMappings( + sourceMap: BabelSourceMap, +): Array { const rawMappings = []; new SourceMap.SourceMapConsumer(sourceMap).eachMapping(map => { @@ -110,7 +112,9 @@ function toRawMappings(sourceMap: BabelSourceMap): Array { return rawMappings; } -function compactMapping(mapping: BabelRawMapping): MetroSourceMapSegmentTuple { +function compactMapping( + mapping: BabelSourceMapSegment, +): MetroSourceMapSegmentTuple { const {column, line} = mapping.generated; const {name, original} = mapping;