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
This commit is contained in:
David Aurelio 2017-05-23 10:24:59 -07:00 committed by Facebook Github Bot
parent 6b2122be13
commit f9f1245560
2 changed files with 6 additions and 6 deletions

View File

@ -12,7 +12,7 @@
import type Bundle from '../../packager/src/Bundler/Bundle'; import type Bundle from '../../packager/src/Bundler/Bundle';
import type {Unbundle} 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'; import type {FBSourceMap, SourceMap} from '../../packager/src/lib/SourceMap';
export type {Bundle, FBSourceMap, ModuleTransport, SourceMap, Unbundle}; export type {Bundle, FBSourceMap, ModuleTransport, SourceMap, Unbundle};
@ -24,11 +24,11 @@ export type ModuleGroups = {|
|}; |};
export type ModuleTransportLike = { export type ModuleTransportLike = {
code: string, +code: string,
id: number, +id: number,
map?: $PropertyType<ModuleTransport, 'map'>, +map: ?SourceMapOrMappings,
+name?: string, +name?: string,
sourcePath: string, +sourcePath: string,
}; };
export type OutputOptions = { export type OutputOptions = {

View File

@ -15,7 +15,7 @@ import type {RawMapping} from '../Bundler/source-map';
import type Module from '../node-haste/Module'; import type Module from '../node-haste/Module';
import type {SourceMap} from './SourceMap'; import type {SourceMap} from './SourceMap';
type SourceMapOrMappings = SourceMap | Array<RawMapping>; export type SourceMapOrMappings = SourceMap | Array<RawMapping>;
type Metadata = { type Metadata = {
dependencies?: ?Array<string>, dependencies?: ?Array<string>,