mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
merge with master
This commit is contained in:
@@ -31,6 +31,7 @@ scripts/processDiagnosticMessages.js
|
||||
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
|
||||
src/harness/*.js
|
||||
src/compiler/diagnosticInformationMap.generated.ts
|
||||
src/compiler/diagnosticMessages.generated.json
|
||||
rwc-report.html
|
||||
*.swp
|
||||
build.json
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
built
|
||||
doc
|
||||
lib/README.md
|
||||
scripts
|
||||
src
|
||||
tests
|
||||
|
||||
@@ -32,6 +32,19 @@ Your pull request should:
|
||||
* Follow the code conventions descriped in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
|
||||
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
|
||||
|
||||
## Contributing `lib.d.ts` fixes
|
||||
|
||||
The library sources are in: [src/lib](https://github.com/Microsoft/TypeScript/tree/master/src/lib)
|
||||
|
||||
To build the library files, run
|
||||
```Shell
|
||||
jake lib
|
||||
```
|
||||
|
||||
#### `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts`
|
||||
|
||||
These two files represent the DOM typings and are auto-generated. To make any modifications to them, please submit a PR to https://github.com/Microsoft/TSJS-lib-generator
|
||||
|
||||
## Running the Tests
|
||||
|
||||
To run all tests, invoke the `runtests` target using jake:
|
||||
|
||||
+23
-7
@@ -96,7 +96,7 @@ var servicesSources = [
|
||||
return path.join(servicesDirectory, f);
|
||||
}));
|
||||
|
||||
var serverSources = [
|
||||
var serverCoreSources = [
|
||||
"node.d.ts",
|
||||
"editorServices.ts",
|
||||
"protocol.d.ts",
|
||||
@@ -104,7 +104,9 @@ var serverSources = [
|
||||
"server.ts"
|
||||
].map(function (f) {
|
||||
return path.join(serverDirectory, f);
|
||||
}).concat(servicesSources);
|
||||
});
|
||||
|
||||
var serverSources = serverCoreSources.concat(servicesSources);
|
||||
|
||||
var languageServiceLibrarySources = [
|
||||
"editorServices.ts",
|
||||
@@ -145,7 +147,8 @@ var harnessSources = harnessCoreSources.concat([
|
||||
"transpile.ts",
|
||||
"reuseProgramStructure.ts",
|
||||
"cachingInServerLSHost.ts",
|
||||
"moduleResolution.ts"
|
||||
"moduleResolution.ts",
|
||||
"tsconfigParsing.ts"
|
||||
].map(function (f) {
|
||||
return path.join(unittestsDirectory, f);
|
||||
})).concat([
|
||||
@@ -164,7 +167,7 @@ var librarySourceMap = [
|
||||
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
|
||||
{ target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
|
||||
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
|
||||
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
|
||||
{ target: "lib.es6.d.ts", sources: ["es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }
|
||||
];
|
||||
|
||||
var libraryTargets = librarySourceMap.map(function (f) {
|
||||
@@ -225,7 +228,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
|
||||
file(outFile, prereqs, function() {
|
||||
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
|
||||
var options = "--module commonjs --noImplicitAny --noEmitOnError";
|
||||
var options = "--module commonjs --noImplicitAny --noEmitOnError --pretty";
|
||||
|
||||
// Keep comments when specifically requested
|
||||
// or when in debug mode.
|
||||
@@ -320,6 +323,8 @@ var processDiagnosticMessagesJs = path.join(scriptsDirectory, "processDiagnostic
|
||||
var processDiagnosticMessagesTs = path.join(scriptsDirectory, "processDiagnosticMessages.ts");
|
||||
var diagnosticMessagesJson = path.join(compilerDirectory, "diagnosticMessages.json");
|
||||
var diagnosticInfoMapTs = path.join(compilerDirectory, "diagnosticInformationMap.generated.ts");
|
||||
var generatedDiagnosticMessagesJSON = path.join(compilerDirectory, "diagnosticMessages.generated.json");
|
||||
var builtGeneratedDiagnosticMessagesJSON = path.join(builtLocalDirectory, "diagnosticMessages.generated.json");
|
||||
|
||||
file(processDiagnosticMessagesTs);
|
||||
|
||||
@@ -348,6 +353,12 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
|
||||
ex.run();
|
||||
}, {async: true});
|
||||
|
||||
file(builtGeneratedDiagnosticMessagesJSON,[generatedDiagnosticMessagesJSON], function() {
|
||||
if (fs.existsSync(builtLocalDirectory)) {
|
||||
jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON);
|
||||
}
|
||||
});
|
||||
|
||||
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
|
||||
task("generate-diagnostics", [diagnosticInfoMapTs]);
|
||||
|
||||
@@ -444,6 +455,8 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
|
||||
// Stanalone/web definition file using global 'ts' namespace
|
||||
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
|
||||
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
|
||||
definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4');
|
||||
fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents);
|
||||
|
||||
// Official node package definition file, pointed to by 'typings' in package.json
|
||||
// Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module
|
||||
@@ -476,7 +489,7 @@ task("lssl", [lsslFile]);
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Builds the full compiler and services");
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]);
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
|
||||
|
||||
// Local target to build only tsc.js
|
||||
desc("Builds only the compiler");
|
||||
@@ -846,6 +859,7 @@ var tslintRuleDir = "scripts/tslint";
|
||||
var tslintRules = ([
|
||||
"nextLineRule",
|
||||
"noNullRule",
|
||||
"preferConstRule",
|
||||
"booleanTriviaRule",
|
||||
"typeOperatorSpacingRule"
|
||||
]);
|
||||
@@ -890,7 +904,9 @@ function lintFileAsync(options, path, cb) {
|
||||
});
|
||||
}
|
||||
|
||||
var lintTargets = compilerSources.concat(harnessCoreSources);
|
||||
var lintTargets = compilerSources
|
||||
.concat(harnessCoreSources)
|
||||
.concat(serverCoreSources);
|
||||
|
||||
desc("Runs tslint on the compiler sources");
|
||||
task("lint", ["build-rules"], function() {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# Read this!
|
||||
|
||||
These files are not meant to be edited by hand.
|
||||
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory.
|
||||
Vendored
+1
-1
@@ -1225,7 +1225,7 @@ interface ArrayBuffer {
|
||||
interface ArrayBufferConstructor {
|
||||
prototype: ArrayBuffer;
|
||||
new (byteLength: number): ArrayBuffer;
|
||||
isView(arg: any): boolean;
|
||||
isView(arg: any): arg is ArrayBufferView;
|
||||
}
|
||||
declare var ArrayBuffer: ArrayBufferConstructor;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1225,7 +1225,7 @@ interface ArrayBuffer {
|
||||
interface ArrayBufferConstructor {
|
||||
prototype: ArrayBuffer;
|
||||
new (byteLength: number): ArrayBuffer;
|
||||
isView(arg: any): boolean;
|
||||
isView(arg: any): arg is ArrayBufferView;
|
||||
}
|
||||
declare var ArrayBuffer: ArrayBufferConstructor;
|
||||
|
||||
|
||||
Vendored
+64
-4
@@ -1225,7 +1225,7 @@ interface ArrayBuffer {
|
||||
interface ArrayBufferConstructor {
|
||||
prototype: ArrayBuffer;
|
||||
new (byteLength: number): ArrayBuffer;
|
||||
isView(arg: any): boolean;
|
||||
isView(arg: any): arg is ArrayBufferView;
|
||||
}
|
||||
declare var ArrayBuffer: ArrayBufferConstructor;
|
||||
|
||||
@@ -6234,6 +6234,68 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement;
|
||||
createElement(tagName: "xmp"): HTMLBlockElement;
|
||||
createElement(tagName: string): HTMLElement;
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feBlend"): SVGFEBlendElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feColorMatrix"): SVGFEColorMatrixElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComponentTransfer"): SVGFEComponentTransferElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComposite"): SVGFECompositeElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feConvolveMatrix"): SVGFEConvolveMatrixElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDiffuseLighting"): SVGFEDiffuseLightingElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDisplacementMap"): SVGFEDisplacementMapElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDistantLight"): SVGFEDistantLightElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFlood"): SVGFEFloodElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncA"): SVGFEFuncAElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncB"): SVGFEFuncBElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncG"): SVGFEFuncGElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncR"): SVGFEFuncRElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feGaussianBlur"): SVGFEGaussianBlurElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feImage"): SVGFEImageElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMerge"): SVGFEMergeElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMergeNode"): SVGFEMergeNodeElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMorphology"): SVGFEMorphologyElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feOffset"): SVGFEOffsetElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "fePointLight"): SVGFEPointLightElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpecularLighting"): SVGFESpecularLightingElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpotLight"): SVGFESpotLightElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTile"): SVGFETileElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTurbulence"): SVGFETurbulenceElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "filter"): SVGFilterElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "foreignObject"): SVGForeignObjectElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "g"): SVGGElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "image"): SVGImageElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "gradient"): SVGGradientElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "line"): SVGLineElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "linearGradient"): SVGLinearGradientElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "marker"): SVGMarkerElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "mask"): SVGMaskElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "path"): SVGPathElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "metadata"): SVGMetadataElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "pattern"): SVGPatternElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polygon"): SVGPolygonElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polyline"): SVGPolylineElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "radialGradient"): SVGRadialGradientElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "rect"): SVGRectElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "svg"): SVGSVGElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "stop"): SVGStopElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "switch"): SVGSwitchElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "symbol"): SVGSymbolElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "tspan"): SVGTSpanElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textContent"): SVGTextContentElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "text"): SVGTextElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPath"): SVGTextPathElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPositioning"): SVGTextPositioningElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement
|
||||
createElementNS(namespaceURI: string, qualifiedName: string): Element;
|
||||
createExpression(expression: string, resolver: XPathNSResolver): XPathExpression;
|
||||
createNSResolver(nodeResolver: Node): XPathNSResolver;
|
||||
@@ -11055,14 +11117,12 @@ interface ImageData {
|
||||
width: number;
|
||||
}
|
||||
|
||||
interface ImageDataConstructor {
|
||||
declare var ImageData: {
|
||||
prototype: ImageData;
|
||||
new(width: number, height: number): ImageData;
|
||||
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
|
||||
}
|
||||
|
||||
declare var ImageData: ImageDataConstructor;
|
||||
|
||||
interface KeyboardEvent extends UIEvent {
|
||||
altKey: boolean;
|
||||
char: string;
|
||||
|
||||
Vendored
+63
-3
@@ -2410,6 +2410,68 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement;
|
||||
createElement(tagName: "xmp"): HTMLBlockElement;
|
||||
createElement(tagName: string): HTMLElement;
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feBlend"): SVGFEBlendElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feColorMatrix"): SVGFEColorMatrixElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComponentTransfer"): SVGFEComponentTransferElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComposite"): SVGFECompositeElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feConvolveMatrix"): SVGFEConvolveMatrixElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDiffuseLighting"): SVGFEDiffuseLightingElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDisplacementMap"): SVGFEDisplacementMapElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDistantLight"): SVGFEDistantLightElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFlood"): SVGFEFloodElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncA"): SVGFEFuncAElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncB"): SVGFEFuncBElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncG"): SVGFEFuncGElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncR"): SVGFEFuncRElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feGaussianBlur"): SVGFEGaussianBlurElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feImage"): SVGFEImageElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMerge"): SVGFEMergeElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMergeNode"): SVGFEMergeNodeElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMorphology"): SVGFEMorphologyElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feOffset"): SVGFEOffsetElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "fePointLight"): SVGFEPointLightElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpecularLighting"): SVGFESpecularLightingElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpotLight"): SVGFESpotLightElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTile"): SVGFETileElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTurbulence"): SVGFETurbulenceElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "filter"): SVGFilterElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "foreignObject"): SVGForeignObjectElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "g"): SVGGElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "image"): SVGImageElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "gradient"): SVGGradientElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "line"): SVGLineElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "linearGradient"): SVGLinearGradientElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "marker"): SVGMarkerElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "mask"): SVGMaskElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "path"): SVGPathElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "metadata"): SVGMetadataElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "pattern"): SVGPatternElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polygon"): SVGPolygonElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polyline"): SVGPolylineElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "radialGradient"): SVGRadialGradientElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "rect"): SVGRectElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "svg"): SVGSVGElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "stop"): SVGStopElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "switch"): SVGSwitchElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "symbol"): SVGSymbolElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "tspan"): SVGTSpanElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textContent"): SVGTextContentElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "text"): SVGTextElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPath"): SVGTextPathElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPositioning"): SVGTextPositioningElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement
|
||||
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement
|
||||
createElementNS(namespaceURI: string, qualifiedName: string): Element;
|
||||
createExpression(expression: string, resolver: XPathNSResolver): XPathExpression;
|
||||
createNSResolver(nodeResolver: Node): XPathNSResolver;
|
||||
@@ -7231,14 +7293,12 @@ interface ImageData {
|
||||
width: number;
|
||||
}
|
||||
|
||||
interface ImageDataConstructor {
|
||||
declare var ImageData: {
|
||||
prototype: ImageData;
|
||||
new(width: number, height: number): ImageData;
|
||||
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
|
||||
}
|
||||
|
||||
declare var ImageData: ImageDataConstructor;
|
||||
|
||||
interface KeyboardEvent extends UIEvent {
|
||||
altKey: boolean;
|
||||
char: string;
|
||||
|
||||
Vendored
+1379
-1319
File diff suppressed because it is too large
Load Diff
Vendored
+1
-3
@@ -682,14 +682,12 @@ interface ImageData {
|
||||
width: number;
|
||||
}
|
||||
|
||||
interface ImageDataConstructor {
|
||||
declare var ImageData: {
|
||||
prototype: ImageData;
|
||||
new(width: number, height: number): ImageData;
|
||||
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
|
||||
}
|
||||
|
||||
declare var ImageData: ImageDataConstructor;
|
||||
|
||||
interface MSApp {
|
||||
clearTemporaryWebDataAsync(): MSAppAsyncOperation;
|
||||
createBlobFromRandomAccessStream(type: string, seeker: any): Blob;
|
||||
|
||||
+2433
-1559
File diff suppressed because it is too large
Load Diff
+2578
-1760
File diff suppressed because it is too large
Load Diff
Vendored
+67
-49
@@ -17,19 +17,22 @@ declare namespace ts {
|
||||
interface Map<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
type Path = string & {
|
||||
__pathBrand: any;
|
||||
};
|
||||
interface FileMap<T> {
|
||||
get(fileName: string): T;
|
||||
set(fileName: string, value: T): void;
|
||||
contains(fileName: string): boolean;
|
||||
remove(fileName: string): void;
|
||||
forEachValue(f: (v: T) => void): void;
|
||||
get(fileName: Path): T;
|
||||
set(fileName: Path, value: T): void;
|
||||
contains(fileName: Path): boolean;
|
||||
remove(fileName: Path): void;
|
||||
forEachValue(f: (key: Path, v: T) => void): void;
|
||||
clear(): void;
|
||||
}
|
||||
interface TextRange {
|
||||
pos: number;
|
||||
end: number;
|
||||
}
|
||||
const enum SyntaxKind {
|
||||
enum SyntaxKind {
|
||||
Unknown = 0,
|
||||
EndOfFileToken = 1,
|
||||
SingleLineCommentTrivia = 2,
|
||||
@@ -327,30 +330,34 @@ declare namespace ts {
|
||||
LastBinaryOperator = 68,
|
||||
FirstNode = 135,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
Ambient = 2,
|
||||
Public = 16,
|
||||
Private = 32,
|
||||
Protected = 64,
|
||||
Static = 128,
|
||||
Abstract = 256,
|
||||
Async = 512,
|
||||
Default = 1024,
|
||||
MultiLine = 2048,
|
||||
Synthetic = 4096,
|
||||
DeclarationFile = 8192,
|
||||
Let = 16384,
|
||||
Const = 32768,
|
||||
OctalLiteral = 65536,
|
||||
Namespace = 131072,
|
||||
ExportContext = 262144,
|
||||
ContainsThis = 524288,
|
||||
Modifier = 2035,
|
||||
AccessibilityModifier = 112,
|
||||
BlockScoped = 49152,
|
||||
enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 2,
|
||||
Ambient = 4,
|
||||
Public = 8,
|
||||
Private = 16,
|
||||
Protected = 32,
|
||||
Static = 64,
|
||||
Abstract = 128,
|
||||
Async = 256,
|
||||
Default = 512,
|
||||
MultiLine = 1024,
|
||||
Synthetic = 2048,
|
||||
DeclarationFile = 4096,
|
||||
Let = 8192,
|
||||
Const = 16384,
|
||||
OctalLiteral = 32768,
|
||||
Namespace = 65536,
|
||||
ExportContext = 131072,
|
||||
ContainsThis = 262144,
|
||||
HasImplicitReturn = 524288,
|
||||
HasExplicitReturn = 1048576,
|
||||
Modifier = 1022,
|
||||
AccessibilityModifier = 56,
|
||||
BlockScoped = 24576,
|
||||
ReachabilityCheckFlags = 1572864,
|
||||
}
|
||||
const enum JsxFlags {
|
||||
enum JsxFlags {
|
||||
None = 0,
|
||||
IntrinsicNamedElement = 1,
|
||||
IntrinsicIndexedElement = 2,
|
||||
@@ -930,6 +937,7 @@ declare namespace ts {
|
||||
statements: NodeArray<Statement>;
|
||||
endOfFileToken: Node;
|
||||
fileName: string;
|
||||
path: Path;
|
||||
text: string;
|
||||
amdDependencies: {
|
||||
path: string;
|
||||
@@ -954,7 +962,7 @@ declare namespace ts {
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface ParseConfigHost extends ModuleResolutionHost {
|
||||
interface ParseConfigHost {
|
||||
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
|
||||
}
|
||||
interface WriteFileCallback {
|
||||
@@ -1092,7 +1100,7 @@ declare namespace ts {
|
||||
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
||||
reportInaccessibleThisError(): void;
|
||||
}
|
||||
const enum TypeFormatFlags {
|
||||
enum TypeFormatFlags {
|
||||
None = 0,
|
||||
WriteArrayAsGenericType = 1,
|
||||
UseTypeOfFunction = 2,
|
||||
@@ -1103,7 +1111,7 @@ declare namespace ts {
|
||||
InElementType = 64,
|
||||
UseFullyQualifiedType = 128,
|
||||
}
|
||||
const enum SymbolFormatFlags {
|
||||
enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
WriteTypeParametersOrArguments = 1,
|
||||
UseOnlyExternalAliasing = 2,
|
||||
@@ -1113,7 +1121,7 @@ declare namespace ts {
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
BlockScopedVariable = 2,
|
||||
@@ -1190,7 +1198,7 @@ declare namespace ts {
|
||||
interface SymbolTable {
|
||||
[index: string]: Symbol;
|
||||
}
|
||||
const enum TypeFlags {
|
||||
enum TypeFlags {
|
||||
Any = 1,
|
||||
String = 2,
|
||||
Number = 4,
|
||||
@@ -1261,7 +1269,7 @@ declare namespace ts {
|
||||
interface TypeParameter extends Type {
|
||||
constraint: Type;
|
||||
}
|
||||
const enum SignatureKind {
|
||||
enum SignatureKind {
|
||||
Call = 0,
|
||||
Construct = 1,
|
||||
}
|
||||
@@ -1271,7 +1279,7 @@ declare namespace ts {
|
||||
parameters: Symbol[];
|
||||
typePredicate?: TypePredicate;
|
||||
}
|
||||
const enum IndexKind {
|
||||
enum IndexKind {
|
||||
String = 0,
|
||||
Number = 1,
|
||||
}
|
||||
@@ -1279,6 +1287,7 @@ declare namespace ts {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
message: string;
|
||||
}
|
||||
/**
|
||||
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
|
||||
@@ -1305,7 +1314,7 @@ declare namespace ts {
|
||||
Error = 1,
|
||||
Message = 2,
|
||||
}
|
||||
const enum ModuleResolutionKind {
|
||||
enum ModuleResolutionKind {
|
||||
Classic = 1,
|
||||
NodeJs = 2,
|
||||
}
|
||||
@@ -1350,9 +1359,14 @@ declare namespace ts {
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
allowUnusedLabels?: boolean;
|
||||
allowUnreachableCode?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
AMD = 2,
|
||||
@@ -1361,12 +1375,12 @@ declare namespace ts {
|
||||
ES6 = 5,
|
||||
ES2015 = 5,
|
||||
}
|
||||
const enum JsxEmit {
|
||||
enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2,
|
||||
}
|
||||
const enum NewLineKind {
|
||||
enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1,
|
||||
}
|
||||
@@ -1374,14 +1388,14 @@ declare namespace ts {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
const enum ScriptTarget {
|
||||
enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES6 = 2,
|
||||
ES2015 = 2,
|
||||
Latest = 2,
|
||||
}
|
||||
const enum LanguageVariant {
|
||||
enum LanguageVariant {
|
||||
Standard = 0,
|
||||
JSX = 1,
|
||||
}
|
||||
@@ -1521,11 +1535,10 @@ declare namespace ts {
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
function getTypeParameterOwner(d: Declaration): Declaration;
|
||||
function arrayStructurallyIsEqualTo<T>(array1: Array<T>, array2: Array<T>): boolean;
|
||||
}
|
||||
declare namespace ts {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node;
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
@@ -1564,10 +1577,15 @@ declare namespace ts {
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param host Instance of ParseConfigHost used to enumerate files in folder.
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): {
|
||||
options: CompilerOptions;
|
||||
errors: Diagnostic[];
|
||||
};
|
||||
}
|
||||
declare namespace ts {
|
||||
/** The version of the language service API */
|
||||
@@ -1931,7 +1949,7 @@ declare namespace ts {
|
||||
outputFiles: OutputFile[];
|
||||
emitSkipped: boolean;
|
||||
}
|
||||
const enum OutputFileType {
|
||||
enum OutputFileType {
|
||||
JavaScript = 0,
|
||||
SourceMap = 1,
|
||||
Declaration = 2,
|
||||
@@ -1941,7 +1959,7 @@ declare namespace ts {
|
||||
writeByteOrderMark: boolean;
|
||||
text: string;
|
||||
}
|
||||
const enum EndOfLineState {
|
||||
enum EndOfLineState {
|
||||
None = 0,
|
||||
InMultiLineCommentTrivia = 1,
|
||||
InSingleQuoteStringLiteral = 2,
|
||||
@@ -2109,7 +2127,7 @@ declare namespace ts {
|
||||
static parameterName: string;
|
||||
static docCommentTagName: string;
|
||||
}
|
||||
const enum ClassificationType {
|
||||
enum ClassificationType {
|
||||
comment = 1,
|
||||
identifier = 2,
|
||||
keyword = 3,
|
||||
@@ -2152,7 +2170,7 @@ declare namespace ts {
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
|
||||
+2705
-1792
File diff suppressed because it is too large
Load Diff
Vendored
+67
-49
@@ -17,19 +17,22 @@ declare namespace ts {
|
||||
interface Map<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
type Path = string & {
|
||||
__pathBrand: any;
|
||||
};
|
||||
interface FileMap<T> {
|
||||
get(fileName: string): T;
|
||||
set(fileName: string, value: T): void;
|
||||
contains(fileName: string): boolean;
|
||||
remove(fileName: string): void;
|
||||
forEachValue(f: (v: T) => void): void;
|
||||
get(fileName: Path): T;
|
||||
set(fileName: Path, value: T): void;
|
||||
contains(fileName: Path): boolean;
|
||||
remove(fileName: Path): void;
|
||||
forEachValue(f: (key: Path, v: T) => void): void;
|
||||
clear(): void;
|
||||
}
|
||||
interface TextRange {
|
||||
pos: number;
|
||||
end: number;
|
||||
}
|
||||
const enum SyntaxKind {
|
||||
enum SyntaxKind {
|
||||
Unknown = 0,
|
||||
EndOfFileToken = 1,
|
||||
SingleLineCommentTrivia = 2,
|
||||
@@ -327,30 +330,34 @@ declare namespace ts {
|
||||
LastBinaryOperator = 68,
|
||||
FirstNode = 135,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
Ambient = 2,
|
||||
Public = 16,
|
||||
Private = 32,
|
||||
Protected = 64,
|
||||
Static = 128,
|
||||
Abstract = 256,
|
||||
Async = 512,
|
||||
Default = 1024,
|
||||
MultiLine = 2048,
|
||||
Synthetic = 4096,
|
||||
DeclarationFile = 8192,
|
||||
Let = 16384,
|
||||
Const = 32768,
|
||||
OctalLiteral = 65536,
|
||||
Namespace = 131072,
|
||||
ExportContext = 262144,
|
||||
ContainsThis = 524288,
|
||||
Modifier = 2035,
|
||||
AccessibilityModifier = 112,
|
||||
BlockScoped = 49152,
|
||||
enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 2,
|
||||
Ambient = 4,
|
||||
Public = 8,
|
||||
Private = 16,
|
||||
Protected = 32,
|
||||
Static = 64,
|
||||
Abstract = 128,
|
||||
Async = 256,
|
||||
Default = 512,
|
||||
MultiLine = 1024,
|
||||
Synthetic = 2048,
|
||||
DeclarationFile = 4096,
|
||||
Let = 8192,
|
||||
Const = 16384,
|
||||
OctalLiteral = 32768,
|
||||
Namespace = 65536,
|
||||
ExportContext = 131072,
|
||||
ContainsThis = 262144,
|
||||
HasImplicitReturn = 524288,
|
||||
HasExplicitReturn = 1048576,
|
||||
Modifier = 1022,
|
||||
AccessibilityModifier = 56,
|
||||
BlockScoped = 24576,
|
||||
ReachabilityCheckFlags = 1572864,
|
||||
}
|
||||
const enum JsxFlags {
|
||||
enum JsxFlags {
|
||||
None = 0,
|
||||
IntrinsicNamedElement = 1,
|
||||
IntrinsicIndexedElement = 2,
|
||||
@@ -930,6 +937,7 @@ declare namespace ts {
|
||||
statements: NodeArray<Statement>;
|
||||
endOfFileToken: Node;
|
||||
fileName: string;
|
||||
path: Path;
|
||||
text: string;
|
||||
amdDependencies: {
|
||||
path: string;
|
||||
@@ -954,7 +962,7 @@ declare namespace ts {
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface ParseConfigHost extends ModuleResolutionHost {
|
||||
interface ParseConfigHost {
|
||||
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
|
||||
}
|
||||
interface WriteFileCallback {
|
||||
@@ -1092,7 +1100,7 @@ declare namespace ts {
|
||||
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
||||
reportInaccessibleThisError(): void;
|
||||
}
|
||||
const enum TypeFormatFlags {
|
||||
enum TypeFormatFlags {
|
||||
None = 0,
|
||||
WriteArrayAsGenericType = 1,
|
||||
UseTypeOfFunction = 2,
|
||||
@@ -1103,7 +1111,7 @@ declare namespace ts {
|
||||
InElementType = 64,
|
||||
UseFullyQualifiedType = 128,
|
||||
}
|
||||
const enum SymbolFormatFlags {
|
||||
enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
WriteTypeParametersOrArguments = 1,
|
||||
UseOnlyExternalAliasing = 2,
|
||||
@@ -1113,7 +1121,7 @@ declare namespace ts {
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
BlockScopedVariable = 2,
|
||||
@@ -1190,7 +1198,7 @@ declare namespace ts {
|
||||
interface SymbolTable {
|
||||
[index: string]: Symbol;
|
||||
}
|
||||
const enum TypeFlags {
|
||||
enum TypeFlags {
|
||||
Any = 1,
|
||||
String = 2,
|
||||
Number = 4,
|
||||
@@ -1261,7 +1269,7 @@ declare namespace ts {
|
||||
interface TypeParameter extends Type {
|
||||
constraint: Type;
|
||||
}
|
||||
const enum SignatureKind {
|
||||
enum SignatureKind {
|
||||
Call = 0,
|
||||
Construct = 1,
|
||||
}
|
||||
@@ -1271,7 +1279,7 @@ declare namespace ts {
|
||||
parameters: Symbol[];
|
||||
typePredicate?: TypePredicate;
|
||||
}
|
||||
const enum IndexKind {
|
||||
enum IndexKind {
|
||||
String = 0,
|
||||
Number = 1,
|
||||
}
|
||||
@@ -1279,6 +1287,7 @@ declare namespace ts {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
message: string;
|
||||
}
|
||||
/**
|
||||
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
|
||||
@@ -1305,7 +1314,7 @@ declare namespace ts {
|
||||
Error = 1,
|
||||
Message = 2,
|
||||
}
|
||||
const enum ModuleResolutionKind {
|
||||
enum ModuleResolutionKind {
|
||||
Classic = 1,
|
||||
NodeJs = 2,
|
||||
}
|
||||
@@ -1350,9 +1359,14 @@ declare namespace ts {
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
allowUnusedLabels?: boolean;
|
||||
allowUnreachableCode?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
AMD = 2,
|
||||
@@ -1361,12 +1375,12 @@ declare namespace ts {
|
||||
ES6 = 5,
|
||||
ES2015 = 5,
|
||||
}
|
||||
const enum JsxEmit {
|
||||
enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2,
|
||||
}
|
||||
const enum NewLineKind {
|
||||
enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1,
|
||||
}
|
||||
@@ -1374,14 +1388,14 @@ declare namespace ts {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
const enum ScriptTarget {
|
||||
enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES6 = 2,
|
||||
ES2015 = 2,
|
||||
Latest = 2,
|
||||
}
|
||||
const enum LanguageVariant {
|
||||
enum LanguageVariant {
|
||||
Standard = 0,
|
||||
JSX = 1,
|
||||
}
|
||||
@@ -1521,11 +1535,10 @@ declare namespace ts {
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
function getTypeParameterOwner(d: Declaration): Declaration;
|
||||
function arrayStructurallyIsEqualTo<T>(array1: Array<T>, array2: Array<T>): boolean;
|
||||
}
|
||||
declare namespace ts {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node;
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
@@ -1564,10 +1577,15 @@ declare namespace ts {
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param host Instance of ParseConfigHost used to enumerate files in folder.
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): {
|
||||
options: CompilerOptions;
|
||||
errors: Diagnostic[];
|
||||
};
|
||||
}
|
||||
declare namespace ts {
|
||||
/** The version of the language service API */
|
||||
@@ -1931,7 +1949,7 @@ declare namespace ts {
|
||||
outputFiles: OutputFile[];
|
||||
emitSkipped: boolean;
|
||||
}
|
||||
const enum OutputFileType {
|
||||
enum OutputFileType {
|
||||
JavaScript = 0,
|
||||
SourceMap = 1,
|
||||
Declaration = 2,
|
||||
@@ -1941,7 +1959,7 @@ declare namespace ts {
|
||||
writeByteOrderMark: boolean;
|
||||
text: string;
|
||||
}
|
||||
const enum EndOfLineState {
|
||||
enum EndOfLineState {
|
||||
None = 0,
|
||||
InMultiLineCommentTrivia = 1,
|
||||
InSingleQuoteStringLiteral = 2,
|
||||
@@ -2109,7 +2127,7 @@ declare namespace ts {
|
||||
static parameterName: string;
|
||||
static docCommentTagName: string;
|
||||
}
|
||||
const enum ClassificationType {
|
||||
enum ClassificationType {
|
||||
comment = 1,
|
||||
identifier = 2,
|
||||
keyword = 3,
|
||||
@@ -2152,7 +2170,7 @@ declare namespace ts {
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
|
||||
+2705
-1792
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,228 @@
|
||||
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
|
||||
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
|
||||
|
||||
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
public static FAILURE_STRING_FACTORY = (identifier: string) => `Identifier '${identifier}' never appears on the LHS of an assignment - use const instead of let for its declaration.`;
|
||||
|
||||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
||||
return this.applyWithWalker(new PreferConstWalker(sourceFile, this.getOptions()));
|
||||
}
|
||||
}
|
||||
|
||||
function isBindingPattern(node: ts.Node): node is ts.BindingPattern {
|
||||
return !!node && (node.kind === ts.SyntaxKind.ArrayBindingPattern || node.kind === ts.SyntaxKind.ObjectBindingPattern);
|
||||
}
|
||||
|
||||
function walkUpBindingElementsAndPatterns(node: ts.Node): ts.Node {
|
||||
while (node && (node.kind === ts.SyntaxKind.BindingElement || isBindingPattern(node))) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function getCombinedNodeFlags(node: ts.Node): ts.NodeFlags {
|
||||
node = walkUpBindingElementsAndPatterns(node);
|
||||
|
||||
let flags = node.flags;
|
||||
if (node.kind === ts.SyntaxKind.VariableDeclaration) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
if (node && node.kind === ts.SyntaxKind.VariableDeclarationList) {
|
||||
flags |= node.flags;
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
if (node && node.kind === ts.SyntaxKind.VariableStatement) {
|
||||
flags |= node.flags;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
function isLet(node: ts.Node) {
|
||||
return !!(getCombinedNodeFlags(node) & ts.NodeFlags.Let);
|
||||
}
|
||||
|
||||
function isExported(node: ts.Node) {
|
||||
return !!(getCombinedNodeFlags(node) & ts.NodeFlags.Export);
|
||||
}
|
||||
|
||||
function isAssignmentOperator(token: ts.SyntaxKind): boolean {
|
||||
return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment;
|
||||
}
|
||||
|
||||
function isBindingLiteralExpression(node: ts.Node): node is (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) {
|
||||
return (!!node) && (node.kind === ts.SyntaxKind.ObjectLiteralExpression || node.kind === ts.SyntaxKind.ArrayLiteralExpression);
|
||||
}
|
||||
|
||||
interface DeclarationUsages {
|
||||
declaration: ts.VariableDeclaration;
|
||||
usages: number;
|
||||
}
|
||||
|
||||
class PreferConstWalker extends Lint.RuleWalker {
|
||||
private inScopeLetDeclarations: ts.Map<DeclarationUsages>[] = [];
|
||||
private errors: Lint.RuleFailure[] = [];
|
||||
private markAssignment(identifier: ts.Identifier) {
|
||||
const name = identifier.text;
|
||||
for (let i = this.inScopeLetDeclarations.length - 1; i >= 0; i--) {
|
||||
const declarations = this.inScopeLetDeclarations[i];
|
||||
if (declarations[name]) {
|
||||
declarations[name].usages++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitSourceFile(node: ts.SourceFile) {
|
||||
super.visitSourceFile(node);
|
||||
// Sort errors by position because tslint doesn't
|
||||
this.errors.sort((a, b) => a.getStartPosition().getPosition() - b.getStartPosition().getPosition()).forEach(e => this.addFailure(e));
|
||||
}
|
||||
|
||||
visitBinaryExpression(node: ts.BinaryExpression) {
|
||||
if (isAssignmentOperator(node.operatorToken.kind)) {
|
||||
this.visitLHSExpressions(node.left);
|
||||
}
|
||||
super.visitBinaryExpression(node);
|
||||
}
|
||||
|
||||
private visitLHSExpressions(node: ts.Expression) {
|
||||
while (node.kind === ts.SyntaxKind.ParenthesizedExpression) {
|
||||
node = (node as ts.ParenthesizedExpression).expression;
|
||||
}
|
||||
if (node.kind === ts.SyntaxKind.Identifier) {
|
||||
this.markAssignment(node as ts.Identifier);
|
||||
}
|
||||
else if (isBindingLiteralExpression(node)) {
|
||||
this.visitBindingLiteralExpression(node as (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression));
|
||||
}
|
||||
}
|
||||
|
||||
private visitBindingLiteralExpression(node: ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) {
|
||||
if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) {
|
||||
const pattern = node as ts.ObjectLiteralExpression;
|
||||
for (const element of pattern.properties) {
|
||||
if (element.name.kind === ts.SyntaxKind.Identifier) {
|
||||
this.markAssignment(element.name as ts.Identifier)
|
||||
}
|
||||
else if (isBindingPattern(element.name)) {
|
||||
this.visitBindingPatternIdentifiers(element.name as ts.BindingPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) {
|
||||
const pattern = node as ts.ArrayLiteralExpression;
|
||||
for (const element of pattern.elements) {
|
||||
this.visitLHSExpressions(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private visitBindingPatternIdentifiers(pattern: ts.BindingPattern) {
|
||||
for (const element of pattern.elements) {
|
||||
if (element.name.kind === ts.SyntaxKind.Identifier) {
|
||||
this.markAssignment(element.name as ts.Identifier);
|
||||
}
|
||||
else {
|
||||
this.visitBindingPatternIdentifiers(element.name as ts.BindingPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) {
|
||||
this.visitAnyUnaryExpression(node);
|
||||
super.visitPrefixUnaryExpression(node);
|
||||
}
|
||||
|
||||
visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) {
|
||||
this.visitAnyUnaryExpression(node);
|
||||
super.visitPostfixUnaryExpression(node);
|
||||
}
|
||||
|
||||
private visitAnyUnaryExpression(node: ts.PrefixUnaryExpression | ts.PostfixUnaryExpression) {
|
||||
if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator === ts.SyntaxKind.MinusMinusToken) {
|
||||
this.visitLHSExpressions(node.operand);
|
||||
}
|
||||
}
|
||||
|
||||
visitModuleDeclaration(node: ts.ModuleDeclaration) {
|
||||
if (node.body.kind === ts.SyntaxKind.ModuleBlock) {
|
||||
// For some reason module blocks are left out of the visit block traversal
|
||||
this.visitBlock(node.body as ts.ModuleBlock);
|
||||
}
|
||||
super.visitModuleDeclaration(node);
|
||||
}
|
||||
|
||||
visitForOfStatement(node: ts.ForOfStatement) {
|
||||
this.visitAnyForStatement(node);
|
||||
super.visitForOfStatement(node);
|
||||
this.popDeclarations();
|
||||
}
|
||||
|
||||
visitForInStatement(node: ts.ForInStatement) {
|
||||
this.visitAnyForStatement(node);
|
||||
super.visitForInStatement(node);
|
||||
this.popDeclarations();
|
||||
}
|
||||
|
||||
private visitAnyForStatement(node: ts.ForOfStatement | ts.ForInStatement) {
|
||||
const names: ts.Map<DeclarationUsages> = {};
|
||||
if (isLet(node.initializer)) {
|
||||
if (node.initializer.kind === ts.SyntaxKind.VariableDeclarationList) {
|
||||
this.collectLetIdentifiers(node.initializer as ts.VariableDeclarationList, names);
|
||||
}
|
||||
}
|
||||
this.inScopeLetDeclarations.push(names);
|
||||
}
|
||||
|
||||
private popDeclarations() {
|
||||
const completed = this.inScopeLetDeclarations.pop();
|
||||
for (const name in completed) {
|
||||
if (Object.hasOwnProperty.call(completed, name)) {
|
||||
const element = completed[name];
|
||||
if (element.usages === 0) {
|
||||
this.errors.push(this.createFailure(element.declaration.getStart(this.getSourceFile()), element.declaration.getWidth(this.getSourceFile()), Rule.FAILURE_STRING_FACTORY(name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitBlock(node: ts.Block) {
|
||||
const names: ts.Map<DeclarationUsages> = {};
|
||||
for (const statement of node.statements) {
|
||||
if (statement.kind === ts.SyntaxKind.VariableStatement) {
|
||||
this.collectLetIdentifiers((statement as ts.VariableStatement).declarationList, names);
|
||||
}
|
||||
}
|
||||
this.inScopeLetDeclarations.push(names);
|
||||
super.visitBlock(node);
|
||||
this.popDeclarations();
|
||||
}
|
||||
|
||||
private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.Map<DeclarationUsages>) {
|
||||
for (const node of list.declarations) {
|
||||
if (isLet(node) && !isExported(node)) {
|
||||
this.collectNameIdentifiers(node, node.name, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private collectNameIdentifiers(value: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.Map<DeclarationUsages>) {
|
||||
if (node.kind === ts.SyntaxKind.Identifier) {
|
||||
table[(node as ts.Identifier).text] = {declaration: value, usages: 0};
|
||||
}
|
||||
else {
|
||||
this.collectBindingPatternIdentifiers(value, node as ts.BindingPattern, table);
|
||||
}
|
||||
}
|
||||
|
||||
private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.Map<DeclarationUsages>) {
|
||||
for (const element of pattern.elements) {
|
||||
this.collectNameIdentifiers(value, element.name, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
+490
-66
@@ -10,6 +10,21 @@ namespace ts {
|
||||
ConstEnumOnly = 2
|
||||
}
|
||||
|
||||
const enum Reachability {
|
||||
Unintialized = 1 << 0,
|
||||
Reachable = 1 << 1,
|
||||
Unreachable = 1 << 2,
|
||||
ReportedUnreachable = 1 << 3
|
||||
}
|
||||
|
||||
function or(state1: Reachability, state2: Reachability): Reachability {
|
||||
return (state1 | state2) & Reachability.Reachable
|
||||
? Reachability.Reachable
|
||||
: (state1 & state2) & Reachability.ReportedUnreachable
|
||||
? Reachability.ReportedUnreachable
|
||||
: Reachability.Unreachable;
|
||||
}
|
||||
|
||||
export function getModuleInstanceState(node: Node): ModuleInstanceState {
|
||||
// A module is uninstantiated if it contains only
|
||||
// 1. interface declarations, type alias declarations
|
||||
@@ -77,35 +92,64 @@ namespace ts {
|
||||
IsContainerWithLocals = IsContainer | HasLocals
|
||||
}
|
||||
|
||||
export function bindSourceFile(file: SourceFile) {
|
||||
let start = new Date().getTime();
|
||||
bindSourceFileWorker(file);
|
||||
const binder = createBinder();
|
||||
|
||||
export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
|
||||
const start = new Date().getTime();
|
||||
binder(file, options);
|
||||
bindTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
function bindSourceFileWorker(file: SourceFile) {
|
||||
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
let file: SourceFile;
|
||||
let options: CompilerOptions;
|
||||
let parent: Node;
|
||||
let container: Node;
|
||||
let blockScopeContainer: Node;
|
||||
let lastContainer: Node;
|
||||
let seenThisKeyword: boolean;
|
||||
|
||||
// state used by reachability checks
|
||||
let hasExplicitReturn: boolean;
|
||||
let currentReachabilityState: Reachability;
|
||||
let labelStack: Reachability[];
|
||||
let labelIndexMap: Map<number>;
|
||||
let implicitLabels: number[];
|
||||
|
||||
// If this file is an external module, then it is automatically in strict-mode according to
|
||||
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
|
||||
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
|
||||
let inStrictMode = !!file.externalModuleIndicator;
|
||||
let inStrictMode: boolean;
|
||||
|
||||
let symbolCount = 0;
|
||||
let Symbol = objectAllocator.getSymbolConstructor();
|
||||
let classifiableNames: Map<string> = {};
|
||||
let Symbol: { new (flags: SymbolFlags, name: string): Symbol };
|
||||
let classifiableNames: Map<string>;
|
||||
|
||||
if (!file.locals) {
|
||||
bind(file);
|
||||
file.symbolCount = symbolCount;
|
||||
file.classifiableNames = classifiableNames;
|
||||
function bindSourceFile(f: SourceFile, opts: CompilerOptions) {
|
||||
file = f;
|
||||
options = opts;
|
||||
inStrictMode = !!file.externalModuleIndicator;
|
||||
classifiableNames = {};
|
||||
Symbol = objectAllocator.getSymbolConstructor();
|
||||
|
||||
if (!file.locals) {
|
||||
bind(file);
|
||||
file.symbolCount = symbolCount;
|
||||
file.classifiableNames = classifiableNames;
|
||||
}
|
||||
|
||||
parent = undefined;
|
||||
container = undefined;
|
||||
blockScopeContainer = undefined;
|
||||
lastContainer = undefined;
|
||||
seenThisKeyword = false;
|
||||
hasExplicitReturn = false;
|
||||
labelStack = undefined;
|
||||
labelIndexMap = undefined;
|
||||
implicitLabels = undefined;
|
||||
}
|
||||
|
||||
return;
|
||||
return bindSourceFile;
|
||||
|
||||
function createSymbol(flags: SymbolFlags, name: string): Symbol {
|
||||
symbolCount++;
|
||||
@@ -143,7 +187,7 @@ namespace ts {
|
||||
return `"${(<LiteralExpression>node.name).text}"`;
|
||||
}
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
let nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
const nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
|
||||
return getPropertyNameForKnownSymbolName((<PropertyAccessExpression>nameExpression).name.text);
|
||||
}
|
||||
@@ -185,9 +229,9 @@ namespace ts {
|
||||
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
||||
let isDefaultExport = node.flags & NodeFlags.Default;
|
||||
const isDefaultExport = node.flags & NodeFlags.Default;
|
||||
// The exported symbol for an export default function/class node is always named "default"
|
||||
let name = isDefaultExport && parent ? "default" : getDeclarationName(node);
|
||||
const name = isDefaultExport && parent ? "default" : getDeclarationName(node);
|
||||
|
||||
let symbol: Symbol;
|
||||
if (name !== undefined) {
|
||||
@@ -254,7 +298,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {
|
||||
let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
|
||||
const hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
|
||||
if (symbolFlags & SymbolFlags.Alias) {
|
||||
if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) {
|
||||
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
@@ -276,11 +320,11 @@ namespace ts {
|
||||
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
|
||||
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
|
||||
if (hasExportModifier || container.flags & NodeFlags.ExportContext) {
|
||||
let exportKind =
|
||||
const exportKind =
|
||||
(symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
|
||||
(symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) |
|
||||
(symbolFlags & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0);
|
||||
let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
|
||||
const local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
|
||||
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
node.localSymbol = local;
|
||||
return local;
|
||||
@@ -298,9 +342,9 @@ namespace ts {
|
||||
// Before we recurse into a node's chilren, we first save the existing parent, container
|
||||
// and block-container. Then after we pop out of processing the children, we restore
|
||||
// these saved values.
|
||||
let saveParent = parent;
|
||||
let saveContainer = container;
|
||||
let savedBlockScopeContainer = blockScopeContainer;
|
||||
const saveParent = parent;
|
||||
const saveContainer = container;
|
||||
const savedBlockScopeContainer = blockScopeContainer;
|
||||
|
||||
// This node will now be set as the parent of all of its children as we recurse into them.
|
||||
parent = node;
|
||||
@@ -322,7 +366,7 @@ namespace ts {
|
||||
// reusing a node from a previous compilation, that node may have had 'locals' created
|
||||
// for it. We must clear this so we don't accidently move any stale data forward from
|
||||
// a previous compilation.
|
||||
let containerFlags = getContainerFlags(node);
|
||||
const containerFlags = getContainerFlags(node);
|
||||
if (containerFlags & ContainerFlags.IsContainer) {
|
||||
container = blockScopeContainer = node;
|
||||
|
||||
@@ -338,13 +382,56 @@ namespace ts {
|
||||
blockScopeContainer.locals = undefined;
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
let savedReachabilityState: Reachability;
|
||||
let savedLabelStack: Reachability[];
|
||||
let savedLabels: Map<number>;
|
||||
let savedImplicitLabels: number[];
|
||||
let savedHasExplicitReturn: boolean;
|
||||
|
||||
const kind = node.kind;
|
||||
let flags = node.flags;
|
||||
|
||||
// reset all reachability check related flags on node (for incremental scenarios)
|
||||
flags &= ~NodeFlags.ReachabilityCheckFlags;
|
||||
|
||||
if (kind === SyntaxKind.InterfaceDeclaration) {
|
||||
seenThisKeyword = false;
|
||||
forEachChild(node, bind);
|
||||
node.flags = seenThisKeyword ? node.flags | NodeFlags.ContainsThis : node.flags & ~NodeFlags.ContainsThis;
|
||||
}
|
||||
else {
|
||||
forEachChild(node, bind);
|
||||
|
||||
const saveState = kind === SyntaxKind.SourceFile || kind === SyntaxKind.ModuleBlock || isFunctionLikeKind(kind);
|
||||
if (saveState) {
|
||||
savedReachabilityState = currentReachabilityState;
|
||||
savedLabelStack = labelStack;
|
||||
savedLabels = labelIndexMap;
|
||||
savedImplicitLabels = implicitLabels;
|
||||
savedHasExplicitReturn = hasExplicitReturn;
|
||||
|
||||
currentReachabilityState = Reachability.Reachable;
|
||||
hasExplicitReturn = false;
|
||||
labelStack = labelIndexMap = implicitLabels = undefined;
|
||||
}
|
||||
|
||||
bindReachableStatement(node);
|
||||
|
||||
if (currentReachabilityState === Reachability.Reachable && isFunctionLikeKind(kind) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
|
||||
flags |= NodeFlags.HasImplicitReturn;
|
||||
if (hasExplicitReturn) {
|
||||
flags |= NodeFlags.HasExplicitReturn;
|
||||
}
|
||||
}
|
||||
|
||||
if (kind === SyntaxKind.InterfaceDeclaration) {
|
||||
flags = seenThisKeyword ? flags | NodeFlags.ContainsThis : flags & ~NodeFlags.ContainsThis;
|
||||
}
|
||||
|
||||
node.flags = flags;
|
||||
|
||||
if (saveState) {
|
||||
hasExplicitReturn = savedHasExplicitReturn;
|
||||
currentReachabilityState = savedReachabilityState;
|
||||
labelStack = savedLabelStack;
|
||||
labelIndexMap = savedLabels;
|
||||
implicitLabels = savedImplicitLabels;
|
||||
}
|
||||
|
||||
container = saveContainer;
|
||||
@@ -352,6 +439,220 @@ namespace ts {
|
||||
blockScopeContainer = savedBlockScopeContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if node and its subnodes were successfully traversed.
|
||||
* Returning false means that node was not examined and caller needs to dive into the node himself.
|
||||
*/
|
||||
function bindReachableStatement(node: Node): void {
|
||||
if (checkUnreachable(node)) {
|
||||
forEachChild(node, bind);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.WhileStatement:
|
||||
bindWhileStatement(<WhileStatement>node);
|
||||
break;
|
||||
case SyntaxKind.DoStatement:
|
||||
bindDoStatement(<DoStatement>node);
|
||||
break;
|
||||
case SyntaxKind.ForStatement:
|
||||
bindForStatement(<ForStatement>node);
|
||||
break;
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
bindForInOrForOfStatement(<ForInStatement | ForOfStatement>node);
|
||||
break;
|
||||
case SyntaxKind.IfStatement:
|
||||
bindIfStatement(<IfStatement>node);
|
||||
break;
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.ThrowStatement:
|
||||
bindReturnOrThrow(<ReturnStatement | ThrowStatement>node);
|
||||
break;
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
bindBreakOrContinueStatement(<BreakOrContinueStatement>node);
|
||||
break;
|
||||
case SyntaxKind.TryStatement:
|
||||
bindTryStatement(<TryStatement>node);
|
||||
break;
|
||||
case SyntaxKind.SwitchStatement:
|
||||
bindSwitchStatement(<SwitchStatement>node);
|
||||
break;
|
||||
case SyntaxKind.CaseBlock:
|
||||
bindCaseBlock(<CaseBlock>node);
|
||||
break;
|
||||
case SyntaxKind.LabeledStatement:
|
||||
bindLabeledStatement(<LabeledStatement>node);
|
||||
break;
|
||||
default:
|
||||
forEachChild(node, bind);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function bindWhileStatement(n: WhileStatement): void {
|
||||
const preWhileState =
|
||||
n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState;
|
||||
const postWhileState =
|
||||
n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : currentReachabilityState;
|
||||
|
||||
// bind expressions (don't affect reachability)
|
||||
bind(n.expression);
|
||||
|
||||
currentReachabilityState = preWhileState;
|
||||
const postWhileLabel = pushImplicitLabel();
|
||||
bind(n.statement);
|
||||
popImplicitLabel(postWhileLabel, postWhileState);
|
||||
}
|
||||
|
||||
function bindDoStatement(n: DoStatement): void {
|
||||
const preDoState = currentReachabilityState;
|
||||
|
||||
const postDoLabel = pushImplicitLabel();
|
||||
bind(n.statement);
|
||||
const postDoState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : preDoState;
|
||||
popImplicitLabel(postDoLabel, postDoState);
|
||||
|
||||
// bind expressions (don't affect reachability)
|
||||
bind(n.expression);
|
||||
}
|
||||
|
||||
function bindForStatement(n: ForStatement): void {
|
||||
const preForState = currentReachabilityState;
|
||||
const postForLabel = pushImplicitLabel();
|
||||
|
||||
// bind expressions (don't affect reachability)
|
||||
bind(n.initializer);
|
||||
bind(n.condition);
|
||||
bind(n.incrementor);
|
||||
|
||||
bind(n.statement);
|
||||
|
||||
// for statement is considered infinite when it condition is either omitted or is true keyword
|
||||
// - for(..;;..)
|
||||
// - for(..;true;..)
|
||||
const isInfiniteLoop = (!n.condition || n.condition.kind === SyntaxKind.TrueKeyword);
|
||||
const postForState = isInfiniteLoop ? Reachability.Unreachable : preForState;
|
||||
popImplicitLabel(postForLabel, postForState);
|
||||
}
|
||||
|
||||
function bindForInOrForOfStatement(n: ForInStatement | ForOfStatement): void {
|
||||
const preStatementState = currentReachabilityState;
|
||||
const postStatementLabel = pushImplicitLabel();
|
||||
|
||||
// bind expressions (don't affect reachability)
|
||||
bind(n.initializer);
|
||||
bind(n.expression);
|
||||
|
||||
bind(n.statement);
|
||||
popImplicitLabel(postStatementLabel, preStatementState);
|
||||
}
|
||||
|
||||
function bindIfStatement(n: IfStatement): void {
|
||||
// denotes reachability state when entering 'thenStatement' part of the if statement:
|
||||
// i.e. if condition is false then thenStatement is unreachable
|
||||
const ifTrueState = n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState;
|
||||
// denotes reachability state when entering 'elseStatement':
|
||||
// i.e. if condition is true then elseStatement is unreachable
|
||||
const ifFalseState = n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : currentReachabilityState;
|
||||
|
||||
currentReachabilityState = ifTrueState;
|
||||
|
||||
// bind expression (don't affect reachability)
|
||||
bind(n.expression);
|
||||
|
||||
bind(n.thenStatement);
|
||||
if (n.elseStatement) {
|
||||
const preElseState = currentReachabilityState;
|
||||
currentReachabilityState = ifFalseState;
|
||||
bind(n.elseStatement);
|
||||
currentReachabilityState = or(currentReachabilityState, preElseState);
|
||||
}
|
||||
else {
|
||||
currentReachabilityState = or(currentReachabilityState, ifFalseState);
|
||||
}
|
||||
}
|
||||
|
||||
function bindReturnOrThrow(n: ReturnStatement | ThrowStatement): void {
|
||||
// bind expression (don't affect reachability)
|
||||
bind(n.expression);
|
||||
if (n.kind === SyntaxKind.ReturnStatement) {
|
||||
hasExplicitReturn = true;
|
||||
}
|
||||
currentReachabilityState = Reachability.Unreachable;
|
||||
}
|
||||
|
||||
function bindBreakOrContinueStatement(n: BreakOrContinueStatement): void {
|
||||
// call bind on label (don't affect reachability)
|
||||
bind(n.label);
|
||||
// for continue case touch label so it will be marked a used
|
||||
const isValidJump = jumpToLabel(n.label, n.kind === SyntaxKind.BreakStatement ? currentReachabilityState : Reachability.Unreachable);
|
||||
if (isValidJump) {
|
||||
currentReachabilityState = Reachability.Unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
function bindTryStatement(n: TryStatement): void {
|
||||
// catch\finally blocks has the same reachability as try block
|
||||
const preTryState = currentReachabilityState;
|
||||
bind(n.tryBlock);
|
||||
const postTryState = currentReachabilityState;
|
||||
|
||||
currentReachabilityState = preTryState;
|
||||
bind(n.catchClause);
|
||||
const postCatchState = currentReachabilityState;
|
||||
|
||||
currentReachabilityState = preTryState;
|
||||
bind(n.finallyBlock);
|
||||
|
||||
// post catch/finally state is reachable if
|
||||
// - post try state is reachable - control flow can fall out of try block
|
||||
// - post catch state is reachable - control flow can fall out of catch block
|
||||
currentReachabilityState = or(postTryState, postCatchState);
|
||||
}
|
||||
|
||||
function bindSwitchStatement(n: SwitchStatement): void {
|
||||
const preSwitchState = currentReachabilityState;
|
||||
const postSwitchLabel = pushImplicitLabel();
|
||||
|
||||
// bind expression (don't affect reachability)
|
||||
bind(n.expression);
|
||||
|
||||
bind(n.caseBlock);
|
||||
|
||||
const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
|
||||
|
||||
// post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case
|
||||
const postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState;
|
||||
|
||||
popImplicitLabel(postSwitchLabel, postSwitchState);
|
||||
}
|
||||
|
||||
function bindCaseBlock(n: CaseBlock): void {
|
||||
const startState = currentReachabilityState;
|
||||
|
||||
for (const clause of n.clauses) {
|
||||
currentReachabilityState = startState;
|
||||
bind(clause);
|
||||
if (clause.statements.length && currentReachabilityState === Reachability.Reachable && options.noFallthroughCasesInSwitch) {
|
||||
errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bindLabeledStatement(n: LabeledStatement): void {
|
||||
// call bind on label (don't affect reachability)
|
||||
bind(n.label);
|
||||
|
||||
const ok = pushNamedLabel(n.label);
|
||||
bind(n.statement);
|
||||
if (ok) {
|
||||
popNamedLabel(n.label, currentReachabilityState);
|
||||
}
|
||||
}
|
||||
|
||||
function getContainerFlags(node: Node): ContainerFlags {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
@@ -488,21 +789,10 @@ namespace ts {
|
||||
: declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
|
||||
function isAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & NodeFlags.Ambient) {
|
||||
return true;
|
||||
}
|
||||
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
|
||||
let body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
|
||||
const body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
|
||||
if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) {
|
||||
for (let stat of (<Block>body).statements) {
|
||||
for (const stat of (<Block>body).statements) {
|
||||
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
|
||||
return true;
|
||||
}
|
||||
@@ -514,7 +804,7 @@ namespace ts {
|
||||
function setExportContextFlag(node: ModuleDeclaration | SourceFile) {
|
||||
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
|
||||
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
|
||||
if (isAmbientContext(node) && !hasExportDeclarations(node)) {
|
||||
if (isInAmbientContext(node) && !hasExportDeclarations(node)) {
|
||||
node.flags |= NodeFlags.ExportContext;
|
||||
}
|
||||
else {
|
||||
@@ -528,7 +818,7 @@ namespace ts {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
|
||||
}
|
||||
else {
|
||||
let state = getModuleInstanceState(node);
|
||||
const state = getModuleInstanceState(node);
|
||||
if (state === ModuleInstanceState.NonInstantiated) {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
|
||||
}
|
||||
@@ -540,7 +830,7 @@ namespace ts {
|
||||
node.symbol.constEnumOnlyModule = false;
|
||||
}
|
||||
else {
|
||||
let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
|
||||
const currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
|
||||
if (node.symbol.constEnumOnlyModule === undefined) {
|
||||
// non-merged case - use the current state
|
||||
node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly;
|
||||
@@ -561,10 +851,10 @@ namespace ts {
|
||||
// We do that by making an anonymous type literal symbol, and then setting the function
|
||||
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
|
||||
// from an actual type literal symbol you would have gotten had you used the long form.
|
||||
let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
|
||||
const symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
|
||||
addDeclarationToSymbol(symbol, node, SymbolFlags.Signature);
|
||||
|
||||
let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
|
||||
const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
|
||||
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
|
||||
typeLiteralSymbol.members = { [symbol.name]: symbol };
|
||||
}
|
||||
@@ -576,14 +866,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (inStrictMode) {
|
||||
let seen: Map<ElementKind> = {};
|
||||
const seen: Map<ElementKind> = {};
|
||||
|
||||
for (let prop of node.properties) {
|
||||
for (const prop of node.properties) {
|
||||
if (prop.name.kind !== SyntaxKind.Identifier) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let identifier = <Identifier>prop.name;
|
||||
const identifier = <Identifier>prop.name;
|
||||
|
||||
// ECMA-262 11.1.5 Object Initialiser
|
||||
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
@@ -593,18 +883,18 @@ namespace ts {
|
||||
// c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
||||
// d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
|
||||
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
|
||||
let currentKind = prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment || prop.kind === SyntaxKind.MethodDeclaration
|
||||
const currentKind = prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment || prop.kind === SyntaxKind.MethodDeclaration
|
||||
? ElementKind.Property
|
||||
: ElementKind.Accessor;
|
||||
|
||||
let existingKind = seen[identifier.text];
|
||||
const existingKind = seen[identifier.text];
|
||||
if (!existingKind) {
|
||||
seen[identifier.text] = currentKind;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentKind === ElementKind.Property && existingKind === ElementKind.Property) {
|
||||
let span = getErrorSpanForNode(file, identifier);
|
||||
const span = getErrorSpanForNode(file, identifier);
|
||||
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length,
|
||||
Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode));
|
||||
}
|
||||
@@ -615,7 +905,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) {
|
||||
let symbol = createSymbol(symbolFlags, name);
|
||||
const symbol = createSymbol(symbolFlags, name);
|
||||
addDeclarationToSymbol(symbol, node, symbolFlags);
|
||||
}
|
||||
|
||||
@@ -694,7 +984,7 @@ namespace ts {
|
||||
if (inStrictMode && node.expression.kind === SyntaxKind.Identifier) {
|
||||
// When a delete operator occurs within strict mode code, a SyntaxError is thrown if its
|
||||
// UnaryExpression is a direct reference to a variable, function argument, or function name
|
||||
let span = getErrorSpanForNode(file, node.expression);
|
||||
const span = getErrorSpanForNode(file, node.expression);
|
||||
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
|
||||
}
|
||||
}
|
||||
@@ -706,11 +996,11 @@ namespace ts {
|
||||
|
||||
function checkStrictModeEvalOrArguments(contextNode: Node, name: Node) {
|
||||
if (name && name.kind === SyntaxKind.Identifier) {
|
||||
let identifier = <Identifier>name;
|
||||
const identifier = <Identifier>name;
|
||||
if (isEvalOrArgumentsIdentifier(identifier)) {
|
||||
// We check first if the name is inside class declaration or class expression; if so give explicit message
|
||||
// otherwise report generic error message.
|
||||
let span = getErrorSpanForNode(file, name);
|
||||
const span = getErrorSpanForNode(file, name);
|
||||
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length,
|
||||
getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text));
|
||||
}
|
||||
@@ -766,12 +1056,12 @@ namespace ts {
|
||||
function checkStrictModeWithStatement(node: WithStatement) {
|
||||
// Grammar checking for withStatement
|
||||
if (inStrictMode) {
|
||||
grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
|
||||
errorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
|
||||
}
|
||||
}
|
||||
|
||||
function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) {
|
||||
let span = getSpanOfTokenAtPosition(file, node.pos);
|
||||
function errorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) {
|
||||
const span = getSpanOfTokenAtPosition(file, node.pos);
|
||||
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
|
||||
}
|
||||
|
||||
@@ -780,9 +1070,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bind(node: Node) {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
node.parent = parent;
|
||||
|
||||
let savedInStrictMode = inStrictMode;
|
||||
const savedInStrictMode = inStrictMode;
|
||||
if (!savedInStrictMode) {
|
||||
updateStrictMode(node);
|
||||
}
|
||||
@@ -828,7 +1122,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function updateStrictModeStatementList(statements: NodeArray<Statement>) {
|
||||
for (let statement of statements) {
|
||||
for (const statement of statements) {
|
||||
if (!isPrologueDirective(statement)) {
|
||||
return;
|
||||
}
|
||||
@@ -842,7 +1136,7 @@ namespace ts {
|
||||
|
||||
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
|
||||
function isUseStrictPrologueDirective(node: ExpressionStatement): boolean {
|
||||
let nodeText = getTextOfNodeFromSourceText(file.text, node.expression);
|
||||
const nodeText = getTextOfNodeFromSourceText(file.text, node.expression);
|
||||
|
||||
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
|
||||
// string to contain unicode escapes (as per ES5).
|
||||
@@ -917,7 +1211,7 @@ namespace ts {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
checkStrictModeFunctionName(<FunctionExpression>node);
|
||||
let bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
|
||||
const bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
|
||||
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
@@ -990,7 +1284,7 @@ namespace ts {
|
||||
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
|
||||
}
|
||||
else {
|
||||
let bindingName = node.name ? node.name.text : "__class";
|
||||
const bindingName = node.name ? node.name.text : "__class";
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
|
||||
// Add name of class expression into the map for semantic classifier
|
||||
if (node.name) {
|
||||
@@ -998,7 +1292,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
let symbol = node.symbol;
|
||||
const symbol = node.symbol;
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 8.4
|
||||
// Every class automatically contains a static property member named 'prototype', the
|
||||
@@ -1009,7 +1303,7 @@ namespace ts {
|
||||
// Note: we check for this here because this class may be merging into a module. The
|
||||
// module might have an exported variable called 'prototype'. We can't allow that as
|
||||
// that would clash with the built-in 'prototype' for the class.
|
||||
let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
|
||||
const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
|
||||
if (hasProperty(symbol.exports, prototypeSymbol.name)) {
|
||||
if (node.name) {
|
||||
node.name.parent = node;
|
||||
@@ -1074,7 +1368,7 @@ namespace ts {
|
||||
node.parent.kind === SyntaxKind.Constructor &&
|
||||
isClassLike(node.parent.parent)) {
|
||||
|
||||
let classDeclaration = <ClassLikeDeclaration>node.parent.parent;
|
||||
const classDeclaration = <ClassLikeDeclaration>node.parent.parent;
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
}
|
||||
@@ -1084,5 +1378,135 @@ namespace ts {
|
||||
? bindAnonymousDeclaration(node, symbolFlags, "__computed")
|
||||
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
|
||||
// reachability checks
|
||||
|
||||
function pushNamedLabel(name: Identifier): boolean {
|
||||
initializeReachabilityStateIfNecessary();
|
||||
|
||||
if (hasProperty(labelIndexMap, name.text)) {
|
||||
return false;
|
||||
}
|
||||
labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
function pushImplicitLabel(): number {
|
||||
initializeReachabilityStateIfNecessary();
|
||||
|
||||
const index = labelStack.push(Reachability.Unintialized) - 1;
|
||||
implicitLabels.push(index);
|
||||
return index;
|
||||
}
|
||||
|
||||
function popNamedLabel(label: Identifier, outerState: Reachability): void {
|
||||
const index = labelIndexMap[label.text];
|
||||
Debug.assert(index !== undefined);
|
||||
Debug.assert(labelStack.length == index + 1);
|
||||
|
||||
labelIndexMap[label.text] = undefined;
|
||||
|
||||
setCurrentStateAtLabel(labelStack.pop(), outerState, label);
|
||||
}
|
||||
|
||||
function popImplicitLabel(implicitLabelIndex: number, outerState: Reachability): void {
|
||||
if (labelStack.length !== implicitLabelIndex + 1) {
|
||||
Debug.assert(false, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`);
|
||||
}
|
||||
|
||||
const i = implicitLabels.pop();
|
||||
|
||||
if (implicitLabelIndex !== i) {
|
||||
Debug.assert(false, `i: ${i}, index: ${implicitLabelIndex}`);
|
||||
}
|
||||
|
||||
setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined);
|
||||
}
|
||||
|
||||
function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void {
|
||||
if (innerMergedState === Reachability.Unintialized) {
|
||||
if (label && !options.allowUnusedLabels) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label));
|
||||
}
|
||||
currentReachabilityState = outerState;
|
||||
}
|
||||
else {
|
||||
currentReachabilityState = or(innerMergedState, outerState);
|
||||
}
|
||||
}
|
||||
|
||||
function jumpToLabel(label: Identifier, outerState: Reachability): boolean {
|
||||
initializeReachabilityStateIfNecessary();
|
||||
|
||||
const index = label ? labelIndexMap[label.text] : lastOrUndefined(implicitLabels);
|
||||
if (index === undefined) {
|
||||
// reference to unknown label or
|
||||
// break/continue used outside of loops
|
||||
return false;
|
||||
}
|
||||
const stateAtLabel = labelStack[index];
|
||||
labelStack[index] = stateAtLabel === Reachability.Unintialized ? outerState : or(stateAtLabel, outerState);
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkUnreachable(node: Node): boolean {
|
||||
switch (currentReachabilityState) {
|
||||
case Reachability.Unreachable:
|
||||
const reportError =
|
||||
// report error on all statements except empty ones
|
||||
(isStatement(node) && node.kind !== SyntaxKind.EmptyStatement) ||
|
||||
// report error on class declarations
|
||||
node.kind === SyntaxKind.ClassDeclaration ||
|
||||
// report error on instantiated modules or const-enums only modules if preserveConstEnums is set
|
||||
(node.kind === SyntaxKind.ModuleDeclaration && shouldReportErrorOnModuleDeclaration(<ModuleDeclaration>node)) ||
|
||||
// report error on regular enums and const enums if preserveConstEnums is set
|
||||
(node.kind === SyntaxKind.EnumDeclaration && (!isConstEnumDeclaration(node) || options.preserveConstEnums));
|
||||
|
||||
if (reportError) {
|
||||
currentReachabilityState = Reachability.ReportedUnreachable;
|
||||
|
||||
// unreachable code is reported if
|
||||
// - user has explicitly asked about it AND
|
||||
// - statement is in not ambient context (statements in ambient context is already an error
|
||||
// so we should not report extras) AND
|
||||
// - node is not variable statement OR
|
||||
// - node is block scoped variable statement OR
|
||||
// - node is not block scoped variable statement and at least one variable declaration has initializer
|
||||
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted
|
||||
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
|
||||
const reportUnreachableCode =
|
||||
!options.allowUnreachableCode &&
|
||||
!isInAmbientContext(node) &&
|
||||
(
|
||||
node.kind !== SyntaxKind.VariableStatement ||
|
||||
getCombinedNodeFlags((<VariableStatement>node).declarationList) & NodeFlags.BlockScoped ||
|
||||
forEach((<VariableStatement>node).declarationList.declarations, d => d.initializer)
|
||||
);
|
||||
|
||||
if (reportUnreachableCode) {
|
||||
errorOnFirstToken(node, Diagnostics.Unreachable_code_detected);
|
||||
}
|
||||
}
|
||||
case Reachability.ReportedUnreachable:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
function shouldReportErrorOnModuleDeclaration(node: ModuleDeclaration): boolean {
|
||||
const instanceState = getModuleInstanceState(node);
|
||||
return instanceState === ModuleInstanceState.Instantiated || (instanceState === ModuleInstanceState.ConstEnumOnly && options.preserveConstEnums);
|
||||
}
|
||||
}
|
||||
|
||||
function initializeReachabilityStateIfNecessary(): void {
|
||||
if (labelIndexMap) {
|
||||
return;
|
||||
}
|
||||
currentReachabilityState = Reachability.Reachable;
|
||||
labelIndexMap = {};
|
||||
labelStack = [];
|
||||
implicitLabels = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1282
-1273
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
/// <reference path="sys.ts"/>
|
||||
/// <reference path="types.ts"/>
|
||||
/// <reference path="core.ts"/>
|
||||
/// <reference path="diagnosticInformationMap.generated.ts"/>
|
||||
/// <reference path="scanner.ts"/>
|
||||
|
||||
namespace ts {
|
||||
@@ -150,6 +151,12 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
|
||||
},
|
||||
{
|
||||
name: "pretty",
|
||||
paramType: Diagnostics.KIND,
|
||||
description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental,
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "project",
|
||||
shortName: "p",
|
||||
@@ -247,6 +254,31 @@ namespace ts {
|
||||
},
|
||||
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
|
||||
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic,
|
||||
},
|
||||
{
|
||||
name: "allowUnusedLabels",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_report_errors_on_unused_labels
|
||||
},
|
||||
{
|
||||
name: "noImplicitReturns",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
|
||||
},
|
||||
{
|
||||
name: "noFallthroughCasesInSwitch",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
|
||||
},
|
||||
{
|
||||
name: "allowUnreachableCode",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_report_errors_on_unreachable_code
|
||||
},
|
||||
{
|
||||
name: "forceConsistentCasingInFileNames",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
|
||||
}
|
||||
];
|
||||
|
||||
@@ -263,8 +295,8 @@ namespace ts {
|
||||
return optionNameMapCache;
|
||||
}
|
||||
|
||||
let optionNameMap: Map<CommandLineOption> = {};
|
||||
let shortOptionNames: Map<string> = {};
|
||||
const optionNameMap: Map<CommandLineOption> = {};
|
||||
const shortOptionNames: Map<string> = {};
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name.toLowerCase()] = option;
|
||||
if (option.shortName) {
|
||||
@@ -277,10 +309,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
|
||||
let options: CompilerOptions = {};
|
||||
let fileNames: string[] = [];
|
||||
let errors: Diagnostic[] = [];
|
||||
let { optionNameMap, shortOptionNames } = getOptionNameMap();
|
||||
const options: CompilerOptions = {};
|
||||
const fileNames: string[] = [];
|
||||
const errors: Diagnostic[] = [];
|
||||
const { optionNameMap, shortOptionNames } = getOptionNameMap();
|
||||
|
||||
parseStrings(commandLine);
|
||||
return {
|
||||
@@ -305,7 +337,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (hasProperty(optionNameMap, s)) {
|
||||
let opt = optionNameMap[s];
|
||||
const opt = optionNameMap[s];
|
||||
|
||||
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
|
||||
if (!args[i] && opt.type !== "boolean") {
|
||||
@@ -345,19 +377,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseResponseFile(fileName: string) {
|
||||
let text = readFile ? readFile(fileName) : sys.readFile(fileName);
|
||||
const text = readFile ? readFile(fileName) : sys.readFile(fileName);
|
||||
|
||||
if (!text) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
let args: string[] = [];
|
||||
const args: string[] = [];
|
||||
let pos = 0;
|
||||
while (true) {
|
||||
while (pos < text.length && text.charCodeAt(pos) <= CharacterCodes.space) pos++;
|
||||
if (pos >= text.length) break;
|
||||
let start = pos;
|
||||
const start = pos;
|
||||
if (text.charCodeAt(start) === CharacterCodes.doubleQuote) {
|
||||
pos++;
|
||||
while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.doubleQuote) pos++;
|
||||
@@ -400,13 +432,41 @@ namespace ts {
|
||||
*/
|
||||
export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } {
|
||||
try {
|
||||
return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} };
|
||||
const jsonTextWithoutComments = removeComments(jsonText);
|
||||
return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} };
|
||||
}
|
||||
catch (e) {
|
||||
return { error: createCompilerDiagnostic(Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the comments from a json like text.
|
||||
* Comments can be single line comments (starting with # or //) or multiline comments using / * * /
|
||||
*
|
||||
* This method replace comment content by whitespace rather than completely remove them to keep positions in json parsing error reporting accurate.
|
||||
*/
|
||||
function removeComments(jsonText: string): string {
|
||||
let output = "";
|
||||
const scanner = createScanner(ScriptTarget.ES5, /* skipTrivia */ false, LanguageVariant.Standard, jsonText);
|
||||
let token: SyntaxKind;
|
||||
while ((token = scanner.scan()) !== SyntaxKind.EndOfFileToken) {
|
||||
switch (token) {
|
||||
case SyntaxKind.SingleLineCommentTrivia:
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
// replace comments with whitespace to preserve original character positions
|
||||
output += scanner.getTokenText().replace(/\S/g, " ");
|
||||
break;
|
||||
default:
|
||||
output += scanner.getTokenText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
@@ -415,7 +475,7 @@ namespace ts {
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
|
||||
let { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath);
|
||||
const { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath);
|
||||
|
||||
return {
|
||||
options,
|
||||
@@ -434,12 +494,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
|
||||
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
|
||||
const exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
|
||||
const sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
|
||||
for (let i = 0; i < sysFiles.length; i++) {
|
||||
let name = sysFiles[i];
|
||||
const name = sysFiles[i];
|
||||
if (fileExtensionIs(name, ".d.ts")) {
|
||||
let baseName = name.substr(0, name.length - ".d.ts".length);
|
||||
const baseName = name.substr(0, name.length - ".d.ts".length);
|
||||
if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) {
|
||||
fileNames.push(name);
|
||||
}
|
||||
@@ -459,24 +519,24 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { options: CompilerOptions, errors: Diagnostic[] } {
|
||||
let options: CompilerOptions = {};
|
||||
let errors: Diagnostic[] = [];
|
||||
const options: CompilerOptions = {};
|
||||
const errors: Diagnostic[] = [];
|
||||
|
||||
if (!jsonOptions) {
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
let optionNameMap = arrayToMap(optionDeclarations, opt => opt.name);
|
||||
const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name);
|
||||
|
||||
for (let id in jsonOptions) {
|
||||
for (const id in jsonOptions) {
|
||||
if (hasProperty(optionNameMap, id)) {
|
||||
let opt = optionNameMap[id];
|
||||
let optType = opt.type;
|
||||
const opt = optionNameMap[id];
|
||||
const optType = opt.type;
|
||||
let value = jsonOptions[id];
|
||||
let expectedType = typeof optType === "string" ? optType : "string";
|
||||
const expectedType = typeof optType === "string" ? optType : "string";
|
||||
if (typeof value === expectedType) {
|
||||
if (typeof optType !== "string") {
|
||||
let key = value.toLowerCase();
|
||||
const key = value.toLowerCase();
|
||||
if (hasProperty(optType, key)) {
|
||||
value = optType[key];
|
||||
}
|
||||
|
||||
+84
-74
@@ -17,45 +17,55 @@ namespace ts {
|
||||
True = -1
|
||||
}
|
||||
|
||||
export function createFileMap<T>(getCanonicalFileName: (fileName: string) => string): FileMap<T> {
|
||||
export function createFileMap<T>(keyMapper?: (key: string) => string): FileMap<T> {
|
||||
let files: Map<T> = {};
|
||||
return {
|
||||
get,
|
||||
set,
|
||||
contains,
|
||||
remove,
|
||||
clear,
|
||||
forEachValue: forEachValueInMap
|
||||
forEachValue: forEachValueInMap,
|
||||
clear
|
||||
};
|
||||
|
||||
function set(fileName: string, value: T) {
|
||||
files[normalizeKey(fileName)] = value;
|
||||
function forEachValueInMap(f: (key: Path, value: T) => void) {
|
||||
for (const key in files) {
|
||||
f(<Path>key, files[key]);
|
||||
}
|
||||
}
|
||||
|
||||
function get(fileName: string) {
|
||||
return files[normalizeKey(fileName)];
|
||||
// path should already be well-formed so it does not need to be normalized
|
||||
function get(path: Path): T {
|
||||
return files[toKey(path)];
|
||||
}
|
||||
|
||||
function contains(fileName: string) {
|
||||
return hasProperty(files, normalizeKey(fileName));
|
||||
function set(path: Path, value: T) {
|
||||
files[toKey(path)] = value;
|
||||
}
|
||||
|
||||
function remove (fileName: string) {
|
||||
let key = normalizeKey(fileName);
|
||||
function contains(path: Path) {
|
||||
return hasProperty(files, toKey(path));
|
||||
}
|
||||
|
||||
function remove(path: Path) {
|
||||
const key = toKey(path);
|
||||
delete files[key];
|
||||
}
|
||||
|
||||
function forEachValueInMap(f: (value: T) => void) {
|
||||
forEachValue(files, f);
|
||||
}
|
||||
|
||||
function normalizeKey(key: string) {
|
||||
return getCanonicalFileName(normalizeSlashes(key));
|
||||
}
|
||||
|
||||
function clear() {
|
||||
files = {};
|
||||
}
|
||||
|
||||
function toKey(path: Path): string {
|
||||
return keyMapper ? keyMapper(path) : path;
|
||||
}
|
||||
}
|
||||
|
||||
export function toPath(fileName: string, basePath: string, getCanonicalFileName: (path: string) => string): Path {
|
||||
const nonCanonicalizedPath = isRootedDiskPath(fileName)
|
||||
? normalizePath(fileName)
|
||||
: getNormalizedAbsolutePath(fileName, basePath);
|
||||
return <Path>getCanonicalFileName(nonCanonicalizedPath);
|
||||
}
|
||||
|
||||
export const enum Comparison {
|
||||
@@ -74,7 +84,7 @@ namespace ts {
|
||||
export function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U {
|
||||
if (array) {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
let result = callback(array[i], i);
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -85,7 +95,7 @@ namespace ts {
|
||||
|
||||
export function contains<T>(array: T[], value: T): boolean {
|
||||
if (array) {
|
||||
for (let v of array) {
|
||||
for (const v of array) {
|
||||
if (v === value) {
|
||||
return true;
|
||||
}
|
||||
@@ -108,7 +118,7 @@ namespace ts {
|
||||
export function countWhere<T>(array: T[], predicate: (x: T) => boolean): number {
|
||||
let count = 0;
|
||||
if (array) {
|
||||
for (let v of array) {
|
||||
for (const v of array) {
|
||||
if (predicate(v)) {
|
||||
count++;
|
||||
}
|
||||
@@ -121,7 +131,7 @@ namespace ts {
|
||||
let result: T[];
|
||||
if (array) {
|
||||
result = [];
|
||||
for (let item of array) {
|
||||
for (const item of array) {
|
||||
if (f(item)) {
|
||||
result.push(item);
|
||||
}
|
||||
@@ -134,7 +144,7 @@ namespace ts {
|
||||
let result: U[];
|
||||
if (array) {
|
||||
result = [];
|
||||
for (let v of array) {
|
||||
for (const v of array) {
|
||||
result.push(f(v));
|
||||
}
|
||||
}
|
||||
@@ -152,7 +162,7 @@ namespace ts {
|
||||
let result: T[];
|
||||
if (array) {
|
||||
result = [];
|
||||
for (let item of array) {
|
||||
for (const item of array) {
|
||||
if (!contains(result, item)) {
|
||||
result.push(item);
|
||||
}
|
||||
@@ -163,7 +173,7 @@ namespace ts {
|
||||
|
||||
export function sum(array: any[], prop: string): number {
|
||||
let result = 0;
|
||||
for (let v of array) {
|
||||
for (const v of array) {
|
||||
result += v[prop];
|
||||
}
|
||||
return result;
|
||||
@@ -171,7 +181,7 @@ namespace ts {
|
||||
|
||||
export function addRange<T>(to: T[], from: T[]): void {
|
||||
if (to && from) {
|
||||
for (let v of from) {
|
||||
for (const v of from) {
|
||||
to.push(v);
|
||||
}
|
||||
}
|
||||
@@ -210,8 +220,8 @@ namespace ts {
|
||||
let high = array.length - 1;
|
||||
|
||||
while (low <= high) {
|
||||
let middle = low + ((high - low) >> 1);
|
||||
let midValue = array[middle];
|
||||
const middle = low + ((high - low) >> 1);
|
||||
const midValue = array[middle];
|
||||
|
||||
if (midValue === value) {
|
||||
return middle;
|
||||
@@ -260,7 +270,7 @@ namespace ts {
|
||||
return initial;
|
||||
}
|
||||
|
||||
let hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
export function hasProperty<T>(map: Map<T>, key: string): boolean {
|
||||
return hasOwnProperty.call(map, key);
|
||||
@@ -271,7 +281,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isEmpty<T>(map: Map<T>) {
|
||||
for (let id in map) {
|
||||
for (const id in map) {
|
||||
if (hasProperty(map, id)) {
|
||||
return false;
|
||||
}
|
||||
@@ -280,19 +290,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function clone<T>(object: T): T {
|
||||
let result: any = {};
|
||||
for (let id in object) {
|
||||
const result: any = {};
|
||||
for (const id in object) {
|
||||
result[id] = (<any>object)[id];
|
||||
}
|
||||
return <T>result;
|
||||
}
|
||||
|
||||
export function extend<T1, T2>(first: Map<T1>, second: Map<T2>): Map<T1 & T2> {
|
||||
let result: Map<T1 & T2> = {};
|
||||
for (let id in first) {
|
||||
const result: Map<T1 & T2> = {};
|
||||
for (const id in first) {
|
||||
(result as any)[id] = first[id];
|
||||
}
|
||||
for (let id in second) {
|
||||
for (const id in second) {
|
||||
if (!hasProperty(result, id)) {
|
||||
(result as any)[id] = second[id];
|
||||
}
|
||||
@@ -302,7 +312,7 @@ namespace ts {
|
||||
|
||||
export function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U {
|
||||
let result: U;
|
||||
for (let id in map) {
|
||||
for (const id in map) {
|
||||
if (result = callback(map[id])) break;
|
||||
}
|
||||
return result;
|
||||
@@ -310,7 +320,7 @@ namespace ts {
|
||||
|
||||
export function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U {
|
||||
let result: U;
|
||||
for (let id in map) {
|
||||
for (const id in map) {
|
||||
if (result = callback(id)) break;
|
||||
}
|
||||
return result;
|
||||
@@ -321,7 +331,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function copyMap<T>(source: Map<T>, target: Map<T>): void {
|
||||
for (let p in source) {
|
||||
for (const p in source) {
|
||||
target[p] = source[p];
|
||||
}
|
||||
}
|
||||
@@ -337,7 +347,7 @@ namespace ts {
|
||||
* index in the array will be the one associated with the produced key.
|
||||
*/
|
||||
export function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T> {
|
||||
let result: Map<T> = {};
|
||||
const result: Map<T> = {};
|
||||
|
||||
forEach(array, value => {
|
||||
result[makeKey(value)] = value;
|
||||
@@ -373,7 +383,7 @@ namespace ts {
|
||||
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
|
||||
let end = start + length;
|
||||
const end = start + length;
|
||||
|
||||
Debug.assert(start >= 0, "start must be non-negative, is " + start);
|
||||
Debug.assert(length >= 0, "length must be non-negative, is " + length);
|
||||
@@ -469,10 +479,10 @@ namespace ts {
|
||||
function compareMessageText(text1: string | DiagnosticMessageChain, text2: string | DiagnosticMessageChain): Comparison {
|
||||
while (text1 && text2) {
|
||||
// We still have both chains.
|
||||
let string1 = typeof text1 === "string" ? text1 : text1.messageText;
|
||||
let string2 = typeof text2 === "string" ? text2 : text2.messageText;
|
||||
const string1 = typeof text1 === "string" ? text1 : text1.messageText;
|
||||
const string2 = typeof text2 === "string" ? text2 : text2.messageText;
|
||||
|
||||
let res = compareValues(string1, string2);
|
||||
const res = compareValues(string1, string2);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
@@ -499,11 +509,11 @@ namespace ts {
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
let newDiagnostics = [diagnostics[0]];
|
||||
const newDiagnostics = [diagnostics[0]];
|
||||
let previousDiagnostic = diagnostics[0];
|
||||
for (let i = 1; i < diagnostics.length; i++) {
|
||||
let currentDiagnostic = diagnostics[i];
|
||||
let isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo;
|
||||
const currentDiagnostic = diagnostics[i];
|
||||
const isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo;
|
||||
if (!isDupe) {
|
||||
newDiagnostics.push(currentDiagnostic);
|
||||
previousDiagnostic = currentDiagnostic;
|
||||
@@ -521,9 +531,9 @@ namespace ts {
|
||||
export function getRootLength(path: string): number {
|
||||
if (path.charCodeAt(0) === CharacterCodes.slash) {
|
||||
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
|
||||
let p1 = path.indexOf("/", 2);
|
||||
const p1 = path.indexOf("/", 2);
|
||||
if (p1 < 0) return 2;
|
||||
let p2 = path.indexOf("/", p1 + 1);
|
||||
const p2 = path.indexOf("/", p1 + 1);
|
||||
if (p2 < 0) return p1 + 1;
|
||||
return p2 + 1;
|
||||
}
|
||||
@@ -539,7 +549,7 @@ namespace ts {
|
||||
if (path.lastIndexOf("file:///", 0) === 0) {
|
||||
return "file:///".length;
|
||||
}
|
||||
let idx = path.indexOf("://");
|
||||
const idx = path.indexOf("://");
|
||||
if (idx !== -1) {
|
||||
return idx + "://".length;
|
||||
}
|
||||
@@ -548,9 +558,9 @@ namespace ts {
|
||||
|
||||
export let directorySeparator = "/";
|
||||
function getNormalizedParts(normalizedSlashedPath: string, rootLength: number) {
|
||||
let parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
|
||||
let normalized: string[] = [];
|
||||
for (let part of parts) {
|
||||
const parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
|
||||
const normalized: string[] = [];
|
||||
for (const part of parts) {
|
||||
if (part !== ".") {
|
||||
if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") {
|
||||
normalized.pop();
|
||||
@@ -570,8 +580,8 @@ namespace ts {
|
||||
|
||||
export function normalizePath(path: string): string {
|
||||
path = normalizeSlashes(path);
|
||||
let rootLength = getRootLength(path);
|
||||
let normalized = getNormalizedParts(path, rootLength);
|
||||
const rootLength = getRootLength(path);
|
||||
const normalized = getNormalizedParts(path, rootLength);
|
||||
return path.substr(0, rootLength) + normalized.join(directorySeparator);
|
||||
}
|
||||
|
||||
@@ -588,7 +598,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function normalizedPathComponents(path: string, rootLength: number) {
|
||||
let normalizedParts = getNormalizedParts(path, rootLength);
|
||||
const normalizedParts = getNormalizedParts(path, rootLength);
|
||||
return [path.substr(0, rootLength)].concat(normalizedParts);
|
||||
}
|
||||
|
||||
@@ -619,7 +629,7 @@ namespace ts {
|
||||
// In this example the root is: http://www.website.com/
|
||||
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
|
||||
|
||||
let urlLength = url.length;
|
||||
const urlLength = url.length;
|
||||
// Initial root length is http:// part
|
||||
let rootLength = url.indexOf("://") + "://".length;
|
||||
while (rootLength < urlLength) {
|
||||
@@ -640,7 +650,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://)
|
||||
let indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
|
||||
const indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
|
||||
if (indexOfNextSlash !== -1) {
|
||||
// Found the "/" after the website.com so the root is length of http://www.website.com/
|
||||
// and get components afetr the root normally like any other folder components
|
||||
@@ -666,8 +676,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) {
|
||||
let pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
||||
let directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
||||
const pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
||||
const directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
||||
if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") {
|
||||
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
|
||||
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
|
||||
@@ -684,7 +694,7 @@ namespace ts {
|
||||
// Get the relative path
|
||||
if (joinStartIndex) {
|
||||
let relativePath = "";
|
||||
let relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length);
|
||||
const relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length);
|
||||
for (; joinStartIndex < directoryComponents.length; joinStartIndex++) {
|
||||
if (directoryComponents[joinStartIndex] !== "") {
|
||||
relativePath = relativePath + ".." + directorySeparator;
|
||||
@@ -707,7 +717,7 @@ namespace ts {
|
||||
if (!path) {
|
||||
return undefined;
|
||||
}
|
||||
let i = path.lastIndexOf(directorySeparator);
|
||||
const i = path.lastIndexOf(directorySeparator);
|
||||
return i < 0 ? path : path.substring(i + 1);
|
||||
}
|
||||
|
||||
@@ -720,8 +730,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function fileExtensionIs(path: string, extension: string): boolean {
|
||||
let pathLen = path.length;
|
||||
let extLen = extension.length;
|
||||
const pathLen = path.length;
|
||||
const extLen = extension.length;
|
||||
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
|
||||
}
|
||||
|
||||
@@ -739,7 +749,7 @@ namespace ts {
|
||||
export function isSupportedSourceFileName(fileName: string) {
|
||||
if (!fileName) { return false; }
|
||||
|
||||
for (let extension of supportedExtensions) {
|
||||
for (const extension of supportedExtensions) {
|
||||
if (fileExtensionIs(fileName, extension)) {
|
||||
return true;
|
||||
}
|
||||
@@ -749,7 +759,7 @@ namespace ts {
|
||||
|
||||
const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"];
|
||||
export function removeFileExtension(path: string): string {
|
||||
for (let ext of extensionsToRemove) {
|
||||
for (const ext of extensionsToRemove) {
|
||||
if (fileExtensionIs(path, ext)) {
|
||||
return path.substr(0, path.length - ext.length);
|
||||
}
|
||||
@@ -757,9 +767,9 @@ namespace ts {
|
||||
return path;
|
||||
}
|
||||
|
||||
let backslashOrDoubleQuote = /[\"\\]/g;
|
||||
let escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
let escapedCharsMap: Map<string> = {
|
||||
const backslashOrDoubleQuote = /[\"\\]/g;
|
||||
const escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
const escapedCharsMap: Map<string> = {
|
||||
"\0": "\\0",
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
@@ -818,7 +828,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export namespace Debug {
|
||||
let currentAssertionLevel = AssertionLevel.None;
|
||||
const currentAssertionLevel = AssertionLevel.None;
|
||||
|
||||
export function shouldAssert(level: AssertionLevel): boolean {
|
||||
return currentAssertionLevel >= level;
|
||||
@@ -830,7 +840,7 @@ namespace ts {
|
||||
if (verboseDebugInfo) {
|
||||
verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo();
|
||||
}
|
||||
|
||||
debugger;
|
||||
throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString);
|
||||
}
|
||||
}
|
||||
@@ -841,12 +851,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
let copiedList: T[] = [];
|
||||
for (let e of list) {
|
||||
const copiedList: T[] = [];
|
||||
for (const e of list) {
|
||||
if (e !== item) {
|
||||
copiedList.push(e);
|
||||
}
|
||||
}
|
||||
return copiedList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,15 +31,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] {
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js");
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
const jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js");
|
||||
emitDeclarations(host, resolver, diagnostics, jsFilePath, targetSourceFile);
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit {
|
||||
let newLine = host.getNewLine();
|
||||
let compilerOptions = host.getCompilerOptions();
|
||||
const newLine = host.getNewLine();
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
|
||||
let write: (s: string) => void;
|
||||
let writeLine: () => void;
|
||||
@@ -53,10 +53,10 @@ namespace ts {
|
||||
let currentSourceFile: SourceFile;
|
||||
let reportedDeclarationError = false;
|
||||
let errorNameNode: DeclarationName;
|
||||
let emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
|
||||
let emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
|
||||
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
|
||||
let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
const moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[];
|
||||
|
||||
// Contains the reference paths that needs to go in the declaration file.
|
||||
@@ -69,7 +69,7 @@ namespace ts {
|
||||
if (!compilerOptions.noResolve) {
|
||||
let addedGlobalFileReference = false;
|
||||
forEach(root.referencedFiles, fileReference => {
|
||||
let referencedFile = tryResolveScriptReference(host, root, fileReference);
|
||||
const referencedFile = tryResolveScriptReference(host, root, fileReference);
|
||||
|
||||
// All the references that are not going to be part of same file
|
||||
if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||
@@ -88,7 +88,7 @@ namespace ts {
|
||||
|
||||
// create asynchronous output for the importDeclarations
|
||||
if (moduleElementDeclarationEmitInfo.length) {
|
||||
let oldWriter = writer;
|
||||
const oldWriter = writer;
|
||||
forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => {
|
||||
if (aliasEmitInfo.isVisible) {
|
||||
Debug.assert(aliasEmitInfo.node.kind === SyntaxKind.ImportDeclaration);
|
||||
@@ -103,13 +103,13 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// Emit references corresponding to this file
|
||||
let emittedReferencedFiles: SourceFile[] = [];
|
||||
const emittedReferencedFiles: SourceFile[] = [];
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
let referencedFile = tryResolveScriptReference(host, sourceFile, fileReference);
|
||||
const referencedFile = tryResolveScriptReference(host, sourceFile, fileReference);
|
||||
|
||||
// If the reference file is a declaration file or an external module, emit that reference
|
||||
if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) &&
|
||||
@@ -134,14 +134,14 @@ namespace ts {
|
||||
};
|
||||
|
||||
function hasInternalAnnotation(range: CommentRange) {
|
||||
let text = currentSourceFile.text;
|
||||
let comment = text.substring(range.pos, range.end);
|
||||
const text = currentSourceFile.text;
|
||||
const comment = text.substring(range.pos, range.end);
|
||||
return comment.indexOf("@internal") >= 0;
|
||||
}
|
||||
|
||||
function stripInternal(node: Node) {
|
||||
if (node) {
|
||||
let leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
if (forEach(leadingCommentRanges, hasInternalAnnotation)) {
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter {
|
||||
let writer = <EmitTextWriterWithSymbolWriter>createTextWriter(newLine);
|
||||
const writer = <EmitTextWriterWithSymbolWriter>createTextWriter(newLine);
|
||||
writer.trackSymbol = trackSymbol;
|
||||
writer.reportInaccessibleThisError = reportInaccessibleThisError;
|
||||
writer.writeKeyword = writer.write;
|
||||
@@ -175,7 +175,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeAsynchronousModuleElements(nodes: Node[]) {
|
||||
let oldWriter = writer;
|
||||
const oldWriter = writer;
|
||||
forEach(nodes, declaration => {
|
||||
let nodeToCheck: Node;
|
||||
if (declaration.kind === SyntaxKind.VariableDeclaration) {
|
||||
@@ -238,7 +238,7 @@ namespace ts {
|
||||
else {
|
||||
// Report error
|
||||
reportedDeclarationError = true;
|
||||
let errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult);
|
||||
const errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult);
|
||||
if (errorInfo) {
|
||||
if (errorInfo.typeName) {
|
||||
diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
|
||||
@@ -297,14 +297,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitLines(nodes: Node[]) {
|
||||
for (let node of nodes) {
|
||||
for (const node of nodes) {
|
||||
emit(node);
|
||||
}
|
||||
}
|
||||
|
||||
function emitSeparatedList(nodes: Node[], separator: string, eachNodeEmitFn: (node: Node) => void, canEmitFn?: (node: Node) => boolean) {
|
||||
let currentWriterPos = writer.getTextPos();
|
||||
for (let node of nodes) {
|
||||
for (const node of nodes) {
|
||||
if (!canEmitFn || canEmitFn(node)) {
|
||||
if (currentWriterPos !== writer.getTextPos()) {
|
||||
write(separator);
|
||||
@@ -321,7 +321,7 @@ namespace ts {
|
||||
|
||||
function writeJsDocComments(declaration: Node) {
|
||||
if (declaration) {
|
||||
let jsDocComments = getJsDocComments(declaration, currentSourceFile);
|
||||
const jsDocComments = getJsDocComments(declaration, currentSourceFile);
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments);
|
||||
// jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, writeCommentRange);
|
||||
@@ -378,8 +378,8 @@ namespace ts {
|
||||
writeTextOfNode(currentSourceFile, entityName);
|
||||
}
|
||||
else {
|
||||
let left = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).left : (<PropertyAccessExpression>entityName).expression;
|
||||
let right = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).right : (<PropertyAccessExpression>entityName).name;
|
||||
const left = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).left : (<PropertyAccessExpression>entityName).expression;
|
||||
const right = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).right : (<PropertyAccessExpression>entityName).name;
|
||||
writeEntityName(left);
|
||||
write(".");
|
||||
writeTextOfNode(currentSourceFile, right);
|
||||
@@ -387,7 +387,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitEntityName(entityName: EntityName | PropertyAccessExpression) {
|
||||
let visibilityResult = resolver.isEntityNameVisible(entityName,
|
||||
const visibilityResult = resolver.isEntityNameVisible(entityName,
|
||||
// Aliases can be written asynchronously so use correct enclosing declaration
|
||||
entityName.parent.kind === SyntaxKind.ImportEqualsDeclaration ? entityName.parent : enclosingDeclaration);
|
||||
|
||||
@@ -468,6 +468,7 @@ namespace ts {
|
||||
function emitSourceFile(node: SourceFile) {
|
||||
currentSourceFile = node;
|
||||
enclosingDeclaration = node;
|
||||
emitDetachedComments(currentSourceFile, writer, writeCommentRange, node, newLine, true /* remove comments */);
|
||||
emitLines(node.statements);
|
||||
}
|
||||
|
||||
@@ -476,13 +477,13 @@ namespace ts {
|
||||
// Note that export default is only allowed at most once in a module, so we
|
||||
// do not need to keep track of created temp names.
|
||||
function getExportDefaultTempVariableName(): string {
|
||||
let baseName = "_default";
|
||||
const baseName = "_default";
|
||||
if (!hasProperty(currentSourceFile.identifiers, baseName)) {
|
||||
return baseName;
|
||||
}
|
||||
let count = 0;
|
||||
while (true) {
|
||||
let name = baseName + "_" + (++count);
|
||||
const name = baseName + "_" + (++count);
|
||||
if (!hasProperty(currentSourceFile.identifiers, name)) {
|
||||
return name;
|
||||
}
|
||||
@@ -496,7 +497,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// Expression
|
||||
let tempVarName = getExportDefaultTempVariableName();
|
||||
const tempVarName = getExportDefaultTempVariableName();
|
||||
write("declare var ");
|
||||
write(tempVarName);
|
||||
write(": ");
|
||||
@@ -512,7 +513,7 @@ namespace ts {
|
||||
|
||||
// Make all the declarations visible for the export name
|
||||
if (node.expression.kind === SyntaxKind.Identifier) {
|
||||
let nodes = resolver.collectLinkedAliases(<Identifier>node.expression);
|
||||
const nodes = resolver.collectLinkedAliases(<Identifier>node.expression);
|
||||
|
||||
// write each of these declarations asynchronously
|
||||
writeAsynchronousModuleElements(nodes);
|
||||
@@ -549,7 +550,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
let importDeclaration = <ImportDeclaration>node;
|
||||
const importDeclaration = <ImportDeclaration>node;
|
||||
if (importDeclaration.importClause) {
|
||||
isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) ||
|
||||
isVisibleNamedBinding(importDeclaration.importClause.namedBindings);
|
||||
@@ -675,7 +676,7 @@ namespace ts {
|
||||
}
|
||||
write("import ");
|
||||
if (node.importClause) {
|
||||
let currentWriterPos = writer.getTextPos();
|
||||
const currentWriterPos = writer.getTextPos();
|
||||
if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) {
|
||||
writeTextOfNode(currentSourceFile, node.importClause.name);
|
||||
}
|
||||
@@ -713,7 +714,7 @@ namespace ts {
|
||||
emitImportOrExportSpecifier(node);
|
||||
|
||||
// Make all the declarations visible for the export name
|
||||
let nodes = resolver.collectLinkedAliases(node.propertyName || node.name);
|
||||
const nodes = resolver.collectLinkedAliases(node.propertyName || node.name);
|
||||
|
||||
// write each of these declarations asynchronously
|
||||
writeAsynchronousModuleElements(nodes);
|
||||
@@ -753,7 +754,7 @@ namespace ts {
|
||||
write(".");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
}
|
||||
let prevEnclosingDeclaration = enclosingDeclaration;
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
write(" {");
|
||||
writeLine();
|
||||
@@ -766,7 +767,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeTypeAliasDeclaration(node: TypeAliasDeclaration) {
|
||||
let prevEnclosingDeclaration = enclosingDeclaration;
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
@@ -808,7 +809,7 @@ namespace ts {
|
||||
function emitEnumMemberDeclaration(node: EnumMember) {
|
||||
emitJsDocComments(node);
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
let enumMemberValue = resolver.getConstantValue(node);
|
||||
const enumMemberValue = resolver.getConstantValue(node);
|
||||
if (enumMemberValue !== undefined) {
|
||||
write(" = ");
|
||||
write(enumMemberValue.toString());
|
||||
@@ -958,10 +959,10 @@ namespace ts {
|
||||
|
||||
write("class ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
let prevEnclosingDeclaration = enclosingDeclaration;
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
let baseTypeNode = getClassExtendsHeritageClauseElement(node);
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
|
||||
if (baseTypeNode) {
|
||||
emitHeritageClause([baseTypeNode], /*isImplementsList*/ false);
|
||||
}
|
||||
@@ -982,7 +983,7 @@ namespace ts {
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
write("interface ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
let prevEnclosingDeclaration = enclosingDeclaration;
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false);
|
||||
@@ -1068,7 +1069,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
return diagnosticMessage !== undefined ? {
|
||||
diagnosticMessage,
|
||||
errorNode: node,
|
||||
@@ -1082,8 +1083,8 @@ namespace ts {
|
||||
// For example:
|
||||
// original: var [, c,,] = [ 2,3,4]
|
||||
// emitted: declare var c: number; // instead of declare var c:number, ;
|
||||
let elements: Node[] = [];
|
||||
for (let element of bindingPattern.elements) {
|
||||
const elements: Node[] = [];
|
||||
for (const element of bindingPattern.elements) {
|
||||
if (element.kind !== SyntaxKind.OmittedExpression) {
|
||||
elements.push(element);
|
||||
}
|
||||
@@ -1093,7 +1094,7 @@ namespace ts {
|
||||
|
||||
function emitBindingElement(bindingElement: BindingElement) {
|
||||
function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
return diagnosticMessage !== undefined ? {
|
||||
diagnosticMessage,
|
||||
errorNode: bindingElement,
|
||||
@@ -1149,7 +1150,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
|
||||
let accessors = getAllAccessorDeclarations((<ClassDeclaration>node.parent).members, node);
|
||||
const accessors = getAllAccessorDeclarations((<ClassDeclaration>node.parent).members, node);
|
||||
let accessorWithTypeAnnotation: AccessorDeclaration;
|
||||
|
||||
if (node === accessors.firstAccessor) {
|
||||
@@ -1162,7 +1163,7 @@ namespace ts {
|
||||
let type = getTypeAnnotationFromAccessor(node);
|
||||
if (!type) {
|
||||
// couldn't get type for the first accessor, try the another one
|
||||
let anotherAccessor = node.kind === SyntaxKind.GetAccessor ? accessors.setAccessor : accessors.getAccessor;
|
||||
const anotherAccessor = node.kind === SyntaxKind.GetAccessor ? accessors.setAccessor : accessors.getAccessor;
|
||||
type = getTypeAnnotationFromAccessor(anotherAccessor);
|
||||
if (type) {
|
||||
accessorWithTypeAnnotation = anotherAccessor;
|
||||
@@ -1279,7 +1280,7 @@ namespace ts {
|
||||
write("(");
|
||||
}
|
||||
|
||||
let prevEnclosingDeclaration = enclosingDeclaration;
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
|
||||
// Parameters
|
||||
@@ -1293,7 +1294,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// If this is not a constructor and is not private, emit the return type
|
||||
let isFunctionTypeOrConstructorType = node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType;
|
||||
const isFunctionTypeOrConstructorType = node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType;
|
||||
if (isFunctionTypeOrConstructorType || node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
// Emit type literal signature return type only if specified
|
||||
if (node.type) {
|
||||
@@ -1409,7 +1410,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
const diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
return diagnosticMessage !== undefined ? {
|
||||
diagnosticMessage,
|
||||
errorNode: node,
|
||||
@@ -1482,7 +1483,7 @@ namespace ts {
|
||||
}
|
||||
else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) {
|
||||
write("[");
|
||||
let elements = bindingPattern.elements;
|
||||
const elements = bindingPattern.elements;
|
||||
emitCommaList(elements, emitBindingElement);
|
||||
if (elements && elements.hasTrailingComma) {
|
||||
write(", ");
|
||||
@@ -1493,7 +1494,7 @@ namespace ts {
|
||||
|
||||
function emitBindingElement(bindingElement: BindingElement) {
|
||||
function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
const diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
return diagnosticMessage !== undefined ? {
|
||||
diagnosticMessage,
|
||||
errorNode: bindingElement,
|
||||
@@ -1608,11 +1609,11 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) {
|
||||
let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile);
|
||||
const emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile);
|
||||
// TODO(shkamat): Should we not write any declaration file if any of them can produce error,
|
||||
// or should we just not write this file like we are doing now
|
||||
if (!emitDeclarationResult.reportedDeclarationError) {
|
||||
let declarationOutput = emitDeclarationResult.referencePathsOutput
|
||||
const declarationOutput = emitDeclarationResult.referencePathsOutput
|
||||
+ getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo);
|
||||
writeFile(host, diagnostics, removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, host.getCompilerOptions().emitBOM);
|
||||
}
|
||||
|
||||
@@ -799,7 +799,11 @@
|
||||
"'=' can only be used in an object literal property inside a destructuring assignment.": {
|
||||
"category": "Error",
|
||||
"code": 1312
|
||||
},
|
||||
},
|
||||
"The body of an 'if' statement cannot be the empty statement.": {
|
||||
"category": "Error",
|
||||
"code": 1313
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
@@ -1008,7 +1012,7 @@
|
||||
"category": "Error",
|
||||
"code": 2354
|
||||
},
|
||||
"A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.": {
|
||||
"A function whose declared type is neither 'void' nor 'any' must return a value.": {
|
||||
"category": "Error",
|
||||
"code": 2355
|
||||
},
|
||||
@@ -1092,7 +1096,7 @@
|
||||
"category": "Error",
|
||||
"code": 2377
|
||||
},
|
||||
"A 'get' accessor must return a value or consist of a single 'throw' statement.": {
|
||||
"A 'get' accessor must return a value.": {
|
||||
"category": "Error",
|
||||
"code": 2378
|
||||
},
|
||||
@@ -2254,14 +2258,6 @@
|
||||
"code": 6063
|
||||
},
|
||||
|
||||
"Specify JSX code generation: 'preserve' or 'react'": {
|
||||
"category": "Message",
|
||||
"code": 6080
|
||||
},
|
||||
"Argument for '--jsx' must be 'preserve' or 'react'.": {
|
||||
"category": "Message",
|
||||
"code": 6081
|
||||
},
|
||||
"Enables experimental support for ES7 decorators.": {
|
||||
"category": "Message",
|
||||
"code": 6065
|
||||
@@ -2290,6 +2286,39 @@
|
||||
"category": "Message",
|
||||
"code": 6072
|
||||
},
|
||||
"Stylize errors and messages using color and context. (experimental)": {
|
||||
"category": "Message",
|
||||
"code": 6073
|
||||
},
|
||||
"Do not report errors on unused labels.": {
|
||||
"category": "Message",
|
||||
"code": 6074
|
||||
},
|
||||
"Report error when not all code paths in function return a value.": {
|
||||
"category": "Message",
|
||||
"code": 6075
|
||||
},
|
||||
"Report errors for fallthrough cases in switch statement.": {
|
||||
"category": "Message",
|
||||
"code": 6076
|
||||
},
|
||||
"Do not report errors on unreachable code.": {
|
||||
"category": "Message",
|
||||
"code": 6077
|
||||
},
|
||||
"Disallow inconsistently-cased references to the same file.": {
|
||||
"category": "Message",
|
||||
"code": 6078
|
||||
},
|
||||
|
||||
"Specify JSX code generation: 'preserve' or 'react'": {
|
||||
"category": "Message",
|
||||
"code": 6080
|
||||
},
|
||||
"Argument for '--jsx' must be 'preserve' or 'react'.": {
|
||||
"category": "Message",
|
||||
"code": 6081
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
@@ -2359,8 +2388,22 @@
|
||||
"category": "Error",
|
||||
"code": 7026
|
||||
},
|
||||
|
||||
|
||||
"Unreachable code detected.": {
|
||||
"category": "Error",
|
||||
"code": 7027
|
||||
},
|
||||
"Unused label.": {
|
||||
"category": "Error",
|
||||
"code": 7028
|
||||
},
|
||||
"Fallthrough case in switch.": {
|
||||
"category": "Error",
|
||||
"code": 7029
|
||||
},
|
||||
"Not all code paths return a value.": {
|
||||
"category": "Error",
|
||||
"code": 7030
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
|
||||
+316
-377
File diff suppressed because it is too large
Load Diff
+354
-355
File diff suppressed because it is too large
Load Diff
+133
-130
@@ -10,7 +10,7 @@ namespace ts {
|
||||
|
||||
/** The version of the TypeScript compiler release */
|
||||
|
||||
let emptyArray: any[] = [];
|
||||
const emptyArray: any[] = [];
|
||||
|
||||
export const version = "1.8.0";
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ts {
|
||||
if (sys.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
let parentPath = getDirectoryPath(searchPath);
|
||||
const parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
@@ -31,13 +31,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function resolveTripleslashReference(moduleName: string, containingFile: string): string {
|
||||
let basePath = getDirectoryPath(containingFile);
|
||||
let referencedFileName = isRootedDiskPath(moduleName) ? moduleName : combinePaths(basePath, moduleName);
|
||||
const basePath = getDirectoryPath(containingFile);
|
||||
const referencedFileName = isRootedDiskPath(moduleName) ? moduleName : combinePaths(basePath, moduleName);
|
||||
return normalizePath(referencedFileName);
|
||||
}
|
||||
|
||||
export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
let moduleResolution = compilerOptions.moduleResolution !== undefined
|
||||
const moduleResolution = compilerOptions.moduleResolution !== undefined
|
||||
? compilerOptions.moduleResolution
|
||||
: compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
|
||||
|
||||
@@ -48,11 +48,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
let containingDirectory = getDirectoryPath(containingFile);
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
|
||||
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
|
||||
let failedLookupLocations: string[] = [];
|
||||
let candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
const failedLookupLocations: string[] = [];
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
let resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
|
||||
|
||||
if (resolvedFileName) {
|
||||
@@ -73,7 +73,7 @@ namespace ts {
|
||||
return forEach(moduleFileExtensions, tryLoad);
|
||||
|
||||
function tryLoad(ext: string): string {
|
||||
let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
|
||||
const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
|
||||
if (host.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
@@ -85,13 +85,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function loadNodeModuleFromDirectory(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
let packageJsonPath = combinePaths(candidate, "package.json");
|
||||
const packageJsonPath = combinePaths(candidate, "package.json");
|
||||
if (host.fileExists(packageJsonPath)) {
|
||||
|
||||
let jsonContent: { typings?: string };
|
||||
|
||||
try {
|
||||
let jsonText = host.readFile(packageJsonPath);
|
||||
const jsonText = host.readFile(packageJsonPath);
|
||||
jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined };
|
||||
}
|
||||
catch (e) {
|
||||
@@ -100,7 +100,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (jsonContent.typings) {
|
||||
let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
|
||||
const result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -115,13 +115,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
let failedLookupLocations: string[] = [];
|
||||
const failedLookupLocations: string[] = [];
|
||||
directory = normalizeSlashes(directory);
|
||||
while (true) {
|
||||
let baseName = getBaseFileName(directory);
|
||||
const baseName = getBaseFileName(directory);
|
||||
if (baseName !== "node_modules") {
|
||||
let nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
const nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
let result = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
@@ -133,7 +133,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
let parentPath = getDirectoryPath(directory);
|
||||
const parentPath = getDirectoryPath(directory);
|
||||
if (parentPath === directory) {
|
||||
break;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function nameStartsWithDotSlashOrDotDotSlash(name: string) {
|
||||
let i = name.lastIndexOf("./", 1);
|
||||
const i = name.lastIndexOf("./", 1);
|
||||
return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace ts {
|
||||
let searchPath = getDirectoryPath(containingFile);
|
||||
let searchName: string;
|
||||
|
||||
let failedLookupLocations: string[] = [];
|
||||
const failedLookupLocations: string[] = [];
|
||||
|
||||
let referencedSourceFile: string;
|
||||
while (true) {
|
||||
@@ -171,7 +171,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let candidate = searchName + extension;
|
||||
const candidate = searchName + extension;
|
||||
if (host.fileExists(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace ts {
|
||||
break;
|
||||
}
|
||||
|
||||
let parentPath = getDirectoryPath(searchPath);
|
||||
const parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
@@ -199,16 +199,13 @@ namespace ts {
|
||||
/* @internal */
|
||||
export const defaultInitCompilerOptions: CompilerOptions = {
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES3,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
outDir: "built",
|
||||
rootDir: ".",
|
||||
sourceMap: false,
|
||||
};
|
||||
|
||||
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
|
||||
let currentDirectory: string;
|
||||
let existingDirectories: Map<boolean> = {};
|
||||
const existingDirectories: Map<boolean> = {};
|
||||
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
// if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form.
|
||||
@@ -217,12 +214,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
// returned by CScript sys environment
|
||||
let unsupportedFileEncodingErrorCode = -2147024809;
|
||||
const unsupportedFileEncodingErrorCode = -2147024809;
|
||||
|
||||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
|
||||
let text: string;
|
||||
try {
|
||||
let start = new Date().getTime();
|
||||
const start = new Date().getTime();
|
||||
text = sys.readFile(fileName, options.charset);
|
||||
ioReadTime += new Date().getTime() - start;
|
||||
}
|
||||
@@ -251,7 +248,7 @@ namespace ts {
|
||||
|
||||
function ensureDirectoriesExist(directoryPath: string) {
|
||||
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
|
||||
let parentDirectory = getDirectoryPath(directoryPath);
|
||||
const parentDirectory = getDirectoryPath(directoryPath);
|
||||
ensureDirectoriesExist(parentDirectory);
|
||||
sys.createDirectory(directoryPath);
|
||||
}
|
||||
@@ -259,7 +256,7 @@ namespace ts {
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
|
||||
try {
|
||||
let start = new Date().getTime();
|
||||
const start = new Date().getTime();
|
||||
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
|
||||
sys.writeFile(fileName, data, writeByteOrderMark);
|
||||
ioWriteTime += new Date().getTime() - start;
|
||||
@@ -277,7 +274,7 @@ namespace ts {
|
||||
getSourceFile,
|
||||
getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)),
|
||||
writeFile,
|
||||
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
||||
getCurrentDirectory: memoize(() => sys.getCurrentDirectory()),
|
||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||
getCanonicalFileName,
|
||||
getNewLine: () => newLine,
|
||||
@@ -287,7 +284,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] {
|
||||
let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
|
||||
program.getGlobalDiagnostics(cancellationToken),
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken));
|
||||
@@ -329,7 +326,7 @@ namespace ts {
|
||||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
let fileProcessingDiagnostics = createDiagnosticCollection();
|
||||
let programDiagnostics = createDiagnosticCollection();
|
||||
const programDiagnostics = createDiagnosticCollection();
|
||||
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
@@ -338,20 +335,24 @@ namespace ts {
|
||||
|
||||
let skipDefaultLib = options.noLib;
|
||||
|
||||
let start = new Date().getTime();
|
||||
const start = new Date().getTime();
|
||||
|
||||
host = host || createCompilerHost(options);
|
||||
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
const resolveModuleNamesWorker = host.resolveModuleNames
|
||||
? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile))
|
||||
: ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule));
|
||||
|
||||
let filesByName = createFileMap<SourceFile>(fileName => host.getCanonicalFileName(fileName));
|
||||
const filesByName = createFileMap<SourceFile>();
|
||||
// stores 'filename -> file association' ignoring case
|
||||
// used to track cases when two file names differ only in casing
|
||||
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap<SourceFile>(fileName => fileName.toLowerCase()) : undefined;
|
||||
|
||||
if (oldProgram) {
|
||||
// check properties that can affect structure of the program or module resolution strategy
|
||||
// if any of these properties has changed - structure cannot be reused
|
||||
let oldOptions = oldProgram.getCompilerOptions();
|
||||
const oldOptions = oldProgram.getCompilerOptions();
|
||||
if ((oldOptions.module !== options.module) ||
|
||||
(oldOptions.noResolve !== options.noResolve) ||
|
||||
(oldOptions.target !== options.target) ||
|
||||
@@ -381,7 +382,7 @@ namespace ts {
|
||||
|
||||
program = {
|
||||
getRootFileNames: () => rootNames,
|
||||
getSourceFile: getSourceFile,
|
||||
getSourceFile,
|
||||
getSourceFiles: () => files,
|
||||
getCompilerOptions: () => options,
|
||||
getSyntacticDiagnostics,
|
||||
@@ -394,7 +395,7 @@ namespace ts {
|
||||
getDiagnosticsProducingTypeChecker,
|
||||
getCommonSourceDirectory: () => commonSourceDirectory,
|
||||
emit,
|
||||
getCurrentDirectory: () => host.getCurrentDirectory(),
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getNodeCount: () => getDiagnosticsProducingTypeChecker().getNodeCount(),
|
||||
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
|
||||
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
|
||||
@@ -409,7 +410,7 @@ namespace ts {
|
||||
getTypeChecker();
|
||||
classifiableNames = {};
|
||||
|
||||
for (let sourceFile of files) {
|
||||
for (const sourceFile of files) {
|
||||
copyMap(sourceFile.classifiableNames, classifiableNames);
|
||||
}
|
||||
}
|
||||
@@ -425,20 +426,25 @@ namespace ts {
|
||||
Debug.assert(!oldProgram.structureIsReused);
|
||||
|
||||
// there is an old program, check if we can reuse its structure
|
||||
let oldRootNames = oldProgram.getRootFileNames();
|
||||
const oldRootNames = oldProgram.getRootFileNames();
|
||||
if (!arrayIsEqualTo(oldRootNames, rootNames)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if program source files has changed in the way that can affect structure of the program
|
||||
let newSourceFiles: SourceFile[] = [];
|
||||
let modifiedSourceFiles: SourceFile[] = [];
|
||||
for (let oldSourceFile of oldProgram.getSourceFiles()) {
|
||||
const newSourceFiles: SourceFile[] = [];
|
||||
const filePaths: Path[] = [];
|
||||
const modifiedSourceFiles: SourceFile[] = [];
|
||||
|
||||
for (const oldSourceFile of oldProgram.getSourceFiles()) {
|
||||
let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
|
||||
if (!newSourceFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
newSourceFile.path = oldSourceFile.path;
|
||||
filePaths.push(newSourceFile.path);
|
||||
|
||||
if (oldSourceFile !== newSourceFile) {
|
||||
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
||||
// value of no-default-lib has changed
|
||||
@@ -460,13 +466,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (resolveModuleNamesWorker) {
|
||||
let moduleNames = map(newSourceFile.imports, name => name.text);
|
||||
let resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName);
|
||||
const moduleNames = map(newSourceFile.imports, name => name.text);
|
||||
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory));
|
||||
// ensure that module resolution results are still correct
|
||||
for (let i = 0; i < moduleNames.length; ++i) {
|
||||
let newResolution = resolutions[i];
|
||||
let oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]);
|
||||
let resolutionChanged = oldResolution
|
||||
const newResolution = resolutions[i];
|
||||
const oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]);
|
||||
const resolutionChanged = oldResolution
|
||||
? !newResolution ||
|
||||
oldResolution.resolvedFileName !== newResolution.resolvedFileName ||
|
||||
!!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport
|
||||
@@ -491,14 +497,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
// update fileName -> file mapping
|
||||
for (let file of newSourceFiles) {
|
||||
filesByName.set(file.fileName, file);
|
||||
for (let i = 0, len = newSourceFiles.length; i < len; ++i) {
|
||||
filesByName.set(filePaths[i], newSourceFiles[i]);
|
||||
}
|
||||
|
||||
files = newSourceFiles;
|
||||
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
|
||||
|
||||
for (let modifiedFile of modifiedSourceFiles) {
|
||||
for (const modifiedFile of modifiedSourceFiles) {
|
||||
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
|
||||
}
|
||||
oldProgram.structureIsReused = true;
|
||||
@@ -508,10 +514,10 @@ namespace ts {
|
||||
|
||||
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
|
||||
return {
|
||||
getCanonicalFileName: fileName => host.getCanonicalFileName(fileName),
|
||||
getCanonicalFileName,
|
||||
getCommonSourceDirectory: program.getCommonSourceDirectory,
|
||||
getCompilerOptions: program.getCompilerOptions,
|
||||
getCurrentDirectory: () => host.getCurrentDirectory(),
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getNewLine: () => host.getNewLine(),
|
||||
getSourceFile: program.getSourceFile,
|
||||
getSourceFiles: program.getSourceFiles,
|
||||
@@ -548,11 +554,11 @@ namespace ts {
|
||||
// This is because in the -out scenario all files need to be emitted, and therefore all
|
||||
// files need to be type checked. And the way to specify that all files need to be type
|
||||
// checked is to not pass the file to getEmitResolver.
|
||||
let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile);
|
||||
const emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile);
|
||||
|
||||
let start = new Date().getTime();
|
||||
const start = new Date().getTime();
|
||||
|
||||
let emitResult = emitFiles(
|
||||
const emitResult = emitFiles(
|
||||
emitResolver,
|
||||
getEmitHost(writeFileCallback),
|
||||
sourceFile);
|
||||
@@ -561,10 +567,8 @@ namespace ts {
|
||||
return emitResult;
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string) {
|
||||
// first try to use file name as is to find file
|
||||
// then try to convert relative file name to absolute and use it to retrieve source file
|
||||
return filesByName.get(fileName) || filesByName.get(getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()));
|
||||
function getSourceFile(fileName: string): SourceFile {
|
||||
return filesByName.get(toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
}
|
||||
|
||||
function getDiagnosticsHelper(
|
||||
@@ -575,7 +579,7 @@ namespace ts {
|
||||
return getDiagnostics(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
const allDiagnostics: Diagnostic[] = [];
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
if (cancellationToken) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
@@ -627,13 +631,13 @@ namespace ts {
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
const typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
let bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
let fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
let programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
const bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
const checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
|
||||
});
|
||||
@@ -642,23 +646,23 @@ namespace ts {
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
||||
const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
let writeFile: WriteFileCallback = () => { };
|
||||
const writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getOptionsDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
const allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics());
|
||||
addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
const allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
@@ -685,7 +689,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let imports: LiteralExpression[];
|
||||
for (let node of file.statements) {
|
||||
for (const node of file.statements) {
|
||||
collect(node, /* allowRelativeModuleNames */ true);
|
||||
}
|
||||
|
||||
@@ -735,7 +739,7 @@ namespace ts {
|
||||
diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1;
|
||||
diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"];
|
||||
}
|
||||
else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
@@ -745,13 +749,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd);
|
||||
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd);
|
||||
if (!nonTsFile) {
|
||||
if (options.allowNonTsExtensions) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd))) {
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
@@ -769,24 +773,31 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
if (filesByName.contains(fileName)) {
|
||||
// We've already looked for this file, use cached result
|
||||
return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false);
|
||||
function reportFileNamesDifferOnlyInCasingError(fileName: string, existingFileName: string, refFile: SourceFile, refPos: number, refEnd: number): void {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName));
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName));
|
||||
}
|
||||
}
|
||||
|
||||
let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, normalizedAbsolutePath: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
if (filesByName.contains(normalizedAbsolutePath)) {
|
||||
const file = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true);
|
||||
// we don't have resolution for this relative file name but the match was found by absolute file name
|
||||
// store resolution for relative name as well
|
||||
filesByName.set(fileName, file);
|
||||
const file = filesByName.get(normalizedAbsolutePath);
|
||||
// try to check if we've already seen this file but with a different casing in path
|
||||
// NOTE: this only makes sense for case-insensitive file systems
|
||||
if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== normalizedAbsolutePath) {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
let file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
const file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
@@ -796,14 +807,24 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
filesByName.set(fileName, file);
|
||||
filesByName.set(normalizedAbsolutePath, file);
|
||||
if (file) {
|
||||
file.path = normalizedAbsolutePath;
|
||||
|
||||
if (host.useCaseSensitiveFileNames()) {
|
||||
// for case-sensitive file systems check if we've already seen some file with similar filename ignoring case
|
||||
const existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath);
|
||||
if (existingFile) {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
else {
|
||||
filesByNameIgnoreCase.set(normalizedAbsolutePath, file);
|
||||
}
|
||||
}
|
||||
|
||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||
|
||||
// Set the source file for normalized absolute path
|
||||
filesByName.set(normalizedAbsolutePath, file);
|
||||
|
||||
let basePath = getDirectoryPath(fileName);
|
||||
const basePath = getDirectoryPath(fileName);
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, basePath);
|
||||
}
|
||||
@@ -821,50 +842,38 @@ namespace ts {
|
||||
}
|
||||
|
||||
return file;
|
||||
|
||||
function getSourceFileFromCache(fileName: string, useAbsolutePath: boolean): SourceFile {
|
||||
let file = filesByName.get(fileName);
|
||||
if (file && host.useCaseSensitiveFileNames()) {
|
||||
let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
|
||||
if (normalizeSlashes(fileName) !== normalizeSlashes(sourceFileName)) {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
function processReferencedFiles(file: SourceFile, basePath: string) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
let referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
|
||||
const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
|
||||
processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
return host.getCanonicalFileName(fileName);
|
||||
}
|
||||
|
||||
function processImportedModules(file: SourceFile, basePath: string) {
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length) {
|
||||
file.resolvedModules = {};
|
||||
let moduleNames = map(file.imports, name => name.text);
|
||||
let resolutions = resolveModuleNamesWorker(moduleNames, file.fileName);
|
||||
const moduleNames = map(file.imports, name => name.text);
|
||||
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
|
||||
for (let i = 0; i < file.imports.length; ++i) {
|
||||
let resolution = resolutions[i];
|
||||
const resolution = resolutions[i];
|
||||
setResolvedModule(file, moduleNames[i], resolution);
|
||||
if (resolution && !options.noResolve) {
|
||||
const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
|
||||
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /* isDefaultLib */ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
if (!isExternalModule(importedFile)) {
|
||||
let start = getTokenPosOfNode(file.imports[i], file);
|
||||
const start = getTokenPosOfNode(file.imports[i], file);
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
}
|
||||
else if (importedFile.referencedFiles.length) {
|
||||
let firstRef = importedFile.referencedFiles[0];
|
||||
const firstRef = importedFile.referencedFiles[0];
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
|
||||
}
|
||||
}
|
||||
@@ -876,22 +885,17 @@ namespace ts {
|
||||
file.resolvedModules = undefined;
|
||||
}
|
||||
return;
|
||||
|
||||
function findModuleSourceFile(fileName: string, nameLiteral: Expression) {
|
||||
return findSourceFile(fileName, /* isDefaultLib */ false, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
|
||||
}
|
||||
}
|
||||
|
||||
function computeCommonSourceDirectory(sourceFiles: SourceFile[]): string {
|
||||
let commonPathComponents: string[];
|
||||
let currentDirectory = host.getCurrentDirectory();
|
||||
forEach(files, sourceFile => {
|
||||
// Each file contributes into common source file path
|
||||
if (isDeclarationFile(sourceFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory);
|
||||
const sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory);
|
||||
sourcePathComponents.pop(); // The base file name is not part of the common directory path
|
||||
|
||||
if (!commonPathComponents) {
|
||||
@@ -925,12 +929,11 @@ namespace ts {
|
||||
function checkSourceFilesBelongToPath(sourceFiles: SourceFile[], rootDirectory: string): boolean {
|
||||
let allFilesBelongToPath = true;
|
||||
if (sourceFiles) {
|
||||
let currentDirectory = host.getCurrentDirectory();
|
||||
let absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
|
||||
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
|
||||
|
||||
for (var sourceFile of sourceFiles) {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
|
||||
const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
|
||||
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
|
||||
allFilesBelongToPath = false;
|
||||
@@ -995,24 +998,24 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
|
||||
let languageVersion = options.target || ScriptTarget.ES3;
|
||||
let outFile = options.outFile || options.out;
|
||||
const languageVersion = options.target || ScriptTarget.ES3;
|
||||
const outFile = options.outFile || options.out;
|
||||
|
||||
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
const firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (options.isolatedModules) {
|
||||
if (!options.module && languageVersion < ScriptTarget.ES6) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
|
||||
}
|
||||
|
||||
let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
if (firstNonExternalModuleSourceFile) {
|
||||
let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
}
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
|
||||
@@ -1030,7 +1033,7 @@ namespace ts {
|
||||
|
||||
if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) {
|
||||
// If a rootDir is specified and is valid use it as the commonSourceDirectory
|
||||
commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory());
|
||||
commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory);
|
||||
}
|
||||
else {
|
||||
// Compute the commonSourceDirectory from the input files
|
||||
|
||||
+51
-51
File diff suppressed because one or more lines are too long
+40
-37
@@ -51,15 +51,15 @@ namespace ts {
|
||||
|
||||
function getWScriptSystem(): System {
|
||||
|
||||
let fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
const fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
let fileStream = new ActiveXObject("ADODB.Stream");
|
||||
const fileStream = new ActiveXObject("ADODB.Stream");
|
||||
fileStream.Type = 2 /*text*/;
|
||||
|
||||
let binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
const binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
binaryStream.Type = 1 /*binary*/;
|
||||
|
||||
let args: string[] = [];
|
||||
const args: string[] = [];
|
||||
for (let i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace ts {
|
||||
// Load file and read the first two bytes into a string with no interpretation
|
||||
fileStream.Charset = "x-ansi";
|
||||
fileStream.LoadFromFile(fileName);
|
||||
let bom = fileStream.ReadText(2) || "";
|
||||
const bom = fileStream.ReadText(2) || "";
|
||||
// Position must be at 0 before encoding can be changed
|
||||
fileStream.Position = 0;
|
||||
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
|
||||
@@ -124,7 +124,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getNames(collection: any): string[] {
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
result.push(e.item().Name);
|
||||
}
|
||||
@@ -132,22 +132,22 @@ namespace ts {
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
let folder = fso.GetFolder(path || ".");
|
||||
let files = getNames(folder.files);
|
||||
for (let current of files) {
|
||||
let name = combinePaths(path, current);
|
||||
const folder = fso.GetFolder(path || ".");
|
||||
const files = getNames(folder.files);
|
||||
for (const current of files) {
|
||||
const name = combinePaths(path, current);
|
||||
if ((!extension || fileExtensionIs(name, extension)) && !contains(exclude, getCanonicalPath(name))) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
let subfolders = getNames(folder.subfolders);
|
||||
for (let current of subfolders) {
|
||||
let name = combinePaths(path, current);
|
||||
const subfolders = getNames(folder.subfolders);
|
||||
for (const current of subfolders) {
|
||||
const name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
visitDirectory(name);
|
||||
}
|
||||
@@ -198,6 +198,7 @@ namespace ts {
|
||||
const _fs = require("fs");
|
||||
const _path = require("path");
|
||||
const _os = require("os");
|
||||
const _tty = require("tty");
|
||||
|
||||
// average async stat takes about 30 microseconds
|
||||
// set chunk size to do 30 files in < 1 millisecond
|
||||
@@ -211,7 +212,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function poll(checkedIndex: number) {
|
||||
let watchedFile = watchedFiles[checkedIndex];
|
||||
const watchedFile = watchedFiles[checkedIndex];
|
||||
if (!watchedFile) {
|
||||
return;
|
||||
}
|
||||
@@ -251,7 +252,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function addFile(fileName: string, callback: (fileName: string, removed?: boolean) => void): WatchedFile {
|
||||
let file: WatchedFile = {
|
||||
const file: WatchedFile = {
|
||||
fileName,
|
||||
callback,
|
||||
mtime: getModifiedTime(fileName)
|
||||
@@ -290,7 +291,7 @@ namespace ts {
|
||||
// changes for large reference sets? If so, do we want
|
||||
// to increase the chunk size or decrease the interval
|
||||
// time dynamically to match the large reference set?
|
||||
let watchedFileSet = createWatchedFileSet();
|
||||
const watchedFileSet = createWatchedFileSet();
|
||||
|
||||
function isNode4OrLater(): Boolean {
|
||||
return parseInt(process.version.charAt(1)) >= 4;
|
||||
@@ -304,14 +305,14 @@ namespace ts {
|
||||
if (!_fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
let buffer = _fs.readFileSync(fileName);
|
||||
const buffer = _fs.readFileSync(fileName);
|
||||
let len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
// flip all byte pairs and treat as little endian.
|
||||
len &= ~1;
|
||||
for (let i = 0; i < len; i += 2) {
|
||||
let temp = buffer[i];
|
||||
const temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
@@ -335,7 +336,17 @@ namespace ts {
|
||||
data = "\uFEFF" + data;
|
||||
}
|
||||
|
||||
_fs.writeFileSync(fileName, data, "utf8");
|
||||
let fd: number;
|
||||
|
||||
try {
|
||||
fd = _fs.openSync(fileName, "w");
|
||||
_fs.writeSync(fd, data, undefined, "utf8");
|
||||
}
|
||||
finally {
|
||||
if (fd !== undefined) {
|
||||
_fs.closeSync(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCanonicalPath(path: string): string {
|
||||
@@ -343,17 +354,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
let files = _fs.readdirSync(path || ".").sort();
|
||||
let directories: string[] = [];
|
||||
for (let current of files) {
|
||||
let name = combinePaths(path, current);
|
||||
const files = _fs.readdirSync(path || ".").sort();
|
||||
const directories: string[] = [];
|
||||
for (const current of files) {
|
||||
const name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
let stat = _fs.statSync(name);
|
||||
const stat = _fs.statSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
@@ -364,7 +375,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let current of directories) {
|
||||
for (const current of directories) {
|
||||
visitDirectory(current);
|
||||
}
|
||||
}
|
||||
@@ -375,15 +386,7 @@ namespace ts {
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write(s: string): void {
|
||||
const buffer = new Buffer(s, "utf8");
|
||||
let offset = 0;
|
||||
let toWrite: number = buffer.length;
|
||||
let written = 0;
|
||||
// 1 is a standard descriptor for stdout
|
||||
while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) {
|
||||
offset += written;
|
||||
toWrite -= written;
|
||||
}
|
||||
process.stdout.write(s);
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
@@ -397,7 +400,7 @@ namespace ts {
|
||||
return _fs.watch(fileName, (eventName: string, relativeFileName: string) => callback(fileName));
|
||||
}
|
||||
|
||||
let watchedFile = watchedFileSet.addFile(fileName, callback);
|
||||
const watchedFile = watchedFileSet.addFile(fileName, callback);
|
||||
return {
|
||||
close: () => watchedFileSet.removeFile(watchedFile)
|
||||
};
|
||||
|
||||
+164
-65
@@ -6,20 +6,28 @@ namespace ts {
|
||||
fileWatcher?: FileWatcher;
|
||||
}
|
||||
|
||||
let reportDiagnostic = reportDiagnosticSimply;
|
||||
|
||||
function reportDiagnostics(diagnostics: Diagnostic[], host: CompilerHost): void {
|
||||
for (const diagnostic of diagnostics) {
|
||||
reportDiagnostic(diagnostic, host);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the locale is in the appropriate format,
|
||||
* and if it is, attempts to set the appropriate language.
|
||||
*/
|
||||
function validateLocaleAndSetLanguage(locale: string, errors: Diagnostic[]): boolean {
|
||||
let matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
const matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
|
||||
if (!matchResult) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
|
||||
return false;
|
||||
}
|
||||
|
||||
let language = matchResult[1];
|
||||
let territory = matchResult[3];
|
||||
const language = matchResult[1];
|
||||
const territory = matchResult[3];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
if (!trySetLanguageAndTerritory(language, territory, errors) &&
|
||||
@@ -33,8 +41,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function trySetLanguageAndTerritory(language: string, territory: string, errors: Diagnostic[]): boolean {
|
||||
let compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
let containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
const compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
const containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
|
||||
let filePath = combinePaths(containingDirectoryPath, language);
|
||||
|
||||
@@ -77,35 +85,122 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string {
|
||||
let diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
const diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
return <string>diagnostic.messageText;
|
||||
}
|
||||
|
||||
function reportDiagnostic(diagnostic: Diagnostic) {
|
||||
function getRelativeFileName(fileName: string, host: CompilerHost): string {
|
||||
return host ? convertToRelativePath(fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : fileName;
|
||||
}
|
||||
|
||||
function reportDiagnosticSimply(diagnostic: Diagnostic, host: CompilerHost): void {
|
||||
let output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
|
||||
const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
const relativeFileName = getRelativeFileName(diagnostic.file.fileName, host);
|
||||
output += `${ relativeFileName }(${ line + 1 },${ character + 1 }): `;
|
||||
}
|
||||
|
||||
let category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
|
||||
function reportDiagnostics(diagnostics: Diagnostic[]) {
|
||||
for (let i = 0; i < diagnostics.length; i++) {
|
||||
reportDiagnostic(diagnostics[i]);
|
||||
|
||||
const redForegroundEscapeSequence = "\u001b[91m";
|
||||
const yellowForegroundEscapeSequence = "\u001b[93m";
|
||||
const blueForegroundEscapeSequence = "\u001b[93m";
|
||||
const gutterStyleSequence = "\u001b[100;30m";
|
||||
const gutterSeparator = " ";
|
||||
const resetEscapeSequence = "\u001b[0m";
|
||||
const elipsis = "...";
|
||||
const categoryFormatMap: Map<string> = {
|
||||
[DiagnosticCategory.Warning]: yellowForegroundEscapeSequence,
|
||||
[DiagnosticCategory.Error]: redForegroundEscapeSequence,
|
||||
[DiagnosticCategory.Message]: blueForegroundEscapeSequence,
|
||||
};
|
||||
|
||||
function formatAndReset(text: string, formatStyle: string) {
|
||||
return formatStyle + text + resetEscapeSequence;
|
||||
}
|
||||
|
||||
function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic, host: CompilerHost): void {
|
||||
let output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
const { start, length, file } = diagnostic;
|
||||
const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start);
|
||||
const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length);
|
||||
const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line;
|
||||
const relativeFileName = getRelativeFileName(file.fileName, host);
|
||||
|
||||
const hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
|
||||
let gutterWidth = (lastLine + 1 + "").length;
|
||||
if (hasMoreThanFiveLines) {
|
||||
gutterWidth = Math.max(elipsis.length, gutterWidth);
|
||||
}
|
||||
|
||||
output += sys.newLine;
|
||||
for (let i = firstLine; i <= lastLine; i++) {
|
||||
// If the error spans over 5 lines, we'll only show the first 2 and last 2 lines,
|
||||
// so we'll skip ahead to the second-to-last line.
|
||||
if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
|
||||
output += formatAndReset(padLeft(elipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine;
|
||||
i = lastLine - 1;
|
||||
}
|
||||
|
||||
const lineStart = getPositionOfLineAndCharacter(file, i, 0);
|
||||
const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
|
||||
let lineContent = file.text.slice(lineStart, lineEnd);
|
||||
lineContent = lineContent.replace(/\s+$/g, ""); // trim from end
|
||||
lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces
|
||||
|
||||
// Output the gutter and the actual contents of the line.
|
||||
output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
output += lineContent + sys.newLine;
|
||||
|
||||
// Output the gutter and the error span for the line using tildes.
|
||||
output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
|
||||
output += redForegroundEscapeSequence;
|
||||
if (i === firstLine) {
|
||||
// If we're on the last line, then limit it to the last character of the last line.
|
||||
// Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
|
||||
const lastCharForLine = i === lastLine ? lastLineChar : undefined;
|
||||
|
||||
output += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
|
||||
output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
|
||||
}
|
||||
else if (i === lastLine) {
|
||||
output += lineContent.slice(0, lastLineChar).replace(/./g, "~");
|
||||
}
|
||||
else {
|
||||
// Squiggle the entire line.
|
||||
output += lineContent.replace(/./g, "~");
|
||||
}
|
||||
output += resetEscapeSequence;
|
||||
|
||||
output += sys.newLine;
|
||||
}
|
||||
|
||||
output += sys.newLine;
|
||||
output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `;
|
||||
}
|
||||
|
||||
const categoryColor = categoryFormatMap[diagnostic.category];
|
||||
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`;
|
||||
output += sys.newLine + sys.newLine;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
|
||||
function reportWatchDiagnostic(diagnostic: Diagnostic) {
|
||||
let output = new Date().toLocaleTimeString() + " - ";
|
||||
|
||||
if (diagnostic.file) {
|
||||
let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
const loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
|
||||
}
|
||||
|
||||
@@ -146,7 +241,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
let commandLine = parseCommandLine(args);
|
||||
const commandLine = parseCommandLine(args);
|
||||
let configFileName: string; // Configuration file name (if any)
|
||||
let cachedConfigFileText: string; // Cached configuration file text, used for reparsing (if any)
|
||||
let configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
@@ -166,7 +261,7 @@ namespace ts {
|
||||
|
||||
if (commandLine.options.locale) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), /* compilerHost */ undefined);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
@@ -175,7 +270,7 @@ namespace ts {
|
||||
// If there are any errors due to command line parsing and/or
|
||||
// setting up localization, report them and quit.
|
||||
if (commandLine.errors.length > 0) {
|
||||
reportDiagnostics(commandLine.errors);
|
||||
reportDiagnostics(commandLine.errors, compilerHost);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
|
||||
@@ -185,7 +280,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (commandLine.options.version) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version), /* compilerHost */ undefined);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
@@ -197,17 +292,17 @@ namespace ts {
|
||||
|
||||
if (commandLine.options.project) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"), /* compilerHost */ undefined);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
|
||||
if (commandLine.fileNames.length !== 0) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line), /* compilerHost */ undefined);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
}
|
||||
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
|
||||
let searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
const searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
configFileName = findConfigFile(searchPath);
|
||||
}
|
||||
|
||||
@@ -220,14 +315,14 @@ namespace ts {
|
||||
// Firefox has Object.prototype.watch
|
||||
if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
if (configFileName) {
|
||||
configFileWatcher = sys.watchFile(configFileName, configFileChanged);
|
||||
}
|
||||
if (sys.watchDirectory && configFileName) {
|
||||
let directory = ts.getDirectoryPath(configFileName);
|
||||
const directory = ts.getDirectoryPath(configFileName);
|
||||
directoryWatcher = sys.watchDirectory(
|
||||
// When the configFileName is just "tsconfig.json", the watched directory should be
|
||||
// the current direcotry; if there is a given "project" parameter, then the configFileName
|
||||
@@ -245,18 +340,18 @@ namespace ts {
|
||||
cachedConfigFileText = sys.readFile(configFileName);
|
||||
}
|
||||
catch (e) {
|
||||
let error = createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message);
|
||||
const error = createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message);
|
||||
reportWatchDiagnostic(error);
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let result = parseConfigFileTextToJson(configFileName, cachedConfigFileText);
|
||||
let configObject = result.config;
|
||||
let configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName));
|
||||
const result = parseConfigFileTextToJson(configFileName, cachedConfigFileText);
|
||||
const configObject = result.config;
|
||||
const configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName));
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors);
|
||||
reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined);
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
return;
|
||||
}
|
||||
@@ -268,7 +363,7 @@ namespace ts {
|
||||
|
||||
if (!cachedProgram) {
|
||||
if (configFileName) {
|
||||
let configParseResult = parseConfigFile();
|
||||
const configParseResult = parseConfigFile();
|
||||
rootFileNames = configParseResult.fileNames;
|
||||
compilerOptions = extend(commandLine.options, configParseResult.options);
|
||||
}
|
||||
@@ -284,10 +379,14 @@ namespace ts {
|
||||
compilerHost.fileExists = cachedFileExists;
|
||||
}
|
||||
|
||||
if (compilerOptions.pretty) {
|
||||
reportDiagnostic = reportDiagnosticWithColorAndContext;
|
||||
}
|
||||
|
||||
// reset the cache of existing files
|
||||
cachedExistingFiles = {};
|
||||
|
||||
let compileResult = compile(rootFileNames, compilerOptions, compilerHost);
|
||||
const compileResult = compile(rootFileNames, compilerOptions, compilerHost);
|
||||
|
||||
if (!compilerOptions.watch) {
|
||||
return sys.exit(compileResult.exitStatus);
|
||||
@@ -307,14 +406,14 @@ namespace ts {
|
||||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) {
|
||||
// Return existing SourceFile object if one is available
|
||||
if (cachedProgram) {
|
||||
let sourceFile = cachedProgram.getSourceFile(fileName);
|
||||
const sourceFile = cachedProgram.getSourceFile(fileName);
|
||||
// A modified source file has no watcher and should not be reused
|
||||
if (sourceFile && sourceFile.fileWatcher) {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
// Use default host function
|
||||
let sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && compilerOptions.watch) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
|
||||
@@ -325,7 +424,7 @@ namespace ts {
|
||||
// Change cached program to the given program
|
||||
function setCachedProgram(program: Program) {
|
||||
if (cachedProgram) {
|
||||
let newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
const newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
forEach(cachedProgram.getSourceFiles(), sourceFile => {
|
||||
if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) {
|
||||
if (sourceFile.fileWatcher) {
|
||||
@@ -343,7 +442,7 @@ namespace ts {
|
||||
sourceFile.fileWatcher.close();
|
||||
sourceFile.fileWatcher = undefined;
|
||||
if (removed) {
|
||||
let index = rootFileNames.indexOf(sourceFile.fileName);
|
||||
const index = rootFileNames.indexOf(sourceFile.fileName);
|
||||
if (index >= 0) {
|
||||
rootFileNames.splice(index, 1);
|
||||
}
|
||||
@@ -374,9 +473,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function directoryChangeHandler() {
|
||||
let parsedCommandLine = parseConfigFile();
|
||||
let newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName);
|
||||
let canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName);
|
||||
const parsedCommandLine = parseConfigFile();
|
||||
const newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName);
|
||||
const canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName);
|
||||
|
||||
// We check if the project file list has changed. If so, we just throw away the old program and start fresh.
|
||||
if (!arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) {
|
||||
@@ -410,8 +509,8 @@ namespace ts {
|
||||
checkTime = 0;
|
||||
emitTime = 0;
|
||||
|
||||
let program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
let exitStatus = compileProgram();
|
||||
const program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
const exitStatus = compileProgram();
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
@@ -420,7 +519,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (compilerOptions.diagnostics) {
|
||||
let memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
const memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
reportCountStatistic("Nodes", program.getNodeCount());
|
||||
@@ -463,7 +562,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
reportDiagnostics(diagnostics);
|
||||
reportDiagnostics(diagnostics, compilerHost);
|
||||
|
||||
// If the user doesn't want us to emit, then we're done at this point.
|
||||
if (compilerOptions.noEmit) {
|
||||
@@ -473,8 +572,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Otherwise, emit and report any errors we ran into.
|
||||
let emitOutput = program.emit();
|
||||
reportDiagnostics(emitOutput.diagnostics);
|
||||
const emitOutput = program.emit();
|
||||
reportDiagnostics(emitOutput.diagnostics, compilerHost);
|
||||
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
if (emitOutput.emitSkipped) {
|
||||
@@ -499,8 +598,8 @@ namespace ts {
|
||||
let output = "";
|
||||
|
||||
// We want to align our "syntax" and "examples" commands to a certain margin.
|
||||
let syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length;
|
||||
let examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length;
|
||||
const syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length;
|
||||
const examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length;
|
||||
let marginLength = Math.max(syntaxLength, examplesLength);
|
||||
|
||||
// Build up the syntactic skeleton.
|
||||
@@ -511,7 +610,7 @@ namespace ts {
|
||||
output += sys.newLine + sys.newLine;
|
||||
|
||||
// Build up the list of examples.
|
||||
let padding = makePadding(marginLength);
|
||||
const padding = makePadding(marginLength);
|
||||
output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine;
|
||||
output += padding + "tsc --out file.js file.ts" + sys.newLine;
|
||||
output += padding + "tsc @args.txt" + sys.newLine;
|
||||
@@ -520,17 +619,17 @@ namespace ts {
|
||||
output += getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine;
|
||||
|
||||
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
|
||||
let optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
const optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
optsList.sort((a, b) => compareValues<string>(a.name.toLowerCase(), b.name.toLowerCase()));
|
||||
|
||||
// We want our descriptions to align at the same column in our output,
|
||||
// so we keep track of the longest option usage string.
|
||||
marginLength = 0;
|
||||
let usageColumn: string[] = []; // Things like "-d, --declaration" go in here.
|
||||
let descriptionColumn: string[] = [];
|
||||
const usageColumn: string[] = []; // Things like "-d, --declaration" go in here.
|
||||
const descriptionColumn: string[] = [];
|
||||
|
||||
for (let i = 0; i < optsList.length; i++) {
|
||||
let option = optsList[i];
|
||||
const option = optsList[i];
|
||||
|
||||
// If an option lacks a description,
|
||||
// it is not officially supported.
|
||||
@@ -556,15 +655,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Special case that can't fit in the loop.
|
||||
let usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">";
|
||||
const usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">";
|
||||
usageColumn.push(usageText);
|
||||
descriptionColumn.push(getDiagnosticText(Diagnostics.Insert_command_line_options_and_files_from_a_file));
|
||||
marginLength = Math.max(usageText.length, marginLength);
|
||||
|
||||
// Print out each row, aligning all the descriptions on the same column.
|
||||
for (let i = 0; i < usageColumn.length; i++) {
|
||||
let usage = usageColumn[i];
|
||||
let description = descriptionColumn[i];
|
||||
const usage = usageColumn[i];
|
||||
const description = descriptionColumn[i];
|
||||
output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine;
|
||||
}
|
||||
|
||||
@@ -584,14 +683,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeConfigFile(options: CompilerOptions, fileNames: string[]) {
|
||||
let currentDirectory = sys.getCurrentDirectory();
|
||||
let file = normalizePath(combinePaths(currentDirectory, "tsconfig.json"));
|
||||
const currentDirectory = sys.getCurrentDirectory();
|
||||
const file = normalizePath(combinePaths(currentDirectory, "tsconfig.json"));
|
||||
if (sys.fileExists(file)) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* compilerHost */ undefined);
|
||||
}
|
||||
else {
|
||||
let compilerOptions = extend(options, defaultInitCompilerOptions);
|
||||
let configurations: any = {
|
||||
const compilerOptions = extend(options, defaultInitCompilerOptions);
|
||||
const configurations: any = {
|
||||
compilerOptions: serializeCompilerOptions(compilerOptions),
|
||||
exclude: ["node_modules"]
|
||||
};
|
||||
@@ -602,18 +701,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* compilerHost */ undefined);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
function serializeCompilerOptions(options: CompilerOptions): Map<string | number | boolean> {
|
||||
let result: Map<string | number | boolean> = {};
|
||||
let optionsNameMap = getOptionNameMap().optionNameMap;
|
||||
const result: Map<string | number | boolean> = {};
|
||||
const optionsNameMap = getOptionNameMap().optionNameMap;
|
||||
|
||||
for (let name in options) {
|
||||
for (const name in options) {
|
||||
if (hasProperty(options, name)) {
|
||||
let value = options[name];
|
||||
const value = options[name];
|
||||
switch (name) {
|
||||
case "init":
|
||||
case "watch":
|
||||
@@ -630,8 +729,8 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// Enum
|
||||
let typeMap = <Map<number>>optionDefinition.type;
|
||||
for (let key in typeMap) {
|
||||
const typeMap = <Map<number>>optionDefinition.type;
|
||||
for (const key in typeMap) {
|
||||
if (hasProperty(typeMap, key)) {
|
||||
if (typeMap[key] === value)
|
||||
result[name] = key;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"core.ts",
|
||||
"sys.ts",
|
||||
"types.ts",
|
||||
"diagnosticInformationMap.generated.ts",
|
||||
"scanner.ts",
|
||||
"parser.ts",
|
||||
"utilities.ts",
|
||||
@@ -19,7 +20,6 @@
|
||||
"emitter.ts",
|
||||
"program.ts",
|
||||
"commandLineParser.ts",
|
||||
"tsc.ts",
|
||||
"diagnosticInformationMap.generated.ts"
|
||||
"tsc.ts"
|
||||
]
|
||||
}
|
||||
|
||||
+46
-25
@@ -3,12 +3,17 @@ namespace ts {
|
||||
[index: string]: T;
|
||||
}
|
||||
|
||||
// branded string type used to store absolute, normalized and canonicalized paths
|
||||
// arbitrary file name can be converted to Path via toPath function
|
||||
export type Path = string & { __pathBrand: any };
|
||||
|
||||
export interface FileMap<T> {
|
||||
get(fileName: string): T;
|
||||
set(fileName: string, value: T): void;
|
||||
contains(fileName: string): boolean;
|
||||
remove(fileName: string): void;
|
||||
forEachValue(f: (v: T) => void): void;
|
||||
get(fileName: Path): T;
|
||||
set(fileName: Path, value: T): void;
|
||||
contains(fileName: Path): boolean;
|
||||
remove(fileName: Path): void;
|
||||
|
||||
forEachValue(f: (key: Path, v: T) => void): void;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
@@ -362,28 +367,31 @@ namespace ts {
|
||||
|
||||
export const enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 0x00000001, // Declarations
|
||||
Ambient = 0x00000002, // Declarations
|
||||
Public = 0x00000010, // Property/Method
|
||||
Private = 0x00000020, // Property/Method
|
||||
Protected = 0x00000040, // Property/Method
|
||||
Static = 0x00000080, // Property/Method
|
||||
Abstract = 0x00000100, // Class/Method/ConstructSignature
|
||||
Async = 0x00000200, // Property/Method/Function
|
||||
Default = 0x00000400, // Function/Class (export default declaration)
|
||||
MultiLine = 0x00000800, // Multi-line array or object literal
|
||||
Synthetic = 0x00001000, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 0x00002000, // Node is a .d.ts file
|
||||
Let = 0x00004000, // Variable declaration
|
||||
Const = 0x00008000, // Variable declaration
|
||||
OctalLiteral = 0x00010000, // Octal numeric literal
|
||||
Namespace = 0x00020000, // Namespace declaration
|
||||
ExportContext = 0x00040000, // Export context (initialized by binding)
|
||||
ContainsThis = 0x00080000, // Interface contains references to "this"
|
||||
|
||||
Export = 1 << 1, // Declarations
|
||||
Ambient = 1 << 2, // Declarations
|
||||
Public = 1 << 3, // Property/Method
|
||||
Private = 1 << 4, // Property/Method
|
||||
Protected = 1 << 5, // Property/Method
|
||||
Static = 1 << 6, // Property/Method
|
||||
Abstract = 1 << 7, // Class/Method/ConstructSignature
|
||||
Async = 1 << 8, // Property/Method/Function
|
||||
Default = 1 << 9, // Function/Class (export default declaration)
|
||||
MultiLine = 1 << 10, // Multi-line array or object literal
|
||||
Synthetic = 1 << 11, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 1 << 12, // Node is a .d.ts file
|
||||
Let = 1 << 13, // Variable declaration
|
||||
Const = 1 << 14, // Variable declaration
|
||||
OctalLiteral = 1 << 15, // Octal numeric literal
|
||||
Namespace = 1 << 16, // Namespace declaration
|
||||
ExportContext = 1 << 17, // Export context (initialized by binding)
|
||||
ContainsThis = 1 << 18, // Interface contains references to "this"
|
||||
HasImplicitReturn = 1 << 19, // If function implicitly returns on one of codepaths (initialized by binding)
|
||||
HasExplicitReturn = 1 << 20, // If function has explicit reachable return on one of codepaths (initialized by binding)
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
BlockScoped = Let | Const
|
||||
BlockScoped = Let | Const,
|
||||
|
||||
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1250,6 +1258,7 @@ namespace ts {
|
||||
endOfFileToken: Node;
|
||||
|
||||
fileName: string;
|
||||
/* internal */ path: Path;
|
||||
text: string;
|
||||
|
||||
amdDependencies: {path: string; name: string}[];
|
||||
@@ -2080,6 +2089,7 @@ namespace ts {
|
||||
outFile?: string;
|
||||
outDir?: string;
|
||||
preserveConstEnums?: boolean;
|
||||
/* @internal */ pretty?: DiagnosticStyle;
|
||||
project?: string;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
@@ -2094,6 +2104,11 @@ namespace ts {
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
allowUnusedLabels?: boolean;
|
||||
allowUnreachableCode?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
@@ -2144,6 +2159,12 @@ namespace ts {
|
||||
JSX,
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export const enum DiagnosticStyle {
|
||||
Simple,
|
||||
Pretty,
|
||||
}
|
||||
|
||||
export interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
fileNames: string[];
|
||||
|
||||
+193
-111
@@ -16,9 +16,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
|
||||
let declarations = symbol.declarations;
|
||||
const declarations = symbol.declarations;
|
||||
if (declarations) {
|
||||
for (let declaration of declarations) {
|
||||
for (const declaration of declarations) {
|
||||
if (declaration.kind === kind) {
|
||||
return declaration;
|
||||
}
|
||||
@@ -43,12 +43,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Pool writers to avoid needing to allocate them for every symbol we write.
|
||||
let stringWriters: StringSymbolWriter[] = [];
|
||||
const stringWriters: StringSymbolWriter[] = [];
|
||||
export function getSingleLineStringWriter(): StringSymbolWriter {
|
||||
if (stringWriters.length === 0) {
|
||||
let str = "";
|
||||
|
||||
let writeText: (text: string) => void = text => str += text;
|
||||
const writeText: (text: string) => void = text => str += text;
|
||||
return {
|
||||
string: () => str,
|
||||
writeKeyword: writeText,
|
||||
@@ -92,7 +92,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
for (let i = 0; i < array1.length; ++i) {
|
||||
let equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
|
||||
const equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
|
||||
if (!equals) {
|
||||
return false;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace ts {
|
||||
// A node is considered to contain a parse error if:
|
||||
// a) the parser explicitly marked that it had an error
|
||||
// b) any of it's children reported that it had an error.
|
||||
let thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & ParserContextFlags.ThisNodeHasError) !== 0) ||
|
||||
const thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & ParserContextFlags.ThisNodeHasError) !== 0) ||
|
||||
forEachChild(node, containsParseError);
|
||||
|
||||
// If so, mark ourselves accordingly.
|
||||
@@ -157,8 +157,8 @@ namespace ts {
|
||||
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
let file = getSourceFileOfNode(node);
|
||||
let loc = getLineAndCharacterOfPosition(file, node.pos);
|
||||
const file = getSourceFileOfNode(node);
|
||||
const loc = getLineAndCharacterOfPosition(file, node.pos);
|
||||
return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace ts {
|
||||
return "";
|
||||
}
|
||||
|
||||
let text = sourceFile.text;
|
||||
const text = sourceFile.text;
|
||||
return text.substring(includeTrivia ? node.pos : skipTrivia(text, node.pos), node.end);
|
||||
}
|
||||
|
||||
@@ -294,14 +294,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
|
||||
let sourceFile = getSourceFileOfNode(node);
|
||||
let span = getErrorSpanForNode(sourceFile, node);
|
||||
const sourceFile = getSourceFileOfNode(node);
|
||||
const span = getErrorSpanForNode(sourceFile, node);
|
||||
return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic {
|
||||
let sourceFile = getSourceFileOfNode(node);
|
||||
let span = getErrorSpanForNode(sourceFile, node);
|
||||
const sourceFile = getSourceFileOfNode(node);
|
||||
const span = getErrorSpanForNode(sourceFile, node);
|
||||
return {
|
||||
file: sourceFile,
|
||||
start: span.start,
|
||||
@@ -313,9 +313,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan {
|
||||
let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos);
|
||||
const scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos);
|
||||
scanner.scan();
|
||||
let start = scanner.getTokenPos();
|
||||
const start = scanner.getTokenPos();
|
||||
return createTextSpanFromBounds(start, scanner.getTextPos());
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace ts {
|
||||
return getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
}
|
||||
|
||||
let pos = nodeIsMissing(errorNode)
|
||||
const pos = nodeIsMissing(errorNode)
|
||||
? errorNode.pos
|
||||
: skipTrivia(sourceFile.text, errorNode.pos);
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) {
|
||||
let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ?
|
||||
const commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ?
|
||||
concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos),
|
||||
getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) :
|
||||
getLeadingCommentRangesOfNode(node, sourceFileOfNode);
|
||||
@@ -579,7 +579,7 @@ namespace ts {
|
||||
return;
|
||||
default:
|
||||
if (isFunctionLike(node)) {
|
||||
let name = (<FunctionLikeDeclaration>node).name;
|
||||
const name = (<FunctionLikeDeclaration>node).name;
|
||||
if (name && name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
// Note that we will not include methods/accessors of a class because they would require
|
||||
// first descending into the class. This is by design.
|
||||
@@ -622,25 +622,26 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isFunctionLike(node: Node): node is FunctionLikeDeclaration {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
return true;
|
||||
}
|
||||
return node && isFunctionLikeKind(node.kind);
|
||||
}
|
||||
|
||||
export function isFunctionLikeKind(kind: SyntaxKind): boolean {
|
||||
switch (kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function introducesArgumentsExoticObject(node: Node) {
|
||||
@@ -1029,7 +1030,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
|
||||
let moduleState = getModuleInstanceState(node);
|
||||
const moduleState = getModuleInstanceState(node);
|
||||
return moduleState === ModuleInstanceState.Instantiated ||
|
||||
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
|
||||
}
|
||||
@@ -1052,7 +1053,7 @@ namespace ts {
|
||||
return (<ImportDeclaration>node).moduleSpecifier;
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
let reference = (<ImportEqualsDeclaration>node).moduleReference;
|
||||
const reference = (<ImportEqualsDeclaration>node).moduleReference;
|
||||
if (reference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
return (<ExternalModuleReference>reference).expression;
|
||||
}
|
||||
@@ -1087,7 +1088,7 @@ namespace ts {
|
||||
|
||||
function getJSDocTag(node: Node, kind: SyntaxKind): JSDocTag {
|
||||
if (node && node.jsDocComment) {
|
||||
for (let tag of node.jsDocComment.tags) {
|
||||
for (const tag of node.jsDocComment.tags) {
|
||||
if (tag.kind === kind) {
|
||||
return tag;
|
||||
}
|
||||
@@ -1111,14 +1112,14 @@ namespace ts {
|
||||
if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) {
|
||||
// If it's a parameter, see if the parent has a jsdoc comment with an @param
|
||||
// annotation.
|
||||
let parameterName = (<Identifier>parameter.name).text;
|
||||
const parameterName = (<Identifier>parameter.name).text;
|
||||
|
||||
let docComment = parameter.parent.jsDocComment;
|
||||
const docComment = parameter.parent.jsDocComment;
|
||||
if (docComment) {
|
||||
return <JSDocParameterTag>forEach(docComment.tags, t => {
|
||||
if (t.kind === SyntaxKind.JSDocParameterTag) {
|
||||
let parameterTag = <JSDocParameterTag>t;
|
||||
let name = parameterTag.preParameterName || parameterTag.postParameterName;
|
||||
const parameterTag = <JSDocParameterTag>t;
|
||||
const name = parameterTag.preParameterName || parameterTag.postParameterName;
|
||||
if (name.text === parameterName) {
|
||||
return t;
|
||||
}
|
||||
@@ -1139,7 +1140,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
let paramTag = getCorrespondingJSDocParameterTag(node);
|
||||
const paramTag = getCorrespondingJSDocParameterTag(node);
|
||||
if (paramTag && paramTag.typeExpression) {
|
||||
return paramTag.typeExpression.type.kind === SyntaxKind.JSDocVariadicType;
|
||||
}
|
||||
@@ -1167,6 +1168,14 @@ namespace ts {
|
||||
return !!node && (node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern);
|
||||
}
|
||||
|
||||
export function isNodeDescendentOf(node: Node, ancestor: Node): boolean {
|
||||
while (node) {
|
||||
if (node === ancestor) return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isInAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) {
|
||||
@@ -1228,7 +1237,7 @@ namespace ts {
|
||||
case SyntaxKind.LabeledStatement:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.ThrowKeyword:
|
||||
case SyntaxKind.ThrowStatement:
|
||||
case SyntaxKind.TryStatement:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
@@ -1261,7 +1270,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
let parent = name.parent;
|
||||
const parent = name.parent;
|
||||
if (parent.kind === SyntaxKind.ImportSpecifier || parent.kind === SyntaxKind.ExportSpecifier) {
|
||||
if ((<ImportOrExportSpecifier>parent).propertyName) {
|
||||
return true;
|
||||
@@ -1328,23 +1337,23 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration) {
|
||||
let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
|
||||
}
|
||||
|
||||
export function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration) {
|
||||
let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword);
|
||||
const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword);
|
||||
return heritageClause ? heritageClause.types : undefined;
|
||||
}
|
||||
|
||||
export function getInterfaceBaseTypeNodes(node: InterfaceDeclaration) {
|
||||
let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
|
||||
return heritageClause ? heritageClause.types : undefined;
|
||||
}
|
||||
|
||||
export function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind) {
|
||||
if (clauses) {
|
||||
for (let clause of clauses) {
|
||||
for (const clause of clauses) {
|
||||
if (clause.token === kind) {
|
||||
return clause;
|
||||
}
|
||||
@@ -1356,8 +1365,7 @@ namespace ts {
|
||||
|
||||
export function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference) {
|
||||
if (!host.getCompilerOptions().noResolve) {
|
||||
let referenceFileName = isRootedDiskPath(reference.fileName) ? reference.fileName : combinePaths(getDirectoryPath(sourceFile.fileName), reference.fileName);
|
||||
referenceFileName = getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory());
|
||||
const referenceFileName = isRootedDiskPath(reference.fileName) ? reference.fileName : combinePaths(getDirectoryPath(sourceFile.fileName), reference.fileName);
|
||||
return host.getSourceFile(referenceFileName);
|
||||
}
|
||||
}
|
||||
@@ -1373,8 +1381,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult {
|
||||
let simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
let isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
|
||||
const simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
const isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
|
||||
if (simpleReferenceRegEx.exec(comment)) {
|
||||
if (isNoDefaultLibRegEx.exec(comment)) {
|
||||
return {
|
||||
@@ -1382,10 +1390,10 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
else {
|
||||
let matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
const matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
if (matchResult) {
|
||||
let start = commentRange.pos;
|
||||
let end = commentRange.end;
|
||||
const start = commentRange.pos;
|
||||
const end = commentRange.end;
|
||||
return {
|
||||
fileReference: {
|
||||
pos: start,
|
||||
@@ -1446,9 +1454,9 @@ namespace ts {
|
||||
return (<Identifier | LiteralExpression>name).text;
|
||||
}
|
||||
if (name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
let nameExpression = (<ComputedPropertyName>name).expression;
|
||||
const nameExpression = (<ComputedPropertyName>name).expression;
|
||||
if (isWellKnownSymbolSyntactically(nameExpression)) {
|
||||
let rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
|
||||
const rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
|
||||
return getPropertyNameForKnownSymbolName(rightHandSideName);
|
||||
}
|
||||
}
|
||||
@@ -1485,7 +1493,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isParameterDeclaration(node: VariableLikeDeclaration) {
|
||||
let root = getRootDeclaration(node);
|
||||
const root = getRootDeclaration(node);
|
||||
return root.kind === SyntaxKind.Parameter;
|
||||
}
|
||||
|
||||
@@ -1502,12 +1510,12 @@ namespace ts {
|
||||
|
||||
export function cloneEntityName(node: EntityName): EntityName {
|
||||
if (node.kind === SyntaxKind.Identifier) {
|
||||
let clone = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
const clone = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
clone.text = (<Identifier>node).text;
|
||||
return clone;
|
||||
}
|
||||
else {
|
||||
let clone = <QualifiedName>createSynthesizedNode(SyntaxKind.QualifiedName);
|
||||
const clone = <QualifiedName>createSynthesizedNode(SyntaxKind.QualifiedName);
|
||||
clone.left = cloneEntityName((<QualifiedName>node).left);
|
||||
clone.left.parent = clone;
|
||||
clone.right = <Identifier>cloneEntityName((<QualifiedName>node).right);
|
||||
@@ -1521,13 +1529,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node {
|
||||
let node = <SynthesizedNode>createNode(kind, /* pos */ -1, /* end */ -1);
|
||||
const node = <SynthesizedNode>createNode(kind, /* pos */ -1, /* end */ -1);
|
||||
node.startsOnNewLine = startsOnNewLine;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createSynthesizedNodeArray(): NodeArray<any> {
|
||||
let array = <NodeArray<any>>[];
|
||||
const array = <NodeArray<any>>[];
|
||||
array.pos = -1;
|
||||
array.end = -1;
|
||||
return array;
|
||||
@@ -1535,7 +1543,7 @@ namespace ts {
|
||||
|
||||
export function createDiagnosticCollection(): DiagnosticCollection {
|
||||
let nonFileDiagnostics: Diagnostic[] = [];
|
||||
let fileDiagnostics: Map<Diagnostic[]> = {};
|
||||
const fileDiagnostics: Map<Diagnostic[]> = {};
|
||||
|
||||
let diagnosticsModified = false;
|
||||
let modificationCount = 0;
|
||||
@@ -1557,7 +1565,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let diagnostic of fileDiagnostics[newFile.fileName]) {
|
||||
for (const diagnostic of fileDiagnostics[newFile.fileName]) {
|
||||
diagnostic.file = newFile;
|
||||
}
|
||||
}
|
||||
@@ -1591,14 +1599,14 @@ namespace ts {
|
||||
return fileDiagnostics[fileName] || [];
|
||||
}
|
||||
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
const allDiagnostics: Diagnostic[] = [];
|
||||
function pushDiagnostic(d: Diagnostic) {
|
||||
allDiagnostics.push(d);
|
||||
}
|
||||
|
||||
forEach(nonFileDiagnostics, pushDiagnostic);
|
||||
|
||||
for (let key in fileDiagnostics) {
|
||||
for (const key in fileDiagnostics) {
|
||||
if (hasProperty(fileDiagnostics, key)) {
|
||||
forEach(fileDiagnostics[key], pushDiagnostic);
|
||||
}
|
||||
@@ -1615,7 +1623,7 @@ namespace ts {
|
||||
diagnosticsModified = false;
|
||||
nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics);
|
||||
|
||||
for (let key in fileDiagnostics) {
|
||||
for (const key in fileDiagnostics) {
|
||||
if (hasProperty(fileDiagnostics, key)) {
|
||||
fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]);
|
||||
}
|
||||
@@ -1628,8 +1636,8 @@ namespace ts {
|
||||
// the language service. These characters should be escaped when printing, and if any characters are added,
|
||||
// the map below must be updated. Note that this regexp *does not* include the 'delete' character.
|
||||
// There is no reason for this other than that JSON.stringify does not handle it either.
|
||||
let escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
let escapedCharsMap: Map<string> = {
|
||||
const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
const escapedCharsMap: Map<string> = {
|
||||
"\0": "\\0",
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
@@ -1660,17 +1668,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isIntrinsicJsxName(name: string) {
|
||||
let ch = name.substr(0, 1);
|
||||
const ch = name.substr(0, 1);
|
||||
return ch.toLowerCase() === ch;
|
||||
}
|
||||
|
||||
function get16BitUnicodeEscapeSequence(charCode: number): string {
|
||||
let hexCharCode = charCode.toString(16).toUpperCase();
|
||||
let paddedHexCode = ("0000" + hexCharCode).slice(-4);
|
||||
const hexCharCode = charCode.toString(16).toUpperCase();
|
||||
const paddedHexCode = ("0000" + hexCharCode).slice(-4);
|
||||
return "\\u" + paddedHexCode;
|
||||
}
|
||||
|
||||
let nonAsciiCharacters = /[^\u0000-\u007F]/g;
|
||||
const nonAsciiCharacters = /[^\u0000-\u007F]/g;
|
||||
export function escapeNonAsciiCharacters(s: string): string {
|
||||
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
|
||||
// Otherwise just return the original string.
|
||||
@@ -1694,7 +1702,7 @@ namespace ts {
|
||||
getIndent(): number;
|
||||
}
|
||||
|
||||
let indentStrings: string[] = ["", " "];
|
||||
const indentStrings: string[] = ["", " "];
|
||||
export function getIndentString(level: number) {
|
||||
if (indentStrings[level] === undefined) {
|
||||
indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
|
||||
@@ -1735,7 +1743,7 @@ namespace ts {
|
||||
function writeLiteral(s: string) {
|
||||
if (s && s.length) {
|
||||
write(s);
|
||||
let lineStartsOfS = computeLineStarts(s);
|
||||
const lineStartsOfS = computeLineStarts(s);
|
||||
if (lineStartsOfS.length > 1) {
|
||||
lineCount = lineCount + lineStartsOfS.length - 1;
|
||||
linePos = output.length - s.length + lastOrUndefined(lineStartsOfS);
|
||||
@@ -1773,7 +1781,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) {
|
||||
let compilerOptions = host.getCompilerOptions();
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
let emitOutputFilePathWithoutExtension: string;
|
||||
if (compilerOptions.outDir) {
|
||||
emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir));
|
||||
@@ -1846,8 +1854,8 @@ namespace ts {
|
||||
forEach(declarations, (member: Declaration) => {
|
||||
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor)
|
||||
&& (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) {
|
||||
let memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
let accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
||||
const memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
|
||||
if (memberName === accessorName) {
|
||||
if (!firstAccessor) {
|
||||
firstAccessor = <AccessorDeclaration>member;
|
||||
@@ -1905,13 +1913,81 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Detached comment is a comment at the top of file or function body that is separated from
|
||||
* the next statement by space.
|
||||
*/
|
||||
export function emitDetachedComments(currentSourceFile: SourceFile, writer: EmitTextWriter,
|
||||
writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void,
|
||||
node: TextRange, newLine: string, removeComments: boolean) {
|
||||
let leadingComments: CommentRange[];
|
||||
let currentDetachedCommentInfo: {nodePos: number, detachedCommentEndPos: number};
|
||||
if (removeComments) {
|
||||
// removeComments is true, only reserve pinned comment at the top of file
|
||||
// For example:
|
||||
// /*! Pinned Comment */
|
||||
//
|
||||
// var x = 10;
|
||||
if (node.pos === 0) {
|
||||
leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// removeComments is false, just get detached as normal and bypass the process to filter comment
|
||||
leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
}
|
||||
|
||||
if (leadingComments) {
|
||||
const detachedComments: CommentRange[] = [];
|
||||
let lastComment: CommentRange;
|
||||
|
||||
for (const comment of leadingComments) {
|
||||
if (lastComment) {
|
||||
const lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end);
|
||||
const commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos);
|
||||
|
||||
if (commentLine >= lastCommentLine + 2) {
|
||||
// There was a blank line between the last comment and this comment. This
|
||||
// comment is not part of the copyright comments. Return what we have so
|
||||
// far.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
detachedComments.push(comment);
|
||||
lastComment = comment;
|
||||
}
|
||||
|
||||
if (detachedComments.length) {
|
||||
// All comments look like they could have been part of the copyright header. Make
|
||||
// sure there is at least one blank line between it and the node. If not, it's not
|
||||
// a copyright header.
|
||||
const lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastOrUndefined(detachedComments).end);
|
||||
const nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
|
||||
if (nodeLine >= lastCommentLine + 2) {
|
||||
// Valid detachedComments
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
|
||||
emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: lastOrUndefined(detachedComments).end };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return currentDetachedCommentInfo;
|
||||
|
||||
function isPinnedComment(comment: CommentRange) {
|
||||
return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) {
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
let firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos);
|
||||
let lineCount = getLineStarts(currentSourceFile).length;
|
||||
const firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos);
|
||||
const lineCount = getLineStarts(currentSourceFile).length;
|
||||
let firstCommentLineIndent: number;
|
||||
for (let pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
|
||||
let nextLineStart = (currentLine + 1) === lineCount
|
||||
const nextLineStart = (currentLine + 1) === lineCount
|
||||
? currentSourceFile.text.length + 1
|
||||
: getStartPositionOfLine(currentLine + 1, currentSourceFile);
|
||||
|
||||
@@ -1922,7 +1998,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// These are number of spaces writer is going to write at current indent
|
||||
let currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
|
||||
const currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
|
||||
|
||||
// Number of spaces we want to be writing
|
||||
// eg: Assume writer indent
|
||||
@@ -1938,10 +2014,10 @@ namespace ts {
|
||||
// More right indented comment */ --4 = 8 - 4 + 11
|
||||
// class c { }
|
||||
// }
|
||||
let spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart);
|
||||
const spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart);
|
||||
if (spacesToEmit > 0) {
|
||||
let numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
|
||||
let indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
|
||||
const indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
|
||||
|
||||
// Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces
|
||||
writer.rawWrite(indentSizeSpaceString);
|
||||
@@ -1970,8 +2046,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeTrimmedCurrentLine(pos: number, nextLineStart: number) {
|
||||
let end = Math.min(comment.end, nextLineStart - 1);
|
||||
let currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, "");
|
||||
const end = Math.min(comment.end, nextLineStart - 1);
|
||||
const currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, "");
|
||||
if (currentLineText) {
|
||||
// trimmed forward and ending spaces text
|
||||
writer.write(currentLineText);
|
||||
@@ -2085,7 +2161,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean {
|
||||
let kind = expression.kind;
|
||||
const kind = expression.kind;
|
||||
if (kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
return (<ObjectLiteralExpression>expression).properties.length === 0;
|
||||
}
|
||||
@@ -2112,11 +2188,11 @@ namespace ts {
|
||||
* representing the UTF-8 encoding of the character, and return the expanded char code list.
|
||||
*/
|
||||
function getExpandedCharCodes(input: string): number[] {
|
||||
let output: number[] = [];
|
||||
let length = input.length;
|
||||
const output: number[] = [];
|
||||
const length = input.length;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
let charCode = input.charCodeAt(i);
|
||||
const charCode = input.charCodeAt(i);
|
||||
|
||||
// handel utf8
|
||||
if (charCode < 0x80) {
|
||||
@@ -2152,9 +2228,9 @@ namespace ts {
|
||||
*/
|
||||
export function convertToBase64(input: string): string {
|
||||
let result = "";
|
||||
let charCodes = getExpandedCharCodes(input);
|
||||
const charCodes = getExpandedCharCodes(input);
|
||||
let i = 0;
|
||||
let length = charCodes.length;
|
||||
const length = charCodes.length;
|
||||
let byte1: number, byte2: number, byte3: number, byte4: number;
|
||||
|
||||
while (i < length) {
|
||||
@@ -2183,6 +2259,12 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string {
|
||||
return !isRootedDiskPath(absoluteOrRelativePath)
|
||||
? absoluteOrRelativePath
|
||||
: getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false);
|
||||
}
|
||||
|
||||
const carriageReturnLineFeed = "\r\n";
|
||||
const lineFeed = "\n";
|
||||
export function getNewLineCharacter(options: CompilerOptions): string {
|
||||
@@ -2222,14 +2304,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function textSpanOverlapsWith(span: TextSpan, other: TextSpan) {
|
||||
let overlapStart = Math.max(span.start, other.start);
|
||||
let overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
|
||||
const overlapStart = Math.max(span.start, other.start);
|
||||
const overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
|
||||
return overlapStart < overlapEnd;
|
||||
}
|
||||
|
||||
export function textSpanOverlap(span1: TextSpan, span2: TextSpan) {
|
||||
let overlapStart = Math.max(span1.start, span2.start);
|
||||
let overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
const overlapStart = Math.max(span1.start, span2.start);
|
||||
const overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
if (overlapStart < overlapEnd) {
|
||||
return createTextSpanFromBounds(overlapStart, overlapEnd);
|
||||
}
|
||||
@@ -2241,13 +2323,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWith(span: TextSpan, start: number, length: number) {
|
||||
let end = start + length;
|
||||
const end = start + length;
|
||||
return start <= textSpanEnd(span) && end >= span.start;
|
||||
}
|
||||
|
||||
export function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number) {
|
||||
let end1 = start1 + length1;
|
||||
let end2 = start2 + length2;
|
||||
const end1 = start1 + length1;
|
||||
const end2 = start2 + length2;
|
||||
return start2 <= end1 && end2 >= start1;
|
||||
}
|
||||
|
||||
@@ -2256,8 +2338,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function textSpanIntersection(span1: TextSpan, span2: TextSpan) {
|
||||
let intersectStart = Math.max(span1.start, span2.start);
|
||||
let intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
const intersectStart = Math.max(span1.start, span2.start);
|
||||
const intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
if (intersectStart <= intersectEnd) {
|
||||
return createTextSpanFromBounds(intersectStart, intersectEnd);
|
||||
}
|
||||
@@ -2316,14 +2398,14 @@ namespace ts {
|
||||
|
||||
// We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
|
||||
// as it makes things much easier to reason about.
|
||||
let change0 = changes[0];
|
||||
const change0 = changes[0];
|
||||
|
||||
let oldStartN = change0.span.start;
|
||||
let oldEndN = textSpanEnd(change0.span);
|
||||
let newEndN = oldStartN + change0.newLength;
|
||||
|
||||
for (let i = 1; i < changes.length; i++) {
|
||||
let nextChange = changes[i];
|
||||
const nextChange = changes[i];
|
||||
|
||||
// Consider the following case:
|
||||
// i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
|
||||
@@ -2405,13 +2487,13 @@ namespace ts {
|
||||
// newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
|
||||
// }
|
||||
|
||||
let oldStart1 = oldStartN;
|
||||
let oldEnd1 = oldEndN;
|
||||
let newEnd1 = newEndN;
|
||||
const oldStart1 = oldStartN;
|
||||
const oldEnd1 = oldEndN;
|
||||
const newEnd1 = newEndN;
|
||||
|
||||
let oldStart2 = nextChange.span.start;
|
||||
let oldEnd2 = textSpanEnd(nextChange.span);
|
||||
let newEnd2 = oldStart2 + nextChange.newLength;
|
||||
const oldStart2 = nextChange.span.start;
|
||||
const oldEnd2 = textSpanEnd(nextChange.span);
|
||||
const newEnd2 = oldStart2 + nextChange.newLength;
|
||||
|
||||
oldStartN = Math.min(oldStart1, oldStart2);
|
||||
oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
|
||||
|
||||
@@ -140,7 +140,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
it("Correct sourcemap content for " + fileName, () => {
|
||||
if (options.sourceMap || options.inlineSourceMap) {
|
||||
Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => {
|
||||
let record = result.getSourceMapRecord();
|
||||
const record = result.getSourceMapRecord();
|
||||
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
|
||||
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required.
|
||||
return null;
|
||||
@@ -159,7 +159,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// check js output
|
||||
Harness.Baseline.runBaseline("Correct JS output for " + fileName, justName.replace(/\.tsx?/, ".js"), () => {
|
||||
let tsCode = "";
|
||||
let tsSources = otherFiles.concat(toBeCompiled);
|
||||
const tsSources = otherFiles.concat(toBeCompiled);
|
||||
if (tsSources.length > 1) {
|
||||
tsCode += "//// [" + fileName + "] ////\r\n\r\n";
|
||||
}
|
||||
@@ -184,7 +184,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
}
|
||||
|
||||
let declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) {
|
||||
const declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) {
|
||||
harnessCompiler.setCompilerSettings(tcSettings);
|
||||
}, options);
|
||||
|
||||
@@ -257,15 +257,15 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// These types are equivalent, but depend on what order the compiler observed
|
||||
// certain parts of the program.
|
||||
|
||||
let allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||
const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||
|
||||
let fullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ true);
|
||||
let pullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ false);
|
||||
const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ true);
|
||||
const pullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ false);
|
||||
|
||||
let fullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
let pullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
const fullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
const pullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
|
||||
for (let sourceFile of allFiles) {
|
||||
for (const sourceFile of allFiles) {
|
||||
fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName);
|
||||
pullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName);
|
||||
}
|
||||
@@ -294,11 +294,11 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
return;
|
||||
|
||||
function checkBaseLines(isSymbolBaseLine: boolean) {
|
||||
let fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine);
|
||||
let pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine);
|
||||
const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine);
|
||||
const pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine);
|
||||
|
||||
let fullExtension = isSymbolBaseLine ? ".symbols" : ".types";
|
||||
let pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull";
|
||||
const fullExtension = isSymbolBaseLine ? ".symbols" : ".types";
|
||||
const pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull";
|
||||
|
||||
if (fullBaseLine !== pullBaseLine) {
|
||||
Harness.Baseline.runBaseline("Correct full information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine);
|
||||
@@ -310,24 +310,24 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function generateBaseLine(typeWriterResults: ts.Map<TypeWriterResult[]>, isSymbolBaseline: boolean): string {
|
||||
let typeLines: string[] = [];
|
||||
let typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {};
|
||||
const typeLines: string[] = [];
|
||||
const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {};
|
||||
|
||||
allFiles.forEach(file => {
|
||||
let codeLines = file.content.split("\n");
|
||||
const codeLines = file.content.split("\n");
|
||||
typeWriterResults[file.unitName].forEach(result => {
|
||||
if (isSymbolBaseline && !result.symbol) {
|
||||
return;
|
||||
}
|
||||
|
||||
let typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type;
|
||||
let formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString;
|
||||
const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type;
|
||||
const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString;
|
||||
if (!typeMap[file.unitName]) {
|
||||
typeMap[file.unitName] = {};
|
||||
}
|
||||
|
||||
let typeInfo = [formattedLine];
|
||||
let existingTypeInfo = typeMap[file.unitName][result.line];
|
||||
const existingTypeInfo = typeMap[file.unitName][result.line];
|
||||
if (existingTypeInfo) {
|
||||
typeInfo = existingTypeInfo.concat(typeInfo);
|
||||
}
|
||||
@@ -336,10 +336,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
typeLines.push("=== " + file.unitName + " ===\r\n");
|
||||
for (let i = 0; i < codeLines.length; i++) {
|
||||
let currentCodeLine = codeLines[i];
|
||||
const currentCodeLine = codeLines[i];
|
||||
typeLines.push(currentCodeLine + "\r\n");
|
||||
if (typeMap[file.unitName]) {
|
||||
let typeInfo = typeMap[file.unitName][i];
|
||||
const typeInfo = typeMap[file.unitName][i];
|
||||
if (typeInfo) {
|
||||
typeInfo.forEach(ty => {
|
||||
typeLines.push(">" + ty + "\r\n");
|
||||
@@ -367,13 +367,13 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
public initializeTests() {
|
||||
describe(this.testSuiteName + " tests", () => {
|
||||
describe("Setup compiler for compiler baselines", () => {
|
||||
let harnessCompiler = Harness.Compiler.getCompiler();
|
||||
const harnessCompiler = Harness.Compiler.getCompiler();
|
||||
this.parseOptions();
|
||||
});
|
||||
|
||||
// this will set up a series of describe/it blocks to run between the setup and cleanup phases
|
||||
if (this.tests.length === 0) {
|
||||
let testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true });
|
||||
const testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true });
|
||||
testFiles.forEach(fn => {
|
||||
fn = fn.replace(/\\/g, "/");
|
||||
this.checkTestCodeOutput(fn);
|
||||
@@ -392,7 +392,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
this.decl = false;
|
||||
this.output = false;
|
||||
|
||||
let opts = this.options.split(",");
|
||||
const opts = this.options.split(",");
|
||||
for (let i = 0; i < opts.length; i++) {
|
||||
switch (opts[i]) {
|
||||
case "error":
|
||||
|
||||
+278
-278
File diff suppressed because it is too large
Load Diff
@@ -45,10 +45,10 @@ class FourSlashRunner extends RunnerBase {
|
||||
this.tests.forEach((fn: string) => {
|
||||
describe(fn, () => {
|
||||
fn = ts.normalizeSlashes(fn);
|
||||
let justName = fn.replace(/^.*[\\\/]/, "");
|
||||
const justName = fn.replace(/^.*[\\\/]/, "");
|
||||
|
||||
// Convert to relative path
|
||||
let testIndex = fn.indexOf("tests/");
|
||||
const testIndex = fn.indexOf("tests/");
|
||||
if (testIndex >= 0) fn = fn.substr(testIndex);
|
||||
|
||||
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
|
||||
@@ -60,21 +60,21 @@ class FourSlashRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
describe("Generate Tao XML", () => {
|
||||
let invalidReasons: any = {};
|
||||
const invalidReasons: any = {};
|
||||
FourSlash.xmlData.forEach(xml => {
|
||||
if (xml.invalidReason !== null) {
|
||||
invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1;
|
||||
}
|
||||
});
|
||||
let invalidReport: { reason: string; count: number }[] = [];
|
||||
for (let reason in invalidReasons) {
|
||||
const invalidReport: { reason: string; count: number }[] = [];
|
||||
for (const reason in invalidReasons) {
|
||||
if (invalidReasons.hasOwnProperty(reason)) {
|
||||
invalidReport.push({ reason: reason, count: invalidReasons[reason] });
|
||||
}
|
||||
}
|
||||
invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1);
|
||||
|
||||
let lines: string[] = [];
|
||||
const lines: string[] = [];
|
||||
lines.push("<!-- Blocked Test Report");
|
||||
invalidReport.forEach((reasonAndCount) => {
|
||||
lines.push(reasonAndCount.count + " tests blocked by " + reasonAndCount.reason);
|
||||
|
||||
+105
-103
@@ -67,7 +67,7 @@ namespace Utils {
|
||||
}
|
||||
|
||||
export function evalFile(fileContents: string, fileName: string, nodeContext?: any) {
|
||||
let environment = getExecutionEnvironment();
|
||||
const environment = getExecutionEnvironment();
|
||||
switch (environment) {
|
||||
case ExecutionEnvironment.CScript:
|
||||
case ExecutionEnvironment.Browser:
|
||||
@@ -121,11 +121,11 @@ namespace Utils {
|
||||
}
|
||||
|
||||
export function memoize<T extends Function>(f: T): T {
|
||||
let cache: { [idx: string]: any } = {};
|
||||
const cache: { [idx: string]: any } = {};
|
||||
|
||||
return <any>(function () {
|
||||
let key = Array.prototype.join.call(arguments);
|
||||
let cachedResult = cache[key];
|
||||
const key = Array.prototype.join.call(arguments);
|
||||
const cachedResult = cache[key];
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
}
|
||||
@@ -172,14 +172,14 @@ namespace Utils {
|
||||
currentPos = array.end;
|
||||
});
|
||||
|
||||
let childNodesAndArrays: any[] = [];
|
||||
const childNodesAndArrays: any[] = [];
|
||||
ts.forEachChild(node, child => { childNodesAndArrays.push(child); }, array => { childNodesAndArrays.push(array); });
|
||||
|
||||
for (let childName in node) {
|
||||
for (const childName in node) {
|
||||
if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator") {
|
||||
continue;
|
||||
}
|
||||
let child = (<any>node)[childName];
|
||||
const child = (<any>node)[childName];
|
||||
if (isNodeOrArray(child)) {
|
||||
assert.isFalse(childNodesAndArrays.indexOf(child) < 0,
|
||||
"Missing child when forEach'ing over node: " + (<any>ts).SyntaxKind[node.kind] + "-" + childName);
|
||||
@@ -247,7 +247,7 @@ namespace Utils {
|
||||
function getParserContextFlagName(f: number) { return getFlagName((<any>ts).ParserContextFlags, f); }
|
||||
|
||||
function serializeNode(n: ts.Node): any {
|
||||
let o: any = { kind: getKindName(n.kind) };
|
||||
const o: any = { kind: getKindName(n.kind) };
|
||||
if (ts.containsParseError(n)) {
|
||||
o.containsParseError = true;
|
||||
}
|
||||
@@ -329,8 +329,8 @@ namespace Utils {
|
||||
assert.equal(array1.length, array2.length, "array1.length !== array2.length");
|
||||
|
||||
for (let i = 0, n = array1.length; i < n; i++) {
|
||||
let d1 = array1[i];
|
||||
let d2 = array2[i];
|
||||
const d1 = array1[i];
|
||||
const d2 = array2[i];
|
||||
|
||||
assert.equal(d1.start, d2.start, "d1.start !== d2.start");
|
||||
assert.equal(d1.length, d2.length, "d1.length !== d2.length");
|
||||
@@ -361,14 +361,14 @@ namespace Utils {
|
||||
|
||||
ts.forEachChild(node1,
|
||||
child1 => {
|
||||
let childName = findChildName(node1, child1);
|
||||
let child2: ts.Node = (<any>node2)[childName];
|
||||
const childName = findChildName(node1, child1);
|
||||
const child2: ts.Node = (<any>node2)[childName];
|
||||
|
||||
assertStructuralEquals(child1, child2);
|
||||
},
|
||||
(array1: ts.NodeArray<ts.Node>) => {
|
||||
let childName = findChildName(node1, array1);
|
||||
let array2: ts.NodeArray<ts.Node> = (<any>node2)[childName];
|
||||
const childName = findChildName(node1, array1);
|
||||
const array2: ts.NodeArray<ts.Node> = (<any>node2)[childName];
|
||||
|
||||
assertArrayStructuralEquals(array1, array2);
|
||||
});
|
||||
@@ -391,7 +391,7 @@ namespace Utils {
|
||||
}
|
||||
|
||||
function findChildName(parent: any, child: any) {
|
||||
for (let name in parent) {
|
||||
for (const name in parent) {
|
||||
if (parent.hasOwnProperty(name) && parent[name] === child) {
|
||||
return name;
|
||||
}
|
||||
@@ -408,8 +408,8 @@ namespace Harness.Path {
|
||||
|
||||
export function filePath(fullPath: string) {
|
||||
fullPath = ts.normalizeSlashes(fullPath);
|
||||
let components = fullPath.split("/");
|
||||
let path: string[] = components.slice(0, components.length - 1);
|
||||
const components = fullPath.split("/");
|
||||
const path: string[] = components.slice(0, components.length - 1);
|
||||
return path.join("/") + "/";
|
||||
}
|
||||
}
|
||||
@@ -510,15 +510,15 @@ namespace Harness {
|
||||
return paths;
|
||||
}
|
||||
|
||||
let folder: any = fso.GetFolder(path);
|
||||
let paths: string[] = [];
|
||||
const folder: any = fso.GetFolder(path);
|
||||
const paths: string[] = [];
|
||||
|
||||
return filesInFolder(folder, path);
|
||||
};
|
||||
}
|
||||
|
||||
export namespace Node {
|
||||
declare let require: any;
|
||||
declare const require: any;
|
||||
let fs: any, pathModule: any;
|
||||
if (require) {
|
||||
fs = require("fs");
|
||||
@@ -579,10 +579,10 @@ namespace Harness {
|
||||
function filesInFolder(folder: string): string[] {
|
||||
let paths: string[] = [];
|
||||
|
||||
let files = fs.readdirSync(folder);
|
||||
const files = fs.readdirSync(folder);
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let pathToFile = pathModule.join(folder, files[i]);
|
||||
let stat = fs.statSync(pathToFile);
|
||||
const pathToFile = pathModule.join(folder, files[i]);
|
||||
const stat = fs.statSync(pathToFile);
|
||||
if (options.recursive && stat.isDirectory()) {
|
||||
paths = paths.concat(filesInFolder(pathToFile));
|
||||
}
|
||||
@@ -606,7 +606,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
export namespace Network {
|
||||
let serverRoot = "http://localhost:8888/";
|
||||
const serverRoot = "http://localhost:8888/";
|
||||
|
||||
export const newLine = () => harnessNewLine;
|
||||
export const useCaseSensitiveFileNames = () => false;
|
||||
@@ -615,7 +615,7 @@ namespace Harness {
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => {};
|
||||
|
||||
let supportsCodePage = () => false;
|
||||
const supportsCodePage = () => false;
|
||||
export let log = (s: string) => console.log(s);
|
||||
|
||||
namespace Http {
|
||||
@@ -626,7 +626,7 @@ namespace Harness {
|
||||
|
||||
/// Ask the server to use node's path.resolve to resolve the given path
|
||||
function getResolvedPathFromServer(path: string) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
try {
|
||||
xhr.open("GET", path + "?resolve", false);
|
||||
xhr.send();
|
||||
@@ -645,7 +645,7 @@ namespace Harness {
|
||||
|
||||
/// Ask the server for the contents of the file at the given URL via a simple GET request
|
||||
export function getFileFromServerSync(url: string): XHRResponse {
|
||||
let xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
try {
|
||||
xhr.open("GET", url, false);
|
||||
xhr.send();
|
||||
@@ -659,9 +659,9 @@ namespace Harness {
|
||||
|
||||
/// Submit a POST request to the server to do the given action (ex WRITE, DELETE) on the provided URL
|
||||
export function writeToServerSync(url: string, action: string, contents?: string): XHRResponse {
|
||||
let xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
try {
|
||||
let actionMsg = "?action=" + action;
|
||||
const actionMsg = "?action=" + action;
|
||||
xhr.open("POST", url + actionMsg, false);
|
||||
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
|
||||
xhr.send(contents);
|
||||
@@ -712,14 +712,14 @@ namespace Harness {
|
||||
export const resolvePath = (path: string) => directoryName(path);
|
||||
|
||||
export function fileExists(path: string): boolean {
|
||||
let response = Http.getFileFromServerSync(serverRoot + path);
|
||||
const response = Http.getFileFromServerSync(serverRoot + path);
|
||||
return response.status === 200;
|
||||
}
|
||||
|
||||
export function _listFilesImpl(path: string, spec?: RegExp, options?: any) {
|
||||
let response = Http.getFileFromServerSync(serverRoot + path);
|
||||
const response = Http.getFileFromServerSync(serverRoot + path);
|
||||
if (response.status === 200) {
|
||||
let results = response.responseText.split(",");
|
||||
const results = response.responseText.split(",");
|
||||
if (spec) {
|
||||
return results.filter(file => spec.test(file));
|
||||
}
|
||||
@@ -734,7 +734,7 @@ namespace Harness {
|
||||
export let listFiles = Utils.memoize(_listFilesImpl);
|
||||
|
||||
export function readFile(file: string) {
|
||||
let response = Http.getFileFromServerSync(serverRoot + file);
|
||||
const response = Http.getFileFromServerSync(serverRoot + file);
|
||||
if (response.status === 200) {
|
||||
return response.responseText;
|
||||
}
|
||||
@@ -856,10 +856,10 @@ namespace Harness {
|
||||
public reset() { this.fileCollection = {}; }
|
||||
|
||||
public toArray(): { fileName: string; file: WriterAggregator; }[] {
|
||||
let result: { fileName: string; file: WriterAggregator; }[] = [];
|
||||
for (let p in this.fileCollection) {
|
||||
const result: { fileName: string; file: WriterAggregator; }[] = [];
|
||||
for (const p in this.fileCollection) {
|
||||
if (this.fileCollection.hasOwnProperty(p)) {
|
||||
let current = <Harness.Compiler.WriterAggregator>this.fileCollection[p];
|
||||
const current = <Harness.Compiler.WriterAggregator>this.fileCollection[p];
|
||||
if (current.lines.length > 0) {
|
||||
if (p.indexOf(".d.ts") !== -1) { current.lines.unshift(["////[", Path.getFileName(p), "]"].join("")); }
|
||||
result.push({ fileName: p, file: this.fileCollection[p] });
|
||||
@@ -878,7 +878,7 @@ namespace Harness {
|
||||
const shouldAssertInvariants = !Harness.lightMode;
|
||||
|
||||
// Only set the parent nodes if we're asserting inletiants. We don't need them otherwise.
|
||||
let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants);
|
||||
const result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants);
|
||||
|
||||
if (shouldAssertInvariants) {
|
||||
Utils.assertInvariants(result, /*parent:*/ undefined);
|
||||
@@ -916,14 +916,16 @@ namespace Harness {
|
||||
return useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
let filemap: { [fileName: string]: ts.SourceFile; } = {};
|
||||
let getCurrentDirectory = currentDirectory === undefined ? Harness.IO.getCurrentDirectory : () => currentDirectory;
|
||||
const filemap: { [fileName: string]: ts.SourceFile; } = {};
|
||||
const getCurrentDirectory = currentDirectory === undefined ? Harness.IO.getCurrentDirectory : () => currentDirectory;
|
||||
|
||||
// Register input files
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
let fileName = ts.normalizePath(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
const fileName = ts.normalizePath(file.unitName);
|
||||
const sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
filemap[getCanonicalFileName(fileName)] = sourceFile;
|
||||
filemap[getCanonicalFileName(ts.getNormalizedAbsolutePath(fileName, getCurrentDirectory()))] = sourceFile;
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
@@ -934,11 +936,11 @@ namespace Harness {
|
||||
return filemap[getCanonicalFileName(fn)];
|
||||
}
|
||||
else if (currentDirectory) {
|
||||
let canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory));
|
||||
const canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory));
|
||||
return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined;
|
||||
}
|
||||
else if (fn === fourslashFileName) {
|
||||
let tsFn = "tests/cases/fourslash/" + fourslashFileName;
|
||||
const tsFn = "tests/cases/fourslash/" + fourslashFileName;
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
return fourslashSourceFile;
|
||||
}
|
||||
@@ -951,7 +953,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
let newLine =
|
||||
const newLine =
|
||||
newLineKind === ts.NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed :
|
||||
newLineKind === ts.NewLineKind.LineFeed ? lineFeed :
|
||||
Harness.IO.newLine();
|
||||
@@ -989,8 +991,8 @@ namespace Harness {
|
||||
function getCommandLineOption(name: string): ts.CommandLineOption {
|
||||
if (!optionsIndex) {
|
||||
optionsIndex = {};
|
||||
let optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations);
|
||||
for (let option of optionDeclarations) {
|
||||
const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations);
|
||||
for (const option of optionDeclarations) {
|
||||
optionsIndex[option.name.toLowerCase()] = option;
|
||||
}
|
||||
}
|
||||
@@ -998,13 +1000,13 @@ namespace Harness {
|
||||
}
|
||||
|
||||
export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void {
|
||||
for (let name in settings) {
|
||||
for (const name in settings) {
|
||||
if (settings.hasOwnProperty(name)) {
|
||||
let value = settings[name];
|
||||
const value = settings[name];
|
||||
if (value === undefined) {
|
||||
throw new Error(`Cannot have undefined value for compiler option '${name}'.`);
|
||||
}
|
||||
let option = getCommandLineOption(name);
|
||||
const option = getCommandLineOption(name);
|
||||
if (option) {
|
||||
switch (option.type) {
|
||||
case "boolean":
|
||||
@@ -1100,37 +1102,37 @@ namespace Harness {
|
||||
settingsCallback(null);
|
||||
}
|
||||
|
||||
let newLine = "\r\n";
|
||||
const newLine = "\r\n";
|
||||
|
||||
// Parse settings
|
||||
setCompilerOptionsFromHarnessSetting(this.settings, options);
|
||||
|
||||
// Files from built\local that are requested by test "@includeBuiltFiles" to be in the context.
|
||||
// Treat them as library files, so include them in build, but not in baselines.
|
||||
let includeBuiltFiles: { unitName: string; content: string }[] = [];
|
||||
const includeBuiltFiles: { unitName: string; content: string }[] = [];
|
||||
if (options.includeBuiltFile) {
|
||||
let builtFileName = libFolder + options.includeBuiltFile;
|
||||
const builtFileName = libFolder + options.includeBuiltFile;
|
||||
includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) });
|
||||
}
|
||||
|
||||
let useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : Harness.IO.useCaseSensitiveFileNames();
|
||||
const useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : Harness.IO.useCaseSensitiveFileNames();
|
||||
|
||||
let fileOutputs: GeneratedFile[] = [];
|
||||
const fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
let programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
const programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
|
||||
let compilerHost = createCompilerHost(
|
||||
const compilerHost = createCompilerHost(
|
||||
inputFiles.concat(includeBuiltFiles).concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine);
|
||||
let program = ts.createProgram(programFiles, options, compilerHost);
|
||||
const program = ts.createProgram(programFiles, options, compilerHost);
|
||||
|
||||
let emitResult = program.emit();
|
||||
const emitResult = program.emit();
|
||||
|
||||
let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
const errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
this.lastErrors = errors;
|
||||
|
||||
let result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
const result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
onComplete(result, program);
|
||||
|
||||
return options;
|
||||
@@ -1147,8 +1149,8 @@ namespace Harness {
|
||||
throw new Error("There were no errors and declFiles generated did not match number of js files generated");
|
||||
}
|
||||
|
||||
let declInputFiles: { unitName: string; content: string }[] = [];
|
||||
let declOtherFiles: { unitName: string; content: string }[] = [];
|
||||
const declInputFiles: { unitName: string; content: string }[] = [];
|
||||
const declOtherFiles: { unitName: string; content: string }[] = [];
|
||||
let declResult: Harness.Compiler.CompilerResult;
|
||||
|
||||
// if the .d.ts is non-empty, confirm it compiles correctly as well
|
||||
@@ -1166,18 +1168,18 @@ namespace Harness {
|
||||
dtsFiles.push(file);
|
||||
}
|
||||
else if (isTS(file.unitName)) {
|
||||
let declFile = findResultCodeFile(file.unitName);
|
||||
const declFile = findResultCodeFile(file.unitName);
|
||||
if (!findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) {
|
||||
dtsFiles.push({ unitName: declFile.fileName, content: declFile.code });
|
||||
}
|
||||
}
|
||||
|
||||
function findResultCodeFile(fileName: string) {
|
||||
let sourceFile = result.program.getSourceFile(fileName);
|
||||
const sourceFile = result.program.getSourceFile(fileName);
|
||||
assert(sourceFile, "Program has no source file with name '" + fileName + "'");
|
||||
// Is this file going to be emitted separately
|
||||
let sourceFileName: string;
|
||||
let outFile = options.outFile || options.out;
|
||||
const outFile = options.outFile || options.out;
|
||||
if (ts.isExternalModule(sourceFile) || !outFile) {
|
||||
if (options.outDir) {
|
||||
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram);
|
||||
@@ -1193,7 +1195,7 @@ namespace Harness {
|
||||
sourceFileName = outFile;
|
||||
}
|
||||
|
||||
let dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts";
|
||||
const dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts";
|
||||
|
||||
return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined);
|
||||
}
|
||||
@@ -1218,7 +1220,7 @@ namespace Harness {
|
||||
let errorOutput = "";
|
||||
ts.forEach(diagnostics, diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
let lineAndCharacter = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
const lineAndCharacter = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): ";
|
||||
}
|
||||
|
||||
@@ -1230,14 +1232,14 @@ namespace Harness {
|
||||
|
||||
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) {
|
||||
diagnostics.sort(ts.compareDiagnostics);
|
||||
let outputLines: string[] = [];
|
||||
const outputLines: string[] = [];
|
||||
// Count up all errors that were found in files other than lib.d.ts so we don't miss any
|
||||
let totalErrorsReportedInNonLibraryFiles = 0;
|
||||
|
||||
function outputErrorText(error: ts.Diagnostic) {
|
||||
let message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine());
|
||||
const message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine());
|
||||
|
||||
let errLines = RunnerBase.removeFullPaths(message)
|
||||
const errLines = RunnerBase.removeFullPaths(message)
|
||||
.split("\n")
|
||||
.map(s => s.length > 0 && s.charAt(s.length - 1) === "\r" ? s.substr(0, s.length - 1) : s)
|
||||
.filter(s => s.length > 0)
|
||||
@@ -1255,14 +1257,14 @@ namespace Harness {
|
||||
}
|
||||
|
||||
// Report global errors
|
||||
let globalErrors = diagnostics.filter(err => !err.file);
|
||||
const globalErrors = diagnostics.filter(err => !err.file);
|
||||
globalErrors.forEach(outputErrorText);
|
||||
|
||||
// 'merge' the lines of each input file with any errors associated with it
|
||||
inputFiles.filter(f => f.content !== undefined).forEach(inputFile => {
|
||||
// Filter down to the errors in the file
|
||||
let fileErrors = diagnostics.filter(e => {
|
||||
let errFn = e.file;
|
||||
const fileErrors = diagnostics.filter(e => {
|
||||
const errFn = e.file;
|
||||
return errFn && errFn.fileName === inputFile.unitName;
|
||||
});
|
||||
|
||||
@@ -1276,7 +1278,7 @@ namespace Harness {
|
||||
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
|
||||
// we have to string-based splitting instead and try to figure out the delimiting chars
|
||||
|
||||
let lineStarts = ts.computeLineStarts(inputFile.content);
|
||||
const lineStarts = ts.computeLineStarts(inputFile.content);
|
||||
let lines = inputFile.content.split("\n");
|
||||
if (lines.length === 1) {
|
||||
lines = lines[0].split("\r");
|
||||
@@ -1287,7 +1289,7 @@ namespace Harness {
|
||||
line = line.substr(0, line.length - 1);
|
||||
}
|
||||
|
||||
let thisLineStart = lineStarts[lineIndex];
|
||||
const thisLineStart = lineStarts[lineIndex];
|
||||
let nextLineStart: number;
|
||||
// On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly
|
||||
if (lineIndex === lines.length - 1) {
|
||||
@@ -1300,14 +1302,14 @@ namespace Harness {
|
||||
outputLines.push(" " + line);
|
||||
fileErrors.forEach(err => {
|
||||
// Does any error start or continue on to this line? Emit squiggles
|
||||
let end = ts.textSpanEnd(err);
|
||||
const end = ts.textSpanEnd(err);
|
||||
if ((end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
|
||||
// How many characters from the start of this line the error starts at (could be positive or negative)
|
||||
let relativeOffset = err.start - thisLineStart;
|
||||
const relativeOffset = err.start - thisLineStart;
|
||||
// How many characters of the error are on this line (might be longer than this line in reality)
|
||||
let length = (end - err.start) - Math.max(0, thisLineStart - err.start);
|
||||
const length = (end - err.start) - Math.max(0, thisLineStart - err.start);
|
||||
// Calculate the start of the squiggle
|
||||
let squiggleStart = Math.max(0, relativeOffset);
|
||||
const squiggleStart = Math.max(0, relativeOffset);
|
||||
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
|
||||
outputLines.push(" " + line.substr(0, squiggleStart).replace(/[^\s]/g, " ") + new Array(Math.min(length, line.length - squiggleStart) + 1).join("~"));
|
||||
|
||||
@@ -1327,11 +1329,11 @@ namespace Harness {
|
||||
assert.equal(markedErrorCount, fileErrors.length, "count of errors in " + inputFile.unitName);
|
||||
});
|
||||
|
||||
let numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
const numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
return diagnostic.file && (isLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName));
|
||||
});
|
||||
|
||||
let numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
const numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
// Count an error generated from tests262-harness folder.This should only apply for test262
|
||||
return diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0;
|
||||
});
|
||||
@@ -1349,7 +1351,7 @@ namespace Harness {
|
||||
|
||||
// Emit them
|
||||
let result = "";
|
||||
for (let outputFile of outputFiles) {
|
||||
for (const outputFile of outputFiles) {
|
||||
// Some extra spacing if this isn't the first file
|
||||
if (result.length) {
|
||||
result += "\r\n\r\n";
|
||||
@@ -1364,7 +1366,7 @@ namespace Harness {
|
||||
return result;
|
||||
|
||||
function cleanName(fn: string) {
|
||||
let lastSlash = ts.normalizeSlashes(fn).lastIndexOf("/");
|
||||
const lastSlash = ts.normalizeSlashes(fn).lastIndexOf("/");
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
}
|
||||
}
|
||||
@@ -1473,10 +1475,10 @@ namespace Harness {
|
||||
}
|
||||
|
||||
// Regex for parsing options in the format "@Alpha: Value of any sort"
|
||||
let optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
const optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSettings {
|
||||
let opts: CompilerSettings = {};
|
||||
const opts: CompilerSettings = {};
|
||||
|
||||
let match: RegExpExecArray;
|
||||
while ((match = optionRegex.exec(content)) != null) {
|
||||
@@ -1488,12 +1490,12 @@ namespace Harness {
|
||||
|
||||
/** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */
|
||||
export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSettings; testUnitData: TestUnitData[]; } {
|
||||
let settings = extractCompilerSettings(code);
|
||||
const settings = extractCompilerSettings(code);
|
||||
|
||||
// List of all the subfiles we've parsed out
|
||||
let testUnitData: TestUnitData[] = [];
|
||||
const testUnitData: TestUnitData[] = [];
|
||||
|
||||
let lines = Utils.splitContentByNewlines(code);
|
||||
const lines = Utils.splitContentByNewlines(code);
|
||||
|
||||
// Stuff related to the subfile we're parsing
|
||||
let currentFileContent: string = null;
|
||||
@@ -1502,12 +1504,12 @@ namespace Harness {
|
||||
let refs: string[] = [];
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
let line = lines[i];
|
||||
let testMetaData = optionRegex.exec(line);
|
||||
const line = lines[i];
|
||||
const testMetaData = optionRegex.exec(line);
|
||||
if (testMetaData) {
|
||||
// Comment line, check for global/file @options and record them
|
||||
optionRegex.lastIndex = 0;
|
||||
let metaDataName = testMetaData[1].toLowerCase();
|
||||
const metaDataName = testMetaData[1].toLowerCase();
|
||||
if (metaDataName === "filename") {
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
}
|
||||
@@ -1518,7 +1520,7 @@ namespace Harness {
|
||||
// New metadata statement after having collected some code to go with the previous metadata
|
||||
if (currentFileName) {
|
||||
// Store result file
|
||||
let newTestFile = {
|
||||
const newTestFile = {
|
||||
content: currentFileContent,
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
@@ -1556,7 +1558,7 @@ namespace Harness {
|
||||
currentFileName = testUnitData.length > 0 ? currentFileName : Path.getFileName(fileName);
|
||||
|
||||
// EOF, push whatever remains
|
||||
let newTestFile2 = {
|
||||
const newTestFile2 = {
|
||||
content: currentFileContent || "",
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
@@ -1604,7 +1606,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
let fileCache: { [idx: string]: boolean } = {};
|
||||
const fileCache: { [idx: string]: boolean } = {};
|
||||
function generateActual(actualFileName: string, generateContent: () => string): string {
|
||||
// For now this is written using TypeScript, because sys is not available when running old test cases.
|
||||
// But we need to move to sys once we have
|
||||
@@ -1615,7 +1617,7 @@ namespace Harness {
|
||||
return;
|
||||
}
|
||||
|
||||
let parentDirectory = IO.directoryName(dirName);
|
||||
const parentDirectory = IO.directoryName(dirName);
|
||||
if (parentDirectory != "") {
|
||||
createDirectoryStructure(parentDirectory);
|
||||
}
|
||||
@@ -1631,7 +1633,7 @@ namespace Harness {
|
||||
IO.deleteFile(actualFileName);
|
||||
}
|
||||
|
||||
let actual = generateContent();
|
||||
const actual = generateContent();
|
||||
|
||||
if (actual === undefined) {
|
||||
throw new Error("The generated content was \"undefined\". Return \"null\" if no baselining is required.\"");
|
||||
@@ -1654,7 +1656,7 @@ namespace Harness {
|
||||
return;
|
||||
}
|
||||
|
||||
let refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
const refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
if (actual === null) {
|
||||
actual = "<no content>";
|
||||
@@ -1669,10 +1671,10 @@ namespace Harness {
|
||||
}
|
||||
|
||||
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
|
||||
let encoded_actual = Utils.encodeString(actual);
|
||||
const encoded_actual = Utils.encodeString(actual);
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
let errMsg = "The baseline file " + relativeFileName + " has changed";
|
||||
const errMsg = "The baseline file " + relativeFileName + " has changed";
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
}
|
||||
@@ -1685,17 +1687,17 @@ namespace Harness {
|
||||
opts?: BaselineOptions): void {
|
||||
|
||||
let actual = <string>undefined;
|
||||
let actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
if (runImmediately) {
|
||||
actual = generateActual(actualFileName, generateContent);
|
||||
let comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
const comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
|
||||
}
|
||||
else {
|
||||
actual = generateActual(actualFileName, generateContent);
|
||||
|
||||
let comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
const comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
|
||||
}
|
||||
}
|
||||
@@ -1710,7 +1712,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
export function getDefaultLibraryFile(io: Harness.IO): { unitName: string, content: string } {
|
||||
let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts";
|
||||
const libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts";
|
||||
return {
|
||||
unitName: libFile,
|
||||
content: io.readFile(libFile)
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace Harness.LanguageService {
|
||||
|
||||
public editContent(start: number, end: number, newText: string): void {
|
||||
// Apply edits
|
||||
let prefix = this.content.substring(0, start);
|
||||
let middle = newText;
|
||||
let suffix = this.content.substring(end);
|
||||
const prefix = this.content.substring(0, start);
|
||||
const middle = newText;
|
||||
const suffix = this.content.substring(end);
|
||||
this.setContent(prefix + middle + suffix);
|
||||
|
||||
// Store edit range + new length of script
|
||||
@@ -48,10 +48,10 @@ namespace Harness.LanguageService {
|
||||
return ts.unchangedTextChangeRange;
|
||||
}
|
||||
|
||||
let initialEditRangeIndex = this.editRanges.length - (this.version - startVersion);
|
||||
let lastEditRangeIndex = this.editRanges.length - (this.version - endVersion);
|
||||
const initialEditRangeIndex = this.editRanges.length - (this.version - startVersion);
|
||||
const lastEditRangeIndex = this.editRanges.length - (this.version - endVersion);
|
||||
|
||||
let entries = this.editRanges.slice(initialEditRangeIndex, lastEditRangeIndex);
|
||||
const entries = this.editRanges.slice(initialEditRangeIndex, lastEditRangeIndex);
|
||||
return ts.collapseTextChangeRangesAcrossMultipleVersions(entries.map(e => e.textChangeRange));
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
|
||||
public getChangeRange(oldScript: ts.IScriptSnapshot): ts.TextChangeRange {
|
||||
let oldShim = <ScriptSnapshot>oldScript;
|
||||
const oldShim = <ScriptSnapshot>oldScript;
|
||||
return this.scriptInfo.getTextChangeRangeBetweenVersions(oldShim.version, this.version);
|
||||
}
|
||||
}
|
||||
@@ -92,9 +92,9 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
|
||||
public getChangeRange(oldScript: ts.ScriptSnapshotShim): string {
|
||||
let oldShim = <ScriptSnapshotProxy>oldScript;
|
||||
const oldShim = <ScriptSnapshotProxy>oldScript;
|
||||
|
||||
let range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot);
|
||||
const range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot);
|
||||
if (range === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
|
||||
public getFilenames(): string[] {
|
||||
let fileNames: string[] = [];
|
||||
const fileNames: string[] = [];
|
||||
ts.forEachKey(this.fileNameToScript, (fileName) => { fileNames.push(fileName); });
|
||||
return fileNames;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
|
||||
public editScript(fileName: string, start: number, end: number, newText: string) {
|
||||
let script = this.getScriptInfo(fileName);
|
||||
const script = this.getScriptInfo(fileName);
|
||||
if (script !== undefined) {
|
||||
script.editContent(start, end, newText);
|
||||
return;
|
||||
@@ -161,7 +161,7 @@ namespace Harness.LanguageService {
|
||||
* @param col 0 based index
|
||||
*/
|
||||
public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter {
|
||||
let script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
const script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
|
||||
return ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
@@ -176,11 +176,11 @@ namespace Harness.LanguageService {
|
||||
getDefaultLibFileName(): string { return ""; }
|
||||
getScriptFileNames(): string[] { return this.getFilenames(); }
|
||||
getScriptSnapshot(fileName: string): ts.IScriptSnapshot {
|
||||
let script = this.getScriptInfo(fileName);
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? new ScriptSnapshot(script) : undefined;
|
||||
}
|
||||
getScriptVersion(fileName: string): string {
|
||||
let script = this.getScriptInfo(fileName);
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? script.version.toString() : undefined;
|
||||
}
|
||||
|
||||
@@ -211,20 +211,20 @@ namespace Harness.LanguageService {
|
||||
this.nativeHost = new NativeLanguageServiceHost(cancellationToken, options);
|
||||
|
||||
if (preprocessToResolve) {
|
||||
let compilerOptions = this.nativeHost.getCompilationSettings();
|
||||
let moduleResolutionHost: ts.ModuleResolutionHost = {
|
||||
const compilerOptions = this.nativeHost.getCompilationSettings();
|
||||
const moduleResolutionHost: ts.ModuleResolutionHost = {
|
||||
fileExists: fileName => this.getScriptInfo(fileName) !== undefined,
|
||||
readFile: fileName => {
|
||||
let scriptInfo = this.getScriptInfo(fileName);
|
||||
const scriptInfo = this.getScriptInfo(fileName);
|
||||
return scriptInfo && scriptInfo.content;
|
||||
}
|
||||
};
|
||||
this.getModuleResolutionsForFile = (fileName) => {
|
||||
let scriptInfo = this.getScriptInfo(fileName);
|
||||
let preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true);
|
||||
let imports: ts.Map<string> = {};
|
||||
for (let module of preprocessInfo.importedFiles) {
|
||||
let resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost);
|
||||
const scriptInfo = this.getScriptInfo(fileName);
|
||||
const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true);
|
||||
const imports: ts.Map<string> = {};
|
||||
for (const module of preprocessInfo.importedFiles) {
|
||||
const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost);
|
||||
if (resolutionInfo.resolvedModule) {
|
||||
imports[module.fileName] = resolutionInfo.resolvedModule.resolvedFileName;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ namespace Harness.LanguageService {
|
||||
getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); }
|
||||
getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); }
|
||||
getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim {
|
||||
let nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
}
|
||||
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
|
||||
@@ -257,7 +257,7 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
|
||||
readFile(fileName: string) {
|
||||
let snapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
const snapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
log(s: string): void { this.nativeHost.log(s); }
|
||||
@@ -272,13 +272,13 @@ namespace Harness.LanguageService {
|
||||
throw new Error("NYI");
|
||||
}
|
||||
getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult {
|
||||
let result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n");
|
||||
let entries: ts.ClassificationInfo[] = [];
|
||||
const result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n");
|
||||
const entries: ts.ClassificationInfo[] = [];
|
||||
let i = 0;
|
||||
let position = 0;
|
||||
|
||||
for (; i < result.length - 1; i += 2) {
|
||||
let t = entries[i / 2] = {
|
||||
const t = entries[i / 2] = {
|
||||
length: parseInt(result[i]),
|
||||
classification: parseInt(result[i + 1])
|
||||
};
|
||||
@@ -286,7 +286,7 @@ namespace Harness.LanguageService {
|
||||
assert.isTrue(t.length > 0, "Result length should be greater than 0, got :" + t.length);
|
||||
position += t.length;
|
||||
}
|
||||
let finalLexState = parseInt(result[result.length - 1]);
|
||||
const finalLexState = parseInt(result[result.length - 1]);
|
||||
|
||||
assert.equal(position, text.length, "Expected cumulative length of all entries to match the length of the source. expected: " + text.length + ", but got: " + position);
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
|
||||
function unwrapJSONCallResult(result: string): any {
|
||||
let parsedResult = JSON.parse(result);
|
||||
const parsedResult = JSON.parse(result);
|
||||
if (parsedResult.error) {
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
||||
}
|
||||
@@ -312,7 +312,7 @@ namespace Harness.LanguageService {
|
||||
constructor(private shim: ts.LanguageServiceShim) {
|
||||
}
|
||||
private unwrappJSONCallResult(result: string): any {
|
||||
let parsedResult = JSON.parse(result);
|
||||
const parsedResult = JSON.parse(result);
|
||||
if (parsedResult.error) {
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
||||
}
|
||||
@@ -443,10 +443,10 @@ namespace Harness.LanguageService {
|
||||
isLibFile: boolean;
|
||||
};
|
||||
|
||||
let coreServicesShim = this.factory.createCoreServicesShim(this.host);
|
||||
const coreServicesShim = this.factory.createCoreServicesShim(this.host);
|
||||
shimResult = unwrapJSONCallResult(coreServicesShim.getPreProcessedFileInfo(fileName, ts.ScriptSnapshot.fromString(fileContents)));
|
||||
|
||||
let convertResult: ts.PreProcessedFileInfo = {
|
||||
const convertResult: ts.PreProcessedFileInfo = {
|
||||
referencedFiles: [],
|
||||
importedFiles: [],
|
||||
ambientExternalModules: [],
|
||||
@@ -530,7 +530,7 @@ namespace Harness.LanguageService {
|
||||
fileName = Harness.Compiler.defaultLibFileName;
|
||||
}
|
||||
|
||||
let snapshot = this.host.getScriptSnapshot(fileName);
|
||||
const snapshot = this.host.getScriptSnapshot(fileName);
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
|
||||
@@ -612,13 +612,13 @@ namespace Harness.LanguageService {
|
||||
private client: ts.server.SessionClient;
|
||||
constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
// This is the main host that tests use to direct tests
|
||||
let clientHost = new SessionClientHost(cancellationToken, options);
|
||||
let client = new ts.server.SessionClient(clientHost);
|
||||
const clientHost = new SessionClientHost(cancellationToken, options);
|
||||
const client = new ts.server.SessionClient(clientHost);
|
||||
|
||||
// This host is just a proxy for the clientHost, it uses the client
|
||||
// host to answer server queries about files on disk
|
||||
let serverHost = new SessionServerHost(clientHost);
|
||||
let server = new ts.server.Session(serverHost,
|
||||
const serverHost = new SessionServerHost(clientHost);
|
||||
const server = new ts.server.Session(serverHost,
|
||||
Buffer ? Buffer.byteLength : (string: string, encoding?: string) => string.length,
|
||||
process.hrtime, serverHost);
|
||||
|
||||
|
||||
+14
-14
@@ -89,7 +89,7 @@ namespace Playback {
|
||||
|
||||
function memoize<T>(func: (s: string) => T): Memoized<T> {
|
||||
let lookup: { [s: string]: T } = {};
|
||||
let run: Memoized<T> = <Memoized<T>>((s: string) => {
|
||||
const run: Memoized<T> = <Memoized<T>>((s: string) => {
|
||||
if (lookup.hasOwnProperty(s)) return lookup[s];
|
||||
return lookup[s] = func(s);
|
||||
});
|
||||
@@ -159,7 +159,7 @@ namespace Playback {
|
||||
wrapper.endRecord = () => {
|
||||
if (recordLog !== undefined) {
|
||||
let i = 0;
|
||||
let fn = () => recordLogFileNameBase + i + ".json";
|
||||
const fn = () => recordLogFileNameBase + i + ".json";
|
||||
while (underlying.fileExists(fn())) i++;
|
||||
underlying.writeFile(fn(), JSON.stringify(recordLog));
|
||||
recordLog = undefined;
|
||||
@@ -209,8 +209,8 @@ namespace Playback {
|
||||
|
||||
wrapper.readFile = recordReplay(wrapper.readFile, underlying)(
|
||||
path => {
|
||||
let result = underlying.readFile(path);
|
||||
let logEntry = { path, codepage: 0, result: { contents: result, codepage: 0 } };
|
||||
const result = underlying.readFile(path);
|
||||
const logEntry = { path, codepage: 0, result: { contents: result, codepage: 0 } };
|
||||
recordLog.filesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
@@ -218,8 +218,8 @@ namespace Playback {
|
||||
|
||||
wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)(
|
||||
(path, extension, exclude) => {
|
||||
let result = (<ts.System>underlying).readDirectory(path, extension, exclude);
|
||||
let logEntry = { path, extension, exclude, result };
|
||||
const result = (<ts.System>underlying).readDirectory(path, extension, exclude);
|
||||
const logEntry = { path, extension, exclude, result };
|
||||
recordLog.directoriesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
@@ -263,10 +263,10 @@ namespace Playback {
|
||||
}
|
||||
|
||||
function findResultByFields<T>(logArray: { result?: T }[], expectedFields: {}, defaultValue?: T): T {
|
||||
let predicate = (entry: { result?: T }) => {
|
||||
const predicate = (entry: { result?: T }) => {
|
||||
return Object.getOwnPropertyNames(expectedFields).every((name) => (<any>entry)[name] === (<any>expectedFields)[name]);
|
||||
};
|
||||
let results = logArray.filter(entry => predicate(entry));
|
||||
const results = logArray.filter(entry => predicate(entry));
|
||||
if (results.length === 0) {
|
||||
if (defaultValue !== undefined) {
|
||||
return defaultValue;
|
||||
@@ -279,7 +279,7 @@ namespace Playback {
|
||||
}
|
||||
|
||||
function findResultByPath<T>(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T {
|
||||
let normalizedName = ts.normalizePath(expectedPath).toLowerCase();
|
||||
const normalizedName = ts.normalizePath(expectedPath).toLowerCase();
|
||||
// Try to find the result through normal fileName
|
||||
for (let i = 0; i < logArray.length; i++) {
|
||||
if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) {
|
||||
@@ -288,7 +288,7 @@ namespace Playback {
|
||||
}
|
||||
// Fallback, try to resolve the target paths as well
|
||||
if (replayLog.pathsResolved.length > 0) {
|
||||
let normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase();
|
||||
const normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase();
|
||||
for (let i = 0; i < logArray.length; i++) {
|
||||
if (wrapper.resolvePath(logArray[i].path).toLowerCase() === normalizedResolvedName) {
|
||||
return logArray[i].result;
|
||||
@@ -305,9 +305,9 @@ namespace Playback {
|
||||
}
|
||||
}
|
||||
|
||||
let pathEquivCache: any = {};
|
||||
const pathEquivCache: any = {};
|
||||
function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) {
|
||||
let key = left + "-~~-" + right;
|
||||
const key = left + "-~~-" + right;
|
||||
function areSame(a: string, b: string) {
|
||||
return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase();
|
||||
}
|
||||
@@ -329,7 +329,7 @@ namespace Playback {
|
||||
}
|
||||
|
||||
export function wrapIO(underlying: Harness.IO): PlaybackIO {
|
||||
let wrapper: PlaybackIO = <any>{};
|
||||
const wrapper: PlaybackIO = <any>{};
|
||||
initWrapper(wrapper, underlying);
|
||||
|
||||
wrapper.directoryName = (path): string => { throw new Error("NotSupported"); };
|
||||
@@ -342,7 +342,7 @@ namespace Playback {
|
||||
}
|
||||
|
||||
export function wrapSystem(underlying: ts.System): PlaybackSystem {
|
||||
let wrapper: PlaybackSystem = <any>{};
|
||||
const wrapper: PlaybackSystem = <any>{};
|
||||
initWrapper(wrapper, underlying);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ interface BatchCompileProjectTestCaseResult extends CompileProjectFilesResult {
|
||||
class ProjectRunner extends RunnerBase {
|
||||
public initializeTests() {
|
||||
if (this.tests.length === 0) {
|
||||
let testFiles = this.enumerateFiles("tests/cases/project", /\.json$/, { recursive: true });
|
||||
const testFiles = this.enumerateFiles("tests/cases/project", /\.json$/, { recursive: true });
|
||||
testFiles.forEach(fn => {
|
||||
fn = fn.replace(/\\/g, "/");
|
||||
this.runProjectTestCase(fn);
|
||||
@@ -101,7 +101,7 @@ class ProjectRunner extends RunnerBase {
|
||||
function cleanProjectUrl(url: string) {
|
||||
let diskProjectPath = ts.normalizeSlashes(Harness.IO.resolvePath(testCase.projectRoot));
|
||||
let projectRootUrl = "file:///" + diskProjectPath;
|
||||
let normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot);
|
||||
const normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot);
|
||||
diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot));
|
||||
projectRootUrl = projectRootUrl.substr(0, projectRootUrl.lastIndexOf(normalizedProjectRoot));
|
||||
if (url && url.length) {
|
||||
@@ -127,15 +127,15 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[],
|
||||
getSourceFileText: (fileName: string) => string,
|
||||
getSourceFileTextImpl: (fileName: string) => string,
|
||||
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
|
||||
|
||||
let program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
|
||||
const program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
|
||||
let errors = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
let emitResult = program.emit();
|
||||
const emitResult = program.emit();
|
||||
errors = ts.concatenate(errors, emitResult.diagnostics);
|
||||
let sourceMapData = emitResult.sourceMaps;
|
||||
const sourceMapData = emitResult.sourceMaps;
|
||||
|
||||
// Clean up source map data that will be used in baselining
|
||||
if (sourceMapData) {
|
||||
@@ -170,13 +170,18 @@ class ProjectRunner extends RunnerBase {
|
||||
};
|
||||
}
|
||||
|
||||
function getSourceFileText(fileName: string): string {
|
||||
const text = getSourceFileTextImpl(fileName);
|
||||
return text !== undefined ? text : getSourceFileTextImpl(ts.getNormalizedAbsolutePath(fileName, getCurrentDirectory()));
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
|
||||
let sourceFile: ts.SourceFile = undefined;
|
||||
if (fileName === Harness.Compiler.defaultLibFileName) {
|
||||
sourceFile = languageVersion === ts.ScriptTarget.ES6 ? Harness.Compiler.defaultES6LibSourceFile : Harness.Compiler.defaultLibSourceFile;
|
||||
}
|
||||
else {
|
||||
let text = getSourceFileText(fileName);
|
||||
const text = getSourceFileText(fileName);
|
||||
if (text !== undefined) {
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion);
|
||||
}
|
||||
@@ -194,7 +199,7 @@ class ProjectRunner extends RunnerBase {
|
||||
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => Harness.IO.useCaseSensitiveFileNames(),
|
||||
getNewLine: () => Harness.IO.newLine(),
|
||||
fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined,
|
||||
fileExists: fileName => fileName === Harness.Compiler.defaultLibFileName || getSourceFileText(fileName) !== undefined,
|
||||
readFile: fileName => Harness.IO.readFile(fileName)
|
||||
};
|
||||
}
|
||||
@@ -203,9 +208,9 @@ class ProjectRunner extends RunnerBase {
|
||||
function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult {
|
||||
let nonSubfolderDiskFiles = 0;
|
||||
|
||||
let outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
|
||||
const outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
|
||||
|
||||
let projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile);
|
||||
const projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile);
|
||||
return {
|
||||
moduleKind,
|
||||
program: projectCompilerResult.program,
|
||||
@@ -229,12 +234,15 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
let diskFileName = ts.isRootedDiskPath(fileName)
|
||||
// convert file name to rooted name
|
||||
// if filename is not rooted - concat it with project root and then expand project root relative to current directory
|
||||
const diskFileName = ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName);
|
||||
: Harness.IO.resolvePath(ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName));
|
||||
|
||||
let diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName,
|
||||
getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
const currentDirectory = getCurrentDirectory();
|
||||
// compute file name relative to current directory (expanded project root)
|
||||
let diskRelativeName = ts.getRelativePathToDirectoryOrUrl(currentDirectory, diskFileName, currentDirectory, Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
|
||||
// If the generated output file resides in the parent folder or is rooted path,
|
||||
// we need to instead create files that can live in the project reference folder
|
||||
@@ -246,14 +254,14 @@ class ProjectRunner extends RunnerBase {
|
||||
|
||||
if (Harness.Compiler.isJS(fileName)) {
|
||||
// Make sure if there is URl we have it cleaned up
|
||||
let indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
|
||||
const indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
|
||||
if (indexOfSourceMapUrl !== -1) {
|
||||
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
|
||||
}
|
||||
}
|
||||
else if (Harness.Compiler.isJSMap(fileName)) {
|
||||
// Make sure sources list is cleaned
|
||||
let sourceMapData = JSON.parse(data);
|
||||
const sourceMapData = JSON.parse(data);
|
||||
for (let i = 0; i < sourceMapData.sources.length; i++) {
|
||||
sourceMapData.sources[i] = cleanProjectUrl(sourceMapData.sources[i]);
|
||||
}
|
||||
@@ -261,7 +269,7 @@ class ProjectRunner extends RunnerBase {
|
||||
data = JSON.stringify(sourceMapData);
|
||||
}
|
||||
|
||||
let outputFilePath = getProjectOutputFolder(diskRelativeName, moduleKind);
|
||||
const outputFilePath = getProjectOutputFolder(diskRelativeName, moduleKind);
|
||||
// Actual writing of file as in tc.ts
|
||||
function ensureDirectoryStructure(directoryname: string) {
|
||||
if (directoryname) {
|
||||
@@ -279,8 +287,8 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function compileCompileDTsFiles(compilerResult: BatchCompileProjectTestCaseResult) {
|
||||
let allInputFiles: { emittedFileName: string; code: string; }[] = [];
|
||||
let compilerOptions = compilerResult.program.getCompilerOptions();
|
||||
const allInputFiles: { emittedFileName: string; code: string; }[] = [];
|
||||
const compilerOptions = compilerResult.program.getCompilerOptions();
|
||||
|
||||
ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => {
|
||||
if (Harness.Compiler.isDTS(sourceFile.fileName)) {
|
||||
@@ -297,12 +305,12 @@ class ProjectRunner extends RunnerBase {
|
||||
emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
|
||||
}
|
||||
|
||||
let outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
const outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName));
|
||||
}
|
||||
else {
|
||||
let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts";
|
||||
let outputDtsFile = findOutpuDtsFile(outputDtsFileName);
|
||||
const outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts";
|
||||
const outputDtsFile = findOutpuDtsFile(outputDtsFileName);
|
||||
if (!ts.contains(allInputFiles, outputDtsFile)) {
|
||||
allInputFiles.unshift(outputDtsFile);
|
||||
}
|
||||
@@ -318,7 +326,16 @@ class ProjectRunner extends RunnerBase {
|
||||
return ts.map(allInputFiles, outputFile => outputFile.emittedFileName);
|
||||
}
|
||||
function getSourceFileText(fileName: string): string {
|
||||
return ts.forEach(allInputFiles, inputFile => inputFile.emittedFileName === fileName ? inputFile.code : undefined);
|
||||
for (const inputFile of allInputFiles) {
|
||||
const isMatchingFile = ts.isRootedDiskPath(fileName)
|
||||
? ts.getNormalizedAbsolutePath(inputFile.emittedFileName, getCurrentDirectory()) === fileName
|
||||
: inputFile.emittedFileName === fileName;
|
||||
|
||||
if (isMatchingFile) {
|
||||
return inputFile.code;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
@@ -326,7 +343,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function getErrorsBaseline(compilerResult: CompileProjectFilesResult) {
|
||||
let inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
const inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
sourceFile => sourceFile.fileName !== "lib.d.ts"),
|
||||
sourceFile => {
|
||||
return { unitName: sourceFile.fileName, content: sourceFile.text };
|
||||
@@ -335,7 +352,7 @@ class ProjectRunner extends RunnerBase {
|
||||
return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors);
|
||||
}
|
||||
|
||||
let name = "Compiling project for " + testCase.scenario + ": testcase " + testCaseFileName;
|
||||
const name = "Compiling project for " + testCase.scenario + ": testcase " + testCaseFileName;
|
||||
|
||||
describe("Projects tests", () => {
|
||||
describe(name, () => {
|
||||
@@ -343,7 +360,7 @@ class ProjectRunner extends RunnerBase {
|
||||
let compilerResult: BatchCompileProjectTestCaseResult;
|
||||
|
||||
function getCompilerResolutionInfo() {
|
||||
let resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
|
||||
const resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
|
||||
scenario: testCase.scenario,
|
||||
projectRoot: testCase.projectRoot,
|
||||
inputFiles: testCase.inputFiles,
|
||||
@@ -359,8 +376,12 @@ class ProjectRunner extends RunnerBase {
|
||||
runTest: testCase.runTest,
|
||||
bug: testCase.bug,
|
||||
rootDir: testCase.rootDir,
|
||||
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName),
|
||||
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName)
|
||||
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => {
|
||||
return ts.convertToRelativePath(inputFile.fileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path));
|
||||
}),
|
||||
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => {
|
||||
return ts.convertToRelativePath(outputFile.emittedFileName, getCurrentDirectory(), path => Harness.Compiler.getCanonicalFileName(path));
|
||||
})
|
||||
};
|
||||
|
||||
return resolutionInfo;
|
||||
@@ -417,7 +438,7 @@ class ProjectRunner extends RunnerBase {
|
||||
|
||||
it("Errors in generated Dts files for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
|
||||
if (!compilerResult.errors.length && testCase.declaration) {
|
||||
let dTsCompileResult = compileCompileDTsFiles(compilerResult);
|
||||
const dTsCompileResult = compileCompileDTsFiles(compilerResult);
|
||||
if (dTsCompileResult.errors.length) {
|
||||
Harness.Baseline.runBaseline("Errors in generated Dts files for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => {
|
||||
return getErrorsBaseline(dTsCompileResult);
|
||||
|
||||
@@ -41,13 +41,13 @@ let testConfigFile =
|
||||
(Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : "");
|
||||
|
||||
if (testConfigFile !== "") {
|
||||
let testConfig = JSON.parse(testConfigFile);
|
||||
const testConfig = JSON.parse(testConfigFile);
|
||||
if (testConfig.light) {
|
||||
Harness.lightMode = true;
|
||||
}
|
||||
|
||||
if (testConfig.test && testConfig.test.length > 0) {
|
||||
for (let option of testConfig.test) {
|
||||
for (const option of testConfig.test) {
|
||||
if (!option) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ abstract class RunnerBase {
|
||||
let fixedPath = path;
|
||||
|
||||
// full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point
|
||||
let fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g;
|
||||
let fullPathList = fixedPath.match(fullPath);
|
||||
const fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g;
|
||||
const fullPathList = fixedPath.match(fullPath);
|
||||
if (fullPathList) {
|
||||
fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match)));
|
||||
}
|
||||
|
||||
// when running in the browser the 'full path' is the host name, shows up in error baselines
|
||||
let localHost = /http:\/localhost:\d+/g;
|
||||
const localHost = /http:\/localhost:\d+/g;
|
||||
fixedPath = fixedPath.replace(localHost, "");
|
||||
return fixedPath;
|
||||
}
|
||||
|
||||
+15
-15
@@ -6,9 +6,9 @@
|
||||
|
||||
namespace RWC {
|
||||
function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) {
|
||||
let oldIO = Harness.IO;
|
||||
const oldIO = Harness.IO;
|
||||
|
||||
let wrappedIO = Playback.wrapIO(oldIO);
|
||||
const wrappedIO = Playback.wrapIO(oldIO);
|
||||
wrappedIO.startReplayFromData(ioLog);
|
||||
Harness.IO = wrappedIO;
|
||||
|
||||
@@ -55,10 +55,10 @@ namespace RWC {
|
||||
});
|
||||
|
||||
it("can compile", () => {
|
||||
let harnessCompiler = Harness.Compiler.getCompiler();
|
||||
const harnessCompiler = Harness.Compiler.getCompiler();
|
||||
let opts: ts.ParsedCommandLine;
|
||||
|
||||
let ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
|
||||
const ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
|
||||
currentDirectory = ioLog.currentDirectory;
|
||||
useCustomLibraryFile = ioLog.useCustomLibraryFile;
|
||||
runWithIOLog(ioLog, () => {
|
||||
@@ -75,26 +75,26 @@ namespace RWC {
|
||||
|
||||
let fileNames = opts.fileNames;
|
||||
|
||||
let tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
|
||||
const tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
|
||||
if (tsconfigFile) {
|
||||
let tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path);
|
||||
let parsedTsconfigFileContents = ts.parseConfigFileTextToJson(tsconfigFile.path, tsconfigFileContents.content);
|
||||
let configParseResult = ts.parseJsonConfigFileContent(parsedTsconfigFileContents.config, Harness.IO, ts.getDirectoryPath(tsconfigFile.path));
|
||||
const tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path);
|
||||
const parsedTsconfigFileContents = ts.parseConfigFileTextToJson(tsconfigFile.path, tsconfigFileContents.content);
|
||||
const configParseResult = ts.parseJsonConfigFileContent(parsedTsconfigFileContents.config, Harness.IO, ts.getDirectoryPath(tsconfigFile.path));
|
||||
fileNames = configParseResult.fileNames;
|
||||
opts.options = ts.extend(opts.options, configParseResult.options);
|
||||
}
|
||||
|
||||
// Load the files
|
||||
for (let fileName of fileNames) {
|
||||
for (const fileName of fileNames) {
|
||||
inputFiles.push(getHarnessCompilerInputUnit(fileName));
|
||||
}
|
||||
|
||||
// Add files to compilation
|
||||
let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath;
|
||||
for (let fileRead of ioLog.filesRead) {
|
||||
const isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath;
|
||||
for (const fileRead of ioLog.filesRead) {
|
||||
// Check if the file is already added into the set of input files.
|
||||
const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path));
|
||||
let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath));
|
||||
const inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath));
|
||||
|
||||
if (isTsConfigFile(fileRead)) {
|
||||
continue;
|
||||
@@ -139,7 +139,7 @@ namespace RWC {
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
let unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName));
|
||||
const unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName));
|
||||
let content: string = null;
|
||||
try {
|
||||
content = Harness.IO.readFile(unitName);
|
||||
@@ -201,7 +201,7 @@ namespace RWC {
|
||||
it("has the expected errors in generated declaration files", () => {
|
||||
if (compilerOptions.declaration && !compilerResult.errors.length) {
|
||||
Harness.Baseline.runBaseline("has the expected errors in generated declaration files", baseName + ".dts.errors.txt", () => {
|
||||
let declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult,
|
||||
const declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult,
|
||||
/*settingscallback*/ undefined, compilerOptions, currentDirectory);
|
||||
if (declFileCompilationResult.declResult.errors.length === 0) {
|
||||
return null;
|
||||
@@ -227,7 +227,7 @@ class RWCRunner extends RunnerBase {
|
||||
*/
|
||||
public initializeTests(): void {
|
||||
// Read in and evaluate the test list
|
||||
let testList = Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/);
|
||||
const testList = Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/);
|
||||
for (let i = 0; i < testList.length; i++) {
|
||||
this.runTest(testList[i]);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
// 6 digit number
|
||||
let currentByte = base64FormatDecode();
|
||||
const currentByte = base64FormatDecode();
|
||||
|
||||
// If msb is set, we still have more bits to continue
|
||||
moreDigits = (currentByte & 32) !== 0;
|
||||
@@ -259,7 +259,7 @@ namespace Harness.SourceMapRecoder {
|
||||
|
||||
export function recordSourceMapSpan(sourceMapSpan: ts.SourceMapSpan) {
|
||||
// verify the decoded span is same as the new span
|
||||
let decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan();
|
||||
const decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan();
|
||||
let decodedErrors: string[];
|
||||
if (decodeResult.error
|
||||
|| decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine
|
||||
@@ -317,8 +317,8 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function getTextOfLine(line: number, lineMap: number[], code: string) {
|
||||
let startPos = lineMap[line];
|
||||
let endPos = lineMap[line + 1];
|
||||
const startPos = lineMap[line];
|
||||
const endPos = lineMap[line + 1];
|
||||
return code.substring(startPos, endPos);
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeRecordedSpans() {
|
||||
let markerIds: string[] = [];
|
||||
const markerIds: string[] = [];
|
||||
|
||||
function getMarkerId(markerIndex: number) {
|
||||
let markerId = "";
|
||||
@@ -364,7 +364,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeSourceMapMarker(currentSpan: SourceMapSpanWithDecodeErrors, index: number, endColumn = currentSpan.sourceMapSpan.emittedColumn, endContinues?: boolean) {
|
||||
let markerId = getMarkerId(index);
|
||||
const markerId = getMarkerId(index);
|
||||
markerIds.push(markerId);
|
||||
|
||||
writeSourceMapIndent(prevEmittedCol, markerId);
|
||||
@@ -380,7 +380,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeSourceMapSourceText(currentSpan: SourceMapSpanWithDecodeErrors, index: number) {
|
||||
let sourcePos = tsLineMap[currentSpan.sourceMapSpan.sourceLine - 1] + (currentSpan.sourceMapSpan.sourceColumn - 1);
|
||||
const sourcePos = tsLineMap[currentSpan.sourceMapSpan.sourceLine - 1] + (currentSpan.sourceMapSpan.sourceColumn - 1);
|
||||
let sourceText = "";
|
||||
if (prevWrittenSourcePos < sourcePos) {
|
||||
// Position that goes forward, get text
|
||||
@@ -395,7 +395,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
}
|
||||
|
||||
let tsCodeLineMap = ts.computeLineStarts(sourceText);
|
||||
const tsCodeLineMap = ts.computeLineStarts(sourceText);
|
||||
for (let i = 0; i < tsCodeLineMap.length; i++) {
|
||||
writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >");
|
||||
sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText));
|
||||
@@ -412,7 +412,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
if (spansOnSingleLine.length) {
|
||||
let currentJsLine = spansOnSingleLine[0].sourceMapSpan.emittedLine;
|
||||
const currentJsLine = spansOnSingleLine[0].sourceMapSpan.emittedLine;
|
||||
|
||||
// Write js line
|
||||
writeJsFileLines(currentJsLine);
|
||||
@@ -420,7 +420,7 @@ namespace Harness.SourceMapRecoder {
|
||||
// Emit markers
|
||||
iterateSpans(writeSourceMapMarker);
|
||||
|
||||
let jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code);
|
||||
const jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code);
|
||||
if (prevEmittedCol < jsFileText.length) {
|
||||
// There is remaining text on this line that will be part of next source span so write marker that continues
|
||||
writeSourceMapMarker(undefined, spansOnSingleLine.length, /*endColumn*/ jsFileText.length, /*endContinues*/ true);
|
||||
@@ -438,16 +438,16 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
export function getSourceMapRecord(sourceMapDataList: ts.SourceMapData[], program: ts.Program, jsFiles: Compiler.GeneratedFile[]) {
|
||||
let sourceMapRecoder = new Compiler.WriterAggregator();
|
||||
const sourceMapRecoder = new Compiler.WriterAggregator();
|
||||
|
||||
for (let i = 0; i < sourceMapDataList.length; i++) {
|
||||
let sourceMapData = sourceMapDataList[i];
|
||||
const sourceMapData = sourceMapDataList[i];
|
||||
let prevSourceFile: ts.SourceFile;
|
||||
|
||||
SourceMapSpanWriter.intializeSourceMapSpanWriter(sourceMapRecoder, sourceMapData, jsFiles[i]);
|
||||
for (let j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) {
|
||||
let decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j];
|
||||
let currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]);
|
||||
const decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j];
|
||||
const currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]);
|
||||
if (currentSourceFile !== prevSourceFile) {
|
||||
SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text);
|
||||
prevSourceFile = currentSourceFile;
|
||||
|
||||
@@ -36,11 +36,11 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
};
|
||||
|
||||
before(() => {
|
||||
let content = Harness.IO.readFile(filePath);
|
||||
let testFilename = ts.removeFileExtension(filePath).replace(/\//g, "_") + ".test";
|
||||
let testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename);
|
||||
const content = Harness.IO.readFile(filePath);
|
||||
const testFilename = ts.removeFileExtension(filePath).replace(/\//g, "_") + ".test";
|
||||
const testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename);
|
||||
|
||||
let inputFiles = testCaseContent.testUnitData.map(unit => {
|
||||
const inputFiles = testCaseContent.testUnitData.map(unit => {
|
||||
return { unitName: Test262BaselineRunner.getTestFilePath(unit.name), content: unit.content };
|
||||
});
|
||||
|
||||
@@ -64,14 +64,14 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
|
||||
it("has the expected emitted code", () => {
|
||||
Harness.Baseline.runBaseline("has the expected emitted code", testState.filename + ".output.js", () => {
|
||||
let files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
const files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
return Harness.Compiler.collateOutputs(files);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
|
||||
it("has the expected errors", () => {
|
||||
Harness.Baseline.runBaseline("has the expected errors", testState.filename + ".errors.txt", () => {
|
||||
let errors = testState.compilerResult.errors;
|
||||
const errors = testState.compilerResult.errors;
|
||||
if (errors.length === 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -81,13 +81,13 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
it("satisfies inletiants", () => {
|
||||
let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
const sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
Utils.assertInvariants(sourceFile, /*parent:*/ undefined);
|
||||
});
|
||||
|
||||
it("has the expected AST", () => {
|
||||
Harness.Baseline.runBaseline("has the expected AST", testState.filename + ".AST.txt", () => {
|
||||
let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
const sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
return Utils.sourceFileToJSON(sourceFile);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
@@ -97,7 +97,7 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
public initializeTests() {
|
||||
// this will set up a series of describe/it blocks to run between the setup and cleanup phases
|
||||
if (this.tests.length === 0) {
|
||||
let testFiles = this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true });
|
||||
const testFiles = this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true });
|
||||
testFiles.forEach(fn => {
|
||||
this.runTest(ts.normalizePath(fn));
|
||||
});
|
||||
|
||||
+12
-12
@@ -21,7 +21,7 @@ class TypeWriterWalker {
|
||||
}
|
||||
|
||||
public getTypeAndSymbols(fileName: string): TypeWriterResult[] {
|
||||
let sourceFile = this.program.getSourceFile(fileName);
|
||||
const sourceFile = this.program.getSourceFile(fileName);
|
||||
this.currentSourceFile = sourceFile;
|
||||
this.results = [];
|
||||
this.visitNode(sourceFile);
|
||||
@@ -37,28 +37,28 @@ class TypeWriterWalker {
|
||||
}
|
||||
|
||||
private logTypeAndSymbol(node: ts.Node): void {
|
||||
let actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
|
||||
let lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
|
||||
let sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
const actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
|
||||
const lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
|
||||
const sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
|
||||
// Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions
|
||||
// let type = this.checker.getTypeAtLocation(node);
|
||||
let type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node);
|
||||
const type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node);
|
||||
|
||||
ts.Debug.assert(type !== undefined, "type doesn't exist");
|
||||
let symbol = this.checker.getSymbolAtLocation(node);
|
||||
const symbol = this.checker.getSymbolAtLocation(node);
|
||||
|
||||
let typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation);
|
||||
const typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation);
|
||||
let symbolString: string;
|
||||
if (symbol) {
|
||||
symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent);
|
||||
if (symbol.declarations) {
|
||||
for (let declaration of symbol.declarations) {
|
||||
for (const declaration of symbol.declarations) {
|
||||
symbolString += ", ";
|
||||
let declSourceFile = declaration.getSourceFile();
|
||||
let declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos);
|
||||
let fileName = ts.getBaseFileName(declSourceFile.fileName);
|
||||
let isLibFile = /lib(.*)\.d\.ts/i.test(fileName);
|
||||
const declSourceFile = declaration.getSourceFile();
|
||||
const declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos);
|
||||
const fileName = ts.getBaseFileName(declSourceFile.fileName);
|
||||
const isLibFile = /lib(.*)\.d\.ts/i.test(fileName);
|
||||
symbolString += `Decl(${ fileName }, ${ isLibFile ? "--" : declLineAndCharacter.line }, ${ isLibFile ? "--" : declLineAndCharacter.character })`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Read this!
|
||||
|
||||
The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.ts`.
|
||||
|
||||
## Generated files
|
||||
|
||||
Any files ending in `.generated.d.ts` aren't mean to be edited by hand.
|
||||
If you need to make changes to such files, make a change to the input files for our [library generator](https://github.com/Microsoft/TSJS-lib-generator).
|
||||
+307
-295
File diff suppressed because it is too large
Load Diff
Vendored
+16
-16
@@ -62,14 +62,14 @@ declare var SlowBuffer: {
|
||||
// Buffer class
|
||||
interface Buffer extends NodeBuffer { }
|
||||
interface BufferConstructor {
|
||||
new (str: string, encoding ?: string): Buffer;
|
||||
new (str: string, encoding?: string): Buffer;
|
||||
new (size: number): Buffer;
|
||||
new (size: Uint8Array): Buffer;
|
||||
new (array: any[]): Buffer;
|
||||
prototype: Buffer;
|
||||
isBuffer(obj: any): boolean;
|
||||
byteLength(string: string, encoding ?: string): number;
|
||||
concat(list: Buffer[], totalLength ?: number): Buffer;
|
||||
byteLength(string: string, encoding?: string): number;
|
||||
concat(list: Buffer[], totalLength?: number): Buffer;
|
||||
}
|
||||
declare var Buffer: BufferConstructor;
|
||||
|
||||
@@ -78,7 +78,7 @@ declare var Buffer: BufferConstructor;
|
||||
* GLOBAL INTERFACES *
|
||||
* *
|
||||
************************************************/
|
||||
declare module NodeJS {
|
||||
declare namespace NodeJS {
|
||||
export interface ErrnoException extends Error {
|
||||
errno?: any;
|
||||
code?: string;
|
||||
@@ -245,7 +245,7 @@ interface NodeBuffer {
|
||||
fill(value: any, offset?: number, end?: number): void;
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
declare namespace NodeJS {
|
||||
export interface Path {
|
||||
normalize(p: string): string;
|
||||
join(...paths: any[]): string;
|
||||
@@ -258,7 +258,7 @@ declare module NodeJS {
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
declare namespace NodeJS {
|
||||
export interface ReadLineInstance extends EventEmitter {
|
||||
setPrompt(prompt: string, length: number): void;
|
||||
prompt(preserveCursor?: boolean): void;
|
||||
@@ -280,8 +280,8 @@ declare module NodeJS {
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module events {
|
||||
declare namespace NodeJS {
|
||||
namespace events {
|
||||
export class EventEmitter implements NodeJS.EventEmitter {
|
||||
static listenerCount(emitter: EventEmitter, event: string): number;
|
||||
|
||||
@@ -297,8 +297,8 @@ declare module NodeJS {
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module stream {
|
||||
declare namespace NodeJS {
|
||||
namespace stream {
|
||||
|
||||
export interface Stream extends events.EventEmitter {
|
||||
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
@@ -397,8 +397,8 @@ declare module NodeJS {
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module fs {
|
||||
declare namespace NodeJS {
|
||||
namespace fs {
|
||||
interface Stats {
|
||||
isFile(): boolean;
|
||||
isDirectory(): boolean;
|
||||
@@ -547,8 +547,8 @@ declare module NodeJS {
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module path {
|
||||
declare namespace NodeJS {
|
||||
namespace path {
|
||||
export function normalize(p: string): string;
|
||||
export function join(...paths: any[]): string;
|
||||
export function resolve(...pathSegments: any[]): string;
|
||||
@@ -560,8 +560,8 @@ declare module NodeJS {
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module _debugger {
|
||||
declare namespace NodeJS {
|
||||
namespace _debugger {
|
||||
export interface Packet {
|
||||
raw: string;
|
||||
headers: string[];
|
||||
|
||||
Vendored
+88
-88
@@ -16,7 +16,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
type: string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Client-initiated request message
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
arguments?: any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request to reload the project structure for all the opened files
|
||||
*/
|
||||
@@ -107,7 +107,7 @@ declare namespace ts.server.protocol {
|
||||
* A request to get the project information of the current file
|
||||
*/
|
||||
export interface ProjectInfoRequest extends Request {
|
||||
arguments: ProjectInfoRequestArgs
|
||||
arguments: ProjectInfoRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ declare namespace ts.server.protocol {
|
||||
/**
|
||||
* Object found in response messages defining a span of text in source code.
|
||||
*/
|
||||
export interface TextSpan {
|
||||
export interface TextSpan {
|
||||
/**
|
||||
* First character of the definition.
|
||||
*/
|
||||
@@ -261,18 +261,18 @@ declare namespace ts.server.protocol {
|
||||
* in the file at a given line and column.
|
||||
*/
|
||||
export interface DocumentHighlightsRequest extends FileLocationRequest {
|
||||
arguments: DocumentHighlightsRequestArgs
|
||||
arguments: DocumentHighlightsRequestArgs;
|
||||
}
|
||||
|
||||
export interface HighlightSpan extends TextSpan {
|
||||
kind: string
|
||||
kind: string;
|
||||
}
|
||||
|
||||
export interface DocumentHighlightsItem {
|
||||
/**
|
||||
* File containing highlight spans.
|
||||
*/
|
||||
file: string,
|
||||
file: string;
|
||||
|
||||
/**
|
||||
* Spans to highlight in file.
|
||||
@@ -422,76 +422,76 @@ declare namespace ts.server.protocol {
|
||||
* Editor options
|
||||
*/
|
||||
export interface EditorOptions {
|
||||
|
||||
|
||||
/** Number of spaces for each tab. Default value is 4. */
|
||||
tabSize?: number;
|
||||
|
||||
|
||||
/** Number of spaces to indent during formatting. Default value is 4. */
|
||||
indentSize?: number;
|
||||
|
||||
|
||||
/** The new line character to be used. Default value is the OS line delimiter. */
|
||||
newLineCharacter?: string;
|
||||
|
||||
|
||||
/** Whether tabs should be converted to spaces. Default value is true. */
|
||||
convertTabsToSpaces?: boolean;
|
||||
convertTabsToSpaces?: boolean;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format options
|
||||
*/
|
||||
export interface FormatOptions extends EditorOptions {
|
||||
|
||||
|
||||
/** Defines space handling after a comma delimiter. Default value is true. */
|
||||
insertSpaceAfterCommaDelimiter?: boolean;
|
||||
|
||||
|
||||
/** Defines space handling after a semicolon in a for statemen. Default value is true */
|
||||
insertSpaceAfterSemicolonInForStatements?: boolean;
|
||||
|
||||
|
||||
/** Defines space handling after a binary operator. Default value is true. */
|
||||
insertSpaceBeforeAndAfterBinaryOperators?: boolean;
|
||||
|
||||
|
||||
/** Defines space handling after keywords in control flow statement. Default value is true. */
|
||||
insertSpaceAfterKeywordsInControlFlowStatements?: boolean;
|
||||
|
||||
|
||||
/** Defines space handling after function keyword for anonymous functions. Default value is false. */
|
||||
insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
|
||||
|
||||
|
||||
/** Defines space handling after opening and before closing non empty parenthesis. Default value is false. */
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
|
||||
|
||||
/** Defines space handling after opening and before closing non empty brackets. Default value is false. */
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
|
||||
|
||||
|
||||
/** Defines whether an open brace is put onto a new line for functions or not. Default value is false. */
|
||||
placeOpenBraceOnNewLineForFunctions?: boolean;
|
||||
|
||||
|
||||
/** Defines whether an open brace is put onto a new line for control blocks or not. Default value is false. */
|
||||
placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
||||
|
||||
|
||||
/** Index operator */
|
||||
[key:string] : string | number | boolean;
|
||||
[key: string] : string | number | boolean;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Information found in a configure request.
|
||||
*/
|
||||
export interface ConfigureRequestArguments {
|
||||
|
||||
|
||||
/**
|
||||
* Information about the host, for example 'Emacs 24.4' or
|
||||
* 'Sublime Text version 3075'
|
||||
*/
|
||||
hostInfo?: string;
|
||||
|
||||
|
||||
/**
|
||||
* If present, tab settings apply only to this file.
|
||||
*/
|
||||
file?: string;
|
||||
|
||||
|
||||
/**
|
||||
* The format options to use during formatting and other code editing features.
|
||||
*/
|
||||
formatOptions?: FormatOptions;
|
||||
formatOptions?: FormatOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,27 +561,27 @@ declare namespace ts.server.protocol {
|
||||
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
|
||||
*/
|
||||
kind: string;
|
||||
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers: string;
|
||||
|
||||
|
||||
/**
|
||||
* Starting file location of symbol.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
|
||||
/**
|
||||
* One past last character of symbol.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
|
||||
/**
|
||||
* Type and kind of symbol.
|
||||
*/
|
||||
displayString: string;
|
||||
|
||||
|
||||
/**
|
||||
* Documentation associated with symbol.
|
||||
*/
|
||||
@@ -603,7 +603,7 @@ declare namespace ts.server.protocol {
|
||||
* Last line of range for which to format text in file.
|
||||
*/
|
||||
endLine: number;
|
||||
|
||||
|
||||
/**
|
||||
* Character offset on last line of range for which to format text in file.
|
||||
*/
|
||||
@@ -619,7 +619,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
export interface FormatRequest extends FileLocationRequest {
|
||||
arguments: FormatRequestArgs;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Object found in response messages defining an editing
|
||||
@@ -638,7 +638,7 @@ declare namespace ts.server.protocol {
|
||||
* One character past last character of the text span to edit.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
|
||||
/**
|
||||
* Replace the span defined above with this string (may be
|
||||
* the empty string).
|
||||
@@ -723,7 +723,7 @@ declare namespace ts.server.protocol {
|
||||
* Text of an item describing the symbol.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
|
||||
*/
|
||||
@@ -773,7 +773,7 @@ declare namespace ts.server.protocol {
|
||||
* Display parts of the symbol (similar to quick info).
|
||||
*/
|
||||
displayParts: SymbolDisplayPart[];
|
||||
|
||||
|
||||
/**
|
||||
* Documentation strings for the symbol.
|
||||
*/
|
||||
@@ -790,94 +790,94 @@ declare namespace ts.server.protocol {
|
||||
|
||||
/**
|
||||
* Signature help information for a single parameter
|
||||
*/
|
||||
*/
|
||||
export interface SignatureHelpParameter {
|
||||
|
||||
|
||||
/**
|
||||
* The parameter's name
|
||||
*/
|
||||
*/
|
||||
name: string;
|
||||
|
||||
|
||||
/**
|
||||
* Documentation of the parameter.
|
||||
*/
|
||||
documentation: SymbolDisplayPart[];
|
||||
|
||||
|
||||
/**
|
||||
* Display parts of the parameter.
|
||||
*/
|
||||
displayParts: SymbolDisplayPart[];
|
||||
|
||||
|
||||
/**
|
||||
* Whether the parameter is optional or not.
|
||||
*/
|
||||
*/
|
||||
isOptional: boolean;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a single signature to show in signature help.
|
||||
*/
|
||||
*/
|
||||
export interface SignatureHelpItem {
|
||||
|
||||
|
||||
/**
|
||||
* Whether the signature accepts a variable number of arguments.
|
||||
*/
|
||||
*/
|
||||
isVariadic: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* The prefix display parts.
|
||||
*/
|
||||
*/
|
||||
prefixDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
|
||||
/**
|
||||
* The suffix disaply parts.
|
||||
*/
|
||||
*/
|
||||
suffixDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
|
||||
/**
|
||||
* The separator display parts.
|
||||
*/
|
||||
*/
|
||||
separatorDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
|
||||
/**
|
||||
* The signature helps items for the parameters.
|
||||
*/
|
||||
*/
|
||||
parameters: SignatureHelpParameter[];
|
||||
|
||||
|
||||
/**
|
||||
* The signature's documentation
|
||||
*/
|
||||
documentation: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signature help items found in the response of a signature help request.
|
||||
*/
|
||||
export interface SignatureHelpItems {
|
||||
|
||||
|
||||
/**
|
||||
* The signature help items.
|
||||
*/
|
||||
*/
|
||||
items: SignatureHelpItem[];
|
||||
|
||||
|
||||
/**
|
||||
* The span for which signature help should appear on a signature
|
||||
*/
|
||||
*/
|
||||
applicableSpan: TextSpan;
|
||||
|
||||
|
||||
/**
|
||||
* The item selected in the set of available help items.
|
||||
*/
|
||||
*/
|
||||
selectedItemIndex: number;
|
||||
|
||||
|
||||
/**
|
||||
* The argument selected in the set of parameters.
|
||||
*/
|
||||
*/
|
||||
argumentIndex: number;
|
||||
|
||||
|
||||
/**
|
||||
* The argument count
|
||||
*/
|
||||
*/
|
||||
argumentCount: number;
|
||||
}
|
||||
|
||||
@@ -885,9 +885,9 @@ declare namespace ts.server.protocol {
|
||||
* Arguments of a signature help request.
|
||||
*/
|
||||
export interface SignatureHelpRequestArgs extends FileLocationRequestArgs {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signature help request; value of command field is "signatureHelp".
|
||||
* Given a file location (file, line, col), return the signature
|
||||
@@ -899,7 +899,7 @@ declare namespace ts.server.protocol {
|
||||
|
||||
/**
|
||||
* Repsonse object for a SignatureHelpRequest.
|
||||
*/
|
||||
*/
|
||||
export interface SignatureHelpResponse extends Response {
|
||||
body?: SignatureHelpItems;
|
||||
}
|
||||
@@ -926,9 +926,9 @@ declare namespace ts.server.protocol {
|
||||
* it request for every file in this project.
|
||||
*/
|
||||
export interface GeterrForProjectRequest extends Request {
|
||||
arguments: GeterrForProjectRequestArgs
|
||||
arguments: GeterrForProjectRequestArgs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Arguments for geterr messages.
|
||||
*/
|
||||
@@ -968,12 +968,12 @@ declare namespace ts.server.protocol {
|
||||
* Starting file location at which text appies.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
|
||||
/**
|
||||
* The last file location at which the text applies.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
|
||||
/**
|
||||
* Text of diagnostic message.
|
||||
*/
|
||||
@@ -985,7 +985,7 @@ declare namespace ts.server.protocol {
|
||||
* The file for which diagnostic information is reported.
|
||||
*/
|
||||
file: string;
|
||||
|
||||
|
||||
/**
|
||||
* An array of diagnostic information items.
|
||||
*/
|
||||
@@ -999,7 +999,7 @@ declare namespace ts.server.protocol {
|
||||
export interface DiagnosticEvent extends Event {
|
||||
body?: DiagnosticEventBody;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Arguments for reload request.
|
||||
*/
|
||||
@@ -1083,12 +1083,12 @@ declare namespace ts.server.protocol {
|
||||
* The symbol's name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
|
||||
|
||||
/**
|
||||
* exact, substring, or prefix.
|
||||
*/
|
||||
@@ -1098,39 +1098,39 @@ declare namespace ts.server.protocol {
|
||||
* If this was a case sensitive or insensitive match.
|
||||
*/
|
||||
isCaseSensitive?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers?: string;
|
||||
|
||||
|
||||
/**
|
||||
* The file in which the symbol is found.
|
||||
*/
|
||||
file: string;
|
||||
|
||||
|
||||
/**
|
||||
* The location within file at which the symbol is found.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
|
||||
/**
|
||||
* One past the last character of the symbol.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
|
||||
/**
|
||||
* Name of symbol's container symbol (if any); for example,
|
||||
* the class name if symbol is a class member.
|
||||
*/
|
||||
containerName?: string;
|
||||
|
||||
|
||||
/**
|
||||
* Kind of symbol's container symbol (if any).
|
||||
*/
|
||||
containerKind?: string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Navto response message. Body is an array of navto items. Each
|
||||
* item gives a symbol that matched the search term.
|
||||
@@ -1208,7 +1208,7 @@ declare namespace ts.server.protocol {
|
||||
childItems?: NavigationBarItem[];
|
||||
}
|
||||
|
||||
export interface NavBarResponse extends Response {
|
||||
export interface NavBarResponse extends Response {
|
||||
body?: NavigationBarItem[];
|
||||
}
|
||||
}
|
||||
|
||||
+25
-23
@@ -1,13 +1,15 @@
|
||||
/// <reference path="node.d.ts" />
|
||||
/// <reference path="session.ts" />
|
||||
// used in fs.writeSync
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
namespace ts.server {
|
||||
var nodeproto: typeof NodeJS._debugger = require('_debugger');
|
||||
var readline: NodeJS.ReadLine = require('readline');
|
||||
var path: NodeJS.Path = require('path');
|
||||
var fs: typeof NodeJS.fs = require('fs');
|
||||
const nodeproto: typeof NodeJS._debugger = require("_debugger");
|
||||
const readline: NodeJS.ReadLine = require("readline");
|
||||
const path: NodeJS.Path = require("path");
|
||||
const fs: typeof NodeJS.fs = require("fs");
|
||||
|
||||
var rl = readline.createInterface({
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
terminal: false,
|
||||
@@ -68,7 +70,7 @@ namespace ts.server {
|
||||
}
|
||||
if (this.fd >= 0) {
|
||||
s = s + "\n";
|
||||
var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
|
||||
const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
|
||||
if (this.firstInGroup) {
|
||||
s = prefix + s;
|
||||
this.firstInGroup = false;
|
||||
@@ -77,7 +79,7 @@ namespace ts.server {
|
||||
this.seq++;
|
||||
this.firstInGroup = true;
|
||||
}
|
||||
var buf = new Buffer(s);
|
||||
const buf = new Buffer(s);
|
||||
fs.writeSync(this.fd, buf, 0, buf.length, null);
|
||||
}
|
||||
}
|
||||
@@ -95,12 +97,12 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
listen() {
|
||||
rl.on('line', (input: string) => {
|
||||
var message = input.trim();
|
||||
rl.on("line", (input: string) => {
|
||||
const message = input.trim();
|
||||
this.onMessage(message);
|
||||
});
|
||||
|
||||
rl.on('close', () => {
|
||||
rl.on("close", () => {
|
||||
this.exit();
|
||||
});
|
||||
}
|
||||
@@ -112,11 +114,11 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
function parseLoggingEnvironmentString(logEnvStr: string): LogOptions {
|
||||
var logEnv: LogOptions = {};
|
||||
var args = logEnvStr.split(' ');
|
||||
for (var i = 0, len = args.length; i < (len - 1); i += 2) {
|
||||
var option = args[i];
|
||||
var value = args[i + 1];
|
||||
const logEnv: LogOptions = {};
|
||||
const args = logEnvStr.split(" ");
|
||||
for (let i = 0, len = args.length; i < (len - 1); i += 2) {
|
||||
const option = args[i];
|
||||
const value = args[i + 1];
|
||||
if (option && value) {
|
||||
switch (option) {
|
||||
case "-file":
|
||||
@@ -133,11 +135,11 @@ namespace ts.server {
|
||||
|
||||
// TSS_LOG "{ level: "normal | verbose | terse", file?: string}"
|
||||
function createLoggerFromEnv() {
|
||||
var fileName: string = undefined;
|
||||
var detailLevel = "normal";
|
||||
var logEnvStr = process.env["TSS_LOG"];
|
||||
let fileName: string = undefined;
|
||||
let detailLevel = "normal";
|
||||
const logEnvStr = process.env["TSS_LOG"];
|
||||
if (logEnvStr) {
|
||||
var logEnv = parseLoggingEnvironmentString(logEnvStr);
|
||||
const logEnv = parseLoggingEnvironmentString(logEnvStr);
|
||||
if (logEnv.file) {
|
||||
fileName = logEnv.file;
|
||||
}
|
||||
@@ -153,9 +155,9 @@ namespace ts.server {
|
||||
// This places log file in the directory containing editorServices.js
|
||||
// TODO: check that this location is writable
|
||||
|
||||
var logger = createLoggerFromEnv();
|
||||
const logger = createLoggerFromEnv();
|
||||
|
||||
let pending: string[] = [];
|
||||
const pending: string[] = [];
|
||||
let canWrite = true;
|
||||
function writeMessage(s: string) {
|
||||
if (!canWrite) {
|
||||
@@ -177,8 +179,8 @@ namespace ts.server {
|
||||
// Override sys.write because fs.writeSync is not reliable on Node 4
|
||||
ts.sys.write = (s: string) => writeMessage(s);
|
||||
|
||||
var ioSession = new IOSession(ts.sys, logger);
|
||||
process.on('uncaughtException', function(err: Error) {
|
||||
const ioSession = new IOSession(ts.sys, logger);
|
||||
process.on("uncaughtException", function(err: Error) {
|
||||
ioSession.logError(err, "unknown");
|
||||
});
|
||||
// Start listening
|
||||
|
||||
+246
-240
File diff suppressed because it is too large
Load Diff
@@ -446,7 +446,7 @@ namespace ts.BreakpointResolver {
|
||||
// fall through.
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
return spanInNode(lastOrUndefined((<Block>node.parent).statements));;
|
||||
return spanInNode(lastOrUndefined((<Block>node.parent).statements));
|
||||
|
||||
case SyntaxKind.CaseBlock:
|
||||
// breakpoint in last statement of the last clause
|
||||
@@ -493,9 +493,6 @@ namespace ts.BreakpointResolver {
|
||||
default:
|
||||
return spanInNode(node.parent);
|
||||
}
|
||||
|
||||
// Default to parent node
|
||||
return spanInNode(node.parent);
|
||||
}
|
||||
|
||||
function spanInColonToken(node: Node): TextSpan {
|
||||
|
||||
@@ -360,7 +360,6 @@ namespace ts.formatting {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace ts.NavigateTo {
|
||||
let patternMatcher = createPatternMatcher(searchValue);
|
||||
let rawItems: RawNavigateToItem[] = [];
|
||||
|
||||
// This means "compare in a case insensitive manner."
|
||||
let baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
|
||||
|
||||
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
@@ -162,8 +165,6 @@ namespace ts.NavigateTo {
|
||||
return bestMatchKind;
|
||||
}
|
||||
|
||||
// This means "compare in a case insensitive manner."
|
||||
let baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
|
||||
function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem) {
|
||||
// TODO(cyrusn): get the gamut of comparisons that VS already uses here.
|
||||
// Right now we just sort by kind first, and then by name of the item.
|
||||
|
||||
+45
-39
@@ -773,6 +773,7 @@ namespace ts {
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public _declarationBrand: any;
|
||||
public fileName: string;
|
||||
public path: Path;
|
||||
public text: string;
|
||||
public scriptSnapshot: IScriptSnapshot;
|
||||
public lineMap: number[];
|
||||
@@ -1695,15 +1696,17 @@ namespace ts {
|
||||
class HostCache {
|
||||
private fileNameToEntry: FileMap<HostFileInformation>;
|
||||
private _compilationSettings: CompilerOptions;
|
||||
private currentDirectory: string;
|
||||
|
||||
constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) {
|
||||
constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) {
|
||||
// script id => script index
|
||||
this.fileNameToEntry = createFileMap<HostFileInformation>(getCanonicalFileName);
|
||||
this.currentDirectory = host.getCurrentDirectory();
|
||||
this.fileNameToEntry = createFileMap<HostFileInformation>();
|
||||
|
||||
// Initialize the list with the root file names
|
||||
let rootFileNames = host.getScriptFileNames();
|
||||
for (let fileName of rootFileNames) {
|
||||
this.createEntry(fileName);
|
||||
this.createEntry(fileName, toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
||||
}
|
||||
|
||||
// store the compilation settings
|
||||
@@ -1714,7 +1717,7 @@ namespace ts {
|
||||
return this._compilationSettings;
|
||||
}
|
||||
|
||||
private createEntry(fileName: string) {
|
||||
private createEntry(fileName: string, path: Path) {
|
||||
let entry: HostFileInformation;
|
||||
let scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
if (scriptSnapshot) {
|
||||
@@ -1725,30 +1728,31 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
this.fileNameToEntry.set(fileName, entry);
|
||||
this.fileNameToEntry.set(path, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
private getEntry(fileName: string): HostFileInformation {
|
||||
return this.fileNameToEntry.get(fileName);
|
||||
private getEntry(path: Path): HostFileInformation {
|
||||
return this.fileNameToEntry.get(path);
|
||||
}
|
||||
|
||||
private contains(fileName: string): boolean {
|
||||
return this.fileNameToEntry.contains(fileName);
|
||||
private contains(path: Path): boolean {
|
||||
return this.fileNameToEntry.contains(path);
|
||||
}
|
||||
|
||||
public getOrCreateEntry(fileName: string): HostFileInformation {
|
||||
if (this.contains(fileName)) {
|
||||
return this.getEntry(fileName);
|
||||
let path = toPath(fileName, this.currentDirectory, this.getCanonicalFileName)
|
||||
if (this.contains(path)) {
|
||||
return this.getEntry(path);
|
||||
}
|
||||
|
||||
return this.createEntry(fileName);
|
||||
return this.createEntry(fileName, path);
|
||||
}
|
||||
|
||||
public getRootFileNames(): string[] {
|
||||
let fileNames: string[] = [];
|
||||
|
||||
this.fileNameToEntry.forEachValue(value => {
|
||||
this.fileNameToEntry.forEachValue((path, value) => {
|
||||
if (value) {
|
||||
fileNames.push(value.hostFileName);
|
||||
}
|
||||
@@ -1757,13 +1761,13 @@ namespace ts {
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
public getVersion(fileName: string): string {
|
||||
let file = this.getEntry(fileName);
|
||||
public getVersion(path: Path): string {
|
||||
let file = this.getEntry(path);
|
||||
return file && file.version;
|
||||
}
|
||||
|
||||
public getScriptSnapshot(fileName: string): IScriptSnapshot {
|
||||
let file = this.getEntry(fileName);
|
||||
public getScriptSnapshot(path: Path): IScriptSnapshot {
|
||||
let file = this.getEntry(path);
|
||||
return file && file.scriptSnapshot;
|
||||
}
|
||||
}
|
||||
@@ -1993,7 +1997,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
|
||||
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry {
|
||||
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry {
|
||||
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
|
||||
// for those settings.
|
||||
let buckets: Map<FileMap<DocumentRegistryEntry>> = {};
|
||||
@@ -2007,7 +2011,7 @@ namespace ts {
|
||||
let key = getKeyFromCompilationSettings(settings);
|
||||
let bucket = lookUp(buckets, key);
|
||||
if (!bucket && createIfMissing) {
|
||||
buckets[key] = bucket = createFileMap<DocumentRegistryEntry>(getCanonicalFileName);
|
||||
buckets[key] = bucket = createFileMap<DocumentRegistryEntry>();
|
||||
}
|
||||
return bucket;
|
||||
}
|
||||
@@ -2016,14 +2020,13 @@ namespace ts {
|
||||
let bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === '_').map(name => {
|
||||
let entries = lookUp(buckets, name);
|
||||
let sourceFiles: { name: string; refCount: number; references: string[]; }[] = [];
|
||||
for (let i in entries) {
|
||||
let entry = entries.get(i);
|
||||
entries.forEachValue((key, entry) => {
|
||||
sourceFiles.push({
|
||||
name: i,
|
||||
name: key,
|
||||
refCount: entry.languageServiceRefCount,
|
||||
references: entry.owners.slice(0)
|
||||
});
|
||||
}
|
||||
});
|
||||
sourceFiles.sort((x, y) => y.refCount - x.refCount);
|
||||
return {
|
||||
bucket: name,
|
||||
@@ -2049,7 +2052,8 @@ namespace ts {
|
||||
acquiring: boolean): SourceFile {
|
||||
|
||||
let bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
|
||||
let entry = bucket.get(fileName);
|
||||
let path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
let entry = bucket.get(path);
|
||||
if (!entry) {
|
||||
Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?");
|
||||
|
||||
@@ -2061,7 +2065,7 @@ namespace ts {
|
||||
languageServiceRefCount: 0,
|
||||
owners: []
|
||||
};
|
||||
bucket.set(fileName, entry);
|
||||
bucket.set(path, entry);
|
||||
}
|
||||
else {
|
||||
// We have an entry for this file. However, it may be for a different version of
|
||||
@@ -2089,12 +2093,14 @@ namespace ts {
|
||||
let bucket = getBucketForCompilationSettings(compilationSettings, false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
let entry = bucket.get(fileName);
|
||||
let path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
|
||||
let entry = bucket.get(path);
|
||||
entry.languageServiceRefCount--;
|
||||
|
||||
Debug.assert(entry.languageServiceRefCount >= 0);
|
||||
if (entry.languageServiceRefCount === 0) {
|
||||
bucket.remove(fileName);
|
||||
bucket.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2556,7 +2562,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry()): LanguageService {
|
||||
export function createLanguageService(host: LanguageServiceHost,
|
||||
documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService {
|
||||
|
||||
let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host);
|
||||
let ruleProvider: formatting.RulesProvider;
|
||||
let program: Program;
|
||||
@@ -2565,6 +2573,7 @@ namespace ts {
|
||||
let useCaseSensitivefileNames = false;
|
||||
let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
|
||||
|
||||
let currentDirectory = host.getCurrentDirectory();
|
||||
// Check if the localized messages json is set, otherwise query the host for it
|
||||
if (!localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
|
||||
localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
|
||||
@@ -2579,8 +2588,7 @@ namespace ts {
|
||||
let getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames);
|
||||
|
||||
function getValidSourceFile(fileName: string): SourceFile {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
let sourceFile = program.getSourceFile(getCanonicalFileName(fileName));
|
||||
let sourceFile = program.getSourceFile(fileName);
|
||||
if (!sourceFile) {
|
||||
throw new Error("Could not find file: '" + fileName + "'.");
|
||||
}
|
||||
@@ -2641,7 +2649,7 @@ namespace ts {
|
||||
getNewLine: () => getNewLineOrDefaultFromHost(host),
|
||||
getDefaultLibFileName: (options) => host.getDefaultLibFileName(options),
|
||||
writeFile: (fileName, data, writeByteOrderMark) => { },
|
||||
getCurrentDirectory: () => host.getCurrentDirectory(),
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
fileExists: (fileName): boolean => {
|
||||
// stub missing host functionality
|
||||
Debug.assert(!host.resolveModuleNames);
|
||||
@@ -2665,9 +2673,8 @@ namespace ts {
|
||||
if (program) {
|
||||
let oldSourceFiles = program.getSourceFiles();
|
||||
for (let oldSourceFile of oldSourceFiles) {
|
||||
let fileName = oldSourceFile.fileName;
|
||||
if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) {
|
||||
documentRegistry.releaseDocument(fileName, oldSettings);
|
||||
if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) {
|
||||
documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2732,7 +2739,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function sourceFileUpToDate(sourceFile: SourceFile): boolean {
|
||||
return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName);
|
||||
let path = sourceFile.path || toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName);
|
||||
return sourceFile && sourceFile.version === hostCache.getVersion(path);
|
||||
}
|
||||
|
||||
function programUpToDate(): boolean {
|
||||
@@ -4929,7 +4937,7 @@ namespace ts {
|
||||
else if (!isFunctionLike(node)) {
|
||||
forEachChild(node, aggregate);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4976,7 +4984,7 @@ namespace ts {
|
||||
else if (!isFunctionLike(node)) {
|
||||
forEachChild(node, aggregate);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function ownsBreakOrContinueStatement(owner: Node, statement: BreakOrContinueStatement): boolean {
|
||||
@@ -6285,8 +6293,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace;
|
||||
|
||||
Debug.fail("Unknown declaration type");
|
||||
}
|
||||
|
||||
function isTypeReference(node: Node): boolean {
|
||||
|
||||
@@ -323,7 +323,6 @@ namespace ts {
|
||||
// TODO: should this be '==='?
|
||||
if (settingsJson == null || settingsJson == "") {
|
||||
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
|
||||
return null;
|
||||
}
|
||||
return <CompilerOptions>JSON.parse(settingsJson);
|
||||
}
|
||||
|
||||
@@ -57,5 +57,5 @@ function compile(fileNames, options) {
|
||||
exports.compile = compile;
|
||||
compile(process.argv.slice(2), {
|
||||
noEmitOnError: true, noImplicitAny: true,
|
||||
target: 1 /* ES5 */, module: 1 /* CommonJS */
|
||||
target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS
|
||||
});
|
||||
|
||||
@@ -75,28 +75,28 @@ function delint(sourceFile) {
|
||||
delintNode(sourceFile);
|
||||
function delintNode(node) {
|
||||
switch (node.kind) {
|
||||
case 199 /* ForStatement */:
|
||||
case 200 /* ForInStatement */:
|
||||
case 198 /* WhileStatement */:
|
||||
case 197 /* DoStatement */:
|
||||
if (node.statement.kind !== 192 /* Block */) {
|
||||
case ts.SyntaxKind.ForStatement:
|
||||
case ts.SyntaxKind.ForInStatement:
|
||||
case ts.SyntaxKind.WhileStatement:
|
||||
case ts.SyntaxKind.DoStatement:
|
||||
if (node.statement.kind !== ts.SyntaxKind.Block) {
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 196 /* IfStatement */:
|
||||
case ts.SyntaxKind.IfStatement:
|
||||
var ifStatement = node;
|
||||
if (ifStatement.thenStatement.kind !== 192 /* Block */) {
|
||||
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== 192 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 196 /* IfStatement */) {
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 181 /* BinaryExpression */:
|
||||
case ts.SyntaxKind.BinaryExpression:
|
||||
var op = node.operatorToken.kind;
|
||||
if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) {
|
||||
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
|
||||
report(node, "Use '===' and '!=='.");
|
||||
}
|
||||
break;
|
||||
@@ -112,7 +112,7 @@ exports.delint = delint;
|
||||
var fileNames = process.argv.slice(2);
|
||||
fileNames.forEach(function (fileName) {
|
||||
// Parse a file
|
||||
var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), 2 /* ES6 */, /*setParentNodes */ true);
|
||||
var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
// delint it
|
||||
delint(sourceFile);
|
||||
});
|
||||
|
||||
@@ -24,5 +24,5 @@ console.log(JSON.stringify(result));
|
||||
*/
|
||||
var ts = require("typescript");
|
||||
var source = "let x: string = 'string'";
|
||||
var result = ts.transpile(source, { module: 1 /* CommonJS */ });
|
||||
var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });
|
||||
console.log(JSON.stringify(result));
|
||||
|
||||
@@ -181,4 +181,4 @@ function watch(rootFileNames, options) {
|
||||
var currentDirectoryFiles = fs.readdirSync(process.cwd()).
|
||||
filter(function (fileName) { return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"; });
|
||||
// Start the watcher
|
||||
watch(currentDirectoryFiles, { module: 1 /* CommonJS */ });
|
||||
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
|
||||
|
||||
@@ -4,6 +4,6 @@ for (const v of union) { }
|
||||
|
||||
//// [ES3For-ofTypeCheck4.js]
|
||||
var union;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
var v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
var v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ for (var v of union) { }
|
||||
|
||||
//// [ES3For-ofTypeCheck6.js]
|
||||
var union;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
var v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
var v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ for (var v of a) {
|
||||
|
||||
//// [ES5For-of24.js]
|
||||
var a = [1, 2, 3];
|
||||
for (var _i = 0; _i < a.length; _i++) {
|
||||
var v = a[_i];
|
||||
var a_1 = 0;
|
||||
for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
|
||||
var v = a_1[_i];
|
||||
var a_2 = 0;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ for (var v of a) {
|
||||
|
||||
//// [ES5For-of25.js]
|
||||
var a = [1, 2, 3];
|
||||
for (var _i = 0; _i < a.length; _i++) {
|
||||
var v = a[_i];
|
||||
for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
|
||||
var v = a_1[_i];
|
||||
v;
|
||||
a;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
//// [ES5For-of25.js.map]
|
||||
{"version":3,"file":"ES5For-of25.js","sourceRoot":"","sources":["ES5For-of25.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,GAAG,CAAC,CAAU,UAAC,EAAV,aAAK,EAAL,IAAU,CAAC;IAAX,IAAI,CAAC,GAAI,CAAC,IAAL;IACN,CAAC,CAAC;IACF,CAAC,CAAC;CACL"}
|
||||
{"version":3,"file":"ES5For-of25.js","sourceRoot":"","sources":["ES5For-of25.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,GAAG,CAAC,CAAU,UAAC,EAAD,OAAC,EAAV,eAAK,EAAL,IAAU,CAAC;IAAX,IAAI,CAAC,UAAA;IACN,CAAC,CAAC;IACF,CAAC,CAAC;CACL"}
|
||||
@@ -21,7 +21,7 @@ sourceFile:ES5For-of25.ts
|
||||
10> ^
|
||||
11> ^
|
||||
12> ^
|
||||
13> ^^^^^^^^^^^^^^^^^^^^^^->
|
||||
13> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
2 >var
|
||||
3 > a
|
||||
@@ -47,17 +47,19 @@ sourceFile:ES5For-of25.ts
|
||||
11>Emitted(1, 18) Source(1, 18) + SourceIndex(0)
|
||||
12>Emitted(1, 19) Source(1, 19) + SourceIndex(0)
|
||||
---
|
||||
>>>for (var _i = 0; _i < a.length; _i++) {
|
||||
>>>for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
|
||||
1->
|
||||
2 >^^^
|
||||
3 > ^
|
||||
4 > ^
|
||||
5 > ^^^^^^^^^^
|
||||
6 > ^^
|
||||
7 > ^^^^^^^^^^^^^
|
||||
8 > ^^
|
||||
9 > ^^^^
|
||||
10> ^
|
||||
7 > ^^^^^^^
|
||||
8 > ^^
|
||||
9 > ^^^^^^^^^^^^^^^
|
||||
10> ^^
|
||||
11> ^^^^
|
||||
12> ^
|
||||
1->
|
||||
>
|
||||
2 >for
|
||||
@@ -65,40 +67,38 @@ sourceFile:ES5For-of25.ts
|
||||
4 > (var v of
|
||||
5 > a
|
||||
6 >
|
||||
7 > var v
|
||||
8 >
|
||||
9 > var v of a
|
||||
10> )
|
||||
7 > a
|
||||
8 >
|
||||
9 > var v
|
||||
10>
|
||||
11> var v of a
|
||||
12> )
|
||||
1->Emitted(2, 1) Source(2, 1) + SourceIndex(0)
|
||||
2 >Emitted(2, 4) Source(2, 4) + SourceIndex(0)
|
||||
3 >Emitted(2, 5) Source(2, 5) + SourceIndex(0)
|
||||
4 >Emitted(2, 6) Source(2, 15) + SourceIndex(0)
|
||||
5 >Emitted(2, 16) Source(2, 16) + SourceIndex(0)
|
||||
6 >Emitted(2, 18) Source(2, 6) + SourceIndex(0)
|
||||
7 >Emitted(2, 31) Source(2, 11) + SourceIndex(0)
|
||||
8 >Emitted(2, 33) Source(2, 6) + SourceIndex(0)
|
||||
9 >Emitted(2, 37) Source(2, 16) + SourceIndex(0)
|
||||
10>Emitted(2, 38) Source(2, 17) + SourceIndex(0)
|
||||
6 >Emitted(2, 18) Source(2, 15) + SourceIndex(0)
|
||||
7 >Emitted(2, 25) Source(2, 16) + SourceIndex(0)
|
||||
8 >Emitted(2, 27) Source(2, 6) + SourceIndex(0)
|
||||
9 >Emitted(2, 42) Source(2, 11) + SourceIndex(0)
|
||||
10>Emitted(2, 44) Source(2, 6) + SourceIndex(0)
|
||||
11>Emitted(2, 48) Source(2, 16) + SourceIndex(0)
|
||||
12>Emitted(2, 49) Source(2, 17) + SourceIndex(0)
|
||||
---
|
||||
>>> var v = a[_i];
|
||||
>>> var v = a_1[_i];
|
||||
1 >^^^^
|
||||
2 > ^^^^
|
||||
3 > ^
|
||||
4 > ^^^
|
||||
5 > ^
|
||||
6 > ^^^^
|
||||
4 > ^^^^^^^^^^
|
||||
1 >
|
||||
2 > var
|
||||
3 > v
|
||||
4 > of
|
||||
5 > a
|
||||
6 >
|
||||
4 >
|
||||
1 >Emitted(3, 5) Source(2, 6) + SourceIndex(0)
|
||||
2 >Emitted(3, 9) Source(2, 10) + SourceIndex(0)
|
||||
3 >Emitted(3, 10) Source(2, 11) + SourceIndex(0)
|
||||
4 >Emitted(3, 13) Source(2, 15) + SourceIndex(0)
|
||||
5 >Emitted(3, 14) Source(2, 16) + SourceIndex(0)
|
||||
6 >Emitted(3, 18) Source(2, 11) + SourceIndex(0)
|
||||
4 >Emitted(3, 20) Source(2, 11) + SourceIndex(0)
|
||||
---
|
||||
>>> v;
|
||||
1 >^^^^
|
||||
|
||||
@@ -9,8 +9,8 @@ for ([a = 1, b = ""] of tuple) {
|
||||
//// [ES5For-of30.js]
|
||||
var a, b;
|
||||
var tuple = [2, "3"];
|
||||
for (var _i = 0; _i < tuple.length; _i++) {
|
||||
_a = tuple[_i], _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? "" : _c;
|
||||
for (var _i = 0, tuple_1 = tuple; _i < tuple_1.length; _i++) {
|
||||
_a = tuple_1[_i], _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? "" : _c;
|
||||
a;
|
||||
b;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ for (v of union) { }
|
||||
//// [ES5For-ofTypeCheck11.js]
|
||||
var union;
|
||||
var v;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ for (var v of tuple) { }
|
||||
|
||||
//// [ES5For-ofTypeCheck3.js]
|
||||
var tuple = ["", 0];
|
||||
for (var _i = 0; _i < tuple.length; _i++) {
|
||||
var v = tuple[_i];
|
||||
for (var _i = 0, tuple_1 = tuple; _i < tuple_1.length; _i++) {
|
||||
var v = tuple_1[_i];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ for (const v of union) { }
|
||||
|
||||
//// [ES5For-ofTypeCheck4.js]
|
||||
var union;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
var v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
var v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ for (var v of union) { }
|
||||
|
||||
//// [ES5For-ofTypeCheck5.js]
|
||||
var union;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
var v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
var v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ for (var v of union) { }
|
||||
|
||||
//// [ES5For-ofTypeCheck6.js]
|
||||
var union;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
var v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
var v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ for (var v of union) { }
|
||||
|
||||
//// [ES5For-ofTypeCheck7.js]
|
||||
var union;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
var v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
var v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ for (v of union) { }
|
||||
//// [ES5For-ofTypeCheck8.js]
|
||||
var union;
|
||||
var v;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ for (let v of union) { }
|
||||
|
||||
//// [ES5For-ofTypeCheck9.js]
|
||||
var union;
|
||||
for (var _i = 0; _i < union.length; _i++) {
|
||||
var v = union[_i];
|
||||
for (var _i = 0, union_1 = union; _i < union_1.length; _i++) {
|
||||
var v = union_1[_i];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [ES5for-of32.ts]
|
||||
|
||||
var array = [1,2,3];
|
||||
var sum = 0;
|
||||
|
||||
for (let num of array) {
|
||||
if (sum === 0) {
|
||||
array = [4,5,6]
|
||||
}
|
||||
|
||||
sum += num;
|
||||
}
|
||||
|
||||
//// [ES5for-of32.js]
|
||||
var array = [1, 2, 3];
|
||||
var sum = 0;
|
||||
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
||||
var num = array_1[_i];
|
||||
if (sum === 0) {
|
||||
array = [4, 5, 6];
|
||||
}
|
||||
sum += num;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5for-of32.ts ===
|
||||
|
||||
var array = [1,2,3];
|
||||
>array : Symbol(array, Decl(ES5for-of32.ts, 1, 3))
|
||||
|
||||
var sum = 0;
|
||||
>sum : Symbol(sum, Decl(ES5for-of32.ts, 2, 3))
|
||||
|
||||
for (let num of array) {
|
||||
>num : Symbol(num, Decl(ES5for-of32.ts, 4, 8))
|
||||
>array : Symbol(array, Decl(ES5for-of32.ts, 1, 3))
|
||||
|
||||
if (sum === 0) {
|
||||
>sum : Symbol(sum, Decl(ES5for-of32.ts, 2, 3))
|
||||
|
||||
array = [4,5,6]
|
||||
>array : Symbol(array, Decl(ES5for-of32.ts, 1, 3))
|
||||
}
|
||||
|
||||
sum += num;
|
||||
>sum : Symbol(sum, Decl(ES5for-of32.ts, 2, 3))
|
||||
>num : Symbol(num, Decl(ES5for-of32.ts, 4, 8))
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5for-of32.ts ===
|
||||
|
||||
var array = [1,2,3];
|
||||
>array : number[]
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
var sum = 0;
|
||||
>sum : number
|
||||
>0 : number
|
||||
|
||||
for (let num of array) {
|
||||
>num : number
|
||||
>array : number[]
|
||||
|
||||
if (sum === 0) {
|
||||
>sum === 0 : boolean
|
||||
>sum : number
|
||||
>0 : number
|
||||
|
||||
array = [4,5,6]
|
||||
>array = [4,5,6] : number[]
|
||||
>array : number[]
|
||||
>[4,5,6] : number[]
|
||||
>4 : number
|
||||
>5 : number
|
||||
>6 : number
|
||||
}
|
||||
|
||||
sum += num;
|
||||
>sum += num : number
|
||||
>sum : number
|
||||
>num : number
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/ParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/compiler/ParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
tests/cases/compiler/ParameterList5.ts(1,16): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/compiler/ParameterList5.ts(1,29): error TS2304: Cannot find name 'C'.
|
||||
|
||||
@@ -6,7 +6,7 @@ tests/cases/compiler/ParameterList5.ts(1,29): error TS2304: Cannot find name 'C'
|
||||
==== tests/cases/compiler/ParameterList5.ts (3 errors) ====
|
||||
function A(): (public B) => C {
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
~
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
@@ -8,6 +8,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): err
|
||||
~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
!!! error TS2378: A 'get' accessor must return a value.
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@@ -11,8 +11,8 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe
|
||||
//// [argumentsObjectIterator01_ES5.js]
|
||||
function doubleAndReturnAsArray(x, y, z) {
|
||||
var result = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
var arg = arguments[_i];
|
||||
for (var _i = 0, arguments_1 = arguments; _i < arguments_1.length; _i++) {
|
||||
var arg = arguments_1[_i];
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -13,6 +13,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(2
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,3): error TS7028: Unused label.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression.
|
||||
@@ -38,7 +39,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ====
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
|
||||
@@ -104,6 +105,8 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
|
||||
|
||||
// object literals
|
||||
{ a: 0} = value;
|
||||
~
|
||||
!!! error TS7028: Unused label.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,11): error TS2304: Cannot find name 'async'.
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,17): error TS1005: ',' expected.
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,20): error TS1005: '=' expected.
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(2,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts(4,11): error TS2304: Cannot find name 'await'.
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
// Legal to use 'await' in a type context.
|
||||
var v: await;
|
||||
~~~~~
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1005: '(' expected.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: '=' expected.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected.
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
~
|
||||
!!! error TS1005: '=>' expected.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,16): error TS1055: Type '{}' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(7,16): error TS1055: Type 'any' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,16): error TS1055: Type 'number' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,16): error TS1055: Type 'PromiseLike<void>' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,16): error TS1055: Type 'PromiseLike' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,16): error TS1055: Type 'typeof Thenable' is not a valid async function return type.
|
||||
Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
|
||||
Types of property 'then' are incompatible.
|
||||
@@ -28,7 +28,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1
|
||||
!!! error TS1055: Type 'number' is not a valid async function return type.
|
||||
async function fn5(): PromiseLike<void> { } // error
|
||||
~~~
|
||||
!!! error TS1055: Type 'PromiseLike<void>' is not a valid async function return type.
|
||||
!!! error TS1055: Type 'PromiseLike' is not a valid async function return type.
|
||||
async function fn6(): Thenable { } // error
|
||||
~~~
|
||||
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,3): error TS1042: 'async' modifier cannot be used here.
|
||||
tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get' accessor must return a value.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es6/asyncGetter_es6.ts (2 errors) ====
|
||||
@@ -8,6 +8,6 @@ tests/cases/conformance/async/es6/asyncGetter_es6.ts(2,13): error TS2378: A 'get
|
||||
~~~~~
|
||||
!!! error TS1042: 'async' modifier cannot be used here.
|
||||
~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
!!! error TS2378: A 'get' accessor must return a value.
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
//// [bestCommonTypeReturnStatement.ts]
|
||||
|
||||
interface IPromise<T> {
|
||||
then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise<any>;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,35 @@
|
||||
=== tests/cases/compiler/bestCommonTypeReturnStatement.ts ===
|
||||
|
||||
interface IPromise<T> {
|
||||
>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 0, 19))
|
||||
>T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 1, 19))
|
||||
|
||||
then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise<any>;
|
||||
>then : Symbol(then, Decl(bestCommonTypeReturnStatement.ts, 0, 23))
|
||||
>successCallback : Symbol(successCallback, Decl(bestCommonTypeReturnStatement.ts, 1, 9))
|
||||
>promiseValue : Symbol(promiseValue, Decl(bestCommonTypeReturnStatement.ts, 1, 27))
|
||||
>T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 0, 19))
|
||||
>errorCallback : Symbol(errorCallback, Decl(bestCommonTypeReturnStatement.ts, 1, 51))
|
||||
>reason : Symbol(reason, Decl(bestCommonTypeReturnStatement.ts, 1, 69))
|
||||
>then : Symbol(then, Decl(bestCommonTypeReturnStatement.ts, 1, 23))
|
||||
>successCallback : Symbol(successCallback, Decl(bestCommonTypeReturnStatement.ts, 2, 9))
|
||||
>promiseValue : Symbol(promiseValue, Decl(bestCommonTypeReturnStatement.ts, 2, 27))
|
||||
>T : Symbol(T, Decl(bestCommonTypeReturnStatement.ts, 1, 19))
|
||||
>errorCallback : Symbol(errorCallback, Decl(bestCommonTypeReturnStatement.ts, 2, 51))
|
||||
>reason : Symbol(reason, Decl(bestCommonTypeReturnStatement.ts, 2, 69))
|
||||
>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0))
|
||||
}
|
||||
|
||||
function f() {
|
||||
>f : Symbol(f, Decl(bestCommonTypeReturnStatement.ts, 2, 1))
|
||||
>f : Symbol(f, Decl(bestCommonTypeReturnStatement.ts, 3, 1))
|
||||
|
||||
if (true) return b();
|
||||
>b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 7, 1))
|
||||
>b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 8, 1))
|
||||
|
||||
return d();
|
||||
>d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 10, 45))
|
||||
>d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 11, 45))
|
||||
}
|
||||
|
||||
|
||||
function b(): IPromise<void> { return null; }
|
||||
>b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 7, 1))
|
||||
>b : Symbol(b, Decl(bestCommonTypeReturnStatement.ts, 8, 1))
|
||||
>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0))
|
||||
|
||||
function d(): IPromise<any> { return null; }
|
||||
>d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 10, 45))
|
||||
>d : Symbol(d, Decl(bestCommonTypeReturnStatement.ts, 11, 45))
|
||||
>IPromise : Symbol(IPromise, Decl(bestCommonTypeReturnStatement.ts, 0, 0))
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
=== tests/cases/compiler/bestCommonTypeReturnStatement.ts ===
|
||||
|
||||
interface IPromise<T> {
|
||||
>IPromise : IPromise<T>
|
||||
>T : T
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//// [breakTarget3.ts]
|
||||
|
||||
target1:
|
||||
target2:
|
||||
while (true) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
=== tests/cases/compiler/breakTarget3.ts ===
|
||||
target1:
|
||||
|
||||
No type information for this code.target1:
|
||||
No type information for this code.target2:
|
||||
No type information for this code.while (true) {
|
||||
No type information for this code. break target1;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
=== tests/cases/compiler/breakTarget3.ts ===
|
||||
|
||||
target1:
|
||||
>target1 : any
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//// [breakTarget4.ts]
|
||||
|
||||
target1:
|
||||
target2:
|
||||
while (true) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
=== tests/cases/compiler/breakTarget4.ts ===
|
||||
target1:
|
||||
|
||||
No type information for this code.target1:
|
||||
No type information for this code.target2:
|
||||
No type information for this code.while (true) {
|
||||
No type information for this code. break target2;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
=== tests/cases/compiler/breakTarget4.ts ===
|
||||
|
||||
target1:
|
||||
>target1 : any
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
tests/cases/compiler/breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary.
|
||||
tests/cases/compiler/breakTarget5.ts(6,7): error TS1107: Jump target cannot cross function boundary.
|
||||
|
||||
|
||||
==== tests/cases/compiler/breakTarget5.ts (1 errors) ====
|
||||
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//// [breakTarget5.ts]
|
||||
|
||||
target:
|
||||
while (true) {
|
||||
function f() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//// [callSignatureWithoutReturnTypeAnnotationInference.ts]
|
||||
|
||||
// Call signatures without a return type should infer one from the function body (if present)
|
||||
|
||||
// Simple types
|
||||
|
||||
+99
-98
@@ -1,55 +1,56 @@
|
||||
=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithoutReturnTypeAnnotationInference.ts ===
|
||||
|
||||
// Call signatures without a return type should infer one from the function body (if present)
|
||||
|
||||
// Simple types
|
||||
function foo(x) {
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 3, 13))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 4, 13))
|
||||
|
||||
return 1;
|
||||
}
|
||||
var r = foo(1);
|
||||
>r : Symbol(r, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 3))
|
||||
>r : Symbol(r, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 7, 3))
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0))
|
||||
|
||||
function foo2(x) {
|
||||
>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 15))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 8, 14))
|
||||
>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 7, 15))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 9, 14))
|
||||
|
||||
return foo(x);
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 8, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 9, 14))
|
||||
}
|
||||
var r2 = foo2(1);
|
||||
>r2 : Symbol(r2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 3))
|
||||
>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 6, 15))
|
||||
>r2 : Symbol(r2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 3))
|
||||
>foo2 : Symbol(foo2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 7, 15))
|
||||
|
||||
function foo3() {
|
||||
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17))
|
||||
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 17))
|
||||
|
||||
return foo3();
|
||||
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17))
|
||||
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 17))
|
||||
}
|
||||
var r3 = foo3();
|
||||
>r3 : Symbol(r3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 3))
|
||||
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 11, 17))
|
||||
>r3 : Symbol(r3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 17, 3))
|
||||
>foo3 : Symbol(foo3, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 12, 17))
|
||||
|
||||
function foo4<T>(x: T) {
|
||||
>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 16))
|
||||
>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 17))
|
||||
>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 14))
|
||||
>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 17, 16))
|
||||
>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 17))
|
||||
>T : Symbol(T, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 14))
|
||||
|
||||
return x;
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 18, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 19, 17))
|
||||
}
|
||||
var r4 = foo4(1);
|
||||
>r4 : Symbol(r4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 3))
|
||||
>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 16, 16))
|
||||
>r4 : Symbol(r4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 22, 3))
|
||||
>foo4 : Symbol(foo4, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 17, 16))
|
||||
|
||||
function foo5(x) {
|
||||
>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 23, 14))
|
||||
>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 22, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 24, 14))
|
||||
|
||||
if (true) {
|
||||
return 1;
|
||||
@@ -58,17 +59,17 @@ function foo5(x) {
|
||||
}
|
||||
}
|
||||
var r5 = foo5(1);
|
||||
>r5 : Symbol(r5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 3))
|
||||
>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 21, 17))
|
||||
>r5 : Symbol(r5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 31, 3))
|
||||
>foo5 : Symbol(foo5, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 22, 17))
|
||||
|
||||
function foo6(x) {
|
||||
>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 32, 14))
|
||||
>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 31, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 33, 14))
|
||||
|
||||
try {
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 35, 11))
|
||||
>e : Symbol(e, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 36, 11))
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -77,179 +78,179 @@ function foo6(x) {
|
||||
}
|
||||
}
|
||||
var r6 = foo6(1);
|
||||
>r6 : Symbol(r6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 3))
|
||||
>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 30, 17))
|
||||
>r6 : Symbol(r6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 43, 3))
|
||||
>foo6 : Symbol(foo6, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 31, 17))
|
||||
|
||||
function foo7(x) {
|
||||
>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 44, 14))
|
||||
>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 43, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 45, 14))
|
||||
|
||||
return typeof x;
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 44, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 45, 14))
|
||||
}
|
||||
var r7 = foo7(1);
|
||||
>r7 : Symbol(r7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 3))
|
||||
>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 42, 17))
|
||||
>r7 : Symbol(r7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 48, 3))
|
||||
>foo7 : Symbol(foo7, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 43, 17))
|
||||
|
||||
// object types
|
||||
function foo8(x: number) {
|
||||
>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 50, 14))
|
||||
>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 48, 17))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 51, 14))
|
||||
|
||||
return { x: x };
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 51, 12))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 50, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 52, 12))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 51, 14))
|
||||
}
|
||||
var r8 = foo8(1);
|
||||
>r8 : Symbol(r8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 3))
|
||||
>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 47, 17))
|
||||
>r8 : Symbol(r8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 54, 3))
|
||||
>foo8 : Symbol(foo8, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 48, 17))
|
||||
|
||||
interface I {
|
||||
>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 17))
|
||||
>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 54, 17))
|
||||
|
||||
foo: string;
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 55, 13))
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 56, 13))
|
||||
}
|
||||
function foo9(x: number) {
|
||||
>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 57, 1))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 58, 14))
|
||||
>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 58, 1))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 14))
|
||||
|
||||
var i: I;
|
||||
>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 7))
|
||||
>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 53, 17))
|
||||
>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 60, 7))
|
||||
>I : Symbol(I, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 54, 17))
|
||||
|
||||
return i;
|
||||
>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 59, 7))
|
||||
>i : Symbol(i, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 60, 7))
|
||||
}
|
||||
var r9 = foo9(1);
|
||||
>r9 : Symbol(r9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 3))
|
||||
>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 57, 1))
|
||||
>r9 : Symbol(r9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 63, 3))
|
||||
>foo9 : Symbol(foo9, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 58, 1))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 17))
|
||||
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 63, 17))
|
||||
|
||||
foo: string;
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 64, 9))
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 65, 9))
|
||||
}
|
||||
function foo10(x: number) {
|
||||
>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 66, 1))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 67, 15))
|
||||
>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 67, 1))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 15))
|
||||
|
||||
var c: C;
|
||||
>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 7))
|
||||
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 62, 17))
|
||||
>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 69, 7))
|
||||
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 63, 17))
|
||||
|
||||
return c;
|
||||
>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 68, 7))
|
||||
>c : Symbol(c, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 69, 7))
|
||||
}
|
||||
var r10 = foo10(1);
|
||||
>r10 : Symbol(r10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 3))
|
||||
>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 66, 1))
|
||||
>r10 : Symbol(r10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 72, 3))
|
||||
>foo10 : Symbol(foo10, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 67, 1))
|
||||
|
||||
module M {
|
||||
>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 19))
|
||||
>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 72, 19))
|
||||
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 74, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 75, 14))
|
||||
|
||||
export class C { foo: string }
|
||||
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 74, 21))
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 75, 20))
|
||||
>C : Symbol(C, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 75, 21))
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 20))
|
||||
}
|
||||
function foo11() {
|
||||
>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 1))
|
||||
>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 77, 1))
|
||||
|
||||
return M;
|
||||
>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 71, 19))
|
||||
>M : Symbol(M, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 72, 19))
|
||||
}
|
||||
var r11 = foo11();
|
||||
>r11 : Symbol(r11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 3))
|
||||
>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 76, 1))
|
||||
>r11 : Symbol(r11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 3))
|
||||
>foo11 : Symbol(foo11, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 77, 1))
|
||||
|
||||
// merged declarations
|
||||
interface I2 {
|
||||
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1))
|
||||
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 1))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 83, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 84, 14))
|
||||
}
|
||||
interface I2 {
|
||||
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1))
|
||||
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 1))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 14))
|
||||
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 87, 14))
|
||||
}
|
||||
function foo12() {
|
||||
>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 88, 1))
|
||||
>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 89, 1))
|
||||
|
||||
var i2: I2;
|
||||
>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 90, 7))
|
||||
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 80, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 85, 1))
|
||||
>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 91, 7))
|
||||
>I2 : Symbol(I2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 81, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 86, 1))
|
||||
|
||||
return i2;
|
||||
>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 90, 7))
|
||||
>i2 : Symbol(i2, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 91, 7))
|
||||
}
|
||||
var r12 = foo12();
|
||||
>r12 : Symbol(r12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 3))
|
||||
>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 88, 1))
|
||||
>r12 : Symbol(r12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 3))
|
||||
>foo12 : Symbol(foo12, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 89, 1))
|
||||
|
||||
function m1() { return 1; }
|
||||
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27))
|
||||
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 27))
|
||||
|
||||
module m1 { export var y = 2; }
|
||||
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27))
|
||||
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 22))
|
||||
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 27))
|
||||
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 97, 22))
|
||||
|
||||
function foo13() {
|
||||
>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 31))
|
||||
>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 97, 31))
|
||||
|
||||
return m1;
|
||||
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 93, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 95, 27))
|
||||
>m1 : Symbol(m1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 94, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 27))
|
||||
}
|
||||
var r13 = foo13();
|
||||
>r13 : Symbol(r13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 3))
|
||||
>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 96, 31))
|
||||
>r13 : Symbol(r13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 3))
|
||||
>foo13 : Symbol(foo13, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 97, 31))
|
||||
|
||||
class c1 {
|
||||
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1))
|
||||
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 106, 1))
|
||||
|
||||
foo: string;
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 102, 10))
|
||||
>foo : Symbol(foo, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 103, 10))
|
||||
|
||||
constructor(x) { }
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 104, 16))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 16))
|
||||
}
|
||||
module c1 {
|
||||
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1))
|
||||
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 106, 1))
|
||||
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 107, 14))
|
||||
>x : Symbol(x, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 14))
|
||||
}
|
||||
function foo14() {
|
||||
>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 1))
|
||||
>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 109, 1))
|
||||
|
||||
return c1;
|
||||
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 100, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 105, 1))
|
||||
>c1 : Symbol(c1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 101, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 106, 1))
|
||||
}
|
||||
var r14 = foo14();
|
||||
>r14 : Symbol(r14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 3))
|
||||
>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 108, 1))
|
||||
>r14 : Symbol(r14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 3))
|
||||
>foo14 : Symbol(foo14, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 109, 1))
|
||||
|
||||
enum e1 { A }
|
||||
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13))
|
||||
>A : Symbol(e1.A, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 9))
|
||||
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 13))
|
||||
>A : Symbol(e1.A, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 9))
|
||||
|
||||
module e1 { export var y = 1; }
|
||||
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13))
|
||||
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 22))
|
||||
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 13))
|
||||
>y : Symbol(y, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 116, 22))
|
||||
|
||||
function foo15() {
|
||||
>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 31))
|
||||
>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 116, 31))
|
||||
|
||||
return e1;
|
||||
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 112, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 114, 13))
|
||||
>e1 : Symbol(e1, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 113, 18), Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 13))
|
||||
}
|
||||
var r15 = foo15();
|
||||
>r15 : Symbol(r15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 119, 3))
|
||||
>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 115, 31))
|
||||
>r15 : Symbol(r15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 120, 3))
|
||||
>foo15 : Symbol(foo15, Decl(callSignatureWithoutReturnTypeAnnotationInference.ts, 116, 31))
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user