Make sourcemap flow types non-nullable

Reviewed By: mjesun

Differential Revision: D6185460

fbshipit-source-id: c33bac5f0e70c142d6238043ce8c2996f1d1ee50
This commit is contained in:
Rafael Oleza 2017-10-31 10:17:34 -07:00 committed by Facebook Github Bot
parent 437a6a3f27
commit 775867445a
3 changed files with 11 additions and 11 deletions

View File

@ -37,7 +37,7 @@ export type DeltaEntryType =
export type DeltaEntry = {| export type DeltaEntry = {|
+code: string, +code: string,
+id: number, +id: number,
+map: ?CompactRawMappings, +map: CompactRawMappings,
+name: string, +name: string,
+path: string, +path: string,
+source: string, +source: string,
@ -284,7 +284,7 @@ class DeltaTransformer extends EventEmitter {
{ {
code, code,
id: moduleId, id: moduleId,
map: null, map: [],
name, name,
source: code, source: code,
path, path,
@ -301,7 +301,7 @@ class DeltaTransformer extends EventEmitter {
append.set(id, { append.set(id, {
code, code,
id, id,
map: null, map: [],
name: 'sourcemap.js', name: 'sourcemap.js',
path: '/sourcemap.js', path: '/sourcemap.js',
source: code, source: code,
@ -417,7 +417,7 @@ class DeltaTransformer extends EventEmitter {
): Promise<{ ): Promise<{
+code: string, +code: string,
+dependencyOffsets: ?Array<number>, +dependencyOffsets: ?Array<number>,
+map: ?CompactRawMappings, +map: CompactRawMappings,
+source: string, +source: string,
}> { }> {
if (module.isAsset()) { if (module.isAsset()) {
@ -430,7 +430,7 @@ class DeltaTransformer extends EventEmitter {
return { return {
code: asset.code, code: asset.code,
dependencyOffsets: asset.meta.dependencyOffsets, dependencyOffsets: asset.meta.dependencyOffsets,
map: undefined, map: [],
source: '', source: '',
}; };
} }

View File

@ -28,7 +28,7 @@ import type {
type ResultWithMap = { type ResultWithMap = {
code: string, code: string,
map: ?MappingsMap, map: MappingsMap,
}; };
function noSourceMap(code: string): string { function noSourceMap(code: string): string {
@ -55,14 +55,14 @@ function withSourceMap(
function withRawMappings( function withRawMappings(
code: string, code: string,
map: ?RawMappings, map: RawMappings,
filename: string, filename: string,
): {code: string, map: ?CompactRawMappings} { ): {code: string, map: CompactRawMappings} {
const result = withSourceMap(code, map, filename); const result = withSourceMap(code, map, filename);
return { return {
code: result.code, code: result.code,
map: result.map ? toRawMappings(result.map).map(compactMapping) : undefined, map: toRawMappings(result.map).map(compactMapping),
}; };
} }

View File

@ -230,10 +230,10 @@ class Resolver {
dependencyPairs: Map<string, string>, dependencyPairs: Map<string, string>,
dependencyOffsets: Array<number>, dependencyOffsets: Array<number>,
name: string, name: string,
map: ?CompactRawMappings, map: CompactRawMappings,
code: string, code: string,
dev?: boolean, dev?: boolean,
}): {code: string, map: ?CompactRawMappings} { }): {code: string, map: CompactRawMappings} {
if (module.isJSON()) { if (module.isJSON()) {
code = `module.exports = ${code}`; code = `module.exports = ${code}`;
} }