Skip to content

Commit

Permalink
Merge pull request #1914 from Microsoft/internalAPIs
Browse files Browse the repository at this point in the history
Remove certain lazyily initialized fields from the public DTS.
  • Loading branch information
CyrusNajmabadi committed Feb 3, 2015
2 parents fab351e + 2ee134c commit 35dde28
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 111 deletions.
10 changes: 8 additions & 2 deletions Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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
Expand Down
29 changes: 16 additions & 13 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;

// @internal
// Diagnostics reported about the "///<reference" comments in the file.
referenceDiagnostics: Diagnostic[];


// @internal
// Parse errors refer specifically to things the parser could not understand at all (like
// missing tokens, or tokens it didn't know how to deal with).
parseDiagnostics: Diagnostic[];

//getSyntacticDiagnostics(): Diagnostic[];


// @internal
// File level diagnostics reported by the binder.
semanticDiagnostics: Diagnostic[];


// @internal
// Returns all syntactic diagnostics (i.e. the reference, parser and grammar diagnostics).
// This field should never be used directly, use getSyntacticDiagnostics function instead.
syntacticDiagnostics: Diagnostic[];

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<string>;

// @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[];
Expand Down
7 changes: 2 additions & 5 deletions tests/baselines/reference/APISample_compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,18 +728,13 @@ declare module "typescript" {
amdDependencies: string[];
amdModuleName: string;
referencedFiles: FileReference[];
referenceDiagnostics: Diagnostic[];
parseDiagnostics: Diagnostic[];
semanticDiagnostics: Diagnostic[];
syntacticDiagnostics: Diagnostic[];
hasNoDefaultLib: boolean;
externalModuleIndicator: Node;
nodeCount: number;
identifierCount: number;
symbolCount: number;
languageVersion: ScriptTarget;
identifiers: Map<string>;
lineMap: number[];
}
interface ScriptReferenceHost {
getCompilerOptions(): CompilerOptions;
Expand Down Expand Up @@ -1186,6 +1181,7 @@ declare module "typescript" {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
stripInternal?: boolean;

This comment has been minimized.

Copy link
@mihailik

mihailik Feb 4, 2015

Contributor

Could somebody put a few lines documenting this feature please?

This comment has been minimized.

Copy link
@mhegazy

mhegazy Mar 3, 2015

Contributor

@mihailik this is an undocumented feature:) we intend to add a proper support but this just to filter out our d.ts. Please do not take a dependency on it.

[option: string]: string | number | boolean;
}
const enum ModuleKind {
Expand Down Expand Up @@ -1216,6 +1212,7 @@ declare module "typescript" {
description?: DiagnosticMessage;
paramType?: DiagnosticMessage;
error?: DiagnosticMessage;
experimental?: boolean;
}
const enum CharacterCodes {
nullCharacter = 0,
Expand Down
25 changes: 6 additions & 19 deletions tests/baselines/reference/APISample_compile.types
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -2258,9 +2242,6 @@ declare module "typescript" {
identifiers: Map<string>;
>identifiers : Map<string>
>Map : Map<T>

lineMap: number[];
>lineMap : number[]
}
interface ScriptReferenceHost {
>ScriptReferenceHost : ScriptReferenceHost
Expand Down Expand Up @@ -3818,6 +3799,9 @@ declare module "typescript" {
watch?: boolean;
>watch : boolean

stripInternal?: boolean;
>stripInternal : boolean

[option: string]: string | number | boolean;
>option : string
}
Expand Down Expand Up @@ -3898,6 +3882,9 @@ declare module "typescript" {
error?: DiagnosticMessage;
>error : DiagnosticMessage
>DiagnosticMessage : DiagnosticMessage

experimental?: boolean;
>experimental : boolean
}
const enum CharacterCodes {
>CharacterCodes : CharacterCodes
Expand Down
7 changes: 2 additions & 5 deletions tests/baselines/reference/APISample_linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,18 +757,13 @@ declare module "typescript" {
amdDependencies: string[];
amdModuleName: string;
referencedFiles: FileReference[];
referenceDiagnostics: Diagnostic[];
parseDiagnostics: Diagnostic[];
semanticDiagnostics: Diagnostic[];
syntacticDiagnostics: Diagnostic[];
hasNoDefaultLib: boolean;
externalModuleIndicator: Node;
nodeCount: number;
identifierCount: number;
symbolCount: number;
languageVersion: ScriptTarget;
identifiers: Map<string>;
lineMap: number[];
}
interface ScriptReferenceHost {
getCompilerOptions(): CompilerOptions;
Expand Down Expand Up @@ -1215,6 +1210,7 @@ declare module "typescript" {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
Expand Down Expand Up @@ -1245,6 +1241,7 @@ declare module "typescript" {
description?: DiagnosticMessage;
paramType?: DiagnosticMessage;
error?: DiagnosticMessage;
experimental?: boolean;
}
const enum CharacterCodes {
nullCharacter = 0,
Expand Down
25 changes: 6 additions & 19 deletions tests/baselines/reference/APISample_linter.types
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -2388,9 +2372,6 @@ declare module "typescript" {
identifiers: Map<string>;
>identifiers : Map<string>
>Map : Map<T>

lineMap: number[];
>lineMap : number[]
}
interface ScriptReferenceHost {
>ScriptReferenceHost : ScriptReferenceHost
Expand Down Expand Up @@ -3948,6 +3929,9 @@ declare module "typescript" {
watch?: boolean;
>watch : boolean

stripInternal?: boolean;
>stripInternal : boolean

[option: string]: string | number | boolean;
>option : string
}
Expand Down Expand Up @@ -4028,6 +4012,9 @@ declare module "typescript" {
error?: DiagnosticMessage;
>error : DiagnosticMessage
>DiagnosticMessage : DiagnosticMessage

experimental?: boolean;
>experimental : boolean
}
const enum CharacterCodes {
>CharacterCodes : CharacterCodes
Expand Down
7 changes: 2 additions & 5 deletions tests/baselines/reference/APISample_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,18 +758,13 @@ declare module "typescript" {
amdDependencies: string[];
amdModuleName: string;
referencedFiles: FileReference[];
referenceDiagnostics: Diagnostic[];
parseDiagnostics: Diagnostic[];
semanticDiagnostics: Diagnostic[];
syntacticDiagnostics: Diagnostic[];
hasNoDefaultLib: boolean;
externalModuleIndicator: Node;
nodeCount: number;
identifierCount: number;
symbolCount: number;
languageVersion: ScriptTarget;
identifiers: Map<string>;
lineMap: number[];
}
interface ScriptReferenceHost {
getCompilerOptions(): CompilerOptions;
Expand Down Expand Up @@ -1216,6 +1211,7 @@ declare module "typescript" {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
Expand Down Expand Up @@ -1246,6 +1242,7 @@ declare module "typescript" {
description?: DiagnosticMessage;
paramType?: DiagnosticMessage;
error?: DiagnosticMessage;
experimental?: boolean;
}
const enum CharacterCodes {
nullCharacter = 0,
Expand Down
25 changes: 6 additions & 19 deletions tests/baselines/reference/APISample_transform.types
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -2336,9 +2320,6 @@ declare module "typescript" {
identifiers: Map<string>;
>identifiers : Map<string>
>Map : Map<T>

lineMap: number[];
>lineMap : number[]
}
interface ScriptReferenceHost {
>ScriptReferenceHost : ScriptReferenceHost
Expand Down Expand Up @@ -3896,6 +3877,9 @@ declare module "typescript" {
watch?: boolean;
>watch : boolean

stripInternal?: boolean;
>stripInternal : boolean

[option: string]: string | number | boolean;
>option : string
}
Expand Down Expand Up @@ -3976,6 +3960,9 @@ declare module "typescript" {
error?: DiagnosticMessage;
>error : DiagnosticMessage
>DiagnosticMessage : DiagnosticMessage

experimental?: boolean;
>experimental : boolean
}
const enum CharacterCodes {
>CharacterCodes : CharacterCodes
Expand Down
7 changes: 2 additions & 5 deletions tests/baselines/reference/APISample_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,18 +795,13 @@ declare module "typescript" {
amdDependencies: string[];
amdModuleName: string;
referencedFiles: FileReference[];
referenceDiagnostics: Diagnostic[];
parseDiagnostics: Diagnostic[];
semanticDiagnostics: Diagnostic[];
syntacticDiagnostics: Diagnostic[];
hasNoDefaultLib: boolean;
externalModuleIndicator: Node;
nodeCount: number;
identifierCount: number;
symbolCount: number;
languageVersion: ScriptTarget;
identifiers: Map<string>;
lineMap: number[];
}
interface ScriptReferenceHost {
getCompilerOptions(): CompilerOptions;
Expand Down Expand Up @@ -1253,6 +1248,7 @@ declare module "typescript" {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
Expand Down Expand Up @@ -1283,6 +1279,7 @@ declare module "typescript" {
description?: DiagnosticMessage;
paramType?: DiagnosticMessage;
error?: DiagnosticMessage;
experimental?: boolean;
}
const enum CharacterCodes {
nullCharacter = 0,
Expand Down
Loading

0 comments on commit 35dde28

Please sign in to comment.