Skip to content

Commit

Permalink
Merge branch 'master' into dtsSignatureChange
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Apr 17, 2019
2 parents 4a55025 + ea2331b commit d5100bb
Show file tree
Hide file tree
Showing 63 changed files with 2,028 additions and 451 deletions.
5 changes: 1 addition & 4 deletions src/compiler/builder.ts
Expand Up @@ -236,10 +236,7 @@ namespace ts {
}
});

if (oldCompilerOptions &&
(oldCompilerOptions.outDir !== compilerOptions.outDir ||
oldCompilerOptions.declarationDir !== compilerOptions.declarationDir ||
(oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) {
if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
// Add all files to affectedFilesPendingEmit since emit changed
addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(f => f.path));
Debug.assert(state.seenAffectedFiles === undefined);
Expand Down
117 changes: 69 additions & 48 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/compiler/commandLineParser.ts
Expand Up @@ -281,33 +281,38 @@ namespace ts {
name: "declaration",
shortName: "d",
type: "boolean",
affectsEmit: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Generates_corresponding_d_ts_file,
},
{
name: "declarationMap",
type: "boolean",
affectsEmit: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
},
{
name: "emitDeclarationOnly",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Only_emit_d_ts_declaration_files,
},
{
name: "sourceMap",
type: "boolean",
affectsEmit: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Generates_corresponding_map_file,
},
{
name: "outFile",
type: "string",
affectsEmit: true,
isFilePath: true,
paramType: Diagnostics.FILE,
showInSimplifiedHelpView: true,
Expand All @@ -317,6 +322,7 @@ namespace ts {
{
name: "outDir",
type: "string",
affectsEmit: true,
isFilePath: true,
paramType: Diagnostics.DIRECTORY,
showInSimplifiedHelpView: true,
Expand All @@ -326,6 +332,7 @@ namespace ts {
{
name: "rootDir",
type: "string",
affectsEmit: true,
isFilePath: true,
paramType: Diagnostics.LOCATION,
category: Diagnostics.Basic_Options,
Expand All @@ -334,13 +341,15 @@ namespace ts {
{
name: "composite",
type: "boolean",
affectsEmit: true,
isTSConfigOnly: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Enable_project_compilation,
},
{
name: "tsBuildInfoFile",
type: "string",
affectsEmit: true,
isFilePath: true,
paramType: Diagnostics.FILE,
category: Diagnostics.Basic_Options,
Expand All @@ -349,26 +358,30 @@ namespace ts {
{
name: "removeComments",
type: "boolean",
affectsEmit: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Do_not_emit_comments_to_output,
},
{
name: "noEmit",
type: "boolean",
affectsEmit: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Do_not_emit_outputs,
},
{
name: "importHelpers",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Import_emit_helpers_from_tslib
},
{
name: "downlevelIteration",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
},
Expand Down Expand Up @@ -580,26 +593,30 @@ namespace ts {
{
name: "sourceRoot",
type: "string",
affectsEmit: true,
paramType: Diagnostics.LOCATION,
category: Diagnostics.Source_Map_Options,
description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
},
{
name: "mapRoot",
type: "string",
affectsEmit: true,
paramType: Diagnostics.LOCATION,
category: Diagnostics.Source_Map_Options,
description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
},
{
name: "inlineSourceMap",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Source_Map_Options,
description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
},
{
name: "inlineSources",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Source_Map_Options,
description: Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
},
Expand Down Expand Up @@ -635,6 +652,7 @@ namespace ts {
{
name: "out",
type: "string",
affectsEmit: true,
isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files
// for correct behaviour, please use outFile
category: Diagnostics.Advanced_Options,
Expand All @@ -644,6 +662,7 @@ namespace ts {
{
name: "reactNamespace",
type: "string",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
},
Expand All @@ -662,6 +681,7 @@ namespace ts {
{
name: "emitBOM",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
},
Expand All @@ -677,6 +697,7 @@ namespace ts {
crlf: NewLineKind.CarriageReturnLineFeed,
lf: NewLineKind.LineFeed
}),
affectsEmit: true,
paramType: Diagnostics.NEWLINE,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
Expand Down Expand Up @@ -704,6 +725,7 @@ namespace ts {
{
name: "stripInternal",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
},
Expand All @@ -724,24 +746,28 @@ namespace ts {
{
name: "noEmitHelpers",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
},
{
name: "noEmitOnError",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
},
{
name: "preserveConstEnums",
type: "boolean",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
},
{
name: "declarationDir",
type: "string",
affectsEmit: true,
isFilePath: true,
paramType: Diagnostics.DIRECTORY,
category: Diagnostics.Advanced_Options,
Expand Down Expand Up @@ -826,6 +852,10 @@ namespace ts {
export const semanticDiagnosticsOptionDeclarations: ReadonlyArray<CommandLineOption> =
optionDeclarations.filter(option => !!option.affectsSemanticDiagnostics);

/* @internal */
export const affectsEmitOptionDeclarations: ReadonlyArray<CommandLineOption> =
optionDeclarations.filter(option => !!option.affectsEmit);

/* @internal */
export const moduleResolutionOptionDeclarations: ReadonlyArray<CommandLineOption> =
optionDeclarations.filter(option => !!option.affectsModuleResolution);
Expand Down
1 change: 1 addition & 0 deletions src/compiler/program.ts
Expand Up @@ -927,6 +927,7 @@ namespace ts {
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
getRelationCacheSizes: () => getDiagnosticsProducingTypeChecker().getRelationCacheSizes(),
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
isSourceFileFromExternalLibrary,
Expand Down
31 changes: 19 additions & 12 deletions src/compiler/types.ts
Expand Up @@ -2961,6 +2961,7 @@ namespace ts {
/* @internal */ getIdentifierCount(): number;
/* @internal */ getSymbolCount(): number;
/* @internal */ getTypeCount(): number;
/* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number };

/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
/* @internal */ getResolvedTypeReferenceDirectives(): Map<ResolvedTypeReferenceDirective | undefined>;
Expand Down Expand Up @@ -3246,6 +3247,7 @@ namespace ts {
/* @internal */ getIdentifierCount(): number;
/* @internal */ getSymbolCount(): number;
/* @internal */ getTypeCount(): number;
/* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number };

/* @internal */ isArrayType(type: Type): boolean;
/* @internal */ isTupleType(type: Type): boolean;
Expand Down Expand Up @@ -3746,19 +3748,21 @@ namespace ts {
SyntheticProperty = 1 << 1, // Property in union or intersection type
SyntheticMethod = 1 << 2, // Method in union or intersection type
Readonly = 1 << 3, // Readonly transient symbol
Partial = 1 << 4, // Synthetic property present in some but not all constituents
HasNonUniformType = 1 << 5, // Synthetic property with non-uniform type in constituents
HasLiteralType = 1 << 6, // Synthetic property with at least one literal type in constituents
ContainsPublic = 1 << 7, // Synthetic property with public constituent(s)
ContainsProtected = 1 << 8, // Synthetic property with protected constituent(s)
ContainsPrivate = 1 << 9, // Synthetic property with private constituent(s)
ContainsStatic = 1 << 10, // Synthetic property with static constituent(s)
Late = 1 << 11, // Late-bound symbol for a computed property with a dynamic name
ReverseMapped = 1 << 12, // Property of reverse-inferred homomorphic mapped type
OptionalParameter = 1 << 13, // Optional parameter
RestParameter = 1 << 14, // Rest parameter
ReadPartial = 1 << 4, // Synthetic property present in some but not all constituents
WritePartial = 1 << 5, // Synthetic property present in some but only satisfied by an index signature in others
HasNonUniformType = 1 << 6, // Synthetic property with non-uniform type in constituents
HasLiteralType = 1 << 7, // Synthetic property with at least one literal type in constituents
ContainsPublic = 1 << 8, // Synthetic property with public constituent(s)
ContainsProtected = 1 << 9, // Synthetic property with protected constituent(s)
ContainsPrivate = 1 << 10, // Synthetic property with private constituent(s)
ContainsStatic = 1 << 11, // Synthetic property with static constituent(s)
Late = 1 << 12, // Late-bound symbol for a computed property with a dynamic name
ReverseMapped = 1 << 13, // Property of reverse-inferred homomorphic mapped type
OptionalParameter = 1 << 14, // Optional parameter
RestParameter = 1 << 15, // Rest parameter
Synthetic = SyntheticProperty | SyntheticMethod,
Discriminant = HasNonUniformType | HasLiteralType
Discriminant = HasNonUniformType | HasLiteralType,
Partial = ReadPartial | WritePartial
}

/* @internal */
Expand Down Expand Up @@ -4171,6 +4175,8 @@ namespace ts {
}

export interface UnionType extends UnionOrIntersectionType {
/* @internal */
possiblePropertyCache?: SymbolTable; // Cache of _all_ resolved properties less any from aparent members
}

export interface IntersectionType extends UnionOrIntersectionType {
Expand Down Expand Up @@ -4823,6 +4829,7 @@ namespace ts {
affectsModuleResolution?: true; // currently same effect as `affectsSourceFile`
affectsBindDiagnostics?: true; // true if this affects binding (currently same effect as `affectsSourceFile`)
affectsSemanticDiagnostics?: true; // true if option affects semantic diagnostics
affectsEmit?: true; // true if the options affects emit
}

/* @internal */
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/utilities.ts
Expand Up @@ -7320,6 +7320,11 @@ namespace ts {
semanticDiagnosticsOptionDeclarations.some(option => !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)));
}

export function compilerOptionsAffectEmit(newOptions: CompilerOptions, oldOptions: CompilerOptions): boolean {
return oldOptions !== newOptions &&
affectsEmitOptionDeclarations.some(option => !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)));
}

export function getCompilerOptionValue(options: CompilerOptions, option: CommandLineOption): unknown {
return option.strictFlag ? getStrictOptionValue(options, option.name as StrictOptionName) : options[option.name];
}
Expand Down
22 changes: 0 additions & 22 deletions src/harness/fakes.ts
Expand Up @@ -397,19 +397,6 @@ namespace fakes {
const value = super.readFile(path);
if (!value || !ts.isBuildInfoFile(path)) return value;
const buildInfo = ts.getBuildInfo(value);
if (buildInfo.program) {
// Fix lib signatures
for (const path of ts.getOwnKeys(buildInfo.program.fileInfos)) {
if (ts.startsWith(path, "/lib/")) {
const currentValue = buildInfo.program.fileInfos[path];
ts.Debug.assert(currentValue.signature === path);
ts.Debug.assert(currentValue.signature === currentValue.version);
const text = super.readFile(path)!;
const signature = ts.generateDjb2Hash(text);
buildInfo.program.fileInfos[path] = { version: signature, signature };
}
}
}
ts.Debug.assert(buildInfo.version === version);
buildInfo.version = ts.version;
return ts.getBuildInfoText(buildInfo);
Expand All @@ -419,15 +406,6 @@ namespace fakes {
if (!ts.isBuildInfoFile(fileName)) return super.writeFile(fileName, content, writeByteOrderMark);
const buildInfo = ts.getBuildInfo(content);
if (buildInfo.program) {
// Fix lib signatures
for (const path of ts.getOwnKeys(buildInfo.program.fileInfos)) {
if (ts.startsWith(path, "/lib/")) {
const currentValue = buildInfo.program.fileInfos[path];
ts.Debug.assert(currentValue.signature === currentValue.version);
buildInfo.program.fileInfos[path] = { version: path, signature: path };
}
}

// reference Map
if (buildInfo.program.referencedMap) {
const referencedMap: ts.MapLike<string[]> = {};
Expand Down
1 change: 1 addition & 0 deletions src/testRunner/tsconfig.json
Expand Up @@ -93,6 +93,7 @@
"unittests/tsbuild/emptyFiles.ts",
"unittests/tsbuild/graphOrdering.ts",
"unittests/tsbuild/inferredTypeFromTransitiveModule.ts",
"unittests/tsbuild/lateBoundSymbol.ts",
"unittests/tsbuild/missingExtendedFile.ts",
"unittests/tsbuild/outFile.ts",
"unittests/tsbuild/referencesWithRootDirInParent.ts",
Expand Down

0 comments on commit d5100bb

Please sign in to comment.