From 2ee134c6b3c0ece87591e8abc9db833ebb7675cc Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 3 Feb 2015 13:47:46 -0800 Subject: [PATCH] Remove certain lazyily initialized fields from the public DTS. These should not be accessed directly. They should be obtained by calling into the appropriate helper functions. --- Jakefile | 10 +++++-- src/compiler/types.ts | 29 ++++++++++--------- .../baselines/reference/APISample_compile.js | 7 ++--- .../reference/APISample_compile.types | 25 ++++------------ tests/baselines/reference/APISample_linter.js | 7 ++--- .../reference/APISample_linter.types | 25 ++++------------ .../reference/APISample_transform.js | 7 ++--- .../reference/APISample_transform.types | 25 ++++------------ .../baselines/reference/APISample_watcher.js | 7 ++--- .../reference/APISample_watcher.types | 25 ++++------------ tests/cases/compiler/APISample_compile.ts | 1 + tests/cases/compiler/APISample_linter.ts | 1 + tests/cases/compiler/APISample_transform.ts | 1 + tests/cases/compiler/APISample_watcher.ts | 1 + 14 files changed, 60 insertions(+), 111 deletions(-) diff --git a/Jakefile b/Jakefile index 15661debff62b..6ab9155f8b3fe 100644 --- a/Jakefile +++ b/Jakefile @@ -194,7 +194,7 @@ var compilerFilename = "tsc.js"; * @param keepComments: false to compile using --removeComments * @param callback: a function to execute after the compilation process ends */ -function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, callback) { +function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) { file(outFile, prereqs, function() { var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory; var options = "--module commonjs -noImplicitAny"; @@ -227,6 +227,10 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu options += " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile)); } + if (stripInternal) { + options += " --stripInternal" + } + var cmd = host + " " + dir + compilerFilename + " " + options + " "; cmd = cmd + sources.join(" "); console.log(cmd + "\n"); @@ -331,7 +335,8 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca /*outDir*/ undefined, /*preserveConstEnums*/ true, /*keepComments*/ false, - /*noResolve*/ false); + /*noResolve*/ false, + /*stripInternal*/ false); var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts"); var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts"); @@ -347,6 +352,7 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright /*preserveConstEnums*/ true, /*keepComments*/ true, /*noResolve*/ true, + /*stripInternal*/ true, /*callback*/ function () { function makeDefinitionFiles(definitionsRoots, standaloneDefinitionsFile, nodeDefinitionsFile) { // Create the standalone definition file diff --git a/src/compiler/types.ts b/src/compiler/types.ts index eb68bab7b743e..a6fb7cdf7efea 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -891,30 +891,33 @@ module ts { amdModuleName: string; referencedFiles: FileReference[]; + hasNoDefaultLib: boolean; + externalModuleIndicator: Node; // The first node that causes this file to be an external module + nodeCount: number; + identifierCount: number; + symbolCount: number; + languageVersion: ScriptTarget; + identifiers: Map; + + // @internal // Diagnostics reported about the "///; - + // @internal // Stores a line map for the file. // This field should never be used directly to obtain line map, use getLineMap function instead. lineMap: number[]; diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index f6a86d4c2455b..f1b1a8e8953f8 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -728,10 +728,6 @@ declare module "typescript" { amdDependencies: string[]; amdModuleName: string; referencedFiles: FileReference[]; - referenceDiagnostics: Diagnostic[]; - parseDiagnostics: Diagnostic[]; - semanticDiagnostics: Diagnostic[]; - syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -739,7 +735,6 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1186,6 +1181,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1216,6 +1212,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 4ef90c6d1146b..064170cd70f80 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -2219,22 +2219,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2258,9 +2242,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -3818,6 +3799,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -3898,6 +3882,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index aef5c70349b7c..aa12cb40cb32d 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -757,10 +757,6 @@ declare module "typescript" { amdDependencies: string[]; amdModuleName: string; referencedFiles: FileReference[]; - referenceDiagnostics: Diagnostic[]; - parseDiagnostics: Diagnostic[]; - semanticDiagnostics: Diagnostic[]; - syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -768,7 +764,6 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1215,6 +1210,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1245,6 +1241,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 957ccd3c01e8f..7065704f422e3 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -2349,22 +2349,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2388,9 +2372,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -3948,6 +3929,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -4028,6 +4012,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 33cea1ea0af9a..58535e42601ca 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -758,10 +758,6 @@ declare module "typescript" { amdDependencies: string[]; amdModuleName: string; referencedFiles: FileReference[]; - referenceDiagnostics: Diagnostic[]; - parseDiagnostics: Diagnostic[]; - semanticDiagnostics: Diagnostic[]; - syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -769,7 +765,6 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1216,6 +1211,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1246,6 +1242,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index c091af5effb2d..5d90818f635c0 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -2297,22 +2297,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2336,9 +2320,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -3896,6 +3877,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -3976,6 +3960,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 7c70ee1532ecc..cd8b44bfe2db2 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -795,10 +795,6 @@ declare module "typescript" { amdDependencies: string[]; amdModuleName: string; referencedFiles: FileReference[]; - referenceDiagnostics: Diagnostic[]; - parseDiagnostics: Diagnostic[]; - semanticDiagnostics: Diagnostic[]; - syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -806,7 +802,6 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1253,6 +1248,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1283,6 +1279,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index c3d03259385db..7050f0497d9ab 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -2475,22 +2475,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2514,9 +2498,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -4074,6 +4055,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -4154,6 +4138,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/cases/compiler/APISample_compile.ts b/tests/cases/compiler/APISample_compile.ts index d2ad7853a19b0..004e22dcb0ccb 100644 --- a/tests/cases/compiler/APISample_compile.ts +++ b/tests/cases/compiler/APISample_compile.ts @@ -1,5 +1,6 @@ // @module: commonjs // @includebuiltfile: typescript.d.ts +// @stripInternal:true /* * Note: This test is a public API sample. The sample sources can be found diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index 8a796fe6fc8b4..1942923a81d92 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -1,5 +1,6 @@ // @module: commonjs // @includebuiltfile: typescript.d.ts +// @stripInternal:true /* * Note: This test is a public API sample. The sample sources can be found diff --git a/tests/cases/compiler/APISample_transform.ts b/tests/cases/compiler/APISample_transform.ts index 4d79ff827cd5b..b0a6c7d37eaf2 100644 --- a/tests/cases/compiler/APISample_transform.ts +++ b/tests/cases/compiler/APISample_transform.ts @@ -1,5 +1,6 @@ // @module: commonjs // @includebuiltfile: typescript.d.ts +// @stripInternal:true /* * Note: This test is a public API sample. The sample sources can be found diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index 119c66697b251..3c65b59801d1d 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -1,5 +1,6 @@ // @module: commonjs // @includebuiltfile: typescript.d.ts +// @stripInternal:true /* * Note: This test is a public API sample. The sample sources can be found