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
|
||||
|
||||
+19
-5
@@ -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",
|
||||
@@ -164,7 +166,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) {
|
||||
@@ -320,6 +322,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 +352,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 +454,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 +488,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");
|
||||
@@ -890,7 +902,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() {
|
||||
|
||||
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;
|
||||
|
||||
+1406
-982
File diff suppressed because it is too large
Load Diff
+1453
-1022
File diff suppressed because it is too large
Load Diff
Vendored
+11
-4
@@ -328,6 +328,7 @@ declare namespace ts {
|
||||
FirstNode = 135,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 1,
|
||||
Ambient = 2,
|
||||
Public = 16,
|
||||
@@ -954,7 +955,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 {
|
||||
@@ -1279,6 +1280,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.
|
||||
@@ -1350,6 +1352,7 @@ declare namespace ts {
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1521,11 +1524,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 +1566,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 */
|
||||
|
||||
+1529
-1056
File diff suppressed because it is too large
Load Diff
Vendored
+11
-4
@@ -328,6 +328,7 @@ declare namespace ts {
|
||||
FirstNode = 135,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 1,
|
||||
Ambient = 2,
|
||||
Public = 16,
|
||||
@@ -954,7 +955,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 {
|
||||
@@ -1279,6 +1280,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.
|
||||
@@ -1350,6 +1352,7 @@ declare namespace ts {
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1521,11 +1524,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 +1566,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 */
|
||||
|
||||
+1529
-1056
File diff suppressed because it is too large
Load Diff
+33
-17
@@ -5481,7 +5481,7 @@ namespace ts {
|
||||
let targetType = getIndexTypeOfType(target, IndexKind.String);
|
||||
if (targetType) {
|
||||
if ((targetType.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) {
|
||||
// non-primitive assignment to any is always allowed, eg
|
||||
// non-primitive assignment to any is always allowed, eg
|
||||
// `var x: { [index: string]: any } = { property: 12 };`
|
||||
return Ternary.True;
|
||||
}
|
||||
@@ -5511,7 +5511,7 @@ namespace ts {
|
||||
let targetType = getIndexTypeOfType(target, IndexKind.Number);
|
||||
if (targetType) {
|
||||
if ((targetType.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) {
|
||||
// non-primitive assignment to any is always allowed, eg
|
||||
// non-primitive assignment to any is always allowed, eg
|
||||
// `var x: { [index: number]: any } = { property: 12 };`
|
||||
return Ternary.True;
|
||||
}
|
||||
@@ -6583,26 +6583,34 @@ namespace ts {
|
||||
|
||||
function checkBlockScopedBindingCapturedInLoop(node: Identifier, symbol: Symbol): void {
|
||||
if (languageVersion >= ScriptTarget.ES6 ||
|
||||
(symbol.flags & SymbolFlags.BlockScopedVariable) === 0 ||
|
||||
(symbol.flags & (SymbolFlags.BlockScopedVariable | SymbolFlags.Class)) === 0 ||
|
||||
symbol.valueDeclaration.parent.kind === SyntaxKind.CatchClause) {
|
||||
return;
|
||||
}
|
||||
|
||||
// - check if binding is used in some function
|
||||
// (stop the walk when reaching container of binding declaration)
|
||||
// - if first check succeeded - check if variable is declared inside the loop
|
||||
// 1. walk from the use site up to the declaration and check
|
||||
// if there is anything function like between declaration and use-site (is binding/class is captured in function).
|
||||
// 2. walk from the declaration up to the boundary of lexical environment and check
|
||||
// if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement)
|
||||
|
||||
// nesting structure:
|
||||
// (variable declaration or binding element) -> variable declaration list -> container
|
||||
let container: Node = symbol.valueDeclaration;
|
||||
while (container.kind !== SyntaxKind.VariableDeclarationList) {
|
||||
container = container.parent;
|
||||
let container: Node;
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
// get parent of class declaration
|
||||
container = getClassLikeDeclarationOfSymbol(symbol).parent;
|
||||
}
|
||||
// get the parent of variable declaration list
|
||||
container = container.parent;
|
||||
if (container.kind === SyntaxKind.VariableStatement) {
|
||||
// if parent is variable statement - get its parent
|
||||
else {
|
||||
// nesting structure:
|
||||
// (variable declaration or binding element) -> variable declaration list -> container
|
||||
container = symbol.valueDeclaration;
|
||||
while (container.kind !== SyntaxKind.VariableDeclarationList) {
|
||||
container = container.parent;
|
||||
}
|
||||
// get the parent of variable declaration list
|
||||
container = container.parent;
|
||||
if (container.kind === SyntaxKind.VariableStatement) {
|
||||
// if parent is variable statement - get its parent
|
||||
container = container.parent;
|
||||
}
|
||||
}
|
||||
|
||||
let inFunction = isInsideFunction(node.parent, container);
|
||||
@@ -11623,9 +11631,12 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
let promiseConstructor = getMergedSymbol(promiseType.symbol);
|
||||
let promiseConstructor = getNodeLinks(node.type).resolvedSymbol;
|
||||
if (!promiseConstructor || !symbolIsValue(promiseConstructor)) {
|
||||
error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType));
|
||||
let typeName = promiseConstructor
|
||||
? symbolToString(promiseConstructor)
|
||||
: typeToString(promiseType);
|
||||
error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName);
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -12211,6 +12222,11 @@ namespace ts {
|
||||
|
||||
checkExpression(node.expression);
|
||||
checkSourceElement(node.thenStatement);
|
||||
|
||||
if (node.thenStatement.kind === SyntaxKind.EmptyStatement) {
|
||||
error(node.thenStatement, Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
||||
}
|
||||
|
||||
checkSourceElement(node.elseStatement);
|
||||
}
|
||||
|
||||
|
||||
@@ -267,6 +267,11 @@ namespace ts {
|
||||
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
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -830,7 +830,7 @@ namespace ts {
|
||||
if (verboseDebugInfo) {
|
||||
verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo();
|
||||
}
|
||||
|
||||
debugger;
|
||||
throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString);
|
||||
}
|
||||
}
|
||||
@@ -849,4 +849,4 @@ namespace ts {
|
||||
}
|
||||
return copiedList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -2290,22 +2294,26 @@
|
||||
"category": "Message",
|
||||
"code": 6072
|
||||
},
|
||||
"Do not report errors on unused labels.": {
|
||||
"Disallow inconsistently-cased references to the same file.": {
|
||||
"category": "Message",
|
||||
"code": 6073
|
||||
},
|
||||
"Report error when not all code paths in function return a value.": {
|
||||
"Do not report errors on unused labels.": {
|
||||
"category": "Message",
|
||||
"code": 6074
|
||||
},
|
||||
"Report errors for fallthrough cases in switch statement.": {
|
||||
"Report error when not all code paths in function return a value.": {
|
||||
"category": "Message",
|
||||
"code": 6075
|
||||
},
|
||||
"Do not report errors on unreachable code.": {
|
||||
"Report errors for fallthrough cases in switch statement.": {
|
||||
"category": "Message",
|
||||
"code": 6076
|
||||
},
|
||||
"Do not report errors on unreachable code.": {
|
||||
"category": "Message",
|
||||
"code": 6077
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
+66
-56
@@ -207,7 +207,6 @@ namespace ts {
|
||||
};
|
||||
|
||||
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
|
||||
let currentDirectory: string;
|
||||
let existingDirectories: Map<boolean> = {};
|
||||
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
@@ -277,7 +276,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,
|
||||
@@ -342,11 +341,15 @@ namespace ts {
|
||||
|
||||
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));
|
||||
let filesByName = createFileMap<SourceFile>(getCanonicalFileName);
|
||||
// stores 'filename -> file association' ignoring case
|
||||
// used to track cases when two file names differ only in casing
|
||||
let filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap<SourceFile>(fileName => fileName.toLowerCase()) : undefined;
|
||||
|
||||
if (oldProgram) {
|
||||
// check properties that can affect structure of the program or module resolution strategy
|
||||
@@ -394,7 +397,7 @@ namespace ts {
|
||||
getDiagnosticsProducingTypeChecker,
|
||||
getCommonSourceDirectory: () => commonSourceDirectory,
|
||||
emit,
|
||||
getCurrentDirectory: () => host.getCurrentDirectory(),
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getNodeCount: () => getDiagnosticsProducingTypeChecker().getNodeCount(),
|
||||
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
|
||||
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
|
||||
@@ -432,13 +435,18 @@ namespace ts {
|
||||
|
||||
// check if program source files has changed in the way that can affect structure of the program
|
||||
let newSourceFiles: SourceFile[] = [];
|
||||
let normalizedAbsoluteFileNames: string[] = [];
|
||||
let modifiedSourceFiles: SourceFile[] = [];
|
||||
|
||||
for (let oldSourceFile of oldProgram.getSourceFiles()) {
|
||||
let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
|
||||
if (!newSourceFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const normalizedAbsolutePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
|
||||
normalizedAbsoluteFileNames.push(normalizedAbsolutePath);
|
||||
|
||||
if (oldSourceFile !== newSourceFile) {
|
||||
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
||||
// value of no-default-lib has changed
|
||||
@@ -461,7 +469,7 @@ namespace ts {
|
||||
|
||||
if (resolveModuleNamesWorker) {
|
||||
let moduleNames = map(newSourceFile.imports, name => name.text);
|
||||
let resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName);
|
||||
let resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath);
|
||||
// ensure that module resolution results are still correct
|
||||
for (let i = 0; i < moduleNames.length; ++i) {
|
||||
let newResolution = resolutions[i];
|
||||
@@ -491,8 +499,8 @@ 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(normalizedAbsoluteFileNames[i], newSourceFiles[i]);
|
||||
}
|
||||
|
||||
files = newSourceFiles;
|
||||
@@ -508,10 +516,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,
|
||||
@@ -561,10 +569,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(getNormalizedAbsolutePath(fileName, currentDirectory));
|
||||
}
|
||||
|
||||
function getDiagnosticsHelper(
|
||||
@@ -735,7 +741,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, getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
@@ -745,13 +751,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd);
|
||||
let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, getNormalizedAbsolutePath(fileName, currentDirectory), 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, getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
@@ -769,19 +775,26 @@ 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: string, 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;
|
||||
}
|
||||
|
||||
@@ -796,12 +809,20 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
filesByName.set(fileName, file);
|
||||
filesByName.set(normalizedAbsolutePath, file);
|
||||
if (file) {
|
||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the source file for normalized absolute path
|
||||
filesByName.set(normalizedAbsolutePath, file);
|
||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||
|
||||
let basePath = getDirectoryPath(fileName);
|
||||
if (!options.noResolve) {
|
||||
@@ -821,23 +842,6 @@ 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) {
|
||||
@@ -847,17 +851,29 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
let resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
|
||||
for (let i = 0; i < file.imports.length; ++i) {
|
||||
let resolution = resolutions[i];
|
||||
setResolvedModule(file, moduleNames[i], resolution);
|
||||
if (resolution && !options.noResolve) {
|
||||
const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
|
||||
const absoluteImportPath = isRootedDiskPath(resolution.resolvedFileName)
|
||||
? resolution.resolvedFileName
|
||||
: getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory);
|
||||
|
||||
// convert an absolute import path to path that is relative to current directory
|
||||
// this was host still can locate it but files names in user output will be shorter (and thus look nicer).
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false);
|
||||
const importedFile = findSourceFile(relativePath, absoluteImportPath, /* 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);
|
||||
@@ -876,15 +892,10 @@ 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)) {
|
||||
@@ -925,7 +936,6 @@ 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));
|
||||
|
||||
for (var sourceFile of sourceFiles) {
|
||||
@@ -1030,7 +1040,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
|
||||
|
||||
@@ -2099,6 +2099,7 @@ namespace ts {
|
||||
allowUnreachableCode?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
|
||||
@@ -923,7 +923,9 @@ namespace Harness {
|
||||
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 sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
filemap[getCanonicalFileName(fileName)] = sourceFile;
|
||||
filemap[getCanonicalFileName(ts.getNormalizedAbsolutePath(fileName, getCurrentDirectory()))] = sourceFile;
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
|
||||
@@ -127,7 +127,7 @@ 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());
|
||||
@@ -170,6 +170,11 @@ 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) {
|
||||
@@ -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)
|
||||
};
|
||||
}
|
||||
@@ -318,7 +323,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) {
|
||||
|
||||
+258
-253
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[];
|
||||
}
|
||||
}
|
||||
|
||||
+24
-22
@@ -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,7 +155,7 @@ 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[] = [];
|
||||
let canWrite = true;
|
||||
@@ -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
|
||||
|
||||
+216
-210
@@ -4,7 +4,7 @@
|
||||
/// <reference path="editorServices.ts" />
|
||||
|
||||
namespace ts.server {
|
||||
var spaceCache:string[] = [];
|
||||
const spaceCache: string[] = [];
|
||||
|
||||
interface StackTraceError extends Error {
|
||||
stack?: string;
|
||||
@@ -12,30 +12,31 @@ namespace ts.server {
|
||||
|
||||
export function generateSpaces(n: number): string {
|
||||
if (!spaceCache[n]) {
|
||||
var strBuilder = "";
|
||||
for (var i = 0; i < n; i++) {
|
||||
let strBuilder = "";
|
||||
for (let i = 0; i < n; i++) {
|
||||
strBuilder += " ";
|
||||
}
|
||||
spaceCache[n] = strBuilder;
|
||||
}
|
||||
}
|
||||
return spaceCache[n];
|
||||
}
|
||||
|
||||
export function generateIndentString(n: number, editorOptions: EditorOptions): string {
|
||||
if (editorOptions.ConvertTabsToSpaces) {
|
||||
return generateSpaces(n);
|
||||
} else {
|
||||
var result = "";
|
||||
for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) {
|
||||
}
|
||||
else {
|
||||
let result = "";
|
||||
for (let i = 0; i < Math.floor(n / editorOptions.TabSize); i++) {
|
||||
result += "\t";
|
||||
}
|
||||
for (var i = 0; i < n % editorOptions.TabSize; i++) {
|
||||
for (let i = 0; i < n % editorOptions.TabSize; i++) {
|
||||
result += " ";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface FileStart {
|
||||
file: string;
|
||||
start: ILineInfo;
|
||||
@@ -56,7 +57,7 @@ namespace ts.server {
|
||||
return -1;
|
||||
}
|
||||
else if (a.file == b.file) {
|
||||
var n = compareNumber(a.start.line, b.start.line);
|
||||
const n = compareNumber(a.start.line, b.start.line);
|
||||
if (n === 0) {
|
||||
return compareNumber(a.start.offset, b.start.offset);
|
||||
}
|
||||
@@ -66,7 +67,7 @@ namespace ts.server {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic) {
|
||||
return {
|
||||
start: project.compilerService.host.positionToLineOffset(fileName, diag.start),
|
||||
@@ -81,7 +82,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
function allEditsBeforePos(edits: ts.TextChange[], pos: number) {
|
||||
for (var i = 0, len = edits.length; i < len; i++) {
|
||||
for (let i = 0, len = edits.length; i < len; i++) {
|
||||
if (ts.textSpanEnd(edits[i].span) >= pos) {
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +90,7 @@ namespace ts.server {
|
||||
return true;
|
||||
}
|
||||
|
||||
export module CommandNames {
|
||||
export namespace CommandNames {
|
||||
export const Brace = "brace";
|
||||
export const Change = "change";
|
||||
export const Close = "close";
|
||||
@@ -119,8 +120,8 @@ namespace ts.server {
|
||||
export const Unknown = "unknown";
|
||||
}
|
||||
|
||||
module Errors {
|
||||
export var NoProject = new Error("No Project.");
|
||||
namespace Errors {
|
||||
export const NoProject = new Error("No Project.");
|
||||
}
|
||||
|
||||
export interface ServerHost extends ts.System {
|
||||
@@ -136,13 +137,13 @@ namespace ts.server {
|
||||
private changeSeq = 0;
|
||||
|
||||
constructor(
|
||||
private host: ServerHost,
|
||||
private byteLength: (buf: string, encoding?: string) => number,
|
||||
private hrtime: (start?: number[]) => number[],
|
||||
private host: ServerHost,
|
||||
private byteLength: (buf: string, encoding?: string) => number,
|
||||
private hrtime: (start?: number[]) => number[],
|
||||
private logger: Logger
|
||||
) {
|
||||
this.projectService =
|
||||
new ProjectService(host, logger, (eventName,project,fileName) => {
|
||||
new ProjectService(host, logger, (eventName, project, fileName) => {
|
||||
this.handleEvent(eventName, project, fileName);
|
||||
});
|
||||
}
|
||||
@@ -156,8 +157,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
public logError(err: Error, cmd: string) {
|
||||
var typedErr = <StackTraceError>err;
|
||||
var msg = "Exception on executing command " + cmd;
|
||||
const typedErr = <StackTraceError>err;
|
||||
let msg = "Exception on executing command " + cmd;
|
||||
if (typedErr.message) {
|
||||
msg += ":\n" + typedErr.message;
|
||||
if (typedErr.stack) {
|
||||
@@ -172,16 +173,16 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
public send(msg: protocol.Message) {
|
||||
var json = JSON.stringify(msg);
|
||||
const json = JSON.stringify(msg);
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info(msg.type + ": " + json);
|
||||
}
|
||||
this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) +
|
||||
'\r\n\r\n' + json);
|
||||
this.sendLineToClient("Content-Length: " + (1 + this.byteLength(json, "utf8")) +
|
||||
"\r\n\r\n" + json);
|
||||
}
|
||||
|
||||
public event(info: any, eventName: string) {
|
||||
var ev: protocol.Event = {
|
||||
const ev: protocol.Event = {
|
||||
seq: 0,
|
||||
type: "event",
|
||||
event: eventName,
|
||||
@@ -191,13 +192,13 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private response(info: any, cmdName: string, reqSeq = 0, errorMsg?: string) {
|
||||
var res: protocol.Response = {
|
||||
const res: protocol.Response = {
|
||||
seq: 0,
|
||||
type: "response",
|
||||
command: cmdName,
|
||||
request_seq: reqSeq,
|
||||
success: !errorMsg,
|
||||
}
|
||||
};
|
||||
if (!errorMsg) {
|
||||
res.body = info;
|
||||
}
|
||||
@@ -213,10 +214,10 @@ namespace ts.server {
|
||||
|
||||
private semanticCheck(file: string, project: Project) {
|
||||
try {
|
||||
var diags = project.compilerService.languageService.getSemanticDiagnostics(file);
|
||||
const diags = project.compilerService.languageService.getSemanticDiagnostics(file);
|
||||
|
||||
if (diags) {
|
||||
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
const bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag");
|
||||
}
|
||||
}
|
||||
@@ -227,9 +228,9 @@ namespace ts.server {
|
||||
|
||||
private syntacticCheck(file: string, project: Project) {
|
||||
try {
|
||||
var diags = project.compilerService.languageService.getSyntacticDiagnostics(file);
|
||||
const diags = project.compilerService.languageService.getSyntacticDiagnostics(file);
|
||||
if (diags) {
|
||||
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
const bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag");
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ namespace ts.server {
|
||||
this.syntacticCheck(file, project);
|
||||
this.semanticCheck(file, project);
|
||||
}
|
||||
|
||||
|
||||
private reloadProjects() {
|
||||
this.projectService.reloadProjects();
|
||||
}
|
||||
@@ -267,10 +268,10 @@ namespace ts.server {
|
||||
clearImmediate(this.immediateId);
|
||||
this.immediateId = undefined;
|
||||
}
|
||||
var index = 0;
|
||||
var checkOne = () => {
|
||||
let index = 0;
|
||||
const checkOne = () => {
|
||||
if (matchSeq(seq)) {
|
||||
var checkSpec = checkList[index++];
|
||||
const checkSpec = checkList[index++];
|
||||
if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) {
|
||||
this.syntacticCheck(checkSpec.fileName, checkSpec.project);
|
||||
this.immediateId = setImmediate(() => {
|
||||
@@ -285,23 +286,23 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if ((checkList.length > index) && (matchSeq(seq))) {
|
||||
this.errorTimer = setTimeout(checkOne, ms);
|
||||
}
|
||||
}
|
||||
|
||||
private getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var definitions = compilerService.languageService.getDefinitionAtPosition(file, position);
|
||||
const definitions = compilerService.languageService.getDefinitionAtPosition(file, position);
|
||||
if (!definitions) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -314,16 +315,16 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getTypeDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position);
|
||||
const definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position);
|
||||
if (!definitions) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -361,7 +362,7 @@ namespace ts.server {
|
||||
end,
|
||||
file: fileName,
|
||||
isWriteAccess
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -375,9 +376,9 @@ namespace ts.server {
|
||||
|
||||
let { compilerService } = project;
|
||||
let position = compilerService.host.lineOffsetToPosition(fileName, line, offset);
|
||||
|
||||
|
||||
let documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch);
|
||||
|
||||
|
||||
if (!documentHighlights) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -402,12 +403,12 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
|
||||
fileName = ts.normalizePath(fileName)
|
||||
let project = this.projectService.getProjectForFile(fileName)
|
||||
fileName = ts.normalizePath(fileName);
|
||||
let project = this.projectService.getProjectForFile(fileName);
|
||||
|
||||
let projectInfo: protocol.ProjectInfo = {
|
||||
configFileName: project.projectFilename
|
||||
}
|
||||
};
|
||||
|
||||
if (needFileNameList) {
|
||||
projectInfo.fileNames = project.getFileNames();
|
||||
@@ -416,16 +417,16 @@ namespace ts.server {
|
||||
return projectInfo;
|
||||
}
|
||||
|
||||
private getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
private getRenameLocations(line: number, offset: number, fileName: string, findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var renameInfo = compilerService.languageService.getRenameInfo(file, position);
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const renameInfo = compilerService.languageService.getRenameInfo(file, position);
|
||||
if (!renameInfo) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -437,12 +438,12 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments);
|
||||
const renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments);
|
||||
if (!renameLocations) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var bakedRenameLocs = renameLocations.map(location => (<protocol.FileSpan>{
|
||||
const bakedRenameLocs = renameLocations.map(location => (<protocol.FileSpan>{
|
||||
file: location.fileName,
|
||||
start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start),
|
||||
end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)),
|
||||
@@ -466,7 +467,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
}).reduce<protocol.SpanGroup[]>((accum: protocol.SpanGroup[], cur: protocol.FileSpan) => {
|
||||
var curFileAccum: protocol.SpanGroup;
|
||||
let curFileAccum: protocol.SpanGroup;
|
||||
if (accum.length > 0) {
|
||||
curFileAccum = accum[accum.length - 1];
|
||||
if (curFileAccum.file != cur.file) {
|
||||
@@ -487,34 +488,34 @@ namespace ts.server {
|
||||
private getReferences(line: number, offset: number, fileName: string): protocol.ReferencesResponseBody {
|
||||
// TODO: get all projects for this file; report refs for all projects deleting duplicates
|
||||
// can avoid duplicates by eliminating same ref file from subsequent projects
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var references = compilerService.languageService.getReferencesAtPosition(file, position);
|
||||
const references = compilerService.languageService.getReferencesAtPosition(file, position);
|
||||
if (!references) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
|
||||
const nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
|
||||
if (!nameInfo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var displayString = ts.displayPartsToString(nameInfo.displayParts);
|
||||
var nameSpan = nameInfo.textSpan;
|
||||
var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
|
||||
var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
|
||||
var bakedRefs: protocol.ReferencesResponseItem[] = references.map(ref => {
|
||||
var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start);
|
||||
var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1);
|
||||
var snap = compilerService.host.getScriptSnapshot(ref.fileName);
|
||||
var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
|
||||
const displayString = ts.displayPartsToString(nameInfo.displayParts);
|
||||
const nameSpan = nameInfo.textSpan;
|
||||
const nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
|
||||
const nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
|
||||
const bakedRefs: protocol.ReferencesResponseItem[] = references.map(ref => {
|
||||
const start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start);
|
||||
const refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1);
|
||||
const snap = compilerService.host.getScriptSnapshot(ref.fileName);
|
||||
const lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
|
||||
return {
|
||||
file: ref.fileName,
|
||||
start: start,
|
||||
@@ -532,26 +533,26 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private openClientFile(fileName: string) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
const file = ts.normalizePath(fileName);
|
||||
this.projectService.openClientFile(file);
|
||||
}
|
||||
|
||||
private getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
|
||||
if (!quickInfo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var displayString = ts.displayPartsToString(quickInfo.displayParts);
|
||||
var docString = ts.displayPartsToString(quickInfo.documentation);
|
||||
const displayString = ts.displayPartsToString(quickInfo.displayParts);
|
||||
const docString = ts.displayPartsToString(quickInfo.documentation);
|
||||
return {
|
||||
kind: quickInfo.kind,
|
||||
kindModifiers: quickInfo.kindModifiers,
|
||||
@@ -563,18 +564,18 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
|
||||
|
||||
const compilerService = project.compilerService;
|
||||
const startPosition = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
|
||||
|
||||
// TODO: avoid duplicate code (with formatonkey)
|
||||
var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition,
|
||||
const edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition,
|
||||
this.projectService.getFormatCodeOptions(file));
|
||||
if (!edits) {
|
||||
return undefined;
|
||||
@@ -590,17 +591,17 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
const file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var formatOptions = this.projectService.getFormatCodeOptions(file);
|
||||
var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key,
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const formatOptions = this.projectService.getFormatCodeOptions(file);
|
||||
const edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key,
|
||||
formatOptions);
|
||||
// Check whether we should auto-indent. This will be when
|
||||
// the position is on a line containing only whitespace.
|
||||
@@ -609,23 +610,24 @@ namespace ts.server {
|
||||
// only to the previous line. If all this is true, then
|
||||
// add edits necessary to properly indent the current line.
|
||||
if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) {
|
||||
var scriptInfo = compilerService.host.getScriptInfo(file);
|
||||
const scriptInfo = compilerService.host.getScriptInfo(file);
|
||||
if (scriptInfo) {
|
||||
var lineInfo = scriptInfo.getLineInfo(line);
|
||||
const lineInfo = scriptInfo.getLineInfo(line);
|
||||
if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) {
|
||||
var lineText = lineInfo.leaf.text;
|
||||
const lineText = lineInfo.leaf.text;
|
||||
if (lineText.search("\\S") < 0) {
|
||||
// TODO: get these options from host
|
||||
var editorOptions: ts.EditorOptions = {
|
||||
const editorOptions: ts.EditorOptions = {
|
||||
IndentSize: formatOptions.IndentSize,
|
||||
TabSize: formatOptions.TabSize,
|
||||
NewLineCharacter: "\n",
|
||||
ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces,
|
||||
IndentStyle: ts.IndentStyle.Smart,
|
||||
};
|
||||
var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
|
||||
var hasIndent = 0;
|
||||
for (var i = 0, len = lineText.length; i < len; i++) {
|
||||
const preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
|
||||
let hasIndent = 0;
|
||||
let i: number, len: number;
|
||||
for (i = 0, len = lineText.length; i < len; i++) {
|
||||
if (lineText.charAt(i) == " ") {
|
||||
hasIndent++;
|
||||
}
|
||||
@@ -638,7 +640,7 @@ namespace ts.server {
|
||||
}
|
||||
// i points to the first non whitespace character
|
||||
if (preferredIndent !== hasIndent) {
|
||||
var firstNoWhiteSpacePosition = lineInfo.offset + i;
|
||||
let firstNoWhiteSpacePosition = lineInfo.offset + i;
|
||||
edits.push({
|
||||
span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition),
|
||||
newText: generateIndentString(preferredIndent, editorOptions)
|
||||
@@ -668,16 +670,16 @@ namespace ts.server {
|
||||
if (!prefix) {
|
||||
prefix = "";
|
||||
}
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var completions = compilerService.languageService.getCompletionsAtPosition(file, position);
|
||||
const completions = compilerService.languageService.getCompletionsAtPosition(file, position);
|
||||
if (!completions) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -692,17 +694,17 @@ namespace ts.server {
|
||||
|
||||
private getCompletionEntryDetails(line: number, offset: number,
|
||||
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
return entryNames.reduce((accum: protocol.CompletionEntryDetails[], entryName: string) => {
|
||||
var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName);
|
||||
const details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName);
|
||||
if (details) {
|
||||
accum.push(details);
|
||||
}
|
||||
@@ -711,21 +713,21 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var helpItems = compilerService.languageService.getSignatureHelpItems(file, position);
|
||||
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const helpItems = compilerService.languageService.getSignatureHelpItems(file, position);
|
||||
if (!helpItems) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var span = helpItems.applicableSpan;
|
||||
var result: protocol.SignatureHelpItems = {
|
||||
|
||||
const span = helpItems.applicableSpan;
|
||||
const result: protocol.SignatureHelpItems = {
|
||||
items: helpItems.items,
|
||||
applicableSpan: {
|
||||
start: compilerService.host.positionToLineOffset(file, span.start),
|
||||
@@ -734,15 +736,15 @@ namespace ts.server {
|
||||
selectedItemIndex: helpItems.selectedItemIndex,
|
||||
argumentIndex: helpItems.argumentIndex,
|
||||
argumentCount: helpItems.argumentCount,
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private getDiagnostics(delay: number, fileNames: string[]) {
|
||||
var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
|
||||
const checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(fileName);
|
||||
const project = this.projectService.getProjectForFile(fileName);
|
||||
if (project) {
|
||||
accum.push({ fileName, project });
|
||||
}
|
||||
@@ -750,17 +752,17 @@ namespace ts.server {
|
||||
}, []);
|
||||
|
||||
if (checkList.length > 0) {
|
||||
this.updateErrorCheck(checkList, this.changeSeq,(n) => n === this.changeSeq, delay)
|
||||
this.updateErrorCheck(checkList, this.changeSeq, (n) => n === this.changeSeq, delay);
|
||||
}
|
||||
}
|
||||
|
||||
private change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (project) {
|
||||
var compilerService = project.compilerService;
|
||||
var start = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
|
||||
const compilerService = project.compilerService;
|
||||
const start = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
const end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
|
||||
if (start >= 0) {
|
||||
compilerService.host.editScript(file, start, end, insertString);
|
||||
this.changeSeq++;
|
||||
@@ -770,9 +772,9 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private reload(fileName: string, tempFileName: string, reqSeq = 0) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var tmpfile = ts.normalizePath(tempFileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const tmpfile = ts.normalizePath(tempFileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (project) {
|
||||
this.changeSeq++;
|
||||
// make sure no changes happen before this one is finished
|
||||
@@ -783,10 +785,10 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private saveToTmp(fileName: string, tempFileName: string) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var tmpfile = ts.normalizePath(tempFileName);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const tmpfile = ts.normalizePath(tempFileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (project) {
|
||||
project.compilerService.host.saveTo(file, tmpfile);
|
||||
}
|
||||
@@ -794,7 +796,7 @@ namespace ts.server {
|
||||
|
||||
private closeClientFile(fileName: string) {
|
||||
if (!fileName) { return; }
|
||||
var file = ts.normalizePath(fileName);
|
||||
const file = ts.normalizePath(fileName);
|
||||
this.projectService.closeClientFile(file);
|
||||
}
|
||||
|
||||
@@ -803,7 +805,7 @@ namespace ts.server {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
const compilerService = project.compilerService;
|
||||
|
||||
return items.map(item => ({
|
||||
text: item.text,
|
||||
@@ -818,14 +820,14 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var items = compilerService.languageService.getNavigationBarItems(file);
|
||||
const compilerService = project.compilerService;
|
||||
const items = compilerService.languageService.getNavigationBarItems(file);
|
||||
if (!items) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -834,22 +836,22 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount);
|
||||
const compilerService = project.compilerService;
|
||||
const navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount);
|
||||
if (!navItems) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return navItems.map((navItem) => {
|
||||
var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start);
|
||||
var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan));
|
||||
var bakedItem: protocol.NavtoItem = {
|
||||
const start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start);
|
||||
const end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan));
|
||||
const bakedItem: protocol.NavtoItem = {
|
||||
name: navItem.name,
|
||||
kind: navItem.kind,
|
||||
file: navItem.fileName,
|
||||
@@ -859,7 +861,7 @@ namespace ts.server {
|
||||
if (navItem.kindModifiers && (navItem.kindModifiers != "")) {
|
||||
bakedItem.kindModifiers = navItem.kindModifiers;
|
||||
}
|
||||
if (navItem.matchKind != 'none') {
|
||||
if (navItem.matchKind !== "none") {
|
||||
bakedItem.matchKind = navItem.matchKind;
|
||||
}
|
||||
if (navItem.containerName && (navItem.containerName.length > 0)) {
|
||||
@@ -873,21 +875,21 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
const file = ts.normalizePath(fileName);
|
||||
|
||||
const project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position);
|
||||
|
||||
const compilerService = project.compilerService;
|
||||
const position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
const spans = compilerService.languageService.getBraceMatchingAtPosition(file, position);
|
||||
if (!spans) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
return spans.map(span => ({
|
||||
start: compilerService.host.positionToLineOffset(file, span.start),
|
||||
end: compilerService.host.positionToLineOffset(file, span.start + span.length)
|
||||
@@ -943,59 +945,59 @@ namespace ts.server {
|
||||
exit() {
|
||||
}
|
||||
|
||||
private handlers : Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = {
|
||||
private handlers: Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = {
|
||||
[CommandNames.Exit]: () => {
|
||||
this.exit();
|
||||
return { responseRequired: false};
|
||||
},
|
||||
[CommandNames.Definition]: (request: protocol.Request) => {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
const defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.TypeDefinition]: (request: protocol.Request) => {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
const defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.References]: (request: protocol.Request) => {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
const defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Rename]: (request: protocol.Request) => {
|
||||
var renameArgs = <protocol.RenameRequestArgs>request.arguments;
|
||||
return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true}
|
||||
const renameArgs = <protocol.RenameRequestArgs>request.arguments;
|
||||
return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Open]: (request: protocol.Request) => {
|
||||
var openArgs = <protocol.OpenRequestArgs>request.arguments;
|
||||
const openArgs = <protocol.OpenRequestArgs>request.arguments;
|
||||
this.openClientFile(openArgs.file);
|
||||
return {responseRequired: false}
|
||||
return {responseRequired: false};
|
||||
},
|
||||
[CommandNames.Quickinfo]: (request: protocol.Request) => {
|
||||
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
const quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Format]: (request: protocol.Request) => {
|
||||
var formatArgs = <protocol.FormatRequestArgs>request.arguments;
|
||||
const formatArgs = <protocol.FormatRequestArgs>request.arguments;
|
||||
return {response: this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Formatonkey]: (request: protocol.Request) => {
|
||||
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
|
||||
const formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
|
||||
return {response: this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Completions]: (request: protocol.Request) => {
|
||||
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
|
||||
return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true}
|
||||
const completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
|
||||
return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.CompletionDetails]: (request: protocol.Request) => {
|
||||
var completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
|
||||
return {response: this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset,
|
||||
completionDetailsArgs.entryNames,completionDetailsArgs.file), responseRequired: true}
|
||||
const completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
|
||||
return {response: this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset,
|
||||
completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.SignatureHelp]: (request: protocol.Request) => {
|
||||
var signatureHelpArgs = <protocol.SignatureHelpRequestArgs>request.arguments;
|
||||
return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true}
|
||||
const signatureHelpArgs = <protocol.SignatureHelpRequestArgs>request.arguments;
|
||||
return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Geterr]: (request: protocol.Request) => {
|
||||
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
|
||||
const geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
|
||||
return {response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false};
|
||||
},
|
||||
[CommandNames.GeterrForProject]: (request: protocol.Request) => {
|
||||
@@ -1003,54 +1005,54 @@ namespace ts.server {
|
||||
return {response: this.getDiagnosticsForProject(delay, file), responseRequired: false};
|
||||
},
|
||||
[CommandNames.Change]: (request: protocol.Request) => {
|
||||
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
|
||||
const changeArgs = <protocol.ChangeRequestArgs>request.arguments;
|
||||
this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset,
|
||||
changeArgs.insertString, changeArgs.file);
|
||||
return {responseRequired: false}
|
||||
return {responseRequired: false};
|
||||
},
|
||||
[CommandNames.Configure]: (request: protocol.Request) => {
|
||||
var configureArgs = <protocol.ConfigureRequestArguments>request.arguments;
|
||||
const configureArgs = <protocol.ConfigureRequestArguments>request.arguments;
|
||||
this.projectService.setHostConfiguration(configureArgs);
|
||||
this.output(undefined, CommandNames.Configure, request.seq);
|
||||
return {responseRequired: false}
|
||||
return {responseRequired: false};
|
||||
},
|
||||
[CommandNames.Reload]: (request: protocol.Request) => {
|
||||
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
|
||||
const reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
|
||||
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
|
||||
return {responseRequired: false}
|
||||
return {responseRequired: false};
|
||||
},
|
||||
[CommandNames.Saveto]: (request: protocol.Request) => {
|
||||
var savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
|
||||
const savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
|
||||
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
|
||||
return {responseRequired: false}
|
||||
return {responseRequired: false};
|
||||
},
|
||||
[CommandNames.Close]: (request: protocol.Request) => {
|
||||
var closeArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
const closeArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
this.closeClientFile(closeArgs.file);
|
||||
return {responseRequired: false};
|
||||
},
|
||||
[CommandNames.Navto]: (request: protocol.Request) => {
|
||||
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
|
||||
const navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
|
||||
return {response: this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Brace]: (request: protocol.Request) => {
|
||||
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
const braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.NavBar]: (request: protocol.Request) => {
|
||||
var navBarArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
const navBarArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
return {response: this.getNavigationBarItems(navBarArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Occurrences]: (request: protocol.Request) => {
|
||||
var { line, offset, file: fileName } = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
const { line, offset, file: fileName } = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getOccurrences(line, offset, fileName), responseRequired: true};
|
||||
},
|
||||
[CommandNames.DocumentHighlights]: (request: protocol.Request) => {
|
||||
var { line, offset, file: fileName, filesToSearch } = <protocol.DocumentHighlightsRequestArgs>request.arguments;
|
||||
const { line, offset, file: fileName, filesToSearch } = <protocol.DocumentHighlightsRequestArgs>request.arguments;
|
||||
return {response: this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true};
|
||||
},
|
||||
[CommandNames.ProjectInfo]: (request: protocol.Request) => {
|
||||
var { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>request.arguments;
|
||||
const { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>request.arguments;
|
||||
return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true};
|
||||
},
|
||||
[CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => {
|
||||
@@ -1065,11 +1067,12 @@ namespace ts.server {
|
||||
this.handlers[command] = handler;
|
||||
}
|
||||
|
||||
public executeCommand(request: protocol.Request) : {response?: any, responseRequired?: boolean} {
|
||||
var handler = this.handlers[request.command];
|
||||
public executeCommand(request: protocol.Request): {response?: any, responseRequired?: boolean} {
|
||||
const handler = this.handlers[request.command];
|
||||
if (handler) {
|
||||
return handler(request);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request));
|
||||
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);
|
||||
return {responseRequired: false};
|
||||
@@ -1077,20 +1080,22 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
public onMessage(message: string) {
|
||||
let start: number[];
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info("request: " + message);
|
||||
var start = this.hrtime();
|
||||
start = this.hrtime();
|
||||
}
|
||||
let request: protocol.Request;
|
||||
try {
|
||||
var request = <protocol.Request>JSON.parse(message);
|
||||
var {response, responseRequired} = this.executeCommand(request);
|
||||
request = <protocol.Request>JSON.parse(message);
|
||||
const {response, responseRequired} = this.executeCommand(request);
|
||||
|
||||
if (this.logger.isVerbose()) {
|
||||
var elapsed = this.hrtime(start);
|
||||
var seconds = elapsed[0]
|
||||
var nanoseconds = elapsed[1];
|
||||
var elapsedMs = ((1e9 * seconds) + nanoseconds)/1000000.0;
|
||||
var leader = "Elapsed time (in milliseconds)";
|
||||
const elapsed = this.hrtime(start);
|
||||
const seconds = elapsed[0];
|
||||
const nanoseconds = elapsed[1];
|
||||
const elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0;
|
||||
let leader = "Elapsed time (in milliseconds)";
|
||||
if (!responseRequired) {
|
||||
leader = "Async elapsed time (in milliseconds)";
|
||||
}
|
||||
@@ -1102,7 +1107,8 @@ namespace ts.server {
|
||||
else if (responseRequired) {
|
||||
this.output(undefined, request.command, request.seq, "No content available.");
|
||||
}
|
||||
} catch (err) {
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof OperationCanceledException) {
|
||||
// Handle cancellation exceptions
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/emptyThenWarning.ts(1,6): error TS1313: The body of an 'if' statement cannot be the empty statement.
|
||||
tests/cases/compiler/emptyThenWarning.ts(4,19): error TS1313: The body of an 'if' statement cannot be the empty statement.
|
||||
|
||||
|
||||
==== tests/cases/compiler/emptyThenWarning.ts (2 errors) ====
|
||||
if(1);
|
||||
~
|
||||
!!! error TS1313: The body of an 'if' statement cannot be the empty statement.
|
||||
|
||||
let x = 0;
|
||||
if (true === true); {
|
||||
~
|
||||
!!! error TS1313: The body of an 'if' statement cannot be the empty statement.
|
||||
x = 1;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [emptyThenWarning.ts]
|
||||
if(1);
|
||||
|
||||
let x = 0;
|
||||
if (true === true); {
|
||||
x = 1;
|
||||
}
|
||||
|
||||
//// [emptyThenWarning.js]
|
||||
if (1)
|
||||
;
|
||||
var x = 0;
|
||||
if (true === true)
|
||||
;
|
||||
{
|
||||
x = 1;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [emptyThenWithoutWarning.ts]
|
||||
let a = 4;
|
||||
|
||||
if(a === 1 || a === 2 || a === 3) {
|
||||
}
|
||||
else {
|
||||
let message = "Ooops";
|
||||
}
|
||||
|
||||
//// [emptyThenWithoutWarning.js]
|
||||
var a = 4;
|
||||
if (a === 1 || a === 2 || a === 3) {
|
||||
}
|
||||
else {
|
||||
var message = "Ooops";
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/emptyThenWithoutWarning.ts ===
|
||||
let a = 4;
|
||||
>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3))
|
||||
|
||||
if(a === 1 || a === 2 || a === 3) {
|
||||
>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3))
|
||||
>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3))
|
||||
>a : Symbol(a, Decl(emptyThenWithoutWarning.ts, 0, 3))
|
||||
}
|
||||
else {
|
||||
let message = "Ooops";
|
||||
>message : Symbol(message, Decl(emptyThenWithoutWarning.ts, 5, 7))
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/compiler/emptyThenWithoutWarning.ts ===
|
||||
let a = 4;
|
||||
>a : number
|
||||
>4 : number
|
||||
|
||||
if(a === 1 || a === 2 || a === 3) {
|
||||
>a === 1 || a === 2 || a === 3 : boolean
|
||||
>a === 1 || a === 2 : boolean
|
||||
>a === 1 : boolean
|
||||
>a : number
|
||||
>1 : number
|
||||
>a === 2 : boolean
|
||||
>a : number
|
||||
>2 : number
|
||||
>a === 3 : boolean
|
||||
>a : number
|
||||
>3 : number
|
||||
}
|
||||
else {
|
||||
let message = "Ooops";
|
||||
>message : string
|
||||
>"Ooops" : string
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [localClassesInLoop.ts]
|
||||
declare function use(a: any);
|
||||
|
||||
"use strict"
|
||||
var data = [];
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
class C { }
|
||||
data.push(() => C);
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
|
||||
//// [localClassesInLoop.js]
|
||||
"use strict";
|
||||
var data = [];
|
||||
var _loop_1 = function(x) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
data.push(function () { return C; });
|
||||
};
|
||||
for (var x = 0; x < 2; ++x) {
|
||||
_loop_1(x);
|
||||
}
|
||||
use(data[0]() === data[1]());
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/localClassesInLoop.ts ===
|
||||
declare function use(a: any);
|
||||
>use : Symbol(use, Decl(localClassesInLoop.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(localClassesInLoop.ts, 0, 21))
|
||||
|
||||
"use strict"
|
||||
var data = [];
|
||||
>data : Symbol(data, Decl(localClassesInLoop.ts, 3, 3))
|
||||
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
>x : Symbol(x, Decl(localClassesInLoop.ts, 4, 8))
|
||||
>x : Symbol(x, Decl(localClassesInLoop.ts, 4, 8))
|
||||
>x : Symbol(x, Decl(localClassesInLoop.ts, 4, 8))
|
||||
|
||||
class C { }
|
||||
>C : Symbol(C, Decl(localClassesInLoop.ts, 4, 29))
|
||||
|
||||
data.push(() => C);
|
||||
>data.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>data : Symbol(data, Decl(localClassesInLoop.ts, 3, 3))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>C : Symbol(C, Decl(localClassesInLoop.ts, 4, 29))
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
>use : Symbol(use, Decl(localClassesInLoop.ts, 0, 0))
|
||||
>data : Symbol(data, Decl(localClassesInLoop.ts, 3, 3))
|
||||
>data : Symbol(data, Decl(localClassesInLoop.ts, 3, 3))
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/compiler/localClassesInLoop.ts ===
|
||||
declare function use(a: any);
|
||||
>use : (a: any) => any
|
||||
>a : any
|
||||
|
||||
"use strict"
|
||||
>"use strict" : string
|
||||
|
||||
var data = [];
|
||||
>data : any[]
|
||||
>[] : undefined[]
|
||||
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
>x : number
|
||||
>0 : number
|
||||
>x < 2 : boolean
|
||||
>x : number
|
||||
>2 : number
|
||||
>++x : number
|
||||
>x : number
|
||||
|
||||
class C { }
|
||||
>C : C
|
||||
|
||||
data.push(() => C);
|
||||
>data.push(() => C) : number
|
||||
>data.push : (...items: any[]) => number
|
||||
>data : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>() => C : () => typeof C
|
||||
>C : typeof C
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
>use(data[0]() === data[1]()) : any
|
||||
>use : (a: any) => any
|
||||
>data[0]() === data[1]() : boolean
|
||||
>data[0]() : any
|
||||
>data[0] : any
|
||||
>data : any[]
|
||||
>0 : number
|
||||
>data[1]() : any
|
||||
>data[1] : any
|
||||
>data : any[]
|
||||
>1 : number
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [localClassesInLoop_ES6.ts]
|
||||
|
||||
declare function use(a: any);
|
||||
|
||||
"use strict"
|
||||
var data = [];
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
class C { }
|
||||
data.push(() => C);
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
|
||||
//// [localClassesInLoop_ES6.js]
|
||||
"use strict";
|
||||
var data = [];
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
class C {
|
||||
}
|
||||
data.push(() => C);
|
||||
}
|
||||
use(data[0]() === data[1]());
|
||||
@@ -0,0 +1,30 @@
|
||||
=== tests/cases/compiler/localClassesInLoop_ES6.ts ===
|
||||
|
||||
declare function use(a: any);
|
||||
>use : Symbol(use, Decl(localClassesInLoop_ES6.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(localClassesInLoop_ES6.ts, 1, 21))
|
||||
|
||||
"use strict"
|
||||
var data = [];
|
||||
>data : Symbol(data, Decl(localClassesInLoop_ES6.ts, 4, 3))
|
||||
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
>x : Symbol(x, Decl(localClassesInLoop_ES6.ts, 5, 8))
|
||||
>x : Symbol(x, Decl(localClassesInLoop_ES6.ts, 5, 8))
|
||||
>x : Symbol(x, Decl(localClassesInLoop_ES6.ts, 5, 8))
|
||||
|
||||
class C { }
|
||||
>C : Symbol(C, Decl(localClassesInLoop_ES6.ts, 5, 29))
|
||||
|
||||
data.push(() => C);
|
||||
>data.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>data : Symbol(data, Decl(localClassesInLoop_ES6.ts, 4, 3))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>C : Symbol(C, Decl(localClassesInLoop_ES6.ts, 5, 29))
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
>use : Symbol(use, Decl(localClassesInLoop_ES6.ts, 0, 0))
|
||||
>data : Symbol(data, Decl(localClassesInLoop_ES6.ts, 4, 3))
|
||||
>data : Symbol(data, Decl(localClassesInLoop_ES6.ts, 4, 3))
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/compiler/localClassesInLoop_ES6.ts ===
|
||||
|
||||
declare function use(a: any);
|
||||
>use : (a: any) => any
|
||||
>a : any
|
||||
|
||||
"use strict"
|
||||
>"use strict" : string
|
||||
|
||||
var data = [];
|
||||
>data : any[]
|
||||
>[] : undefined[]
|
||||
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
>x : number
|
||||
>0 : number
|
||||
>x < 2 : boolean
|
||||
>x : number
|
||||
>2 : number
|
||||
>++x : number
|
||||
>x : number
|
||||
|
||||
class C { }
|
||||
>C : C
|
||||
|
||||
data.push(() => C);
|
||||
>data.push(() => C) : number
|
||||
>data.push : (...items: any[]) => number
|
||||
>data : any[]
|
||||
>push : (...items: any[]) => number
|
||||
>() => C : () => typeof C
|
||||
>C : typeof C
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
>use(data[0]() === data[1]()) : any
|
||||
>use : (a: any) => any
|
||||
>data[0]() === data[1]() : boolean
|
||||
>data[0]() : any
|
||||
>data[0] : any
|
||||
>data : any[]
|
||||
>0 : number
|
||||
>data[1]() : any
|
||||
>data[1] : any
|
||||
>data : any[]
|
||||
>1 : number
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
if(1);
|
||||
|
||||
let x = 0;
|
||||
if (true === true); {
|
||||
x = 1;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
let a = 4;
|
||||
|
||||
if(a === 1 || a === 2 || a === 3) {
|
||||
}
|
||||
else {
|
||||
let message = "Ooops";
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
declare function use(a: any);
|
||||
|
||||
"use strict"
|
||||
var data = [];
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
class C { }
|
||||
data.push(() => C);
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
@@ -0,0 +1,12 @@
|
||||
// @target: ES6
|
||||
|
||||
declare function use(a: any);
|
||||
|
||||
"use strict"
|
||||
var data = [];
|
||||
for (let x = 0; x < 2; ++x) {
|
||||
class C { }
|
||||
data.push(() => C);
|
||||
}
|
||||
|
||||
use(data[0]() === data[1]());
|
||||
@@ -6,21 +6,35 @@ declare namespace chai.assert {
|
||||
}
|
||||
|
||||
module ts {
|
||||
function diagnosticToString(diagnostic: Diagnostic) {
|
||||
let output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += `${diagnostic.file.fileName}(${loc.line + 1},${loc.character + 1}): `;
|
||||
}
|
||||
|
||||
let category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${category} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine)}${sys.newLine}`;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
interface File {
|
||||
name: string
|
||||
content?: string
|
||||
content?: string
|
||||
}
|
||||
|
||||
function createModuleResolutionHost(...files: File[]): ModuleResolutionHost {
|
||||
let map = arrayToMap(files, f => f.name);
|
||||
|
||||
|
||||
return { fileExists, readFile };
|
||||
|
||||
|
||||
function fileExists(path: string): boolean {
|
||||
return hasProperty(map, path);
|
||||
}
|
||||
|
||||
|
||||
function readFile(path: string): string {
|
||||
return hasProperty(map, path) ? map[path].content : undefined;
|
||||
}
|
||||
@@ -28,18 +42,18 @@ module ts {
|
||||
|
||||
function splitPath(path: string): { dir: string; rel: string } {
|
||||
let index = path.indexOf(directorySeparator);
|
||||
return index === -1
|
||||
return index === -1
|
||||
? { dir: path, rel: undefined }
|
||||
: { dir: path.substr(0, index), rel: path.substr(index + 1) };
|
||||
}
|
||||
|
||||
describe("Node module resolution - relative paths", () => {
|
||||
|
||||
|
||||
function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void {
|
||||
for (let ext of supportedExtensions) {
|
||||
let containingFile = { name: containingFileName }
|
||||
let moduleFile = { name: moduleFileNameNoExt + ext }
|
||||
let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile));
|
||||
let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile));
|
||||
assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name);
|
||||
assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false);
|
||||
|
||||
@@ -53,11 +67,11 @@ module ts {
|
||||
failedLookupLocations.push(normalizePath(getRootLength(moduleName) === 0 ? combinePaths(dir, moduleName) : moduleName) + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
assert.deepEqual(resolution.failedLookupLocations, failedLookupLocations);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
it("module name that starts with './' resolved as relative file name", () => {
|
||||
testLoadAsFile("/foo/bar/baz.ts", "/foo/bar/foo", "./foo");
|
||||
});
|
||||
@@ -73,7 +87,7 @@ module ts {
|
||||
it("module name that starts with 'c:/' script extension resolved as relative file name", () => {
|
||||
testLoadAsFile("c:/foo/bar/baz.ts", "c:/foo", "c:/foo");
|
||||
});
|
||||
|
||||
|
||||
function testLoadingFromPackageJson(containingFileName: string, packageJsonFileName: string, fieldRef: string, moduleFileName: string, moduleName: string): void {
|
||||
let containingFile = { name: containingFileName };
|
||||
let packageJson = { name: packageJsonFileName, content: JSON.stringify({ "typings": fieldRef }) };
|
||||
@@ -84,17 +98,17 @@ module ts {
|
||||
// expect three failed lookup location - attempt to load module as file with all supported extensions
|
||||
assert.equal(resolution.failedLookupLocations.length, 3);
|
||||
}
|
||||
|
||||
|
||||
it("module name as directory - load from typings", () => {
|
||||
testLoadingFromPackageJson("/a/b/c/d.ts", "/a/b/c/bar/package.json", "c/d/e.d.ts", "/a/b/c/bar/c/d/e.d.ts", "./bar");
|
||||
testLoadingFromPackageJson("/a/b/c/d.ts", "/a/bar/package.json", "e.d.ts", "/a/bar/e.d.ts", "../../bar");
|
||||
testLoadingFromPackageJson("/a/b/c/d.ts", "/bar/package.json", "e.d.ts", "/bar/e.d.ts", "/bar");
|
||||
testLoadingFromPackageJson("c:/a/b/c/d.ts", "c:/bar/package.json", "e.d.ts", "c:/bar/e.d.ts", "c:/bar");
|
||||
});
|
||||
|
||||
it ("module name as directory - load index.d.ts", () => {
|
||||
let containingFile = {name: "/a/b/c.ts"};
|
||||
let packageJson = {name: "/a/b/foo/package.json", content: JSON.stringify({main: "/c/d"})};
|
||||
|
||||
it("module name as directory - load index.d.ts", () => {
|
||||
let containingFile = { name: "/a/b/c.ts" };
|
||||
let packageJson = { name: "/a/b/foo/package.json", content: JSON.stringify({ main: "/c/d" }) };
|
||||
let indexFile = { name: "/a/b/foo/index.d.ts" };
|
||||
let resolution = nodeModuleNameResolver("./foo", containingFile.name, createModuleResolutionHost(containingFile, packageJson, indexFile));
|
||||
assert.equal(resolution.resolvedModule.resolvedFileName, indexFile.name);
|
||||
@@ -108,7 +122,7 @@ module ts {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("Node module resolution - non-relative paths", () => {
|
||||
it("load module as file - ts files not loaded", () => {
|
||||
let containingFile = { name: "/a/b/c/d/e.ts" };
|
||||
@@ -140,7 +154,7 @@ module ts {
|
||||
assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name);
|
||||
assert.equal(resolution.resolvedModule.isExternalLibraryImport, true);
|
||||
});
|
||||
|
||||
|
||||
it("load module as directory", () => {
|
||||
let containingFile = { name: "/a/node_modules/b/c/node_modules/d/e.ts" };
|
||||
let moduleFile = { name: "/a/node_modules/foo/index.d.ts" };
|
||||
@@ -178,31 +192,15 @@ module ts {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("Module resolution - relative imports", () => {
|
||||
it("should find all modules", () => {
|
||||
const options: CompilerOptions = { module: ModuleKind.CommonJS };
|
||||
const files: Map<string> = {
|
||||
"/a/b/c/first/shared.ts": `
|
||||
class A {}
|
||||
export = A`,
|
||||
"/a/b/c/first/second/class_a.ts": `
|
||||
import Shared = require('../shared');
|
||||
import C = require('../../third/class_c');
|
||||
class B {}
|
||||
export = B;`,
|
||||
"/a/b/c/third/class_c.ts":`
|
||||
import Shared = require('../first/shared');
|
||||
class C {}
|
||||
export = C;
|
||||
`
|
||||
};
|
||||
const currentDirectory = "/a/b/c/first/second";
|
||||
const host: CompilerHost = {
|
||||
getSourceFile: (fileName: string, languageVersion: ScriptTarget) => {
|
||||
let path = normalizePath(combinePaths(currentDirectory, fileName));
|
||||
return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined;
|
||||
},
|
||||
function test(files: Map<string>, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) {
|
||||
const options: CompilerOptions = { module: ModuleKind.CommonJS };
|
||||
const host: CompilerHost = {
|
||||
getSourceFile: (fileName: string, languageVersion: ScriptTarget) => {
|
||||
let path = normalizePath(combinePaths(currentDirectory, fileName));
|
||||
return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined;
|
||||
},
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
@@ -210,38 +208,150 @@ export = C;
|
||||
getNewLine: () => "\r\n",
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
fileExists: fileName => {
|
||||
let path = normalizePath(combinePaths(currentDirectory, fileName));
|
||||
return hasProperty(files, path);
|
||||
let path = normalizePath(combinePaths(currentDirectory, fileName));
|
||||
return hasProperty(files, path);
|
||||
},
|
||||
readFile: (fileName): string => { throw new Error("NotImplemented"); }
|
||||
};
|
||||
};
|
||||
|
||||
const program = createProgram(["class_a.ts"], options, host);
|
||||
const program = createProgram(rootFiles, options, host);
|
||||
|
||||
assert.equal(program.getSourceFiles().length, 3);
|
||||
const syntacticDiagnostics = program.getSyntacticDiagnostics();
|
||||
assert.equal(syntacticDiagnostics.length, 0, `expect no syntactic diagnostics, got: ${JSON.stringify(syntacticDiagnostics.map(diagnosticToString))}`);
|
||||
const semanticDiagnostics = program.getSemanticDiagnostics();
|
||||
assert.equal(semanticDiagnostics.length, 0, `expect no semantic diagnostics, got: ${JSON.stringify(semanticDiagnostics.map(diagnosticToString))}`);
|
||||
assert.equal(program.getSourceFiles().length, expectedFilesCount);
|
||||
const syntacticDiagnostics = program.getSyntacticDiagnostics();
|
||||
assert.equal(syntacticDiagnostics.length, 0, `expect no syntactic diagnostics, got: ${JSON.stringify(syntacticDiagnostics.map(diagnosticToString))}`);
|
||||
const semanticDiagnostics = program.getSemanticDiagnostics();
|
||||
assert.equal(semanticDiagnostics.length, 0, `expect no semantic diagnostics, got: ${JSON.stringify(semanticDiagnostics.map(diagnosticToString))}`);
|
||||
|
||||
// try to get file using a relative name
|
||||
const fileC = program.getSourceFile("../../../c/third/class_c.ts");
|
||||
assert.isTrue(fileC !== undefined, `expected to get file by relative name, got ${fileC}`);
|
||||
});
|
||||
|
||||
function diagnosticToString(diagnostic: Diagnostic) {
|
||||
let output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
|
||||
// try to get file using a relative name
|
||||
for (const relativeFileName of relativeNamesToCheck) {
|
||||
assert.isTrue(program.getSourceFile(relativeFileName) !== undefined, `expected to get file by relative name, got undefined`);
|
||||
}
|
||||
|
||||
let category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
it("should find all modules", () => {
|
||||
const files: Map<string> = {
|
||||
"/a/b/c/first/shared.ts": `
|
||||
class A {}
|
||||
export = A`,
|
||||
"/a/b/c/first/second/class_a.ts": `
|
||||
import Shared = require('../shared');
|
||||
import C = require('../../third/class_c');
|
||||
class B {}
|
||||
export = B;`,
|
||||
"/a/b/c/third/class_c.ts": `
|
||||
import Shared = require('../first/shared');
|
||||
class C {}
|
||||
export = C;
|
||||
`
|
||||
};
|
||||
test(files, "/a/b/c/first/second", ["class_a.ts"], 3, ["../../../c/third/class_c.ts"]);
|
||||
});
|
||||
|
||||
it("should find modules in node_modules", () => {
|
||||
const files: Map<string> = {
|
||||
"/parent/node_modules/mod/index.d.ts": "export var x",
|
||||
"/parent/app/myapp.ts": `import {x} from "mod"`
|
||||
};
|
||||
test(files, "/parent/app",["myapp.ts"], 2, []);
|
||||
});
|
||||
|
||||
it("should find file referenced via absolute and relative names", () => {
|
||||
const files: Map<string> = {
|
||||
"/a/b/c.ts": `/// <reference path="b.ts"/>`,
|
||||
"/a/b/b.ts": "var x"
|
||||
};
|
||||
test(files, "/a/b", ["c.ts", "/a/b/b.ts"], 2, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Files with different casing", () => {
|
||||
const library = createSourceFile("lib.d.ts", "", ScriptTarget.ES5);
|
||||
function test(files: Map<string>, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void {
|
||||
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
if (!useCaseSensitiveFileNames) {
|
||||
let f: Map<string> = {};
|
||||
for (let fileName in files) {
|
||||
f[getCanonicalFileName(fileName)] = files[fileName];
|
||||
}
|
||||
files = f;
|
||||
}
|
||||
|
||||
const host: CompilerHost = {
|
||||
getSourceFile: (fileName: string, languageVersion: ScriptTarget) => {
|
||||
if (fileName === "lib.d.ts") {
|
||||
return library;
|
||||
}
|
||||
let path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName)));
|
||||
return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined;
|
||||
},
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getCanonicalFileName,
|
||||
getNewLine: () => "\r\n",
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
fileExists: fileName => {
|
||||
let path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName)));
|
||||
return hasProperty(files, path);
|
||||
},
|
||||
readFile: (fileName): string => { throw new Error("NotImplemented"); }
|
||||
};
|
||||
const program = createProgram(rootFiles, options, host);
|
||||
const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics()));
|
||||
assert.equal(diagnostics.length, diagnosticCodes.length, `Incorrect number of expected diagnostics, expected ${diagnosticCodes.length}, got '${map(diagnostics, diagnosticToString).join("\r\n")}'`);
|
||||
for (let i = 0; i < diagnosticCodes.length; ++i) {
|
||||
assert.equal(diagnostics[i].code, diagnosticCodes[i], `Expected diagnostic code ${diagnosticCodes[i]}, got '${diagnostics[i].code}': '${diagnostics[i].messageText}'`);
|
||||
}
|
||||
}
|
||||
|
||||
it("should succeed when the same file is referenced using absolute and relative names", () => {
|
||||
const files: Map<string> = {
|
||||
"/a/b/c.ts": `/// <reference path="d.ts"/>`,
|
||||
"/a/b/d.ts": "var x"
|
||||
};
|
||||
test(files, { module: ts.ModuleKind.AMD }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "/a/b/d.ts"], []);
|
||||
});
|
||||
|
||||
it("should fail when two files used in program differ only in casing (tripleslash references)", () => {
|
||||
const files: Map<string> = {
|
||||
"/a/b/c.ts": `/// <reference path="D.ts"/>`,
|
||||
"/a/b/d.ts": "var x"
|
||||
};
|
||||
test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "d.ts"], [1149]);
|
||||
});
|
||||
|
||||
it("should fail when two files used in program differ only in casing (imports)", () => {
|
||||
const files: Map<string> = {
|
||||
"/a/b/c.ts": `import {x} from "D"`,
|
||||
"/a/b/d.ts": "export var x"
|
||||
};
|
||||
test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "d.ts"], [1149]);
|
||||
});
|
||||
|
||||
it("should fail when two files used in program differ only in casing (imports, relative module names)", () => {
|
||||
const files: Map<string> = {
|
||||
"moduleA.ts": `import {x} from "./ModuleB"`,
|
||||
"moduleB.ts": "export var x"
|
||||
};
|
||||
test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /* useCaseSensitiveFileNames */ false, ["moduleA.ts", "moduleB.ts"], [1149]);
|
||||
});
|
||||
|
||||
it("should fail when two files exist on disk that differs only in casing", () => {
|
||||
const files: Map<string> = {
|
||||
"/a/b/c.ts": `import {x} from "D"`,
|
||||
"/a/b/D.ts": "export var x",
|
||||
"/a/b/d.ts": "export var y"
|
||||
};
|
||||
test(files, { module: ts.ModuleKind.AMD }, "/a/b", /* useCaseSensitiveFileNames */ true, ["c.ts", "d.ts"], [1149]);
|
||||
});
|
||||
|
||||
it("should fail when module name in 'require' calls has inconsistent casing", () => {
|
||||
const files: Map<string> = {
|
||||
"moduleA.ts": `import a = require("./ModuleC")`,
|
||||
"moduleB.ts": `import a = require("./moduleC")`,
|
||||
"moduleC.ts": "export var x"
|
||||
};
|
||||
test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /* useCaseSensitiveFileNames */ false, ["moduleA.ts", "moduleB.ts", "moduleC.ts"], [1149, 1149]);
|
||||
})
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user