From f9f12455603c95e5203487b117851806fcfb63ac Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 23 May 2017 10:24:59 -0700 Subject: [PATCH] Covariant properties for `ModuleTransportLike` Summary: Make all properties of `ModuleTraansportLike` covariant to enforce read-only behavior at all sites using it. The type only exists for compatibility reasons between old and new output functionality, and covariant properties give us stronger guarantees. Reviewed By: jeanlauliac Differential Revision: D5111667 fbshipit-source-id: 674658b07eb3a229cbc4344cb636e4a9ea4126d1 --- local-cli/bundle/types.flow.js | 10 +++++----- packager/src/lib/ModuleTransport.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/local-cli/bundle/types.flow.js b/local-cli/bundle/types.flow.js index 6939aab08..b72977004 100644 --- a/local-cli/bundle/types.flow.js +++ b/local-cli/bundle/types.flow.js @@ -12,7 +12,7 @@ import type Bundle from '../../packager/src/Bundler/Bundle'; import type {Unbundle} from '../../packager/src/Bundler/Bundle'; -import type ModuleTransport from '../../packager/src/lib/ModuleTransport'; +import type ModuleTransport, {SourceMapOrMappings} from '../../packager/src/lib/ModuleTransport'; import type {FBSourceMap, SourceMap} from '../../packager/src/lib/SourceMap'; export type {Bundle, FBSourceMap, ModuleTransport, SourceMap, Unbundle}; @@ -24,11 +24,11 @@ export type ModuleGroups = {| |}; export type ModuleTransportLike = { - code: string, - id: number, - map?: $PropertyType, + +code: string, + +id: number, + +map: ?SourceMapOrMappings, +name?: string, - sourcePath: string, + +sourcePath: string, }; export type OutputOptions = { diff --git a/packager/src/lib/ModuleTransport.js b/packager/src/lib/ModuleTransport.js index 4ba202673..9e91ef3c7 100644 --- a/packager/src/lib/ModuleTransport.js +++ b/packager/src/lib/ModuleTransport.js @@ -15,7 +15,7 @@ import type {RawMapping} from '../Bundler/source-map'; import type Module from '../node-haste/Module'; import type {SourceMap} from './SourceMap'; -type SourceMapOrMappings = SourceMap | Array; +export type SourceMapOrMappings = SourceMap | Array; type Metadata = { dependencies?: ?Array,