diff --git a/bin/lib.d.ts b/bin/lib.d.ts
index a3081f2c8d7..ebf92241aff 100644
--- a/bin/lib.d.ts
+++ b/bin/lib.d.ts
@@ -3807,30 +3807,42 @@ declare var Window: {
new(): Window;
}
-interface FormData {
- append(name: any, value: any, blobName?: string): void;
+interface HTMLCollection extends MSHTMLCollectionExtensions {
+ /**
+ * Sets or retrieves the number of objects in a collection.
+ */
+ length: number;
+ /**
+ * Retrieves an object from various collections.
+ */
+ item(nameOrIndex?: any, optionalIndex?: any): Element;
+ /**
+ * Retrieves a select object or an object from an options collection.
+ */
+ namedItem(name: string): Element;
+ // [name: string]: Element;
+ [index: number]: Element;
}
-declare var FormData: {
- prototype: FormData;
- new (form?: HTMLFormElement): FormData;
+declare var HTMLCollection: {
+ prototype: HTMLCollection;
+ new(): HTMLCollection;
}
-interface SourceBuffer extends EventTarget {
- updating: boolean;
- appendWindowStart: number;
- appendWindowEnd: number;
- buffered: TimeRanges;
- timestampOffset: number;
- audioTracks: AudioTrackList;
- appendBuffer(data: ArrayBufferView): void;
- appendBuffer(data: ArrayBuffer): void;
- remove(start: number, end: number): void;
- abort(): void;
- appendStream(stream: MSStream, maxSize?: number): void;
+interface BlobPropertyBag {
+ type?: string;
+ endings?: string;
}
-declare var SourceBuffer: {
- prototype: SourceBuffer;
- new(): SourceBuffer;
+
+interface Blob {
+ type: string;
+ size: number;
+ msDetachStream(): any;
+ slice(start?: number, end?: number, contentType?: string): Blob;
+ msClose(): void;
+}
+declare var Blob: {
+ prototype: Blob;
+ new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface NavigatorID {
@@ -5739,26 +5751,6 @@ declare var MSCSSProperties: {
new(): MSCSSProperties;
}
-interface HTMLCollection extends MSHTMLCollectionExtensions {
- /**
- * Sets or retrieves the number of objects in a collection.
- */
- length: number;
- /**
- * Retrieves an object from various collections.
- */
- item(nameOrIndex?: any, optionalIndex?: any): Element;
- /**
- * Retrieves a select object or an object from an options collection.
- */
- namedItem(name: string): Element;
- // [name: string]: Element;
-}
-declare var HTMLCollection: {
- prototype: HTMLCollection;
- new(): HTMLCollection;
-}
-
interface SVGExternalResourcesRequired {
externalResourcesRequired: SVGAnimatedBoolean;
}
@@ -11994,18 +11986,6 @@ declare var FileReader: {
new(): FileReader;
}
-interface Blob {
- type: string;
- size: number;
- msDetachStream(): any;
- slice(start?: number, end?: number, contentType?: string): Blob;
- msClose(): void;
-}
-declare var Blob: {
- prototype: Blob;
- new(): Blob;
-}
-
interface ApplicationCache extends EventTarget {
status: number;
ondownloading: (ev: Event) => any;
@@ -12164,6 +12144,14 @@ declare var MSManipulationEvent: {
MS_MANIPULATION_STATE_CANCELLED: number;
}
+interface FormData {
+ append(name: any, value: any, blobName?: string): void;
+}
+declare var FormData: {
+ prototype: FormData;
+ new(): FormData;
+}
+
interface HTMLDataListElement extends HTMLElement {
options: HTMLCollection;
}
@@ -12582,6 +12570,23 @@ interface RandomSource {
getRandomValues(array: ArrayBufferView): ArrayBufferView;
}
+interface SourceBuffer extends EventTarget {
+ updating: boolean;
+ appendWindowStart: number;
+ appendWindowEnd: number;
+ buffered: TimeRanges;
+ timestampOffset: number;
+ audioTracks: AudioTrackList;
+ appendBuffer(data: ArrayBuffer): void;
+ remove(start: number, end: number): void;
+ abort(): void;
+ appendStream(stream: MSStream, maxSize?: number): void;
+}
+declare var SourceBuffer: {
+ prototype: SourceBuffer;
+ new(): SourceBuffer;
+}
+
interface MSInputMethodContext extends EventTarget {
oncandidatewindowshow: (ev: any) => any;
target: HTMLElement;
diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts
index c0aceb3fc11..0fe2922830a 100644
--- a/bin/lib.dom.d.ts
+++ b/bin/lib.dom.d.ts
@@ -2704,30 +2704,42 @@ declare var Window: {
new(): Window;
}
-interface FormData {
- append(name: any, value: any, blobName?: string): void;
+interface HTMLCollection extends MSHTMLCollectionExtensions {
+ /**
+ * Sets or retrieves the number of objects in a collection.
+ */
+ length: number;
+ /**
+ * Retrieves an object from various collections.
+ */
+ item(nameOrIndex?: any, optionalIndex?: any): Element;
+ /**
+ * Retrieves a select object or an object from an options collection.
+ */
+ namedItem(name: string): Element;
+ // [name: string]: Element;
+ [index: number]: Element;
}
-declare var FormData: {
- prototype: FormData;
- new (form?: HTMLFormElement): FormData;
+declare var HTMLCollection: {
+ prototype: HTMLCollection;
+ new(): HTMLCollection;
}
-interface SourceBuffer extends EventTarget {
- updating: boolean;
- appendWindowStart: number;
- appendWindowEnd: number;
- buffered: TimeRanges;
- timestampOffset: number;
- audioTracks: AudioTrackList;
- appendBuffer(data: ArrayBufferView): void;
- appendBuffer(data: ArrayBuffer): void;
- remove(start: number, end: number): void;
- abort(): void;
- appendStream(stream: MSStream, maxSize?: number): void;
+interface BlobPropertyBag {
+ type?: string;
+ endings?: string;
}
-declare var SourceBuffer: {
- prototype: SourceBuffer;
- new(): SourceBuffer;
+
+interface Blob {
+ type: string;
+ size: number;
+ msDetachStream(): any;
+ slice(start?: number, end?: number, contentType?: string): Blob;
+ msClose(): void;
+}
+declare var Blob: {
+ prototype: Blob;
+ new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface NavigatorID {
@@ -4636,26 +4648,6 @@ declare var MSCSSProperties: {
new(): MSCSSProperties;
}
-interface HTMLCollection extends MSHTMLCollectionExtensions {
- /**
- * Sets or retrieves the number of objects in a collection.
- */
- length: number;
- /**
- * Retrieves an object from various collections.
- */
- item(nameOrIndex?: any, optionalIndex?: any): Element;
- /**
- * Retrieves a select object or an object from an options collection.
- */
- namedItem(name: string): Element;
- // [name: string]: Element;
-}
-declare var HTMLCollection: {
- prototype: HTMLCollection;
- new(): HTMLCollection;
-}
-
interface SVGExternalResourcesRequired {
externalResourcesRequired: SVGAnimatedBoolean;
}
@@ -10891,18 +10883,6 @@ declare var FileReader: {
new(): FileReader;
}
-interface Blob {
- type: string;
- size: number;
- msDetachStream(): any;
- slice(start?: number, end?: number, contentType?: string): Blob;
- msClose(): void;
-}
-declare var Blob: {
- prototype: Blob;
- new(): Blob;
-}
-
interface ApplicationCache extends EventTarget {
status: number;
ondownloading: (ev: Event) => any;
@@ -11061,6 +11041,14 @@ declare var MSManipulationEvent: {
MS_MANIPULATION_STATE_CANCELLED: number;
}
+interface FormData {
+ append(name: any, value: any, blobName?: string): void;
+}
+declare var FormData: {
+ prototype: FormData;
+ new(): FormData;
+}
+
interface HTMLDataListElement extends HTMLElement {
options: HTMLCollection;
}
@@ -11479,6 +11467,23 @@ interface RandomSource {
getRandomValues(array: ArrayBufferView): ArrayBufferView;
}
+interface SourceBuffer extends EventTarget {
+ updating: boolean;
+ appendWindowStart: number;
+ appendWindowEnd: number;
+ buffered: TimeRanges;
+ timestampOffset: number;
+ audioTracks: AudioTrackList;
+ appendBuffer(data: ArrayBuffer): void;
+ remove(start: number, end: number): void;
+ abort(): void;
+ appendStream(stream: MSStream, maxSize?: number): void;
+}
+declare var SourceBuffer: {
+ prototype: SourceBuffer;
+ new(): SourceBuffer;
+}
+
interface MSInputMethodContext extends EventTarget {
oncandidatewindowshow: (ev: any) => any;
target: HTMLElement;
diff --git a/bin/lib.webworker.d.ts b/bin/lib.webworker.d.ts
index 654d75b0aa9..02485d2602a 100644
--- a/bin/lib.webworker.d.ts
+++ b/bin/lib.webworker.d.ts
@@ -1453,6 +1453,11 @@ declare var FileReader: {
new(): FileReader;
}
+interface BlobPropertyBag {
+ type?: string;
+ endings?: string;
+}
+
interface Blob {
type: string;
size: number;
@@ -1462,7 +1467,7 @@ interface Blob {
}
declare var Blob: {
prototype: Blob;
- new(): Blob;
+ new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface MSStream {
diff --git a/bin/tsc.js b/bin/tsc.js
index 5efd7065d8e..af5f939a80d 100644
--- a/bin/tsc.js
+++ b/bin/tsc.js
@@ -267,6 +267,7 @@ var ts;
Import_name_cannot_be_0: { code: 2438, category: 1 /* Error */, key: "Import name cannot be '{0}'" },
Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: 1 /* Error */, key: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name." },
Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: 1 /* Error */, key: "Import declaration conflicts with local declaration of '{0}'" },
+ Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: 1 /* Error */, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -566,7 +567,8 @@ var ts;
var pos = 0;
var lineStart = 0;
while (pos < text.length) {
- switch (text.charCodeAt(pos++)) {
+ var ch = text.charCodeAt(pos++);
+ switch (ch) {
case 13 /* carriageReturn */:
if (text.charCodeAt(pos) === 10 /* lineFeed */) {
pos++;
@@ -575,6 +577,12 @@ var ts;
result.push(lineStart);
lineStart = pos;
break;
+ default:
+ if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) {
+ result.push(lineStart);
+ lineStart = pos;
+ }
+ break;
}
}
result.push(lineStart);
@@ -608,7 +616,7 @@ var ts;
}
ts.isWhiteSpace = isWhiteSpace;
function isLineBreak(ch) {
- return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || ch === 8233 /* paragraphSeparator */;
+ return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || ch === 8233 /* paragraphSeparator */ || ch === 133 /* nextLine */;
}
ts.isLineBreak = isLineBreak;
function isDigit(ch) {
@@ -748,6 +756,14 @@ var ts;
return getCommentRanges(text, pos, true);
}
ts.getTrailingComments = getTrailingComments;
+ function isIdentifierStart(ch, languageVersion) {
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
+ }
+ ts.isIdentifierStart = isIdentifierStart;
+ function isIdentifierPart(ch, languageVersion) {
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
+ }
+ ts.isIdentifierPart = isIdentifierPart;
function createScanner(languageVersion, text, onError, onComment) {
var pos;
var len;
@@ -1516,6 +1532,7 @@ var ts;
TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None";
TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType";
TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction";
+ TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation";
})(ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
var TypeFormatFlags = ts.TypeFormatFlags;
(function (SymbolAccessibility) {
@@ -1943,6 +1960,8 @@ var ts;
}
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
function createFileDiagnostic(file, start, length, message) {
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
var text = getLocaleSpecificMessage(message.key);
if (arguments.length > 4) {
text = formatStringFromArgs(text, arguments, 4);
@@ -1986,6 +2005,8 @@ var ts;
}
ts.chainDiagnosticMessages = chainDiagnosticMessages;
function flattenDiagnosticChain(file, start, length, diagnosticChain, newLine) {
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
var code = diagnosticChain.code;
var category = diagnosticChain.category;
var messageText = "";
@@ -2241,6 +2262,7 @@ var ts;
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(ts.AssertionLevel || (ts.AssertionLevel = {}));
var AssertionLevel = ts.AssertionLevel;
+ var Debug;
(function (Debug) {
var currentAssertionLevel = 0 /* None */;
function shouldAssert(level) {
@@ -2261,8 +2283,7 @@ var ts;
Debug.assert(false, message);
}
Debug.fail = fail;
- })(ts.Debug || (ts.Debug = {}));
- var Debug = ts.Debug;
+ })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
var sys = (function () {
function getWScriptSystem() {
@@ -2528,7 +2549,7 @@ var ts;
function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
node = getErrorSpanForNode(node);
var file = getSourceFileOfNode(node);
- var start = ts.skipTrivia(file.text, node.pos);
+ var start = node.kind === 111 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos);
var length = node.end - start;
return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
}
@@ -2732,6 +2753,42 @@ var ts;
return false;
}
ts.isInAmbientContext = isInAmbientContext;
+ function isDeclaration(node) {
+ switch (node.kind) {
+ case 113 /* TypeParameter */:
+ case 114 /* Parameter */:
+ case 166 /* VariableDeclaration */:
+ case 115 /* Property */:
+ case 129 /* PropertyAssignment */:
+ case 176 /* EnumMember */:
+ case 116 /* Method */:
+ case 167 /* FunctionDeclaration */:
+ case 118 /* GetAccessor */:
+ case 119 /* SetAccessor */:
+ case 169 /* ClassDeclaration */:
+ case 170 /* InterfaceDeclaration */:
+ case 171 /* EnumDeclaration */:
+ case 172 /* ModuleDeclaration */:
+ case 174 /* ImportDeclaration */:
+ return true;
+ }
+ return false;
+ }
+ ts.isDeclaration = isDeclaration;
+ function isDeclarationOrFunctionExpressionOrCatchVariableName(name) {
+ if (name.kind !== 55 /* Identifier */ && name.kind !== 3 /* StringLiteral */ && name.kind !== 2 /* NumericLiteral */) {
+ return false;
+ }
+ var parent = name.parent;
+ if (isDeclaration(parent) || parent.kind === 136 /* FunctionExpression */) {
+ return parent.name === name;
+ }
+ if (parent.kind === 163 /* CatchBlock */) {
+ return parent.variable === name;
+ }
+ return false;
+ }
+ ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName;
var ParsingContext;
(function (ParsingContext) {
ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
@@ -2820,6 +2877,22 @@ var ts;
ControlBlockContext[ControlBlockContext["Nested"] = 1] = "Nested";
ControlBlockContext[ControlBlockContext["CrossingFunctionBoundary"] = 2] = "CrossingFunctionBoundary";
})(ControlBlockContext || (ControlBlockContext = {}));
+ function isKeyword(token) {
+ return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword;
+ }
+ ts.isKeyword = isKeyword;
+ function isModifier(token) {
+ switch (token) {
+ case 98 /* PublicKeyword */:
+ case 96 /* PrivateKeyword */:
+ case 99 /* StaticKeyword */:
+ case 68 /* ExportKeyword */:
+ case 104 /* DeclareKeyword */:
+ return true;
+ }
+ return false;
+ }
+ ts.isModifier = isModifier;
function createSourceFile(filename, sourceText, languageVersion, version, isOpen) {
if (isOpen === void 0) { isOpen = false; }
var file;
@@ -3054,12 +3127,15 @@ var ts;
function createMissingNode() {
return createNode(111 /* Missing */);
}
+ function internIdentifier(text) {
+ return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text);
+ }
function createIdentifier(isIdentifier) {
identifierCount++;
if (isIdentifier) {
var node = createNode(55 /* Identifier */);
var text = escapeIdentifier(scanner.getTokenValue());
- node.text = ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text);
+ node.text = internIdentifier(text);
nextToken();
return finishNode(node);
}
@@ -3077,24 +3153,10 @@ var ts;
}
function parsePropertyName() {
if (token === 3 /* StringLiteral */ || token === 2 /* NumericLiteral */) {
- return parsePrimaryExpression();
+ return parseLiteralNode(true);
}
return parseIdentifierName();
}
- function isKeyword(token) {
- return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword;
- }
- function isModifier(token) {
- switch (token) {
- case 98 /* PublicKeyword */:
- case 96 /* PrivateKeyword */:
- case 99 /* StaticKeyword */:
- case 68 /* ExportKeyword */:
- case 104 /* DeclareKeyword */:
- return true;
- }
- return false;
- }
function parseContextualModifier(t) {
return token === t && tryParse(function () {
nextToken();
@@ -3309,9 +3371,10 @@ var ts;
nextToken();
return finishNode(node);
}
- function parseLiteralNode() {
+ function parseLiteralNode(internName) {
var node = createNode(token);
- node.text = scanner.getTokenValue();
+ var text = scanner.getTokenValue();
+ node.text = internName ? internIdentifier(text) : text;
var tokenPos = scanner.getTokenPos();
nextToken();
finishNode(node);
@@ -3327,7 +3390,7 @@ var ts;
}
function parseStringLiteral() {
if (token === 3 /* StringLiteral */)
- return parseLiteralNode();
+ return parseLiteralNode(true);
error(ts.Diagnostics.String_literal_expected);
return createMissingNode();
}
@@ -3999,6 +4062,10 @@ var ts;
}
else {
indexedAccess.index = parseExpression();
+ if (indexedAccess.index.kind === 3 /* StringLiteral */ || indexedAccess.index.kind === 2 /* NumericLiteral */) {
+ var literal = indexedAccess.index;
+ literal.text = internIdentifier(literal.text);
+ }
parseExpected(10 /* CloseBracketToken */);
}
expr = finishNode(indexedAccess);
@@ -4673,10 +4740,11 @@ var ts;
parseExpected(88 /* VarKeyword */);
node.declarations = parseVariableDeclarationList(flags, false);
parseSemicolon();
+ finishNode(node);
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
grammarErrorOnNode(node, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
}
- return finishNode(node);
+ return node;
}
function parseFunctionDeclaration(pos, flags) {
var node = createNode(167 /* FunctionDeclaration */, pos);
@@ -5304,6 +5372,7 @@ var ts;
file.version = version;
file.isOpen = isOpen;
file.languageVersion = languageVersion;
+ file.identifiers = identifiers;
return file;
}
ts.createSourceFile = createSourceFile;
@@ -5368,18 +5437,17 @@ var ts;
}
function findSourceFile(filename, isDefaultLib, refFile, refStart, refLength) {
var canonicalName = host.getCanonicalFileName(filename);
- var file = getSourceFile(filename);
- if (file) {
- if (host.useCaseSensitiveFileNames() && canonicalName !== file.filename) {
+ if (ts.hasProperty(filesByName, canonicalName)) {
+ var file = filesByName[canonicalName];
+ if (file && host.useCaseSensitiveFileNames() && canonicalName !== file.filename) {
errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, file.filename));
}
}
else {
- file = host.getSourceFile(filename, options.target, function (hostErrorMessage) {
+ var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, function (hostErrorMessage) {
errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
});
if (file) {
- filesByName[host.getCanonicalFileName(filename)] = file;
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
if (!options.noResolve) {
var basePath = ts.getDirectoryPath(filename);
@@ -5904,18 +5972,10 @@ var ts;
function writeLiteral(s) {
if (s && s.length) {
write(s);
- var pos = 0;
- while (pos < s.length) {
- switch (s.charCodeAt(pos++)) {
- case 13 /* carriageReturn */:
- if (pos < s.length && s.charCodeAt(pos) === 10 /* lineFeed */) {
- pos++;
- }
- case 10 /* lineFeed */:
- lineCount++;
- linePos = output.length - s.length + pos;
- break;
- }
+ var lineStartsOfS = ts.getLineStarts(s);
+ if (lineStartsOfS.length > 1) {
+ lineCount = lineCount + lineStartsOfS.length - 1;
+ linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
}
}
}
@@ -6026,10 +6086,9 @@ var ts;
}
function calculateIndent(pos, end) {
var currentLineIndent = 0;
- while (pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos))) {
- pos++;
+ for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) {
- currentLineIndent += getIndentSize();
+ currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
}
else {
currentLineIndent++;
@@ -7275,14 +7334,12 @@ var ts;
return emitPinnedOrTripleSlashComments(node);
}
emitLeadingComments(node);
- if (!(node.flags & 1 /* Export */)) {
- emitStart(node);
- write("var ");
- emit(node.name);
- write(";");
- emitEnd(node);
- writeLine();
- }
+ emitStart(node);
+ write("var ");
+ emit(node.name);
+ write(";");
+ emitEnd(node);
+ writeLine();
emitStart(node);
write("(function (");
emitStart(node.name);
@@ -7306,21 +7363,15 @@ var ts;
scopeEmitEnd();
}
write(")(");
+ if (node.flags & 1 /* Export */) {
+ emit(node.name);
+ write(" = ");
+ }
emitModuleMemberName(node);
write(" || (");
emitModuleMemberName(node);
write(" = {}));");
emitEnd(node);
- if (node.flags & 1 /* Export */) {
- writeLine();
- emitStart(node);
- write("var ");
- emit(node.name);
- write(" = ");
- emitModuleMemberName(node);
- emitEnd(node);
- write(";");
- }
emitTrailingComments(node);
}
function emitImportDeclaration(node) {
@@ -8327,39 +8378,43 @@ var ts;
}
}
function resolveScriptReference(sourceFile, reference) {
- var referenceFileName = compilerOptions.noResolve ? reference.filename : ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename));
+ var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename));
return program.getSourceFile(referenceFileName);
}
var referencePathsOutput = "";
function writeReferencePath(referencedFile) {
var declFileName = referencedFile.flags & 512 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile) ? getOwnEmitOutputFilePath(referencedFile, ".d.ts") : ts.getModuleNameFromFilename(compilerOptions.out) + ".d.ts";
declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), false);
- referencePathsOutput += "/// " + newLine;
+ referencePathsOutput += "/// " + newLine;
}
if (root) {
- var addedGlobalFileReference = false;
- ts.forEach(root.referencedFiles, function (fileReference) {
- var referencedFile = resolveScriptReference(root, fileReference);
- if ((referencedFile.flags & 512 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile) || !addedGlobalFileReference) {
- writeReferencePath(referencedFile);
- if (!isExternalModuleOrDeclarationFile(referencedFile)) {
- addedGlobalFileReference = true;
+ if (!compilerOptions.noResolve) {
+ var addedGlobalFileReference = false;
+ ts.forEach(root.referencedFiles, function (fileReference) {
+ var referencedFile = resolveScriptReference(root, fileReference);
+ if ((referencedFile.flags & 512 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile) || !addedGlobalFileReference) {
+ writeReferencePath(referencedFile);
+ if (!isExternalModuleOrDeclarationFile(referencedFile)) {
+ addedGlobalFileReference = true;
+ }
}
- }
- });
+ });
+ }
emitNode(root);
}
else {
var emittedReferencedFiles = [];
ts.forEach(program.getSourceFiles(), function (sourceFile) {
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
- ts.forEach(sourceFile.referencedFiles, function (fileReference) {
- var referencedFile = resolveScriptReference(sourceFile, fileReference);
- if (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile)) {
- writeReferencePath(referencedFile);
- emittedReferencedFiles.push(referencedFile);
- }
- });
+ if (!compilerOptions.noResolve) {
+ ts.forEach(sourceFile.referencedFiles, function (fileReference) {
+ var referencedFile = resolveScriptReference(sourceFile, fileReference);
+ if (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile)) {
+ writeReferencePath(referencedFile);
+ emittedReferencedFiles.push(referencedFile);
+ }
+ });
+ }
emitNode(sourceFile);
}
});
@@ -8409,6 +8464,17 @@ var ts;
var nextSymbolId = 1;
var nextNodeId = 1;
var nextMergeId = 1;
+ function getDeclarationOfKind(symbol, kind) {
+ var declarations = symbol.declarations;
+ for (var i = 0; i < declarations.length; i++) {
+ var declaration = declarations[i];
+ if (declaration.kind === kind) {
+ return declaration;
+ }
+ }
+ return undefined;
+ }
+ ts.getDeclarationOfKind = getDeclarationOfKind;
function createTypeChecker(program, fullTypeCheck) {
var Symbol = ts.objectAllocator.getSymbolConstructor();
var Type = ts.objectAllocator.getTypeConstructor();
@@ -8416,6 +8482,7 @@ var ts;
var typeCount = 0;
var emptyArray = [];
var emptySymbols = {};
+ var compilerOptions = program.getCompilerOptions();
var checker = {
getProgram: function () { return program; },
getDiagnostics: getDiagnostics,
@@ -8439,7 +8506,9 @@ var ts;
getApparentType: getApparentType,
typeToString: typeToString,
symbolToString: symbolToString,
- getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType
+ getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType,
+ getRootSymbol: getRootSymbol,
+ getContextualType: getContextualType
};
var undefinedSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "undefined");
var argumentsSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "arguments");
@@ -8887,16 +8956,6 @@ var ts;
}
return false;
}
- function getDeclarationOfKind(symbol, kind) {
- var declarations = symbol.declarations;
- for (var i = 0; i < declarations.length; i++) {
- var declaration = declarations[i];
- if (declaration.kind === kind) {
- return declaration;
- }
- }
- return undefined;
- }
function findConstructorDeclaration(node) {
var members = node.members;
for (var i = 0; i < members.length; i++) {
@@ -9134,7 +9193,7 @@ var ts;
}
return symbol.name;
}
- if (enclosingDeclaration && !(symbol.flags & (ts.SymbolFlags.PropertyOrAccessor | ts.SymbolFlags.Signature | 4096 /* Constructor */ | 2048 /* Method */ | 262144 /* TypeParameter */))) {
+ if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) {
var symbolName;
while (symbol) {
var isFirstName = !symbolName;
@@ -9163,17 +9222,25 @@ var ts;
function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) {
writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
}
- function createSingleLineTextWriter() {
+ function createSingleLineTextWriter(maxLength) {
var result = "";
- return {
- write: function (s) {
+ var overflow = false;
+ function write(s) {
+ if (!overflow) {
result += s;
- },
+ if (result.length > maxLength) {
+ result = result.substr(0, maxLength - 3) + "...";
+ overflow = true;
+ }
+ }
+ }
+ return {
+ write: write,
writeSymbol: function (symbol, enclosingDeclaration, meaning) {
writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
},
writeLine: function () {
- result += " ";
+ write(" ");
},
increaseIndent: function () {
},
@@ -9185,7 +9252,8 @@ var ts;
};
}
function typeToString(type, enclosingDeclaration, flags) {
- var stringWriter = createSingleLineTextWriter();
+ var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100;
+ var stringWriter = createSingleLineTextWriter(maxLength);
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
return stringWriter.getText();
}
@@ -9515,7 +9583,7 @@ var ts;
checkImplicitAny(type);
return type;
function checkImplicitAny(type) {
- if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) {
+ if (!fullTypeCheck || !compilerOptions.noImplicitAny) {
return;
}
if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) {
@@ -9599,7 +9667,7 @@ var ts;
type = getReturnTypeFromBody(getter);
}
else {
- if (program.getCompilerOptions().noImplicitAny) {
+ if (compilerOptions.noImplicitAny) {
error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
}
type = anyType;
@@ -9917,27 +9985,38 @@ var ts;
}
function resolveAnonymousTypeMembers(type) {
var symbol = type.symbol;
- var members = emptySymbols;
- var callSignatures = emptyArray;
- var constructSignatures = emptyArray;
- if (symbol.flags & ts.SymbolFlags.HasExports) {
- members = symbol.exports;
+ if (symbol.flags & 512 /* TypeLiteral */) {
+ var members = symbol.members;
+ var callSignatures = getSignaturesOfSymbol(members["__call"]);
+ var constructSignatures = getSignaturesOfSymbol(members["__new"]);
+ var stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */);
+ var numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */);
}
- if (symbol.flags & (8 /* Function */ | 2048 /* Method */)) {
- callSignatures = getSignaturesOfSymbol(symbol);
- }
- if (symbol.flags & 16 /* Class */) {
- var classType = getDeclaredTypeOfClass(symbol);
- constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]);
- if (!constructSignatures.length)
- constructSignatures = getDefaultConstructSignatures(classType);
- if (classType.baseTypes.length) {
- var members = createSymbolTable(getNamedMembers(members));
- addInheritedMembers(members, getPropertiesOfType(getTypeOfSymbol(classType.baseTypes[0].symbol)));
+ else {
+ var members = emptySymbols;
+ var callSignatures = emptyArray;
+ var constructSignatures = emptyArray;
+ if (symbol.flags & ts.SymbolFlags.HasExports) {
+ members = symbol.exports;
}
+ if (symbol.flags & (8 /* Function */ | 2048 /* Method */)) {
+ callSignatures = getSignaturesOfSymbol(symbol);
+ }
+ if (symbol.flags & 16 /* Class */) {
+ var classType = getDeclaredTypeOfClass(symbol);
+ constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]);
+ if (!constructSignatures.length) {
+ constructSignatures = getDefaultConstructSignatures(classType);
+ }
+ if (classType.baseTypes.length) {
+ members = createSymbolTable(getNamedMembers(members));
+ addInheritedMembers(members, getPropertiesOfType(getTypeOfSymbol(classType.baseTypes[0].symbol)));
+ }
+ }
+ var stringIndexType = undefined;
+ var numberIndexType = (symbol.flags & 64 /* Enum */) ? stringType : undefined;
}
- var numberIndexType = (symbol.flags & 64 /* Enum */) ? stringType : undefined;
- setObjectTypeMembers(type, members, callSignatures, constructSignatures, undefined, numberIndexType);
+ setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
}
function resolveObjectTypeMembers(type) {
if (!type.members) {
@@ -10319,13 +10398,7 @@ var ts;
function getTypeFromTypeLiteralNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- var symbol = node.symbol;
- var members = symbol.members;
- var callSignatures = getSignaturesOfSymbol(members["__call"]);
- var constructSignatures = getSignaturesOfSymbol(members["__new"]);
- var stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */);
- var numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */);
- links.resolvedType = createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
+ links.resolvedType = createObjectType(8192 /* Anonymous */, node.symbol);
}
return links.resolvedType;
}
@@ -11054,45 +11127,6 @@ var ts;
function isTypeOfObjectLiteral(type) {
return (type.flags & 8192 /* Anonymous */) && type.symbol && (type.symbol.flags & 1024 /* ObjectLiteral */) ? true : false;
}
- function getWidenedTypeOfObjectLiteral(type) {
- var properties = getPropertiesOfType(type);
- if (properties.length) {
- var widenedTypes = [];
- var propTypeWasWidened = false;
- ts.forEach(properties, function (p) {
- var propType = getTypeOfSymbol(p);
- var widenedType = getWidenedType(propType);
- if (propType !== widenedType) {
- propTypeWasWidened = true;
- if (program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
- error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
- }
- }
- widenedTypes.push(widenedType);
- });
- if (propTypeWasWidened) {
- var members = {};
- var index = 0;
- ts.forEach(properties, function (p) {
- var symbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, p.name);
- symbol.declarations = p.declarations;
- symbol.parent = p.parent;
- symbol.type = widenedTypes[index++];
- if (p.valueDeclaration)
- symbol.valueDeclaration = p.valueDeclaration;
- members[symbol.name] = symbol;
- });
- var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
- var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
- if (stringIndexType)
- stringIndexType = getWidenedType(stringIndexType);
- if (numberIndexType)
- numberIndexType = getWidenedType(numberIndexType);
- type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
- }
- }
- return type;
- }
function isArrayType(type) {
return type.flags & 4096 /* Reference */ && type.target === globalArrayType;
}
@@ -11102,13 +11136,7 @@ var ts;
}
return type;
}
- function getWidenedTypeOfArrayLiteral(type) {
- var elementType = type.typeArguments[0];
- var widenedType = getWidenedType(elementType);
- type = elementType !== widenedType ? createArrayType(widenedType) : type;
- return type;
- }
- function getWidenedType(type) {
+ function getWidenedType(type, supressNoImplicitAnyErrors) {
if (type.flags & (32 /* Undefined */ | 64 /* Null */)) {
return anyType;
}
@@ -11119,6 +11147,52 @@ var ts;
return getWidenedTypeOfArrayLiteral(type);
}
return type;
+ function getWidenedTypeOfObjectLiteral(type) {
+ var properties = getPropertiesOfType(type);
+ if (properties.length) {
+ var widenedTypes = [];
+ var propTypeWasWidened = false;
+ ts.forEach(properties, function (p) {
+ var propType = getTypeOfSymbol(p);
+ var widenedType = getWidenedType(propType);
+ if (propType !== widenedType) {
+ propTypeWasWidened = true;
+ if (!supressNoImplicitAnyErrors && program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
+ }
+ }
+ widenedTypes.push(widenedType);
+ });
+ if (propTypeWasWidened) {
+ var members = {};
+ var index = 0;
+ ts.forEach(properties, function (p) {
+ var symbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, p.name);
+ symbol.declarations = p.declarations;
+ symbol.parent = p.parent;
+ symbol.type = widenedTypes[index++];
+ symbol.target = p;
+ if (p.valueDeclaration)
+ symbol.valueDeclaration = p.valueDeclaration;
+ members[symbol.name] = symbol;
+ });
+ var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
+ var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
+ if (stringIndexType)
+ stringIndexType = getWidenedType(stringIndexType);
+ if (numberIndexType)
+ numberIndexType = getWidenedType(numberIndexType);
+ type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
+ }
+ }
+ return type;
+ }
+ function getWidenedTypeOfArrayLiteral(type) {
+ var elementType = type.typeArguments[0];
+ var widenedType = getWidenedType(elementType, supressNoImplicitAnyErrors);
+ type = elementType !== widenedType ? createArrayType(widenedType) : type;
+ return type;
+ }
}
function forEachMatchingParameterType(source, target, callback) {
var sourceMax = source.parameters.length;
@@ -11652,6 +11726,7 @@ var ts;
if (member.valueDeclaration)
prop.valueDeclaration = member.valueDeclaration;
prop.type = type;
+ prop.target = member;
member = prop;
}
else {
@@ -11754,7 +11829,7 @@ var ts;
if (stringIndexType) {
return stringIndexType;
}
- if (program.getCompilerOptions().noImplicitAny && objectType !== anyType) {
+ if (compilerOptions.noImplicitAny && objectType !== anyType) {
error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
}
return anyType;
@@ -11825,17 +11900,6 @@ var ts;
});
return getSignatureInstantiation(signature, getInferredTypes(context));
}
- function inferentiallyTypeExpession(expr, contextualType, contextualMapper) {
- var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
- var signature = getSingleCallSignature(type);
- if (signature && signature.typeParameters) {
- var contextualSignature = getSingleCallSignature(contextualType);
- if (contextualSignature && !contextualSignature.typeParameters) {
- type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
- }
- }
- return type;
- }
function inferTypeArguments(signature, args, excludeArgument) {
var typeParameters = signature.typeParameters;
var context = createInferenceContext(typeParameters);
@@ -11843,14 +11907,14 @@ var ts;
for (var i = 0; i < args.length; i++) {
if (!excludeArgument || excludeArgument[i] === undefined) {
var parameterType = getTypeAtPosition(signature, i);
- inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
+ inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
if (excludeArgument) {
for (var i = 0; i < args.length; i++) {
if (excludeArgument[i] === false) {
var parameterType = getTypeAtPosition(signature, i);
- inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
+ inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
}
@@ -12008,7 +12072,7 @@ var ts;
if (node.kind === 133 /* NewExpression */) {
var declaration = signature.declaration;
if (declaration && (declaration.kind !== 117 /* Constructor */ && declaration.kind !== 121 /* ConstructSignature */)) {
- if (program.getCompilerOptions().noImplicitAny) {
+ if (compilerOptions.noImplicitAny) {
error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
}
return anyType;
@@ -12020,9 +12084,9 @@ var ts;
var exprType = checkExpression(node.operand);
var targetType = getTypeFromTypeNode(node.type);
if (fullTypeCheck && targetType !== unknownType) {
- var widenedType = getWidenedType(exprType);
- if (!(isTypeAssignableTo(exprType, targetType) || isTypeAssignableTo(targetType, widenedType))) {
- checkTypeAssignableTo(targetType, widenedType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
+ var widenedType = getWidenedType(exprType, true);
+ if (!(isTypeAssignableTo(targetType, widenedType))) {
+ checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
}
}
return targetType;
@@ -12047,7 +12111,7 @@ var ts;
if (func.body.kind !== 168 /* FunctionBlock */) {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
return widenedType;
@@ -12060,7 +12124,7 @@ var ts;
return unknownType;
}
var widenedType = getWidenedType(commonType);
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
var typeName = typeToString(widenedType);
if (func.name) {
error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.identifierToString(func.name), typeName);
@@ -12162,26 +12226,26 @@ var ts;
}
}
}
+ checkSignatureDeclaration(node);
}
}
- if (fullTypeCheck && !(links.flags & 1 /* TypeChecked */)) {
- checkSignatureDeclaration(node);
- if (node.type) {
- checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
- }
- if (node.body.kind === 168 /* FunctionBlock */) {
- checkSourceElement(node.body);
- }
- else {
- var exprType = checkExpression(node.body);
- if (node.type) {
- checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined, undefined);
- }
- }
- links.flags |= 1 /* TypeChecked */;
- }
return type;
}
+ function checkFunctionExpressionBody(node) {
+ if (node.type) {
+ checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
+ }
+ if (node.body.kind === 168 /* FunctionBlock */) {
+ checkSourceElement(node.body);
+ }
+ else {
+ var exprType = checkExpression(node.body);
+ if (node.type) {
+ checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined, undefined);
+ }
+ checkFunctionExpressionBodies(node.body);
+ }
+ }
function checkArithmeticOperandType(operand, type, diagnostic) {
if (!(type.flags & (1 /* Any */ | ts.TypeFlags.NumberLike))) {
error(operand, diagnostic);
@@ -12396,6 +12460,22 @@ var ts;
return result;
}
function checkExpression(node, contextualMapper) {
+ var type = checkExpressionNode(node, contextualMapper);
+ if (contextualMapper && contextualMapper !== identityMapper) {
+ var signature = getSingleCallSignature(type);
+ if (signature && signature.typeParameters) {
+ var contextualType = getContextualType(node);
+ if (contextualType) {
+ var contextualSignature = getSingleCallSignature(contextualType);
+ if (contextualSignature && !contextualSignature.typeParameters) {
+ type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
+ }
+ }
+ }
+ }
+ return type;
+ }
+ function checkExpressionNode(node, contextualMapper) {
switch (node.kind) {
case 55 /* Identifier */:
return checkIdentifier(node);
@@ -12504,8 +12584,9 @@ var ts;
if (fullTypeCheck) {
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
- if (program.getCompilerOptions().noImplicitAny && !node.type) {
+ if (compilerOptions.noImplicitAny && !node.type) {
switch (node.kind) {
case 121 /* ConstructSignature */:
error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -12916,7 +12997,7 @@ var ts;
if (node.type && !isAccessor(node.kind)) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) {
if (!isPrivateWithinAmbient(node)) {
var typeName = typeToString(anyType);
if (node.name) {
@@ -13031,6 +13112,18 @@ var ts;
}
}
}
+ function checkCollistionWithRequireExportsInGeneratedCode(node, name) {
+ if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
+ return;
+ }
+ if (node.kind === 172 /* ModuleDeclaration */ && !ts.isInstantiated(node)) {
+ return;
+ }
+ var parent = node.kind === 166 /* VariableDeclaration */ ? node.parent.parent : node.parent;
+ if (parent.kind === 177 /* SourceFile */ && ts.isExternalModule(parent)) {
+ error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, name.text, name.text);
+ }
+ }
function checkVariableDeclaration(node) {
checkSourceElement(node.type);
checkExportsOnMergedDeclarations(node);
@@ -13052,6 +13145,7 @@ var ts;
}
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
if (!useTypeFromValueDeclaration) {
if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) {
error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.identifierToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type));
@@ -13250,6 +13344,7 @@ var ts;
checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
checkTypeParameters(node.typeParameters);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
var type = getDeclaredTypeOfSymbol(symbol);
@@ -13417,6 +13512,7 @@ var ts;
}
checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkExportsOnMergedDeclarations(node);
var enumSymbol = getSymbolOfNode(node);
var enumType = getDeclaredTypeOfSymbol(enumSymbol);
@@ -13473,6 +13569,7 @@ var ts;
function checkModuleDeclaration(node) {
if (fullTypeCheck) {
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
if (symbol.flags & 128 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) {
@@ -13505,6 +13602,7 @@ var ts;
}
function checkImportDeclaration(node) {
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
var symbol = getSymbolOfNode(node);
var target;
if (node.entityName) {
@@ -13587,9 +13685,10 @@ var ts;
case 167 /* FunctionDeclaration */:
return checkFunctionDeclaration(node);
case 143 /* Block */:
+ return checkBlock(node);
case 168 /* FunctionBlock */:
case 173 /* ModuleBlock */:
- return checkBlock(node);
+ return checkBody(node);
case 144 /* VariableStatement */:
return checkVariableStatement(node);
case 146 /* ExpressionStatement */:
@@ -13635,12 +13734,79 @@ var ts;
return checkExportAssignment(node);
}
}
+ function checkFunctionExpressionBodies(node) {
+ switch (node.kind) {
+ case 136 /* FunctionExpression */:
+ case 137 /* ArrowFunction */:
+ ts.forEach(node.parameters, checkFunctionExpressionBodies);
+ checkFunctionExpressionBody(node);
+ break;
+ case 116 /* Method */:
+ case 117 /* Constructor */:
+ case 118 /* GetAccessor */:
+ case 119 /* SetAccessor */:
+ case 167 /* FunctionDeclaration */:
+ ts.forEach(node.parameters, checkFunctionExpressionBodies);
+ break;
+ case 155 /* WithStatement */:
+ checkFunctionExpressionBodies(node.expression);
+ break;
+ case 114 /* Parameter */:
+ case 115 /* Property */:
+ case 127 /* ArrayLiteral */:
+ case 128 /* ObjectLiteral */:
+ case 129 /* PropertyAssignment */:
+ case 130 /* PropertyAccess */:
+ case 131 /* IndexedAccess */:
+ case 132 /* CallExpression */:
+ case 133 /* NewExpression */:
+ case 134 /* TypeAssertion */:
+ case 135 /* ParenExpression */:
+ case 138 /* PrefixOperator */:
+ case 139 /* PostfixOperator */:
+ case 140 /* BinaryExpression */:
+ case 141 /* ConditionalExpression */:
+ case 143 /* Block */:
+ case 168 /* FunctionBlock */:
+ case 173 /* ModuleBlock */:
+ case 144 /* VariableStatement */:
+ case 146 /* ExpressionStatement */:
+ case 147 /* IfStatement */:
+ case 148 /* DoStatement */:
+ case 149 /* WhileStatement */:
+ case 150 /* ForStatement */:
+ case 151 /* ForInStatement */:
+ case 152 /* ContinueStatement */:
+ case 153 /* BreakStatement */:
+ case 154 /* ReturnStatement */:
+ case 156 /* SwitchStatement */:
+ case 157 /* CaseClause */:
+ case 158 /* DefaultClause */:
+ case 159 /* LabelledStatement */:
+ case 160 /* ThrowStatement */:
+ case 161 /* TryStatement */:
+ case 162 /* TryBlock */:
+ case 163 /* CatchBlock */:
+ case 164 /* FinallyBlock */:
+ case 166 /* VariableDeclaration */:
+ case 169 /* ClassDeclaration */:
+ case 171 /* EnumDeclaration */:
+ case 176 /* EnumMember */:
+ case 177 /* SourceFile */:
+ ts.forEachChild(node, checkFunctionExpressionBodies);
+ break;
+ }
+ }
+ function checkBody(node) {
+ checkBlock(node);
+ checkFunctionExpressionBodies(node);
+ }
function checkSourceFile(node) {
var links = getNodeLinks(node);
if (!(links.flags & 1 /* TypeChecked */)) {
emitExtends = false;
potentialThisCollisions.length = 0;
- ts.forEach(node.statements, checkSourceElement);
+ checkBody(node);
if (ts.isExternalModule(node)) {
var symbol = getExportAssignmentSymbol(node.symbol);
if (symbol && symbol.flags & 4194304 /* Import */) {
@@ -13754,19 +13920,6 @@ var ts;
function isTypeDeclarationName(name) {
return name.kind == 55 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name;
}
- function isDeclarationOrFunctionExpressionOrCatchVariableName(name) {
- if (name.kind !== 55 /* Identifier */ && name.kind !== 3 /* StringLiteral */ && name.kind !== 2 /* NumericLiteral */) {
- return false;
- }
- var parent = name.parent;
- if (isDeclaration(parent) || parent.kind === 136 /* FunctionExpression */) {
- return parent.name === name;
- }
- if (parent.kind === 163 /* CatchBlock */) {
- return parent.variable === name;
- }
- return false;
- }
function isTypeDeclaration(node) {
switch (node.kind) {
case 113 /* TypeParameter */:
@@ -13776,27 +13929,6 @@ var ts;
return true;
}
}
- function isDeclaration(node) {
- switch (node.kind) {
- case 113 /* TypeParameter */:
- case 114 /* Parameter */:
- case 166 /* VariableDeclaration */:
- case 115 /* Property */:
- case 129 /* PropertyAssignment */:
- case 176 /* EnumMember */:
- case 116 /* Method */:
- case 167 /* FunctionDeclaration */:
- case 118 /* GetAccessor */:
- case 119 /* SetAccessor */:
- case 169 /* ClassDeclaration */:
- case 170 /* InterfaceDeclaration */:
- case 171 /* EnumDeclaration */:
- case 172 /* ModuleDeclaration */:
- case 174 /* ImportDeclaration */:
- return true;
- }
- return false;
- }
function isTypeReferenceIdentifier(entityName) {
var node = entityName;
while (node.parent && node.parent.kind === 112 /* QualifiedName */)
@@ -13940,7 +14072,7 @@ var ts;
return (node.parent.kind === 112 /* QualifiedName */ || node.parent.kind === 130 /* PropertyAccess */) && node.parent.right === node;
}
function getSymbolOfEntityName(entityName) {
- if (isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
+ if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
return getSymbolOfNode(entityName.parent);
}
if (entityName.parent.kind === 175 /* ExportAssignment */) {
@@ -13976,6 +14108,12 @@ var ts;
return undefined;
}
function getSymbolInfo(node) {
+ if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
+ return getSymbolOfNode(node.parent);
+ }
+ if (node.kind === 55 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) {
+ return node.parent.kind === 175 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node);
+ }
switch (node.kind) {
case 55 /* Identifier */:
case 130 /* PropertyAccess */:
@@ -13992,7 +14130,13 @@ var ts;
}
return undefined;
case 3 /* StringLiteral */:
- if (node.parent.kind === 131 /* IndexedAccess */ && node.parent.index === node) {
+ if (node.parent.kind === 174 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
+ var importSymbol = getSymbolOfNode(node.parent);
+ var moduleType = getTypeOfSymbol(importSymbol);
+ return moduleType ? moduleType.symbol : undefined;
+ }
+ case 2 /* NumericLiteral */:
+ if (node.parent.kind == 131 /* IndexedAccess */ && node.parent.index === node) {
var objectType = checkExpression(node.parent.object);
if (objectType === unknownType)
return undefined;
@@ -14001,14 +14145,6 @@ var ts;
return undefined;
return getPropertyOfApparentType(apparentType, node.text);
}
- else if (node.parent.kind === 174 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
- var importSymbol = getSymbolOfNode(node.parent);
- var moduleType = getTypeOfSymbol(importSymbol);
- return moduleType ? moduleType.symbol : undefined;
- }
- else if (node.parent.kind === 172 /* ModuleDeclaration */) {
- return getSymbolOfNode(node.parent);
- }
break;
}
return undefined;
@@ -14028,11 +14164,11 @@ var ts;
var symbol = getSymbolInfo(node);
return getDeclaredTypeOfSymbol(symbol);
}
- if (isDeclaration(node)) {
+ if (ts.isDeclaration(node)) {
var symbol = getSymbolOfNode(node);
return getTypeOfSymbol(symbol);
}
- if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
+ if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
var symbol = getSymbolInfo(node);
return getTypeOfSymbol(symbol);
}
@@ -14079,6 +14215,9 @@ var ts;
return getPropertiesOfType(apparentType);
}
}
+ function getRootSymbol(symbol) {
+ return (symbol.flags & 33554432 /* Transient */) ? getSymbolLinks(symbol).target : symbol;
+ }
function isExternalModuleSymbol(symbol) {
return symbol.flags & 128 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 177 /* SourceFile */;
}
@@ -14155,7 +14294,7 @@ var ts;
return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0);
}
function shouldEmitDeclarations() {
- return program.getCompilerOptions().declaration && !program.getDiagnostics().length && !getDiagnostics().length;
+ return compilerOptions.declaration && !program.getDiagnostics().length && !getDiagnostics().length;
}
function isReferencedImportDeclaration(node) {
var symbol = getSymbolOfNode(node);
diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js
index d9b53be63cf..1efb6d232e3 100644
--- a/bin/typescriptServices.js
+++ b/bin/typescriptServices.js
@@ -267,6 +267,7 @@ var ts;
Import_name_cannot_be_0: { code: 2438, category: 1 /* Error */, key: "Import name cannot be '{0}'" },
Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: 1 /* Error */, key: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name." },
Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: 1 /* Error */, key: "Import declaration conflicts with local declaration of '{0}'" },
+ Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: 1 /* Error */, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -566,7 +567,8 @@ var ts;
var pos = 0;
var lineStart = 0;
while (pos < text.length) {
- switch (text.charCodeAt(pos++)) {
+ var ch = text.charCodeAt(pos++);
+ switch (ch) {
case 13 /* carriageReturn */:
if (text.charCodeAt(pos) === 10 /* lineFeed */) {
pos++;
@@ -575,6 +577,12 @@ var ts;
result.push(lineStart);
lineStart = pos;
break;
+ default:
+ if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) {
+ result.push(lineStart);
+ lineStart = pos;
+ }
+ break;
}
}
result.push(lineStart);
@@ -608,7 +616,7 @@ var ts;
}
ts.isWhiteSpace = isWhiteSpace;
function isLineBreak(ch) {
- return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || ch === 8233 /* paragraphSeparator */;
+ return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || ch === 8233 /* paragraphSeparator */ || ch === 133 /* nextLine */;
}
ts.isLineBreak = isLineBreak;
function isDigit(ch) {
@@ -748,6 +756,14 @@ var ts;
return getCommentRanges(text, pos, true);
}
ts.getTrailingComments = getTrailingComments;
+ function isIdentifierStart(ch, languageVersion) {
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
+ }
+ ts.isIdentifierStart = isIdentifierStart;
+ function isIdentifierPart(ch, languageVersion) {
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
+ }
+ ts.isIdentifierPart = isIdentifierPart;
function createScanner(languageVersion, text, onError, onComment) {
var pos;
var len;
@@ -1516,6 +1532,7 @@ var ts;
TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None";
TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType";
TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction";
+ TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation";
})(ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
var TypeFormatFlags = ts.TypeFormatFlags;
(function (SymbolAccessibility) {
@@ -1943,6 +1960,8 @@ var ts;
}
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
function createFileDiagnostic(file, start, length, message) {
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
var text = getLocaleSpecificMessage(message.key);
if (arguments.length > 4) {
text = formatStringFromArgs(text, arguments, 4);
@@ -1986,6 +2005,8 @@ var ts;
}
ts.chainDiagnosticMessages = chainDiagnosticMessages;
function flattenDiagnosticChain(file, start, length, diagnosticChain, newLine) {
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
var code = diagnosticChain.code;
var category = diagnosticChain.category;
var messageText = "";
@@ -2241,6 +2262,7 @@ var ts;
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive";
})(ts.AssertionLevel || (ts.AssertionLevel = {}));
var AssertionLevel = ts.AssertionLevel;
+ var Debug;
(function (Debug) {
var currentAssertionLevel = 0 /* None */;
function shouldAssert(level) {
@@ -2261,8 +2283,7 @@ var ts;
Debug.assert(false, message);
}
Debug.fail = fail;
- })(ts.Debug || (ts.Debug = {}));
- var Debug = ts.Debug;
+ })(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
var ts;
(function (ts) {
@@ -2333,7 +2354,7 @@ var ts;
function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
node = getErrorSpanForNode(node);
var file = getSourceFileOfNode(node);
- var start = ts.skipTrivia(file.text, node.pos);
+ var start = node.kind === 111 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos);
var length = node.end - start;
return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
}
@@ -2537,6 +2558,42 @@ var ts;
return false;
}
ts.isInAmbientContext = isInAmbientContext;
+ function isDeclaration(node) {
+ switch (node.kind) {
+ case 113 /* TypeParameter */:
+ case 114 /* Parameter */:
+ case 166 /* VariableDeclaration */:
+ case 115 /* Property */:
+ case 129 /* PropertyAssignment */:
+ case 176 /* EnumMember */:
+ case 116 /* Method */:
+ case 167 /* FunctionDeclaration */:
+ case 118 /* GetAccessor */:
+ case 119 /* SetAccessor */:
+ case 169 /* ClassDeclaration */:
+ case 170 /* InterfaceDeclaration */:
+ case 171 /* EnumDeclaration */:
+ case 172 /* ModuleDeclaration */:
+ case 174 /* ImportDeclaration */:
+ return true;
+ }
+ return false;
+ }
+ ts.isDeclaration = isDeclaration;
+ function isDeclarationOrFunctionExpressionOrCatchVariableName(name) {
+ if (name.kind !== 55 /* Identifier */ && name.kind !== 3 /* StringLiteral */ && name.kind !== 2 /* NumericLiteral */) {
+ return false;
+ }
+ var parent = name.parent;
+ if (isDeclaration(parent) || parent.kind === 136 /* FunctionExpression */) {
+ return parent.name === name;
+ }
+ if (parent.kind === 163 /* CatchBlock */) {
+ return parent.variable === name;
+ }
+ return false;
+ }
+ ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName;
var ParsingContext;
(function (ParsingContext) {
ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
@@ -2625,6 +2682,22 @@ var ts;
ControlBlockContext[ControlBlockContext["Nested"] = 1] = "Nested";
ControlBlockContext[ControlBlockContext["CrossingFunctionBoundary"] = 2] = "CrossingFunctionBoundary";
})(ControlBlockContext || (ControlBlockContext = {}));
+ function isKeyword(token) {
+ return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword;
+ }
+ ts.isKeyword = isKeyword;
+ function isModifier(token) {
+ switch (token) {
+ case 98 /* PublicKeyword */:
+ case 96 /* PrivateKeyword */:
+ case 99 /* StaticKeyword */:
+ case 68 /* ExportKeyword */:
+ case 104 /* DeclareKeyword */:
+ return true;
+ }
+ return false;
+ }
+ ts.isModifier = isModifier;
function createSourceFile(filename, sourceText, languageVersion, version, isOpen) {
if (isOpen === void 0) { isOpen = false; }
var file;
@@ -2859,12 +2932,15 @@ var ts;
function createMissingNode() {
return createNode(111 /* Missing */);
}
+ function internIdentifier(text) {
+ return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text);
+ }
function createIdentifier(isIdentifier) {
identifierCount++;
if (isIdentifier) {
var node = createNode(55 /* Identifier */);
var text = escapeIdentifier(scanner.getTokenValue());
- node.text = ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text);
+ node.text = internIdentifier(text);
nextToken();
return finishNode(node);
}
@@ -2882,24 +2958,10 @@ var ts;
}
function parsePropertyName() {
if (token === 3 /* StringLiteral */ || token === 2 /* NumericLiteral */) {
- return parsePrimaryExpression();
+ return parseLiteralNode(true);
}
return parseIdentifierName();
}
- function isKeyword(token) {
- return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword;
- }
- function isModifier(token) {
- switch (token) {
- case 98 /* PublicKeyword */:
- case 96 /* PrivateKeyword */:
- case 99 /* StaticKeyword */:
- case 68 /* ExportKeyword */:
- case 104 /* DeclareKeyword */:
- return true;
- }
- return false;
- }
function parseContextualModifier(t) {
return token === t && tryParse(function () {
nextToken();
@@ -3114,9 +3176,10 @@ var ts;
nextToken();
return finishNode(node);
}
- function parseLiteralNode() {
+ function parseLiteralNode(internName) {
var node = createNode(token);
- node.text = scanner.getTokenValue();
+ var text = scanner.getTokenValue();
+ node.text = internName ? internIdentifier(text) : text;
var tokenPos = scanner.getTokenPos();
nextToken();
finishNode(node);
@@ -3132,7 +3195,7 @@ var ts;
}
function parseStringLiteral() {
if (token === 3 /* StringLiteral */)
- return parseLiteralNode();
+ return parseLiteralNode(true);
error(ts.Diagnostics.String_literal_expected);
return createMissingNode();
}
@@ -3804,6 +3867,10 @@ var ts;
}
else {
indexedAccess.index = parseExpression();
+ if (indexedAccess.index.kind === 3 /* StringLiteral */ || indexedAccess.index.kind === 2 /* NumericLiteral */) {
+ var literal = indexedAccess.index;
+ literal.text = internIdentifier(literal.text);
+ }
parseExpected(10 /* CloseBracketToken */);
}
expr = finishNode(indexedAccess);
@@ -4478,10 +4545,11 @@ var ts;
parseExpected(88 /* VarKeyword */);
node.declarations = parseVariableDeclarationList(flags, false);
parseSemicolon();
+ finishNode(node);
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
grammarErrorOnNode(node, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
}
- return finishNode(node);
+ return node;
}
function parseFunctionDeclaration(pos, flags) {
var node = createNode(167 /* FunctionDeclaration */, pos);
@@ -5109,6 +5177,7 @@ var ts;
file.version = version;
file.isOpen = isOpen;
file.languageVersion = languageVersion;
+ file.identifiers = identifiers;
return file;
}
ts.createSourceFile = createSourceFile;
@@ -5173,18 +5242,17 @@ var ts;
}
function findSourceFile(filename, isDefaultLib, refFile, refStart, refLength) {
var canonicalName = host.getCanonicalFileName(filename);
- var file = getSourceFile(filename);
- if (file) {
- if (host.useCaseSensitiveFileNames() && canonicalName !== file.filename) {
+ if (ts.hasProperty(filesByName, canonicalName)) {
+ var file = filesByName[canonicalName];
+ if (file && host.useCaseSensitiveFileNames() && canonicalName !== file.filename) {
errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, file.filename));
}
}
else {
- file = host.getSourceFile(filename, options.target, function (hostErrorMessage) {
+ var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, function (hostErrorMessage) {
errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
});
if (file) {
- filesByName[host.getCanonicalFileName(filename)] = file;
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
if (!options.noResolve) {
var basePath = ts.getDirectoryPath(filename);
@@ -5709,18 +5777,10 @@ var ts;
function writeLiteral(s) {
if (s && s.length) {
write(s);
- var pos = 0;
- while (pos < s.length) {
- switch (s.charCodeAt(pos++)) {
- case 13 /* carriageReturn */:
- if (pos < s.length && s.charCodeAt(pos) === 10 /* lineFeed */) {
- pos++;
- }
- case 10 /* lineFeed */:
- lineCount++;
- linePos = output.length - s.length + pos;
- break;
- }
+ var lineStartsOfS = ts.getLineStarts(s);
+ if (lineStartsOfS.length > 1) {
+ lineCount = lineCount + lineStartsOfS.length - 1;
+ linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
}
}
}
@@ -5831,10 +5891,9 @@ var ts;
}
function calculateIndent(pos, end) {
var currentLineIndent = 0;
- while (pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos))) {
- pos++;
+ for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) {
- currentLineIndent += getIndentSize();
+ currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
}
else {
currentLineIndent++;
@@ -7080,14 +7139,12 @@ var ts;
return emitPinnedOrTripleSlashComments(node);
}
emitLeadingComments(node);
- if (!(node.flags & 1 /* Export */)) {
- emitStart(node);
- write("var ");
- emit(node.name);
- write(";");
- emitEnd(node);
- writeLine();
- }
+ emitStart(node);
+ write("var ");
+ emit(node.name);
+ write(";");
+ emitEnd(node);
+ writeLine();
emitStart(node);
write("(function (");
emitStart(node.name);
@@ -7111,21 +7168,15 @@ var ts;
scopeEmitEnd();
}
write(")(");
+ if (node.flags & 1 /* Export */) {
+ emit(node.name);
+ write(" = ");
+ }
emitModuleMemberName(node);
write(" || (");
emitModuleMemberName(node);
write(" = {}));");
emitEnd(node);
- if (node.flags & 1 /* Export */) {
- writeLine();
- emitStart(node);
- write("var ");
- emit(node.name);
- write(" = ");
- emitModuleMemberName(node);
- emitEnd(node);
- write(";");
- }
emitTrailingComments(node);
}
function emitImportDeclaration(node) {
@@ -8132,39 +8183,43 @@ var ts;
}
}
function resolveScriptReference(sourceFile, reference) {
- var referenceFileName = compilerOptions.noResolve ? reference.filename : ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename));
+ var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename));
return program.getSourceFile(referenceFileName);
}
var referencePathsOutput = "";
function writeReferencePath(referencedFile) {
var declFileName = referencedFile.flags & 512 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile) ? getOwnEmitOutputFilePath(referencedFile, ".d.ts") : ts.getModuleNameFromFilename(compilerOptions.out) + ".d.ts";
declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), false);
- referencePathsOutput += "/// " + newLine;
+ referencePathsOutput += "/// " + newLine;
}
if (root) {
- var addedGlobalFileReference = false;
- ts.forEach(root.referencedFiles, function (fileReference) {
- var referencedFile = resolveScriptReference(root, fileReference);
- if ((referencedFile.flags & 512 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile) || !addedGlobalFileReference) {
- writeReferencePath(referencedFile);
- if (!isExternalModuleOrDeclarationFile(referencedFile)) {
- addedGlobalFileReference = true;
+ if (!compilerOptions.noResolve) {
+ var addedGlobalFileReference = false;
+ ts.forEach(root.referencedFiles, function (fileReference) {
+ var referencedFile = resolveScriptReference(root, fileReference);
+ if ((referencedFile.flags & 512 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile) || !addedGlobalFileReference) {
+ writeReferencePath(referencedFile);
+ if (!isExternalModuleOrDeclarationFile(referencedFile)) {
+ addedGlobalFileReference = true;
+ }
}
- }
- });
+ });
+ }
emitNode(root);
}
else {
var emittedReferencedFiles = [];
ts.forEach(program.getSourceFiles(), function (sourceFile) {
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
- ts.forEach(sourceFile.referencedFiles, function (fileReference) {
- var referencedFile = resolveScriptReference(sourceFile, fileReference);
- if (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile)) {
- writeReferencePath(referencedFile);
- emittedReferencedFiles.push(referencedFile);
- }
- });
+ if (!compilerOptions.noResolve) {
+ ts.forEach(sourceFile.referencedFiles, function (fileReference) {
+ var referencedFile = resolveScriptReference(sourceFile, fileReference);
+ if (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile)) {
+ writeReferencePath(referencedFile);
+ emittedReferencedFiles.push(referencedFile);
+ }
+ });
+ }
emitNode(sourceFile);
}
});
@@ -8214,6 +8269,17 @@ var ts;
var nextSymbolId = 1;
var nextNodeId = 1;
var nextMergeId = 1;
+ function getDeclarationOfKind(symbol, kind) {
+ var declarations = symbol.declarations;
+ for (var i = 0; i < declarations.length; i++) {
+ var declaration = declarations[i];
+ if (declaration.kind === kind) {
+ return declaration;
+ }
+ }
+ return undefined;
+ }
+ ts.getDeclarationOfKind = getDeclarationOfKind;
function createTypeChecker(program, fullTypeCheck) {
var Symbol = ts.objectAllocator.getSymbolConstructor();
var Type = ts.objectAllocator.getTypeConstructor();
@@ -8221,6 +8287,7 @@ var ts;
var typeCount = 0;
var emptyArray = [];
var emptySymbols = {};
+ var compilerOptions = program.getCompilerOptions();
var checker = {
getProgram: function () { return program; },
getDiagnostics: getDiagnostics,
@@ -8244,7 +8311,9 @@ var ts;
getApparentType: getApparentType,
typeToString: typeToString,
symbolToString: symbolToString,
- getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType
+ getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType,
+ getRootSymbol: getRootSymbol,
+ getContextualType: getContextualType
};
var undefinedSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "undefined");
var argumentsSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "arguments");
@@ -8692,16 +8761,6 @@ var ts;
}
return false;
}
- function getDeclarationOfKind(symbol, kind) {
- var declarations = symbol.declarations;
- for (var i = 0; i < declarations.length; i++) {
- var declaration = declarations[i];
- if (declaration.kind === kind) {
- return declaration;
- }
- }
- return undefined;
- }
function findConstructorDeclaration(node) {
var members = node.members;
for (var i = 0; i < members.length; i++) {
@@ -8939,7 +8998,7 @@ var ts;
}
return symbol.name;
}
- if (enclosingDeclaration && !(symbol.flags & (ts.SymbolFlags.PropertyOrAccessor | ts.SymbolFlags.Signature | 4096 /* Constructor */ | 2048 /* Method */ | 262144 /* TypeParameter */))) {
+ if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) {
var symbolName;
while (symbol) {
var isFirstName = !symbolName;
@@ -8968,17 +9027,25 @@ var ts;
function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) {
writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
}
- function createSingleLineTextWriter() {
+ function createSingleLineTextWriter(maxLength) {
var result = "";
- return {
- write: function (s) {
+ var overflow = false;
+ function write(s) {
+ if (!overflow) {
result += s;
- },
+ if (result.length > maxLength) {
+ result = result.substr(0, maxLength - 3) + "...";
+ overflow = true;
+ }
+ }
+ }
+ return {
+ write: write,
writeSymbol: function (symbol, enclosingDeclaration, meaning) {
writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
},
writeLine: function () {
- result += " ";
+ write(" ");
},
increaseIndent: function () {
},
@@ -8990,7 +9057,8 @@ var ts;
};
}
function typeToString(type, enclosingDeclaration, flags) {
- var stringWriter = createSingleLineTextWriter();
+ var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100;
+ var stringWriter = createSingleLineTextWriter(maxLength);
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
return stringWriter.getText();
}
@@ -9320,7 +9388,7 @@ var ts;
checkImplicitAny(type);
return type;
function checkImplicitAny(type) {
- if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) {
+ if (!fullTypeCheck || !compilerOptions.noImplicitAny) {
return;
}
if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) {
@@ -9404,7 +9472,7 @@ var ts;
type = getReturnTypeFromBody(getter);
}
else {
- if (program.getCompilerOptions().noImplicitAny) {
+ if (compilerOptions.noImplicitAny) {
error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
}
type = anyType;
@@ -9722,27 +9790,38 @@ var ts;
}
function resolveAnonymousTypeMembers(type) {
var symbol = type.symbol;
- var members = emptySymbols;
- var callSignatures = emptyArray;
- var constructSignatures = emptyArray;
- if (symbol.flags & ts.SymbolFlags.HasExports) {
- members = symbol.exports;
+ if (symbol.flags & 512 /* TypeLiteral */) {
+ var members = symbol.members;
+ var callSignatures = getSignaturesOfSymbol(members["__call"]);
+ var constructSignatures = getSignaturesOfSymbol(members["__new"]);
+ var stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */);
+ var numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */);
}
- if (symbol.flags & (8 /* Function */ | 2048 /* Method */)) {
- callSignatures = getSignaturesOfSymbol(symbol);
- }
- if (symbol.flags & 16 /* Class */) {
- var classType = getDeclaredTypeOfClass(symbol);
- constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]);
- if (!constructSignatures.length)
- constructSignatures = getDefaultConstructSignatures(classType);
- if (classType.baseTypes.length) {
- var members = createSymbolTable(getNamedMembers(members));
- addInheritedMembers(members, getPropertiesOfType(getTypeOfSymbol(classType.baseTypes[0].symbol)));
+ else {
+ var members = emptySymbols;
+ var callSignatures = emptyArray;
+ var constructSignatures = emptyArray;
+ if (symbol.flags & ts.SymbolFlags.HasExports) {
+ members = symbol.exports;
}
+ if (symbol.flags & (8 /* Function */ | 2048 /* Method */)) {
+ callSignatures = getSignaturesOfSymbol(symbol);
+ }
+ if (symbol.flags & 16 /* Class */) {
+ var classType = getDeclaredTypeOfClass(symbol);
+ constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]);
+ if (!constructSignatures.length) {
+ constructSignatures = getDefaultConstructSignatures(classType);
+ }
+ if (classType.baseTypes.length) {
+ members = createSymbolTable(getNamedMembers(members));
+ addInheritedMembers(members, getPropertiesOfType(getTypeOfSymbol(classType.baseTypes[0].symbol)));
+ }
+ }
+ var stringIndexType = undefined;
+ var numberIndexType = (symbol.flags & 64 /* Enum */) ? stringType : undefined;
}
- var numberIndexType = (symbol.flags & 64 /* Enum */) ? stringType : undefined;
- setObjectTypeMembers(type, members, callSignatures, constructSignatures, undefined, numberIndexType);
+ setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
}
function resolveObjectTypeMembers(type) {
if (!type.members) {
@@ -10124,13 +10203,7 @@ var ts;
function getTypeFromTypeLiteralNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- var symbol = node.symbol;
- var members = symbol.members;
- var callSignatures = getSignaturesOfSymbol(members["__call"]);
- var constructSignatures = getSignaturesOfSymbol(members["__new"]);
- var stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */);
- var numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */);
- links.resolvedType = createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
+ links.resolvedType = createObjectType(8192 /* Anonymous */, node.symbol);
}
return links.resolvedType;
}
@@ -10859,45 +10932,6 @@ var ts;
function isTypeOfObjectLiteral(type) {
return (type.flags & 8192 /* Anonymous */) && type.symbol && (type.symbol.flags & 1024 /* ObjectLiteral */) ? true : false;
}
- function getWidenedTypeOfObjectLiteral(type) {
- var properties = getPropertiesOfType(type);
- if (properties.length) {
- var widenedTypes = [];
- var propTypeWasWidened = false;
- ts.forEach(properties, function (p) {
- var propType = getTypeOfSymbol(p);
- var widenedType = getWidenedType(propType);
- if (propType !== widenedType) {
- propTypeWasWidened = true;
- if (program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
- error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
- }
- }
- widenedTypes.push(widenedType);
- });
- if (propTypeWasWidened) {
- var members = {};
- var index = 0;
- ts.forEach(properties, function (p) {
- var symbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, p.name);
- symbol.declarations = p.declarations;
- symbol.parent = p.parent;
- symbol.type = widenedTypes[index++];
- if (p.valueDeclaration)
- symbol.valueDeclaration = p.valueDeclaration;
- members[symbol.name] = symbol;
- });
- var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
- var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
- if (stringIndexType)
- stringIndexType = getWidenedType(stringIndexType);
- if (numberIndexType)
- numberIndexType = getWidenedType(numberIndexType);
- type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
- }
- }
- return type;
- }
function isArrayType(type) {
return type.flags & 4096 /* Reference */ && type.target === globalArrayType;
}
@@ -10907,13 +10941,7 @@ var ts;
}
return type;
}
- function getWidenedTypeOfArrayLiteral(type) {
- var elementType = type.typeArguments[0];
- var widenedType = getWidenedType(elementType);
- type = elementType !== widenedType ? createArrayType(widenedType) : type;
- return type;
- }
- function getWidenedType(type) {
+ function getWidenedType(type, supressNoImplicitAnyErrors) {
if (type.flags & (32 /* Undefined */ | 64 /* Null */)) {
return anyType;
}
@@ -10924,6 +10952,52 @@ var ts;
return getWidenedTypeOfArrayLiteral(type);
}
return type;
+ function getWidenedTypeOfObjectLiteral(type) {
+ var properties = getPropertiesOfType(type);
+ if (properties.length) {
+ var widenedTypes = [];
+ var propTypeWasWidened = false;
+ ts.forEach(properties, function (p) {
+ var propType = getTypeOfSymbol(p);
+ var widenedType = getWidenedType(propType);
+ if (propType !== widenedType) {
+ propTypeWasWidened = true;
+ if (!supressNoImplicitAnyErrors && program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
+ }
+ }
+ widenedTypes.push(widenedType);
+ });
+ if (propTypeWasWidened) {
+ var members = {};
+ var index = 0;
+ ts.forEach(properties, function (p) {
+ var symbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, p.name);
+ symbol.declarations = p.declarations;
+ symbol.parent = p.parent;
+ symbol.type = widenedTypes[index++];
+ symbol.target = p;
+ if (p.valueDeclaration)
+ symbol.valueDeclaration = p.valueDeclaration;
+ members[symbol.name] = symbol;
+ });
+ var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
+ var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
+ if (stringIndexType)
+ stringIndexType = getWidenedType(stringIndexType);
+ if (numberIndexType)
+ numberIndexType = getWidenedType(numberIndexType);
+ type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
+ }
+ }
+ return type;
+ }
+ function getWidenedTypeOfArrayLiteral(type) {
+ var elementType = type.typeArguments[0];
+ var widenedType = getWidenedType(elementType, supressNoImplicitAnyErrors);
+ type = elementType !== widenedType ? createArrayType(widenedType) : type;
+ return type;
+ }
}
function forEachMatchingParameterType(source, target, callback) {
var sourceMax = source.parameters.length;
@@ -11457,6 +11531,7 @@ var ts;
if (member.valueDeclaration)
prop.valueDeclaration = member.valueDeclaration;
prop.type = type;
+ prop.target = member;
member = prop;
}
else {
@@ -11559,7 +11634,7 @@ var ts;
if (stringIndexType) {
return stringIndexType;
}
- if (program.getCompilerOptions().noImplicitAny && objectType !== anyType) {
+ if (compilerOptions.noImplicitAny && objectType !== anyType) {
error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
}
return anyType;
@@ -11630,17 +11705,6 @@ var ts;
});
return getSignatureInstantiation(signature, getInferredTypes(context));
}
- function inferentiallyTypeExpession(expr, contextualType, contextualMapper) {
- var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
- var signature = getSingleCallSignature(type);
- if (signature && signature.typeParameters) {
- var contextualSignature = getSingleCallSignature(contextualType);
- if (contextualSignature && !contextualSignature.typeParameters) {
- type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
- }
- }
- return type;
- }
function inferTypeArguments(signature, args, excludeArgument) {
var typeParameters = signature.typeParameters;
var context = createInferenceContext(typeParameters);
@@ -11648,14 +11712,14 @@ var ts;
for (var i = 0; i < args.length; i++) {
if (!excludeArgument || excludeArgument[i] === undefined) {
var parameterType = getTypeAtPosition(signature, i);
- inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
+ inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
if (excludeArgument) {
for (var i = 0; i < args.length; i++) {
if (excludeArgument[i] === false) {
var parameterType = getTypeAtPosition(signature, i);
- inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
+ inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
}
@@ -11813,7 +11877,7 @@ var ts;
if (node.kind === 133 /* NewExpression */) {
var declaration = signature.declaration;
if (declaration && (declaration.kind !== 117 /* Constructor */ && declaration.kind !== 121 /* ConstructSignature */)) {
- if (program.getCompilerOptions().noImplicitAny) {
+ if (compilerOptions.noImplicitAny) {
error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
}
return anyType;
@@ -11825,9 +11889,9 @@ var ts;
var exprType = checkExpression(node.operand);
var targetType = getTypeFromTypeNode(node.type);
if (fullTypeCheck && targetType !== unknownType) {
- var widenedType = getWidenedType(exprType);
- if (!(isTypeAssignableTo(exprType, targetType) || isTypeAssignableTo(targetType, widenedType))) {
- checkTypeAssignableTo(targetType, widenedType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
+ var widenedType = getWidenedType(exprType, true);
+ if (!(isTypeAssignableTo(targetType, widenedType))) {
+ checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
}
}
return targetType;
@@ -11852,7 +11916,7 @@ var ts;
if (func.body.kind !== 168 /* FunctionBlock */) {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
return widenedType;
@@ -11865,7 +11929,7 @@ var ts;
return unknownType;
}
var widenedType = getWidenedType(commonType);
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
var typeName = typeToString(widenedType);
if (func.name) {
error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.identifierToString(func.name), typeName);
@@ -11967,26 +12031,26 @@ var ts;
}
}
}
+ checkSignatureDeclaration(node);
}
}
- if (fullTypeCheck && !(links.flags & 1 /* TypeChecked */)) {
- checkSignatureDeclaration(node);
- if (node.type) {
- checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
- }
- if (node.body.kind === 168 /* FunctionBlock */) {
- checkSourceElement(node.body);
- }
- else {
- var exprType = checkExpression(node.body);
- if (node.type) {
- checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined, undefined);
- }
- }
- links.flags |= 1 /* TypeChecked */;
- }
return type;
}
+ function checkFunctionExpressionBody(node) {
+ if (node.type) {
+ checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
+ }
+ if (node.body.kind === 168 /* FunctionBlock */) {
+ checkSourceElement(node.body);
+ }
+ else {
+ var exprType = checkExpression(node.body);
+ if (node.type) {
+ checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined, undefined);
+ }
+ checkFunctionExpressionBodies(node.body);
+ }
+ }
function checkArithmeticOperandType(operand, type, diagnostic) {
if (!(type.flags & (1 /* Any */ | ts.TypeFlags.NumberLike))) {
error(operand, diagnostic);
@@ -12201,6 +12265,22 @@ var ts;
return result;
}
function checkExpression(node, contextualMapper) {
+ var type = checkExpressionNode(node, contextualMapper);
+ if (contextualMapper && contextualMapper !== identityMapper) {
+ var signature = getSingleCallSignature(type);
+ if (signature && signature.typeParameters) {
+ var contextualType = getContextualType(node);
+ if (contextualType) {
+ var contextualSignature = getSingleCallSignature(contextualType);
+ if (contextualSignature && !contextualSignature.typeParameters) {
+ type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
+ }
+ }
+ }
+ }
+ return type;
+ }
+ function checkExpressionNode(node, contextualMapper) {
switch (node.kind) {
case 55 /* Identifier */:
return checkIdentifier(node);
@@ -12309,8 +12389,9 @@ var ts;
if (fullTypeCheck) {
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
- if (program.getCompilerOptions().noImplicitAny && !node.type) {
+ if (compilerOptions.noImplicitAny && !node.type) {
switch (node.kind) {
case 121 /* ConstructSignature */:
error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -12721,7 +12802,7 @@ var ts;
if (node.type && !isAccessor(node.kind)) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) {
if (!isPrivateWithinAmbient(node)) {
var typeName = typeToString(anyType);
if (node.name) {
@@ -12836,6 +12917,18 @@ var ts;
}
}
}
+ function checkCollistionWithRequireExportsInGeneratedCode(node, name) {
+ if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
+ return;
+ }
+ if (node.kind === 172 /* ModuleDeclaration */ && !ts.isInstantiated(node)) {
+ return;
+ }
+ var parent = node.kind === 166 /* VariableDeclaration */ ? node.parent.parent : node.parent;
+ if (parent.kind === 177 /* SourceFile */ && ts.isExternalModule(parent)) {
+ error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, name.text, name.text);
+ }
+ }
function checkVariableDeclaration(node) {
checkSourceElement(node.type);
checkExportsOnMergedDeclarations(node);
@@ -12857,6 +12950,7 @@ var ts;
}
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
if (!useTypeFromValueDeclaration) {
if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) {
error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.identifierToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type));
@@ -13055,6 +13149,7 @@ var ts;
checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
checkTypeParameters(node.typeParameters);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
var type = getDeclaredTypeOfSymbol(symbol);
@@ -13222,6 +13317,7 @@ var ts;
}
checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkExportsOnMergedDeclarations(node);
var enumSymbol = getSymbolOfNode(node);
var enumType = getDeclaredTypeOfSymbol(enumSymbol);
@@ -13278,6 +13374,7 @@ var ts;
function checkModuleDeclaration(node) {
if (fullTypeCheck) {
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
if (symbol.flags & 128 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) {
@@ -13310,6 +13407,7 @@ var ts;
}
function checkImportDeclaration(node) {
checkCollisionWithCapturedThisVariable(node, node.name);
+ checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
var symbol = getSymbolOfNode(node);
var target;
if (node.entityName) {
@@ -13392,9 +13490,10 @@ var ts;
case 167 /* FunctionDeclaration */:
return checkFunctionDeclaration(node);
case 143 /* Block */:
+ return checkBlock(node);
case 168 /* FunctionBlock */:
case 173 /* ModuleBlock */:
- return checkBlock(node);
+ return checkBody(node);
case 144 /* VariableStatement */:
return checkVariableStatement(node);
case 146 /* ExpressionStatement */:
@@ -13440,12 +13539,79 @@ var ts;
return checkExportAssignment(node);
}
}
+ function checkFunctionExpressionBodies(node) {
+ switch (node.kind) {
+ case 136 /* FunctionExpression */:
+ case 137 /* ArrowFunction */:
+ ts.forEach(node.parameters, checkFunctionExpressionBodies);
+ checkFunctionExpressionBody(node);
+ break;
+ case 116 /* Method */:
+ case 117 /* Constructor */:
+ case 118 /* GetAccessor */:
+ case 119 /* SetAccessor */:
+ case 167 /* FunctionDeclaration */:
+ ts.forEach(node.parameters, checkFunctionExpressionBodies);
+ break;
+ case 155 /* WithStatement */:
+ checkFunctionExpressionBodies(node.expression);
+ break;
+ case 114 /* Parameter */:
+ case 115 /* Property */:
+ case 127 /* ArrayLiteral */:
+ case 128 /* ObjectLiteral */:
+ case 129 /* PropertyAssignment */:
+ case 130 /* PropertyAccess */:
+ case 131 /* IndexedAccess */:
+ case 132 /* CallExpression */:
+ case 133 /* NewExpression */:
+ case 134 /* TypeAssertion */:
+ case 135 /* ParenExpression */:
+ case 138 /* PrefixOperator */:
+ case 139 /* PostfixOperator */:
+ case 140 /* BinaryExpression */:
+ case 141 /* ConditionalExpression */:
+ case 143 /* Block */:
+ case 168 /* FunctionBlock */:
+ case 173 /* ModuleBlock */:
+ case 144 /* VariableStatement */:
+ case 146 /* ExpressionStatement */:
+ case 147 /* IfStatement */:
+ case 148 /* DoStatement */:
+ case 149 /* WhileStatement */:
+ case 150 /* ForStatement */:
+ case 151 /* ForInStatement */:
+ case 152 /* ContinueStatement */:
+ case 153 /* BreakStatement */:
+ case 154 /* ReturnStatement */:
+ case 156 /* SwitchStatement */:
+ case 157 /* CaseClause */:
+ case 158 /* DefaultClause */:
+ case 159 /* LabelledStatement */:
+ case 160 /* ThrowStatement */:
+ case 161 /* TryStatement */:
+ case 162 /* TryBlock */:
+ case 163 /* CatchBlock */:
+ case 164 /* FinallyBlock */:
+ case 166 /* VariableDeclaration */:
+ case 169 /* ClassDeclaration */:
+ case 171 /* EnumDeclaration */:
+ case 176 /* EnumMember */:
+ case 177 /* SourceFile */:
+ ts.forEachChild(node, checkFunctionExpressionBodies);
+ break;
+ }
+ }
+ function checkBody(node) {
+ checkBlock(node);
+ checkFunctionExpressionBodies(node);
+ }
function checkSourceFile(node) {
var links = getNodeLinks(node);
if (!(links.flags & 1 /* TypeChecked */)) {
emitExtends = false;
potentialThisCollisions.length = 0;
- ts.forEach(node.statements, checkSourceElement);
+ checkBody(node);
if (ts.isExternalModule(node)) {
var symbol = getExportAssignmentSymbol(node.symbol);
if (symbol && symbol.flags & 4194304 /* Import */) {
@@ -13559,19 +13725,6 @@ var ts;
function isTypeDeclarationName(name) {
return name.kind == 55 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name;
}
- function isDeclarationOrFunctionExpressionOrCatchVariableName(name) {
- if (name.kind !== 55 /* Identifier */ && name.kind !== 3 /* StringLiteral */ && name.kind !== 2 /* NumericLiteral */) {
- return false;
- }
- var parent = name.parent;
- if (isDeclaration(parent) || parent.kind === 136 /* FunctionExpression */) {
- return parent.name === name;
- }
- if (parent.kind === 163 /* CatchBlock */) {
- return parent.variable === name;
- }
- return false;
- }
function isTypeDeclaration(node) {
switch (node.kind) {
case 113 /* TypeParameter */:
@@ -13581,27 +13734,6 @@ var ts;
return true;
}
}
- function isDeclaration(node) {
- switch (node.kind) {
- case 113 /* TypeParameter */:
- case 114 /* Parameter */:
- case 166 /* VariableDeclaration */:
- case 115 /* Property */:
- case 129 /* PropertyAssignment */:
- case 176 /* EnumMember */:
- case 116 /* Method */:
- case 167 /* FunctionDeclaration */:
- case 118 /* GetAccessor */:
- case 119 /* SetAccessor */:
- case 169 /* ClassDeclaration */:
- case 170 /* InterfaceDeclaration */:
- case 171 /* EnumDeclaration */:
- case 172 /* ModuleDeclaration */:
- case 174 /* ImportDeclaration */:
- return true;
- }
- return false;
- }
function isTypeReferenceIdentifier(entityName) {
var node = entityName;
while (node.parent && node.parent.kind === 112 /* QualifiedName */)
@@ -13745,7 +13877,7 @@ var ts;
return (node.parent.kind === 112 /* QualifiedName */ || node.parent.kind === 130 /* PropertyAccess */) && node.parent.right === node;
}
function getSymbolOfEntityName(entityName) {
- if (isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
+ if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
return getSymbolOfNode(entityName.parent);
}
if (entityName.parent.kind === 175 /* ExportAssignment */) {
@@ -13781,6 +13913,12 @@ var ts;
return undefined;
}
function getSymbolInfo(node) {
+ if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
+ return getSymbolOfNode(node.parent);
+ }
+ if (node.kind === 55 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) {
+ return node.parent.kind === 175 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node);
+ }
switch (node.kind) {
case 55 /* Identifier */:
case 130 /* PropertyAccess */:
@@ -13797,7 +13935,13 @@ var ts;
}
return undefined;
case 3 /* StringLiteral */:
- if (node.parent.kind === 131 /* IndexedAccess */ && node.parent.index === node) {
+ if (node.parent.kind === 174 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
+ var importSymbol = getSymbolOfNode(node.parent);
+ var moduleType = getTypeOfSymbol(importSymbol);
+ return moduleType ? moduleType.symbol : undefined;
+ }
+ case 2 /* NumericLiteral */:
+ if (node.parent.kind == 131 /* IndexedAccess */ && node.parent.index === node) {
var objectType = checkExpression(node.parent.object);
if (objectType === unknownType)
return undefined;
@@ -13806,14 +13950,6 @@ var ts;
return undefined;
return getPropertyOfApparentType(apparentType, node.text);
}
- else if (node.parent.kind === 174 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
- var importSymbol = getSymbolOfNode(node.parent);
- var moduleType = getTypeOfSymbol(importSymbol);
- return moduleType ? moduleType.symbol : undefined;
- }
- else if (node.parent.kind === 172 /* ModuleDeclaration */) {
- return getSymbolOfNode(node.parent);
- }
break;
}
return undefined;
@@ -13833,11 +13969,11 @@ var ts;
var symbol = getSymbolInfo(node);
return getDeclaredTypeOfSymbol(symbol);
}
- if (isDeclaration(node)) {
+ if (ts.isDeclaration(node)) {
var symbol = getSymbolOfNode(node);
return getTypeOfSymbol(symbol);
}
- if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
+ if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
var symbol = getSymbolInfo(node);
return getTypeOfSymbol(symbol);
}
@@ -13884,6 +14020,9 @@ var ts;
return getPropertiesOfType(apparentType);
}
}
+ function getRootSymbol(symbol) {
+ return (symbol.flags & 33554432 /* Transient */) ? getSymbolLinks(symbol).target : symbol;
+ }
function isExternalModuleSymbol(symbol) {
return symbol.flags & 128 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 177 /* SourceFile */;
}
@@ -13960,7 +14099,7 @@ var ts;
return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0);
}
function shouldEmitDeclarations() {
- return program.getCompilerOptions().declaration && !program.getDiagnostics().length && !getDiagnostics().length;
+ return compilerOptions.declaration && !program.getDiagnostics().length && !getDiagnostics().length;
}
function isReferencedImportDeclaration(node) {
var symbol = getSymbolOfNode(node);
@@ -15321,73 +15460,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
- var Hash = (function () {
- function Hash() {
- }
- Hash.computeFnv1aCharArrayHashCode = function (text, start, len) {
- var hashCode = Hash.FNV_BASE;
- var end = start + len;
- for (var i = start; i < end; i++) {
- hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME);
- }
- return hashCode;
- };
- Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) {
- var hash = 0;
- for (var i = 0; i < len; i++) {
- var ch = key[start + i];
- hash = ((((hash << 5) - hash) | 0) + ch) | 0;
- }
- return hash & 0x7FFFFFFF;
- };
- Hash.computeSimple31BitStringHashCode = function (key) {
- var hash = 0;
- var start = 0;
- var len = key.length;
- for (var i = 0; i < len; i++) {
- var ch = key.charCodeAt(start + i);
- hash = ((((hash << 5) - hash) | 0) + ch) | 0;
- }
- return hash & 0x7FFFFFFF;
- };
- Hash.computeMurmur2StringHashCode = function (key, seed) {
- var m = 0x5bd1e995;
- var r = 24;
- var numberOfCharsLeft = key.length;
- var h = Math.abs(seed ^ numberOfCharsLeft);
- var index = 0;
- while (numberOfCharsLeft >= 2) {
- var c1 = key.charCodeAt(index);
- var c2 = key.charCodeAt(index + 1);
- var k = Math.abs(c1 | (c2 << 16));
- k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m);
- k ^= k >> r;
- k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m);
- h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m);
- h ^= k;
- index += 2;
- numberOfCharsLeft -= 2;
- }
- if (numberOfCharsLeft === 1) {
- h ^= key.charCodeAt(index);
- h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m);
- }
- h ^= h >> 13;
- h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m);
- h ^= h >> 15;
- return h;
- };
- Hash.combine = function (value, currentHash) {
- return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF;
- };
- Hash.FNV_BASE = 2166136261;
- Hash.FNV_PRIME = 16777619;
- return Hash;
- })();
- TypeScript.Hash = Hash;
-})(TypeScript || (TypeScript = {}));
-var TypeScript;
-(function (TypeScript) {
+ var IntegerUtilities;
(function (IntegerUtilities) {
function integerDivide(numerator, denominator) {
return (numerator / denominator) >> 0;
@@ -15410,8 +15483,7 @@ var TypeScript;
return /^0(x|X)[0-9a-fA-F]+$/.test(text);
}
IntegerUtilities.isHexInteger = isHexInteger;
- })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {}));
- var IntegerUtilities = TypeScript.IntegerUtilities;
+ })(IntegerUtilities = TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -15649,6 +15721,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var ScriptSnapshot;
(function (ScriptSnapshot) {
var StringScriptSnapshot = (function () {
function StringScriptSnapshot(text) {
@@ -15676,11 +15749,11 @@ var TypeScript;
return new StringScriptSnapshot(text);
}
ScriptSnapshot.fromString = fromString;
- })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {}));
- var ScriptSnapshot = TypeScript.ScriptSnapshot;
+ })(ScriptSnapshot = TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var LineMap1;
(function (LineMap1) {
function fromSimpleText(text) {
return new TypeScript.LineMap(function () { return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { return text.charCodeAt(index); }, length: text.length() }); }, text.length());
@@ -15694,11 +15767,11 @@ var TypeScript;
return new TypeScript.LineMap(function () { return TypeScript.TextUtilities.parseLineStarts(text); }, text.length);
}
LineMap1.fromString = fromString;
- })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {}));
- var LineMap1 = TypeScript.LineMap1;
+ })(LineMap1 = TypeScript.LineMap1 || (TypeScript.LineMap1 = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var SimpleText;
(function (SimpleText) {
var SimpleStringText = (function () {
function SimpleStringText(value) {
@@ -15753,11 +15826,11 @@ var TypeScript;
return new SimpleScriptSnapshotText(scriptSnapshot);
}
SimpleText.fromScriptSnapshot = fromScriptSnapshot;
- })(TypeScript.SimpleText || (TypeScript.SimpleText = {}));
- var SimpleText = TypeScript.SimpleText;
+ })(SimpleText = TypeScript.SimpleText || (TypeScript.SimpleText = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var TextUtilities;
(function (TextUtilities) {
function parseLineStarts(text) {
var length = text.length;
@@ -15825,8 +15898,7 @@ var TypeScript;
return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */;
}
TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter;
- })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {}));
- var TextUtilities = TypeScript.TextUtilities;
+ })(TextUtilities = TypeScript.TextUtilities || (TypeScript.TextUtilities = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -15956,6 +16028,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var CharacterInfo;
(function (CharacterInfo) {
function isDecimalDigit(c) {
return c >= 48 /* _0 */ && c <= 57 /* _9 */;
@@ -16011,8 +16084,7 @@ var TypeScript;
return false;
}
CharacterInfo.isLineTerminator = isLineTerminator;
- })(TypeScript.CharacterInfo || (TypeScript.CharacterInfo = {}));
- var CharacterInfo = TypeScript.CharacterInfo;
+ })(CharacterInfo = TypeScript.CharacterInfo || (TypeScript.CharacterInfo = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -16314,6 +16386,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var SyntaxFacts;
(function (SyntaxFacts) {
var textToKeywordKind = {
"any": 60 /* AnyKeyword */,
@@ -16685,11 +16758,11 @@ var TypeScript;
return false;
}
SyntaxFacts.isType = isType;
- })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {}));
- var SyntaxFacts = TypeScript.SyntaxFacts;
+ })(SyntaxFacts = TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Scanner;
(function (Scanner) {
TypeScript.Debug.assert(TypeScript.SyntaxKind.LastToken <= 127);
var ScannerConstants;
@@ -17919,8 +17992,7 @@ var TypeScript;
};
}
Scanner.createParserSource = createParserSource;
- })(TypeScript.Scanner || (TypeScript.Scanner = {}));
- var Scanner = TypeScript.Scanner;
+ })(Scanner = TypeScript.Scanner || (TypeScript.Scanner = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -18239,6 +18311,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Syntax;
(function (Syntax) {
Syntax._nextSyntaxID = 1;
function childIndex(parent, child) {
@@ -18462,8 +18535,7 @@ var TypeScript;
}
return lineMap.getLineNumberFromPosition(TypeScript.end(_previousToken)) !== lineMap.getLineNumberFromPosition(TypeScript.start(token));
}
- })(TypeScript.Syntax || (TypeScript.Syntax = {}));
- var Syntax = TypeScript.Syntax;
+ })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -18864,6 +18936,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var SyntaxFacts;
(function (SyntaxFacts) {
function isDirectivePrologueElement(node) {
if (node.kind() === 149 /* ExpressionStatement */) {
@@ -18888,11 +18961,11 @@ var TypeScript;
return tokenKind === 11 /* IdentifierName */ || SyntaxFacts.isAnyKeyword(tokenKind);
}
SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword;
- })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {}));
- var SyntaxFacts = TypeScript.SyntaxFacts;
+ })(SyntaxFacts = TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Syntax;
(function (Syntax) {
var _emptyList = [];
var _emptySeparatedList = [];
@@ -18952,8 +19025,7 @@ var TypeScript;
return -1;
}
Syntax.nonSeparatorIndexOf = nonSeparatorIndexOf;
- })(TypeScript.Syntax || (TypeScript.Syntax = {}));
- var Syntax = TypeScript.Syntax;
+ })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -19123,6 +19195,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Syntax;
(function (Syntax) {
function realizeToken(token, text) {
return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text));
@@ -19370,11 +19443,11 @@ var TypeScript;
};
return ConvertedKeywordToken;
})();
- })(TypeScript.Syntax || (TypeScript.Syntax = {}));
- var Syntax = TypeScript.Syntax;
+ })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Syntax;
(function (Syntax) {
var AbstractTrivia = (function () {
function AbstractTrivia(_kind) {
@@ -19497,11 +19570,11 @@ var TypeScript;
return result;
}
Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines;
- })(TypeScript.Syntax || (TypeScript.Syntax = {}));
- var Syntax = TypeScript.Syntax;
+ })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Syntax;
(function (Syntax) {
var EmptyTriviaList = (function () {
function EmptyTriviaList() {
@@ -19674,8 +19747,7 @@ var TypeScript;
return new NormalSyntaxTriviaList(trivia);
}
Syntax.triviaList = triviaList;
- })(TypeScript.Syntax || (TypeScript.Syntax = {}));
- var Syntax = TypeScript.Syntax;
+ })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -20758,6 +20830,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Parser;
(function (Parser) {
Parser.syntaxFactory;
var arrayPool = [];
@@ -21014,14 +21087,20 @@ var TypeScript;
throw TypeScript.Errors.invalidOperation();
}
}
- function replaceTokenInParent(oldToken, newToken) {
+ function replaceTokenInParent(node, oldToken, newToken) {
replaceTokenInParentWorker(oldToken, newToken);
var parent = oldToken.parent;
newToken.parent = parent;
- TypeScript.Debug.assert(TypeScript.isNode(parent) || TypeScript.isList(parent) || TypeScript.isSeparatedList(parent));
- var dataElement = parent;
- if (dataElement.data) {
- dataElement.data &= 4 /* NodeParsedInStrictModeMask */;
+ while (true) {
+ TypeScript.Debug.assert(TypeScript.isNode(parent) || TypeScript.isList(parent) || TypeScript.isSeparatedList(parent));
+ var dataElement = parent;
+ if (dataElement.data) {
+ dataElement.data &= 4 /* NodeParsedInStrictModeMask */;
+ }
+ if (parent === node) {
+ break;
+ }
+ parent = parent.parent;
}
}
function replaceTokenInParentWorker(oldToken, newToken) {
@@ -21063,14 +21142,14 @@ var TypeScript;
function addSkippedTokenAfterNode(node, skippedToken) {
var oldToken = TypeScript.lastToken(node);
var newToken = addSkippedTokenAfterToken(oldToken, skippedToken);
- replaceTokenInParent(oldToken, newToken);
+ replaceTokenInParent(node, oldToken, newToken);
return node;
}
function addSkippedTokensBeforeNode(node, skippedTokens) {
if (skippedTokens.length > 0) {
var oldToken = TypeScript.firstToken(node);
var newToken = addSkippedTokensBeforeToken(oldToken, skippedTokens);
- replaceTokenInParent(oldToken, newToken);
+ replaceTokenInParent(node, oldToken, newToken);
}
return node;
}
@@ -23406,12 +23485,13 @@ var TypeScript;
return parseSyntaxTree(source, isDeclaration);
}
Parser.parseSource = parseSource;
- })(TypeScript.Parser || (TypeScript.Parser = {}));
- var Parser = TypeScript.Parser;
+ })(Parser = TypeScript.Parser || (TypeScript.Parser = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Syntax;
(function (Syntax) {
+ var Concrete;
(function (Concrete) {
TypeScript.Parser.syntaxFactory = Concrete;
Concrete.isConcrete = true;
@@ -24193,10 +24273,8 @@ var TypeScript;
})(TypeScript.SyntaxNode);
Concrete.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax;
SourceUnitSyntax.prototype.__kind = 120 /* SourceUnit */, QualifiedNameSyntax.prototype.__kind = 121 /* QualifiedName */, ObjectTypeSyntax.prototype.__kind = 122 /* ObjectType */, FunctionTypeSyntax.prototype.__kind = 123 /* FunctionType */, ArrayTypeSyntax.prototype.__kind = 124 /* ArrayType */, ConstructorTypeSyntax.prototype.__kind = 125 /* ConstructorType */, GenericTypeSyntax.prototype.__kind = 126 /* GenericType */, TypeQuerySyntax.prototype.__kind = 127 /* TypeQuery */, InterfaceDeclarationSyntax.prototype.__kind = 128 /* InterfaceDeclaration */, FunctionDeclarationSyntax.prototype.__kind = 129 /* FunctionDeclaration */, ModuleDeclarationSyntax.prototype.__kind = 130 /* ModuleDeclaration */, ClassDeclarationSyntax.prototype.__kind = 131 /* ClassDeclaration */, EnumDeclarationSyntax.prototype.__kind = 132 /* EnumDeclaration */, ImportDeclarationSyntax.prototype.__kind = 133 /* ImportDeclaration */, ExportAssignmentSyntax.prototype.__kind = 134 /* ExportAssignment */, MemberFunctionDeclarationSyntax.prototype.__kind = 135 /* MemberFunctionDeclaration */, MemberVariableDeclarationSyntax.prototype.__kind = 136 /* MemberVariableDeclaration */, ConstructorDeclarationSyntax.prototype.__kind = 137 /* ConstructorDeclaration */, IndexMemberDeclarationSyntax.prototype.__kind = 138 /* IndexMemberDeclaration */, GetAccessorSyntax.prototype.__kind = 139 /* GetAccessor */, SetAccessorSyntax.prototype.__kind = 140 /* SetAccessor */, PropertySignatureSyntax.prototype.__kind = 141 /* PropertySignature */, CallSignatureSyntax.prototype.__kind = 142 /* CallSignature */, ConstructSignatureSyntax.prototype.__kind = 143 /* ConstructSignature */, IndexSignatureSyntax.prototype.__kind = 144 /* IndexSignature */, MethodSignatureSyntax.prototype.__kind = 145 /* MethodSignature */, BlockSyntax.prototype.__kind = 146 /* Block */, IfStatementSyntax.prototype.__kind = 147 /* IfStatement */, VariableStatementSyntax.prototype.__kind = 148 /* VariableStatement */, ExpressionStatementSyntax.prototype.__kind = 149 /* ExpressionStatement */, ReturnStatementSyntax.prototype.__kind = 150 /* ReturnStatement */, SwitchStatementSyntax.prototype.__kind = 151 /* SwitchStatement */, BreakStatementSyntax.prototype.__kind = 152 /* BreakStatement */, ContinueStatementSyntax.prototype.__kind = 153 /* ContinueStatement */, ForStatementSyntax.prototype.__kind = 154 /* ForStatement */, ForInStatementSyntax.prototype.__kind = 155 /* ForInStatement */, EmptyStatementSyntax.prototype.__kind = 156 /* EmptyStatement */, ThrowStatementSyntax.prototype.__kind = 157 /* ThrowStatement */, WhileStatementSyntax.prototype.__kind = 158 /* WhileStatement */, TryStatementSyntax.prototype.__kind = 159 /* TryStatement */, LabeledStatementSyntax.prototype.__kind = 160 /* LabeledStatement */, DoStatementSyntax.prototype.__kind = 161 /* DoStatement */, DebuggerStatementSyntax.prototype.__kind = 162 /* DebuggerStatement */, WithStatementSyntax.prototype.__kind = 163 /* WithStatement */, DeleteExpressionSyntax.prototype.__kind = 170 /* DeleteExpression */, TypeOfExpressionSyntax.prototype.__kind = 171 /* TypeOfExpression */, VoidExpressionSyntax.prototype.__kind = 172 /* VoidExpression */, ConditionalExpressionSyntax.prototype.__kind = 186 /* ConditionalExpression */, MemberAccessExpressionSyntax.prototype.__kind = 212 /* MemberAccessExpression */, InvocationExpressionSyntax.prototype.__kind = 213 /* InvocationExpression */, ArrayLiteralExpressionSyntax.prototype.__kind = 214 /* ArrayLiteralExpression */, ObjectLiteralExpressionSyntax.prototype.__kind = 215 /* ObjectLiteralExpression */, ObjectCreationExpressionSyntax.prototype.__kind = 216 /* ObjectCreationExpression */, ParenthesizedExpressionSyntax.prototype.__kind = 217 /* ParenthesizedExpression */, ParenthesizedArrowFunctionExpressionSyntax.prototype.__kind = 218 /* ParenthesizedArrowFunctionExpression */, SimpleArrowFunctionExpressionSyntax.prototype.__kind = 219 /* SimpleArrowFunctionExpression */, CastExpressionSyntax.prototype.__kind = 220 /* CastExpression */, ElementAccessExpressionSyntax.prototype.__kind = 221 /* ElementAccessExpression */, FunctionExpressionSyntax.prototype.__kind = 222 /* FunctionExpression */, OmittedExpressionSyntax.prototype.__kind = 223 /* OmittedExpression */, VariableDeclarationSyntax.prototype.__kind = 224 /* VariableDeclaration */, VariableDeclaratorSyntax.prototype.__kind = 225 /* VariableDeclarator */, ArgumentListSyntax.prototype.__kind = 226 /* ArgumentList */, ParameterListSyntax.prototype.__kind = 227 /* ParameterList */, TypeArgumentListSyntax.prototype.__kind = 228 /* TypeArgumentList */, TypeParameterListSyntax.prototype.__kind = 229 /* TypeParameterList */, EqualsValueClauseSyntax.prototype.__kind = 232 /* EqualsValueClause */, CaseSwitchClauseSyntax.prototype.__kind = 233 /* CaseSwitchClause */, DefaultSwitchClauseSyntax.prototype.__kind = 234 /* DefaultSwitchClause */, ElseClauseSyntax.prototype.__kind = 235 /* ElseClause */, CatchClauseSyntax.prototype.__kind = 236 /* CatchClause */, FinallyClauseSyntax.prototype.__kind = 237 /* FinallyClause */, TypeParameterSyntax.prototype.__kind = 238 /* TypeParameter */, ConstraintSyntax.prototype.__kind = 239 /* Constraint */, SimplePropertyAssignmentSyntax.prototype.__kind = 240 /* SimplePropertyAssignment */, FunctionPropertyAssignmentSyntax.prototype.__kind = 241 /* FunctionPropertyAssignment */, ParameterSyntax.prototype.__kind = 242 /* Parameter */, EnumElementSyntax.prototype.__kind = 243 /* EnumElement */, TypeAnnotationSyntax.prototype.__kind = 244 /* TypeAnnotation */, ExternalModuleReferenceSyntax.prototype.__kind = 245 /* ExternalModuleReference */, ModuleNameModuleReferenceSyntax.prototype.__kind = 246 /* ModuleNameModuleReference */;
- })(Syntax.Concrete || (Syntax.Concrete = {}));
- var Concrete = Syntax.Concrete;
- })(TypeScript.Syntax || (TypeScript.Syntax = {}));
- var Syntax = TypeScript.Syntax;
+ })(Concrete = Syntax.Concrete || (Syntax.Concrete = {}));
+ })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -25427,6 +25505,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var IncrementalParser;
(function (IncrementalParser) {
function createParserSource(oldSyntaxTree, textChangeRange, text) {
var fileName = oldSyntaxTree.fileName();
@@ -25826,11 +25905,11 @@ var TypeScript;
return TypeScript.Parser.parseSource(createParserSource(oldSyntaxTree, textChangeRange, newText), oldSyntaxTree.isDeclaration());
}
IncrementalParser.parse = parse;
- })(TypeScript.IncrementalParser || (TypeScript.IncrementalParser = {}));
- var IncrementalParser = TypeScript.IncrementalParser;
+ })(IncrementalParser = TypeScript.IncrementalParser || (TypeScript.IncrementalParser = {}));
})(TypeScript || (TypeScript = {}));
var ts;
(function (ts) {
+ var OutliningElementsCollector;
(function (OutliningElementsCollector) {
function collectElements(sourceFile) {
var elements = [];
@@ -25880,11 +25959,11 @@ var ts;
return elements;
}
OutliningElementsCollector.collectElements = collectElements;
- })(ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {}));
- var OutliningElementsCollector = ts.OutliningElementsCollector;
+ })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {}));
})(ts || (ts = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
var NavigationBarItemGetter = (function () {
function NavigationBarItemGetter() {
@@ -26131,11 +26210,11 @@ var TypeScript;
return NavigationBarItemGetter;
})();
Services.NavigationBarItemGetter = NavigationBarItemGetter;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
var BraceMatcher = (function () {
function BraceMatcher() {
@@ -26191,12 +26270,13 @@ var TypeScript;
return BraceMatcher;
})();
Services.BraceMatcher = BraceMatcher;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Breakpoints;
(function (Breakpoints) {
function createBreakpointSpanInfo(parentElement) {
var childElements = [];
@@ -27078,13 +27158,12 @@ var TypeScript;
return breakpointResolver.breakpointSpanOf(positionedToken);
}
Breakpoints.getBreakpointLocation = getBreakpointLocation;
- })(Services.Breakpoints || (Services.Breakpoints = {}));
- var Breakpoints = Services.Breakpoints;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Breakpoints = Services.Breakpoints || (Services.Breakpoints = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Indentation;
(function (Indentation) {
function columnForEndOfTokenAtPosition(syntaxTree, position, options) {
var token = TypeScript.findToken(syntaxTree.sourceUnit(), position);
@@ -27180,12 +27259,13 @@ var TypeScript;
return value.length;
}
Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition;
- })(TypeScript.Indentation || (TypeScript.Indentation = {}));
- var Indentation = TypeScript.Indentation;
+ })(Indentation = TypeScript.Indentation || (TypeScript.Indentation = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var TextSnapshot = (function () {
function TextSnapshot(snapshot) {
@@ -27242,14 +27322,14 @@ var TypeScript;
return TextSnapshot;
})();
Formatting.TextSnapshot = TextSnapshot;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var TextSnapshotLine = (function () {
function TextSnapshotLine(_snapshot, _lineNumber, _start, _end, _lineBreak) {
@@ -27292,14 +27372,14 @@ var TypeScript;
return TextSnapshotLine;
})();
Formatting.TextSnapshotLine = TextSnapshotLine;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var SnapshotPoint = (function () {
function SnapshotPoint(snapshot, position) {
@@ -27315,14 +27395,14 @@ var TypeScript;
return SnapshotPoint;
})();
Formatting.SnapshotPoint = SnapshotPoint;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var FormattingContext = (function () {
function FormattingContext(snapshot, formattingRequestKind) {
@@ -27401,14 +27481,14 @@ var TypeScript;
return FormattingContext;
})();
Formatting.FormattingContext = FormattingContext;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var FormattingManager = (function () {
function FormattingManager(syntaxTree, snapshot, rulesProvider, editorOptions) {
@@ -27475,14 +27555,14 @@ var TypeScript;
return FormattingManager;
})();
Formatting.FormattingManager = FormattingManager;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
(function (FormattingRequestKind) {
FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument";
@@ -27493,14 +27573,14 @@ var TypeScript;
FormattingRequestKind[FormattingRequestKind["FormatOnPaste"] = 5] = "FormatOnPaste";
})(Formatting.FormattingRequestKind || (Formatting.FormattingRequestKind = {}));
var FormattingRequestKind = Formatting.FormattingRequestKind;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var Rule = (function () {
function Rule(Descriptor, Operation, Flag) {
@@ -27515,14 +27595,14 @@ var TypeScript;
return Rule;
})();
Formatting.Rule = Rule;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
(function (RuleAction) {
RuleAction[RuleAction["Ignore"] = 0] = "Ignore";
@@ -27531,14 +27611,14 @@ var TypeScript;
RuleAction[RuleAction["Delete"] = 3] = "Delete";
})(Formatting.RuleAction || (Formatting.RuleAction = {}));
var RuleAction = Formatting.RuleAction;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var RuleDescriptor = (function () {
function RuleDescriptor(LeftTokenRange, RightTokenRange) {
@@ -27563,28 +27643,28 @@ var TypeScript;
return RuleDescriptor;
})();
Formatting.RuleDescriptor = RuleDescriptor;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
(function (RuleFlags) {
RuleFlags[RuleFlags["None"] = 0] = "None";
RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines";
})(Formatting.RuleFlags || (Formatting.RuleFlags = {}));
var RuleFlags = Formatting.RuleFlags;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var RuleOperation = (function () {
function RuleOperation() {
@@ -27606,14 +27686,14 @@ var TypeScript;
return RuleOperation;
})();
Formatting.RuleOperation = RuleOperation;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var RuleOperationContext = (function () {
function RuleOperationContext() {
@@ -27641,14 +27721,14 @@ var TypeScript;
return RuleOperationContext;
})();
Formatting.RuleOperationContext = RuleOperationContext;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var Rules = (function () {
function Rules() {
@@ -27997,14 +28077,14 @@ var TypeScript;
return Rules;
})();
Formatting.Rules = Rules;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var RulesMap = (function () {
function RulesMap() {
@@ -28128,14 +28208,14 @@ var TypeScript;
return RulesBucket;
})();
Formatting.RulesBucket = RulesBucket;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var RulesProvider = (function () {
function RulesProvider(logger) {
@@ -28217,14 +28297,14 @@ var TypeScript;
return RulesProvider;
})();
Formatting.RulesProvider = RulesProvider;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var TextEditInfo = (function () {
function TextEditInfo(position, length, replaceWith) {
@@ -28238,15 +28318,16 @@ var TypeScript;
return TextEditInfo;
})();
Formatting.TextEditInfo = TextEditInfo;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
+ var Shared;
(function (Shared) {
var TokenRangeAccess = (function () {
function TokenRangeAccess(from, to, except) {
@@ -28361,16 +28442,15 @@ var TypeScript;
return TokenRange;
})();
Shared.TokenRange = TokenRange;
- })(Formatting.Shared || (Formatting.Shared = {}));
- var Shared = Formatting.Shared;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Shared = Formatting.Shared || (Formatting.Shared = {}));
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var TokenSpan = (function (_super) {
__extends(TokenSpan, _super);
@@ -28381,14 +28461,14 @@ var TypeScript;
return TokenSpan;
})(TypeScript.TextSpan);
Formatting.TokenSpan = TokenSpan;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var IndentationNodeContext = (function () {
function IndentationNodeContext(parent, node, fullStart, indentationAmount, childIndentationAmountDelta) {
@@ -28454,14 +28534,14 @@ var TypeScript;
return IndentationNodeContext;
})();
Formatting.IndentationNodeContext = IndentationNodeContext;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var IndentationNodeContextPool = (function () {
function IndentationNodeContextPool() {
@@ -28488,14 +28568,14 @@ var TypeScript;
return IndentationNodeContextPool;
})();
Formatting.IndentationNodeContextPool = IndentationNodeContextPool;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var IndentationTrackingWalker = (function (_super) {
__extends(IndentationTrackingWalker, _super);
@@ -28702,14 +28782,14 @@ var TypeScript;
return IndentationTrackingWalker;
})(TypeScript.SyntaxWalker);
Formatting.IndentationTrackingWalker = IndentationTrackingWalker;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var MultipleTokenIndenter = (function (_super) {
__extends(MultipleTokenIndenter, _super);
@@ -28842,14 +28922,14 @@ var TypeScript;
return MultipleTokenIndenter;
})(Formatting.IndentationTrackingWalker);
Formatting.MultipleTokenIndenter = MultipleTokenIndenter;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var SingleTokenIndenter = (function (_super) {
__extends(SingleTokenIndenter, _super);
@@ -28874,14 +28954,14 @@ var TypeScript;
return SingleTokenIndenter;
})(Formatting.IndentationTrackingWalker);
Formatting.SingleTokenIndenter = SingleTokenIndenter;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
+ var Formatting;
(function (Formatting) {
var Formatter = (function (_super) {
__extends(Formatter, _super);
@@ -29091,83 +29171,8 @@ var TypeScript;
return Formatter;
})(Formatting.MultipleTokenIndenter);
Formatting.Formatter = Formatter;
- })(Services.Formatting || (Services.Formatting = {}));
- var Formatting = Services.Formatting;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
-})(TypeScript || (TypeScript = {}));
-var TypeScript;
-(function (TypeScript) {
- var BloomFilter = (function () {
- function BloomFilter(expectedCount) {
- var m = Math.max(1, BloomFilter.computeM(expectedCount));
- var k = Math.max(1, BloomFilter.computeK(expectedCount));
- ;
- var sizeInEvenBytes = (m + 7) & ~7;
- this.bitArray = [];
- for (var i = 0, len = sizeInEvenBytes; i < len; i++) {
- this.bitArray[i] = false;
- }
- this.hashFunctionCount = k;
- }
- BloomFilter.computeM = function (expectedCount) {
- var p = BloomFilter.falsePositiveProbability;
- var n = expectedCount;
- var numerator = n * Math.log(p);
- var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0)));
- return Math.ceil(numerator / denominator);
- };
- BloomFilter.computeK = function (expectedCount) {
- var n = expectedCount;
- var m = BloomFilter.computeM(expectedCount);
- var temp = Math.log(2.0) * m / n;
- return Math.round(temp);
- };
- BloomFilter.prototype.computeHash = function (key, seed) {
- return TypeScript.Hash.computeMurmur2StringHashCode(key, seed);
- };
- BloomFilter.prototype.addKeys = function (keys) {
- for (var name in keys) {
- if (ts.lookUp(keys, name)) {
- this.add(name);
- }
- }
- };
- BloomFilter.prototype.add = function (value) {
- for (var i = 0; i < this.hashFunctionCount; i++) {
- var hash = this.computeHash(value, i);
- hash = hash % this.bitArray.length;
- this.bitArray[Math.abs(hash)] = true;
- }
- };
- BloomFilter.prototype.probablyContains = function (value) {
- for (var i = 0; i < this.hashFunctionCount; i++) {
- var hash = this.computeHash(value, i);
- hash = hash % this.bitArray.length;
- if (!this.bitArray[Math.abs(hash)]) {
- return false;
- }
- }
- return true;
- };
- BloomFilter.prototype.isEquivalent = function (filter) {
- return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount;
- };
- BloomFilter.isEquivalent = function (array1, array2) {
- if (array1.length !== array2.length) {
- return false;
- }
- for (var i = 0; i < array1.length; i++) {
- if (array1[i] !== array2[i]) {
- return false;
- }
- }
- return true;
- };
- BloomFilter.falsePositiveProbability = 0.0001;
- return BloomFilter;
- })();
- TypeScript.BloomFilter = BloomFilter;
+ })(Formatting = Services.Formatting || (Services.Formatting = {}));
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -29822,6 +29827,7 @@ var TypeScript;
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
+ var ASTHelpers;
(function (ASTHelpers) {
var sentinelEmptyArray = [];
function isValidAstNode(ast) {
@@ -30393,8 +30399,7 @@ var TypeScript;
return result;
}
ASTHelpers.getModuleNames = getModuleNames;
- })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {}));
- var ASTHelpers = TypeScript.ASTHelpers;
+ })(ASTHelpers = TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {}));
})(TypeScript || (TypeScript = {}));
var TypeScript;
(function (TypeScript) {
@@ -30885,29 +30890,6 @@ var ts;
SourceFileObject.prototype.isDeclareFile = function () {
return TypeScript.isDTSFile(this.filename);
};
- SourceFileObject.prototype.getBloomFilter = function () {
- if (!this.bloomFilter) {
- var identifiers = TypeScript.createIntrinsicsObject();
- var pre = function (cur) {
- if (TypeScript.ASTHelpers.isValidAstNode(cur)) {
- if (cur.kind() === 11 /* IdentifierName */) {
- var nodeText = TypeScript.tokenValueText(cur);
- identifiers[nodeText] = true;
- }
- }
- };
- TypeScript.getAstWalkerFactory().simpleWalk(this.getSourceUnit(), pre, null, identifiers);
- var identifierCount = 0;
- for (var name in identifiers) {
- if (identifiers[name]) {
- identifierCount++;
- }
- }
- this.bloomFilter = new TypeScript.BloomFilter(identifierCount);
- this.bloomFilter.addKeys(identifiers);
- }
- return this.bloomFilter;
- };
SourceFileObject.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) {
var oldSyntaxTree = this.syntaxTree;
if (textChangeRange && ts.Debug.shouldAssert(1 /* Normal */)) {
@@ -31466,6 +31448,79 @@ var ts;
};
}
ts.createDocumentRegistry = createDocumentRegistry;
+ function getTargetLabel(referenceNode, labelName) {
+ while (referenceNode) {
+ if (referenceNode.kind === 159 /* LabelledStatement */ && referenceNode.label.text === labelName) {
+ return referenceNode.label;
+ }
+ referenceNode = referenceNode.parent;
+ }
+ return undefined;
+ }
+ function isJumpStatementTarget(node) {
+ return node.kind === 55 /* Identifier */ && (node.parent.kind === 153 /* BreakStatement */ || node.parent.kind === 152 /* ContinueStatement */) && node.parent.label === node;
+ }
+ function isLabelOfLabeledStatement(node) {
+ return node.kind === 55 /* Identifier */ && node.parent.kind === 159 /* LabelledStatement */ && node.parent.label === node;
+ }
+ function isLabelName(node) {
+ return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node);
+ }
+ function isCallExpressionTarget(node) {
+ if (node.parent.kind === 130 /* PropertyAccess */ && node.parent.right === node)
+ node = node.parent;
+ return node.parent.kind === 132 /* CallExpression */ && node.parent.func === node;
+ }
+ function isNewExpressionTarget(node) {
+ if (node.parent.kind === 130 /* PropertyAccess */ && node.parent.right === node)
+ node = node.parent;
+ return node.parent.kind === 133 /* NewExpression */ && node.parent.func === node;
+ }
+ function isAnyFunction(node) {
+ switch (node.kind) {
+ case 136 /* FunctionExpression */:
+ case 167 /* FunctionDeclaration */:
+ case 137 /* ArrowFunction */:
+ case 116 /* Method */:
+ case 118 /* GetAccessor */:
+ case 119 /* SetAccessor */:
+ case 117 /* Constructor */:
+ return true;
+ }
+ return false;
+ }
+ function isNameOfFunctionDeclaration(node) {
+ return node.kind === 55 /* Identifier */ && isAnyFunction(node.parent) && node.parent.name === node;
+ }
+ function isNameOfPropertyAssignment(node) {
+ return (node.kind === 55 /* Identifier */ || node.kind === 3 /* StringLiteral */ || node.kind === 2 /* NumericLiteral */) && node.parent.kind === 129 /* PropertyAssignment */ && node.parent.name === node;
+ }
+ function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) {
+ if (node.kind === 3 /* StringLiteral */ || node.kind === 2 /* NumericLiteral */) {
+ switch (node.parent.kind) {
+ case 115 /* Property */:
+ case 129 /* PropertyAssignment */:
+ case 176 /* EnumMember */:
+ case 116 /* Method */:
+ case 118 /* GetAccessor */:
+ case 119 /* SetAccessor */:
+ case 172 /* ModuleDeclaration */:
+ return node.parent.name === node;
+ case 131 /* IndexedAccess */:
+ return node.parent.index === node;
+ }
+ }
+ return false;
+ }
+ function isNameOfExternalModuleImportOrDeclaration(node) {
+ return node.kind === 3 /* StringLiteral */ && ((node.parent.kind === 172 /* ModuleDeclaration */ && node.parent.name === node) || (node.parent.kind === 174 /* ImportDeclaration */ && node.parent.externalModuleName === node));
+ }
+ var SearchMeaning;
+ (function (SearchMeaning) {
+ SearchMeaning[SearchMeaning["Value"] = 0x1] = "Value";
+ SearchMeaning[SearchMeaning["Type"] = 0x2] = "Type";
+ SearchMeaning[SearchMeaning["Namespace"] = 0x4] = "Namespace";
+ })(SearchMeaning || (SearchMeaning = {}));
var keywordCompletions = [];
for (var i = ts.SyntaxKind.FirstKeyword; i <= ts.SyntaxKind.LastKeyword; i++) {
keywordCompletions.push({
@@ -31499,8 +31554,7 @@ var ts;
return {
getSourceFile: function (filename, languageVersion) {
var sourceFile = getSourceFile(filename);
- ts.Debug.assert(!!sourceFile, "sourceFile can not be undefined");
- return sourceFile.getSourceFile();
+ return sourceFile && sourceFile.getSourceFile();
},
getCancellationToken: function () { return cancellationToken; },
getCanonicalFileName: function (filename) { return useCaseSensitivefilenames ? filename : filename.toLowerCase(); },
@@ -31757,7 +31811,7 @@ var ts;
isRightOfDot = true;
node = node.parent.left;
}
- var mappedNode = getNodeAtPosition(sourceFile.getSourceFile(), TypeScript.end(node) - 1);
+ var mappedNode = getNodeAtPosition(sourceFile, TypeScript.end(node) - 1);
ts.Debug.assert(mappedNode, "Could not map a Fidelity node to an AST node");
activeCompletionSession = {
filename: filename,
@@ -31844,8 +31898,9 @@ var ts;
current = child;
continue outer;
}
- if (child.end > position)
+ if (child.end > position) {
break;
+ }
}
return current;
}
@@ -31857,6 +31912,7 @@ var ts;
return node;
}
switch (node.kind) {
+ case 177 /* SourceFile */:
case 116 /* Method */:
case 167 /* FunctionDeclaration */:
case 136 /* FunctionExpression */:
@@ -31941,9 +31997,10 @@ var ts;
synchronizeHostData();
fileName = TypeScript.switchToForwardSlashes(fileName);
var sourceFile = getSourceFile(fileName);
- var node = getNodeAtPosition(sourceFile.getSourceFile(), position);
- if (!node)
+ var node = getNodeAtPosition(sourceFile, position);
+ if (!node) {
return undefined;
+ }
var symbol = typeInfoResolver.getSymbolInfo(node);
var type = symbol && typeInfoResolver.getTypeOfSymbol(symbol);
if (type) {
@@ -31952,43 +32009,6 @@ var ts;
return undefined;
}
function getDefinitionAtPosition(filename, position) {
- function getTargetLabel(node, labelName) {
- while (node) {
- if (node.kind === 159 /* LabelledStatement */ && node.label.text === labelName) {
- return node.label;
- }
- node = node.parent;
- }
- return undefined;
- }
- function isJumpStatementTarget(node) {
- return node.kind === 55 /* Identifier */ && (node.parent.kind === 153 /* BreakStatement */ || node.parent.kind === 152 /* ContinueStatement */) && node.parent.label === node;
- }
- function isCallExpressionTarget(node) {
- if (node.parent.kind === 130 /* PropertyAccess */ && node.parent.right === node)
- node = node.parent;
- return node.parent.kind === 132 /* CallExpression */ && node.parent.func === node;
- }
- function isNewExpressionTarget(node) {
- if (node.parent.kind === 130 /* PropertyAccess */ && node.parent.right === node)
- node = node.parent;
- return node.parent.kind === 133 /* NewExpression */ && node.parent.func === node;
- }
- function isFunctionDeclaration(node) {
- switch (node.kind) {
- case 167 /* FunctionDeclaration */:
- case 116 /* Method */:
- case 136 /* FunctionExpression */:
- case 118 /* GetAccessor */:
- case 119 /* SetAccessor */:
- case 137 /* ArrowFunction */:
- return true;
- }
- return false;
- }
- function isNameOfFunctionDeclaration(node) {
- return node.kind === 55 /* Identifier */ && isFunctionDeclaration(node.parent) && node.parent.name === node;
- }
function getDefinitionInfo(node, symbolKind, symbolName, containerName) {
return new DefinitionInfo(node.getSourceFile().filename, TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()), symbolKind, symbolName, undefined, containerName);
}
@@ -32031,7 +32051,7 @@ var ts;
synchronizeHostData();
filename = TypeScript.switchToForwardSlashes(filename);
var sourceFile = getSourceFile(filename);
- var node = getNodeAtPosition(sourceFile.getSourceFile(), position);
+ var node = getNodeAtPosition(sourceFile, position);
if (!node) {
return undefined;
}
@@ -32040,7 +32060,7 @@ var ts;
var label = getTargetLabel(node.parent, node.text);
return label ? [getDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined;
}
- var comment = ts.forEach(sourceFile.getSourceFile().referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; });
+ var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; });
if (comment) {
var targetFilename = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(filename), comment.filename));
if (program.getSourceFile(targetFilename)) {
@@ -32066,6 +32086,500 @@ var ts;
}
return result;
}
+ function getOccurrencesAtPosition(filename, position) {
+ synchronizeHostData();
+ filename = TypeScript.switchToForwardSlashes(filename);
+ var sourceFile = getSourceFile(filename);
+ var node = getNodeAtPosition(sourceFile, position);
+ if (!node) {
+ return undefined;
+ }
+ if (node.kind === 55 /* Identifier */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) {
+ return getReferencesForNode(node, [sourceFile]);
+ }
+ switch (node.kind) {
+ case 86 /* TryKeyword */:
+ case 58 /* CatchKeyword */:
+ case 71 /* FinallyKeyword */:
+ if (hasKind(parent(parent(node)), 161 /* TryStatement */)) {
+ return getTryCatchFinallyOccurrences(node.parent.parent);
+ }
+ break;
+ case 82 /* SwitchKeyword */:
+ if (hasKind(node.parent, 156 /* SwitchStatement */)) {
+ return getSwitchCaseDefaultOccurrences(node.parent);
+ }
+ break;
+ case 57 /* CaseKeyword */:
+ case 63 /* DefaultKeyword */:
+ if (hasKind(parent(parent(node)), 156 /* SwitchStatement */)) {
+ return getSwitchCaseDefaultOccurrences(node.parent.parent);
+ }
+ break;
+ case 56 /* BreakKeyword */:
+ if (hasKind(node.parent, 153 /* BreakStatement */)) {
+ return getBreakStatementOccurences(node.parent);
+ }
+ break;
+ }
+ return undefined;
+ function getTryCatchFinallyOccurrences(tryStatement) {
+ var keywords = [];
+ pushKeywordIf(keywords, tryStatement.getFirstToken(), 86 /* TryKeyword */);
+ if (tryStatement.catchBlock) {
+ pushKeywordIf(keywords, tryStatement.catchBlock.getFirstToken(), 58 /* CatchKeyword */);
+ }
+ if (tryStatement.finallyBlock) {
+ pushKeywordIf(keywords, tryStatement.finallyBlock.getFirstToken(), 71 /* FinallyKeyword */);
+ }
+ return keywordsToReferenceEntries(keywords);
+ }
+ function getSwitchCaseDefaultOccurrences(switchStatement) {
+ var keywords = [];
+ pushKeywordIf(keywords, switchStatement.getFirstToken(), 82 /* SwitchKeyword */);
+ ts.forEach(switchStatement.clauses, function (clause) {
+ pushKeywordIf(keywords, clause.getFirstToken(), 57 /* CaseKeyword */, 63 /* DefaultKeyword */);
+ ts.forEachChild(clause, function aggregateBreakKeywords(node) {
+ switch (node.kind) {
+ case 153 /* BreakStatement */:
+ if (!node.label) {
+ pushKeywordIf(keywords, node.getFirstToken(), 56 /* BreakKeyword */);
+ }
+ case 150 /* ForStatement */:
+ case 151 /* ForInStatement */:
+ case 148 /* DoStatement */:
+ case 149 /* WhileStatement */:
+ case 156 /* SwitchStatement */:
+ return;
+ }
+ if (!isAnyFunction(node)) {
+ ts.forEachChild(node, aggregateBreakKeywords);
+ }
+ });
+ });
+ return keywordsToReferenceEntries(keywords);
+ }
+ function getBreakStatementOccurences(breakStatement) {
+ if (breakStatement.label) {
+ return undefined;
+ }
+ for (var owner = node.parent; owner; owner = owner.parent) {
+ switch (owner.kind) {
+ case 150 /* ForStatement */:
+ case 151 /* ForInStatement */:
+ case 148 /* DoStatement */:
+ case 149 /* WhileStatement */:
+ return undefined;
+ case 156 /* SwitchStatement */:
+ return getSwitchCaseDefaultOccurrences(owner);
+ default:
+ if (isAnyFunction(owner)) {
+ return undefined;
+ }
+ }
+ }
+ return undefined;
+ }
+ function hasKind(node, kind) {
+ return !!(node && node.kind === kind);
+ }
+ function parent(node) {
+ return node && node.parent;
+ }
+ function pushKeywordIf(keywordList, token) {
+ var expected = [];
+ for (var _i = 2; _i < arguments.length; _i++) {
+ expected[_i - 2] = arguments[_i];
+ }
+ if (!token) {
+ return;
+ }
+ if (ts.contains(expected, token.kind)) {
+ keywordList.push(token);
+ }
+ }
+ function keywordsToReferenceEntries(keywords) {
+ return ts.map(keywords, function (keyword) { return new ReferenceEntry(filename, TypeScript.TextSpan.fromBounds(keyword.getStart(), keyword.end), false); });
+ }
+ }
+ function getReferencesAtPosition(filename, position) {
+ synchronizeHostData();
+ filename = TypeScript.switchToForwardSlashes(filename);
+ var sourceFile = getSourceFile(filename);
+ var node = getNodeAtPosition(sourceFile, position);
+ if (!node) {
+ return undefined;
+ }
+ if (node.kind !== 55 /* Identifier */ && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) {
+ return undefined;
+ }
+ return getReferencesForNode(node, program.getSourceFiles());
+ }
+ function getReferencesForNode(node, sourceFiles) {
+ if (isLabelName(node)) {
+ if (isJumpStatementTarget(node)) {
+ var labelDefinition = getTargetLabel(node.parent, node.text);
+ return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : [getReferenceEntry(node)];
+ }
+ else {
+ return getLabelReferencesInNode(node.parent, node);
+ }
+ }
+ var symbol = typeInfoResolver.getSymbolInfo(node);
+ if (!symbol) {
+ return [getReferenceEntry(node)];
+ }
+ if (!symbol.getDeclarations()) {
+ return undefined;
+ }
+ var result;
+ var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), symbol.getDeclarations());
+ var symbolName = getNormalizedSymbolName(symbol);
+ var scope = getSymbolScope(symbol);
+ if (scope) {
+ result = [];
+ getReferencesInNode(scope, symbol, symbolName, node, searchMeaning, result);
+ }
+ else {
+ ts.forEach(sourceFiles, function (sourceFile) {
+ cancellationToken.throwIfCancellationRequested();
+ if (ts.lookUp(sourceFile.identifiers, symbolName)) {
+ result = result || [];
+ getReferencesInNode(sourceFile, symbol, symbolName, node, searchMeaning, result);
+ }
+ });
+ }
+ return result;
+ function getNormalizedSymbolName(symbol) {
+ var functionExpression = ts.getDeclarationOfKind(symbol, 136 /* FunctionExpression */);
+ if (functionExpression && functionExpression.name) {
+ var name = functionExpression.name.text;
+ }
+ else {
+ var name = symbol.name;
+ }
+ var length = name.length;
+ if (length >= 2 && name.charCodeAt(0) === 34 /* doubleQuote */ && name.charCodeAt(length - 1) === 34 /* doubleQuote */) {
+ return name.substring(1, length - 1);
+ }
+ ;
+ return name;
+ }
+ function getSymbolScope(symbol) {
+ if (symbol.getFlags() && (2 /* Property */ | 2048 /* Method */)) {
+ var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; });
+ if (privateDeclaration) {
+ return privateDeclaration.parent;
+ }
+ }
+ if (symbol.parent) {
+ return undefined;
+ }
+ var scope = undefined;
+ var declarations = symbol.getDeclarations();
+ for (var i = 0, n = declarations.length; i < n; i++) {
+ var container = getContainerNode(declarations[i]);
+ if (scope && scope !== container) {
+ return undefined;
+ }
+ if (container.kind === 177 /* SourceFile */ && !ts.isExternalModule(container)) {
+ return undefined;
+ }
+ scope = container;
+ }
+ return scope;
+ }
+ function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) {
+ var positions = [];
+ if (!symbolName || !symbolName.length) {
+ return positions;
+ }
+ var text = sourceFile.text;
+ var sourceLength = text.length;
+ var symbolNameLength = symbolName.length;
+ var position = text.indexOf(symbolName, start);
+ while (position >= 0) {
+ cancellationToken.throwIfCancellationRequested();
+ if (position > end)
+ break;
+ var endPosition = position + symbolNameLength;
+ if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 1 /* ES5 */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 1 /* ES5 */))) {
+ positions.push(position);
+ }
+ position = text.indexOf(symbolName, position + symbolNameLength + 1);
+ }
+ return positions;
+ }
+ function getLabelReferencesInNode(container, targetLabel) {
+ var result = [];
+ var sourceFile = container.getSourceFile();
+ var labelName = targetLabel.text;
+ var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd());
+ ts.forEach(possiblePositions, function (position) {
+ cancellationToken.throwIfCancellationRequested();
+ var node = getNodeAtPosition(sourceFile, position);
+ if (!node || node.getWidth() !== labelName.length) {
+ return;
+ }
+ if (node === targetLabel || (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) {
+ result.push(getReferenceEntry(node));
+ }
+ });
+ return result;
+ }
+ function isValidReferencePosition(node, searchSymbolName) {
+ if (node) {
+ switch (node.kind) {
+ case 55 /* Identifier */:
+ return node.getWidth() === searchSymbolName.length;
+ case 3 /* StringLiteral */:
+ if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) {
+ return node.getWidth() === searchSymbolName.length + 2;
+ }
+ break;
+ case 2 /* NumericLiteral */:
+ if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) {
+ return node.getWidth() === searchSymbolName.length;
+ }
+ break;
+ }
+ }
+ return false;
+ }
+ function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, result) {
+ var sourceFile = container.getSourceFile();
+ var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, container.getStart(), container.getEnd());
+ if (possiblePositions.length) {
+ var searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation);
+ ts.forEach(possiblePositions, function (position) {
+ cancellationToken.throwIfCancellationRequested();
+ var referenceLocation = getNodeAtPosition(sourceFile, position);
+ if (!isValidReferencePosition(referenceLocation, searchText)) {
+ return;
+ }
+ if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) {
+ return;
+ }
+ var referenceSymbol = typeInfoResolver.getSymbolInfo(referenceLocation);
+ if (!referenceSymbol || !(referenceSymbol.getDeclarations())) {
+ return;
+ }
+ if (isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation)) {
+ result.push(getReferenceEntry(referenceLocation));
+ }
+ });
+ }
+ }
+ function populateSearchSymbolSet(symbol, location) {
+ var result = [symbol];
+ var rootSymbol = typeInfoResolver.getRootSymbol(symbol);
+ if (rootSymbol && rootSymbol !== symbol) {
+ result.push(rootSymbol);
+ }
+ if (isNameOfPropertyAssignment(location)) {
+ var symbolFromContextualType = getPropertySymbolFromContextualType(location);
+ if (symbolFromContextualType)
+ result.push(typeInfoResolver.getRootSymbol(symbolFromContextualType));
+ }
+ if (symbol.parent && symbol.parent.flags & (16 /* Class */ | 32 /* Interface */)) {
+ getPropertySymbolsFromBaseTypes(symbol.parent, symbol.getName(), result);
+ }
+ return result;
+ }
+ function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) {
+ if (symbol.flags & (16 /* Class */ | 32 /* Interface */)) {
+ ts.forEach(symbol.getDeclarations(), function (declaration) {
+ if (declaration.kind === 169 /* ClassDeclaration */) {
+ getPropertySymbolFromTypeReference(declaration.baseType);
+ ts.forEach(declaration.implementedTypes, getPropertySymbolFromTypeReference);
+ }
+ else if (declaration.kind === 170 /* InterfaceDeclaration */) {
+ ts.forEach(declaration.baseTypes, getPropertySymbolFromTypeReference);
+ }
+ });
+ }
+ return;
+ function getPropertySymbolFromTypeReference(typeReference) {
+ if (typeReference) {
+ var typeReferenceSymbol = typeInfoResolver.getSymbolInfo(typeReference.typeName);
+ if (typeReferenceSymbol) {
+ var propertySymbol = typeReferenceSymbol.members[propertyName];
+ if (propertySymbol)
+ result.push(typeReferenceSymbol.members[propertyName]);
+ getPropertySymbolsFromBaseTypes(typeReferenceSymbol, propertyName, result);
+ }
+ }
+ }
+ }
+ function isRelatableToSearchSet(searchSymbols, referenceSymbol, referenceLocation) {
+ var referenceSymbolTarget = typeInfoResolver.getRootSymbol(referenceSymbol);
+ if (searchSymbols.indexOf(referenceSymbolTarget) >= 0) {
+ return true;
+ }
+ if (isNameOfPropertyAssignment(referenceLocation)) {
+ var symbolFromContextualType = getPropertySymbolFromContextualType(referenceLocation);
+ if (symbolFromContextualType && searchSymbols.indexOf(typeInfoResolver.getRootSymbol(symbolFromContextualType)) >= 0) {
+ return true;
+ }
+ }
+ if (referenceSymbol.parent && referenceSymbol.parent.flags & (16 /* Class */ | 32 /* Interface */)) {
+ var result = [];
+ getPropertySymbolsFromBaseTypes(referenceSymbol.parent, referenceSymbol.getName(), result);
+ return ts.forEach(result, function (s) { return searchSymbols.indexOf(s) >= 0; });
+ }
+ return false;
+ }
+ function getPropertySymbolFromContextualType(node) {
+ if (isNameOfPropertyAssignment(node)) {
+ var objectLiteral = node.parent.parent;
+ var contextualType = typeInfoResolver.getContextualType(objectLiteral);
+ if (contextualType) {
+ return typeInfoResolver.getPropertyOfType(contextualType, node.text);
+ }
+ }
+ return undefined;
+ }
+ function getReferenceEntry(node) {
+ var start = node.getStart();
+ var end = node.getEnd();
+ if (node.kind === 3 /* StringLiteral */) {
+ start += 1;
+ end -= 1;
+ }
+ return new ReferenceEntry(node.getSourceFile().filename, TypeScript.TextSpan.fromBounds(start, end), isWriteAccess(node));
+ }
+ function getMeaningFromDeclaration(node) {
+ switch (node.kind) {
+ case 114 /* Parameter */:
+ case 166 /* VariableDeclaration */:
+ case 115 /* Property */:
+ case 129 /* PropertyAssignment */:
+ case 176 /* EnumMember */:
+ case 116 /* Method */:
+ case 117 /* Constructor */:
+ case 118 /* GetAccessor */:
+ case 119 /* SetAccessor */:
+ case 167 /* FunctionDeclaration */:
+ case 136 /* FunctionExpression */:
+ case 137 /* ArrowFunction */:
+ case 163 /* CatchBlock */:
+ return 1 /* Value */;
+ case 113 /* TypeParameter */:
+ case 170 /* InterfaceDeclaration */:
+ case 125 /* TypeLiteral */:
+ return 2 /* Type */;
+ case 169 /* ClassDeclaration */:
+ case 171 /* EnumDeclaration */:
+ return 1 /* Value */ | 2 /* Type */;
+ case 172 /* ModuleDeclaration */:
+ if (node.name.kind === 3 /* StringLiteral */) {
+ return 4 /* Namespace */ | 1 /* Value */;
+ }
+ else if (ts.isInstantiated(node)) {
+ return 4 /* Namespace */ | 1 /* Value */;
+ }
+ else {
+ return 4 /* Namespace */;
+ }
+ break;
+ case 174 /* ImportDeclaration */:
+ return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
+ }
+ ts.Debug.fail("Unkown declaration type");
+ }
+ function isTypeReference(node) {
+ if (node.parent.kind === 112 /* QualifiedName */ && node.parent.right === node)
+ node = node.parent;
+ return node.parent.kind === 123 /* TypeReference */;
+ }
+ function isNamespaceReference(node) {
+ var root = node;
+ var isLastClause = true;
+ if (root.parent.kind === 112 /* QualifiedName */) {
+ while (root.parent && root.parent.kind === 112 /* QualifiedName */)
+ root = root.parent;
+ isLastClause = root.right === node;
+ }
+ return root.parent.kind === 123 /* TypeReference */ && !isLastClause;
+ }
+ function isInRightSideOfImport(node) {
+ while (node.parent.kind === 112 /* QualifiedName */) {
+ node = node.parent;
+ }
+ return node.parent.kind === 174 /* ImportDeclaration */ && node.parent.entityName === node;
+ }
+ function getMeaningFromRightHandSideOfImport(node) {
+ ts.Debug.assert(node.kind === 55 /* Identifier */);
+ if (node.parent.kind === 112 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 174 /* ImportDeclaration */) {
+ return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
+ }
+ return 4 /* Namespace */;
+ }
+ function getMeaningFromLocation(node) {
+ if (node.parent.kind === 175 /* ExportAssignment */) {
+ return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
+ }
+ else if (isInRightSideOfImport(node)) {
+ return getMeaningFromRightHandSideOfImport(node);
+ }
+ else if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
+ return getMeaningFromDeclaration(node.parent);
+ }
+ else if (isTypeReference(node)) {
+ return 2 /* Type */;
+ }
+ else if (isNamespaceReference(node)) {
+ return 4 /* Namespace */;
+ }
+ else {
+ return 1 /* Value */;
+ }
+ }
+ function getIntersectingMeaningFromDeclarations(meaning, declarations) {
+ if (declarations) {
+ do {
+ var lastIterationMeaning = meaning;
+ for (var i = 0, n = declarations.length; i < n; i++) {
+ var declarationMeaning = getMeaningFromDeclaration(declarations[i]);
+ if (declarationMeaning & meaning) {
+ meaning |= declarationMeaning;
+ }
+ }
+ } while (meaning !== lastIterationMeaning);
+ }
+ return meaning;
+ }
+ function isWriteAccess(node) {
+ if (node.kind === 55 /* Identifier */ && ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
+ return true;
+ }
+ var parent = node.parent;
+ if (parent) {
+ if (parent.kind === 139 /* PostfixOperator */ || parent.kind === 138 /* PrefixOperator */) {
+ return true;
+ }
+ else if (parent.kind === 140 /* BinaryExpression */ && parent.left === node) {
+ var operator = parent.operator;
+ switch (operator) {
+ case 46 /* AsteriskEqualsToken */:
+ case 47 /* SlashEqualsToken */:
+ case 48 /* PercentEqualsToken */:
+ case 45 /* MinusEqualsToken */:
+ case 49 /* LessThanLessThanEqualsToken */:
+ case 50 /* GreaterThanGreaterThanEqualsToken */:
+ case 51 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 53 /* BarEqualsToken */:
+ case 54 /* CaretEqualsToken */:
+ case 52 /* AmpersandEqualsToken */:
+ case 44 /* PlusEqualsToken */:
+ case 43 /* EqualsToken */:
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ }
function getSyntaxTree(filename) {
filename = TypeScript.switchToForwardSlashes(filename);
return syntaxTreeCache.getCurrentFileSyntaxTree(filename);
@@ -32269,8 +32783,8 @@ var ts;
getSignatureHelpItems: function (filename, position) { return null; },
getSignatureHelpCurrentArgumentState: function (fileName, position, applicableSpanStart) { return null; },
getDefinitionAtPosition: getDefinitionAtPosition,
- getReferencesAtPosition: function (filename, position) { return []; },
- getOccurrencesAtPosition: function (filename, position) { return []; },
+ getReferencesAtPosition: getReferencesAtPosition,
+ getOccurrencesAtPosition: getOccurrencesAtPosition,
getImplementorsAtPosition: function (filename, position) { return []; },
getNameOrDottedNameSpan: getNameOrDottedNameSpan,
getBreakpointStatementAtPosition: getBreakpointStatementAtPosition,
@@ -33165,8 +33679,8 @@ var ts;
})(ts || (ts = {}));
var TypeScript;
(function (TypeScript) {
+ var Services;
(function (Services) {
Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory;
- })(TypeScript.Services || (TypeScript.Services = {}));
- var Services = TypeScript.Services;
+ })(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
diff --git a/package.json b/package.json
index dd1c6276a2b..6b1d991cca6 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "http://typescriptlang.org/",
- "version": "1.0.1",
+ "version": "1.1.0",
"licenses": [
{
"type": "Apache License 2.0",
diff --git a/scripts/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests.ts
index caa6be0063a..f33ba1dd525 100644
--- a/scripts/importDefinitelyTypedTests.ts
+++ b/scripts/importDefinitelyTypedTests.ts
@@ -33,44 +33,44 @@ function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], re
fs.mkdirSync(testDirectoryPath);
child_process.exec(cmd, {
- maxBuffer: 1 * 1024 * 1024,
- cwd: testDirectoryPath
- }, (error, stdout, stderr) => {
- //console.log("importing " + testCaseName + " ...");
- //console.log(cmd);
-
- if (error) {
- console.log("importing " + testCaseName + " ...");
- console.log(cmd);
- console.log("==> error " + JSON.stringify(error));
- console.log("==> stdout " + String(stdout));
- console.log("==> stderr " + String(stderr));
- console.log("\r\n");
- return;
- }
-
- // copy generated file to output location
- var outputFilePath = path.join(testDirectoryPath, "iocapture0.json");
- var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json");
- copyFileSync(outputFilePath, testCasePath);
-
- //console.log("output generated at: " + outputFilePath);
-
- if (!fs.existsSync(testCasePath)) {
- throw new Error("could not find test case at: " + testCasePath);
- }
- else {
- fs.unlinkSync(outputFilePath);
- fs.rmdirSync(testDirectoryPath);
- //console.log("testcase generated at: " + testCasePath);
- //console.log("Done.");
- }
- //console.log("\r\n");
-
- })
- .on('error', function (error) {
- console.log("==> error " + JSON.stringify(error));
- console.log("\r\n");
+ maxBuffer: 1 * 1024 * 1024,
+ cwd: testDirectoryPath
+ }, (error, stdout, stderr) => {
+ console.log("importing " + testCaseName + " ...");
+ console.log(cmd);
+
+ if (error) {
+ console.log("importing " + testCaseName + " ...");
+ console.log(cmd);
+ console.log("==> error " + JSON.stringify(error));
+ console.log("==> stdout " + String(stdout));
+ console.log("==> stderr " + String(stderr));
+ console.log("\r\n");
+ return;
+ }
+
+ // copy generated file to output location
+ var outputFilePath = path.join(testDirectoryPath, "iocapture0.json");
+ var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json");
+ copyFileSync(outputFilePath, testCasePath);
+
+ //console.log("output generated at: " + outputFilePath);
+
+ if (!fs.existsSync(testCasePath)) {
+ throw new Error("could not find test case at: " + testCasePath);
+ }
+ else {
+ fs.unlinkSync(outputFilePath);
+ fs.rmdirSync(testDirectoryPath);
+ //console.log("testcase generated at: " + testCasePath);
+ //console.log("Done.");
+ }
+ //console.log("\r\n");
+
+ })
+ .on('error', function (error) {
+ console.log("==> error " + JSON.stringify(error));
+ console.log("\r\n");
});
}
@@ -79,7 +79,8 @@ function importDefinitelyTypedTests(definitelyTypedRoot: string): void {
if (err) throw err;
subDirectorys
- .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) >= 0)
+ .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0)
+ .filter(i => i.indexOf("sipml") >=0 )
.filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory())
.forEach(d => {
var directoryPath = path.join(definitelyTypedRoot, d);
diff --git a/scripts/importDefinitllyTypedTests.ts b/scripts/importDefinitllyTypedTests.ts
deleted file mode 100644
index caa6be0063a..00000000000
--- a/scripts/importDefinitllyTypedTests.ts
+++ /dev/null
@@ -1,124 +0,0 @@
-declare var require: any, process: any;
-declare var __dirname: any;
-
-var fs = require("fs");
-var path = require("path");
-var child_process = require('child_process');
-
-var tscRoot = path.join(__dirname, "..\\");
-var tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js");
-var rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt");
-var definitelyTypedRoot = process.argv[2];
-
-function fileExtensionIs(path: string, extension: string): boolean {
- var pathLen = path.length;
- var extLen = extension.length;
- return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === extension.toLocaleLowerCase();
-}
-
-function copyFileSync(source, destination) {
- var text = fs.readFileSync(source);
- fs.writeFileSync(destination, text);
-}
-
-function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], responseFile: string ) {
- var cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" ");
- if (responseFile) cmd += " @" + responseFile;
-
- var testDirectoryName = testCaseName + "_" + Math.floor((Math.random() * 10000) + 1);
- var testDirectoryPath = path.join(process.env["temp"], testDirectoryName);
- if (fs.existsSync(testDirectoryPath)) {
- throw new Error("Could not create test directory");
- }
- fs.mkdirSync(testDirectoryPath);
-
- child_process.exec(cmd, {
- maxBuffer: 1 * 1024 * 1024,
- cwd: testDirectoryPath
- }, (error, stdout, stderr) => {
- //console.log("importing " + testCaseName + " ...");
- //console.log(cmd);
-
- if (error) {
- console.log("importing " + testCaseName + " ...");
- console.log(cmd);
- console.log("==> error " + JSON.stringify(error));
- console.log("==> stdout " + String(stdout));
- console.log("==> stderr " + String(stderr));
- console.log("\r\n");
- return;
- }
-
- // copy generated file to output location
- var outputFilePath = path.join(testDirectoryPath, "iocapture0.json");
- var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json");
- copyFileSync(outputFilePath, testCasePath);
-
- //console.log("output generated at: " + outputFilePath);
-
- if (!fs.existsSync(testCasePath)) {
- throw new Error("could not find test case at: " + testCasePath);
- }
- else {
- fs.unlinkSync(outputFilePath);
- fs.rmdirSync(testDirectoryPath);
- //console.log("testcase generated at: " + testCasePath);
- //console.log("Done.");
- }
- //console.log("\r\n");
-
- })
- .on('error', function (error) {
- console.log("==> error " + JSON.stringify(error));
- console.log("\r\n");
- });
-}
-
-function importDefinitelyTypedTests(definitelyTypedRoot: string): void {
- fs.readdir(definitelyTypedRoot, (err, subDirectorys) => {
- if (err) throw err;
-
- subDirectorys
- .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) >= 0)
- .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory())
- .forEach(d => {
- var directoryPath = path.join(definitelyTypedRoot, d);
- fs.readdir(directoryPath, function (err, files) {
- if (err) throw err;
-
- var tsFiles = [];
- var testFiles = [];
- var paramFile;
-
- files
- .map(f => path.join(directoryPath, f))
- .forEach(f => {
- if (fileExtensionIs(f, ".ts")) tsFiles.push(f);
- else if (fileExtensionIs(f, ".tscparams")) paramFile = f;
-
- if (fileExtensionIs(f, "-tests.ts")) testFiles.push(f);
- });
-
- if (testFiles.length === 0) {
- // no test files but multiple d.ts's, e.g. winjs
- var regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))");
- if (tsFiles.length > 1 && tsFiles.every(t => fileExtensionIs(t, ".d.ts") && regexp.test(t))) {
- tsFiles.forEach(filename => {
- importDefinitelyTypedTest(path.basename(filename, ".d.ts"), [filename], paramFile);
- });
- }
- else {
- importDefinitelyTypedTest(d, tsFiles, paramFile);
- }
- }
- else {
- testFiles.forEach(filename => {
- importDefinitelyTypedTest(path.basename(filename, "-tests.ts"), [filename], paramFile);
- });
- }
- });
- })
- });
-}
-
-importDefinitelyTypedTests(definitelyTypedRoot);
\ No newline at end of file
diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 4f982158f79..7a64733a88a 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -37,7 +37,9 @@ module ts {
var emptyArray: any[] = [];
var emptySymbols: SymbolTable = {};
-
+
+ var compilerOptions = program.getCompilerOptions();
+
var checker: TypeChecker = {
getProgram: () => program,
getDiagnostics: getDiagnostics,
@@ -907,8 +909,8 @@ module ts {
// Get qualified name
if (enclosingDeclaration &&
- // Properties/methods/Signatures/Constructors/TypeParameters do not need qualification
- !(symbol.flags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Signature | SymbolFlags.Constructor | SymbolFlags.Method | SymbolFlags.TypeParameter))) {
+ // TypeParameters do not need qualification
+ !(symbol.flags & SymbolFlags.TypeParameter)) {
var symbolName: string;
while (symbol) {
var isFirstName = !symbolName;
@@ -943,20 +945,37 @@ module ts {
writer.write(symbolToString(symbol, enclosingDeclaration, meaning));
}
- function createSingleLineTextWriter() {
+ function createSingleLineTextWriter(maxLength?: number) {
var result = "";
+ var overflow = false;
+ function write(s: string) {
+ if (!overflow) {
+ result += s;
+ if (result.length > maxLength) {
+ result = result.substr(0, maxLength - 3) + "...";
+ overflow = true;
+ }
+ }
+ }
return {
- write(s: string) { result += s; },
- writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) { writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this); },
- writeLine() { result += " "; },
+ write: write,
+ writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
+ writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this);
+ },
+ writeLine() {
+ write(" ");
+ },
increaseIndent() { },
decreaseIndent() { },
- getText() { return result; }
+ getText() {
+ return result;
+ }
};
}
function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string {
- var stringWriter = createSingleLineTextWriter();
+ var maxLength = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation ? undefined : 100;
+ var stringWriter = createSingleLineTextWriter(maxLength);
// TODO(shkamat): typeToString should take enclosingDeclaration as input, once we have implemented enclosingDeclaration
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
return stringWriter.getText();
@@ -1348,7 +1367,7 @@ module ts {
return type;
function checkImplicitAny(type: Type) {
- if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) {
+ if (!fullTypeCheck || !compilerOptions.noImplicitAny) {
return;
}
// We need to have ended up with 'any', 'any[]', 'any[][]', etc.
@@ -1451,7 +1470,7 @@ module ts {
}
// Otherwise, fall back to 'any'.
else {
- if (program.getCompilerOptions().noImplicitAny) {
+ if (compilerOptions.noImplicitAny) {
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name);
}
@@ -3132,45 +3151,6 @@ module ts {
return (type.flags & TypeFlags.Anonymous) && type.symbol && (type.symbol.flags & SymbolFlags.ObjectLiteral) ? true : false;
}
- function getWidenedTypeOfObjectLiteral(type: Type): Type {
- var properties = getPropertiesOfType(type);
- if (properties.length) {
- var widenedTypes: Type[] = [];
- var propTypeWasWidened: boolean = false;
- forEach(properties, p => {
- var propType = getTypeOfSymbol(p);
- var widenedType = getWidenedType(propType);
- if (propType !== widenedType) {
- propTypeWasWidened = true;
-
- if (program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
- error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
- }
- }
- widenedTypes.push(widenedType);
- });
- if (propTypeWasWidened) {
- var members: SymbolTable = {};
- var index = 0;
- forEach(properties, p => {
- var symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, p.name);
- symbol.declarations = p.declarations;
- symbol.parent = p.parent;
- symbol.type = widenedTypes[index++];
- symbol.target = p;
- if (p.valueDeclaration) symbol.valueDeclaration = p.valueDeclaration;
- members[symbol.name] = symbol;
- });
- var stringIndexType = getIndexTypeOfType(type, IndexKind.String);
- var numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
- if (stringIndexType) stringIndexType = getWidenedType(stringIndexType);
- if (numberIndexType) numberIndexType = getWidenedType(numberIndexType);
- type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
- }
- }
- return type;
- }
-
function isArrayType(type: Type): boolean {
return type.flags & TypeFlags.Reference && (type).target === globalArrayType;
}
@@ -3183,17 +3163,8 @@ module ts {
return type;
}
- function getWidenedTypeOfArrayLiteral(type: Type): Type {
- var elementType = (type).typeArguments[0];
- var widenedType = getWidenedType(elementType);
-
- type = elementType !== widenedType ? createArrayType(widenedType) : type;
-
- return type;
- }
-
/* If we are widening on a literal, then we may need to the 'node' parameter for reporting purposes */
- function getWidenedType(type: Type): Type {
+ function getWidenedType(type: Type, supressNoImplicitAnyErrors?: boolean): Type {
if (type.flags & (TypeFlags.Undefined | TypeFlags.Null)) {
return anyType;
}
@@ -3204,6 +3175,54 @@ module ts {
return getWidenedTypeOfArrayLiteral(type);
}
return type;
+
+ function getWidenedTypeOfObjectLiteral(type: Type): Type {
+ var properties = getPropertiesOfType(type);
+ if (properties.length) {
+ var widenedTypes: Type[] = [];
+ var propTypeWasWidened: boolean = false;
+ forEach(properties, p => {
+ var propType = getTypeOfSymbol(p);
+ var widenedType = getWidenedType(propType);
+ if (propType !== widenedType) {
+ propTypeWasWidened = true;
+
+ if (!supressNoImplicitAnyErrors && program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
+ }
+ }
+ widenedTypes.push(widenedType);
+ });
+ if (propTypeWasWidened) {
+ var members: SymbolTable = {};
+ var index = 0;
+ forEach(properties, p => {
+ var symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, p.name);
+ symbol.declarations = p.declarations;
+ symbol.parent = p.parent;
+ symbol.type = widenedTypes[index++];
+ symbol.target = p;
+ if (p.valueDeclaration) symbol.valueDeclaration = p.valueDeclaration;
+ members[symbol.name] = symbol;
+ });
+ var stringIndexType = getIndexTypeOfType(type, IndexKind.String);
+ var numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
+ if (stringIndexType) stringIndexType = getWidenedType(stringIndexType);
+ if (numberIndexType) numberIndexType = getWidenedType(numberIndexType);
+ type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType);
+ }
+ }
+ return type;
+ }
+
+ function getWidenedTypeOfArrayLiteral(type: Type): Type {
+ var elementType = (type).typeArguments[0];
+ var widenedType = getWidenedType(elementType, supressNoImplicitAnyErrors);
+
+ type = elementType !== widenedType ? createArrayType(widenedType) : type;
+
+ return type;
+ }
}
function forEachMatchingParameterType(source: Signature, target: Signature, callback: (s: Type, t: Type) => void) {
@@ -3951,7 +3970,7 @@ module ts {
}
// Fall back to any.
- if (program.getCompilerOptions().noImplicitAny && objectType !== anyType) {
+ if (compilerOptions.noImplicitAny && objectType !== anyType) {
error(node, Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
}
@@ -4049,19 +4068,6 @@ module ts {
return getSignatureInstantiation(signature, getInferredTypes(context));
}
- // Inferentially type an expression by a contextual parameter type (section 4.12.2 in TypeScript spec)
- function inferentiallyTypeExpession(expr: Expression, contextualType: Type, contextualMapper: TypeMapper): Type {
- var type = checkExpressionWithContextualType(expr, contextualType, contextualMapper);
- var signature = getSingleCallSignature(type);
- if (signature && signature.typeParameters) {
- var contextualSignature = getSingleCallSignature(contextualType);
- if (contextualSignature && !contextualSignature.typeParameters) {
- type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
- }
- }
- return type;
- }
-
function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument?: boolean[]): Type[] {
var typeParameters = signature.typeParameters;
var context = createInferenceContext(typeParameters);
@@ -4070,7 +4076,7 @@ module ts {
for (var i = 0; i < args.length; i++) {
if (!excludeArgument || excludeArgument[i] === undefined) {
var parameterType = getTypeAtPosition(signature, i);
- inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
+ inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
// Next, infer from those context sensitive arguments that are no longer excluded
@@ -4078,7 +4084,7 @@ module ts {
for (var i = 0; i < args.length; i++) {
if (excludeArgument[i] === false) {
var parameterType = getTypeAtPosition(signature, i);
- inferTypes(context, inferentiallyTypeExpession(args[i], parameterType, mapper), parameterType);
+ inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
}
}
}
@@ -4296,7 +4302,7 @@ module ts {
var declaration = signature.declaration;
if (declaration && (declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature)) {
// When resolved signature is a call signature (and not a construct signature) the result type is any
- if (program.getCompilerOptions().noImplicitAny) {
+ if (compilerOptions.noImplicitAny) {
error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
}
return anyType;
@@ -4309,7 +4315,7 @@ module ts {
var exprType = checkExpression(node.operand);
var targetType = getTypeFromTypeNode(node.type);
if (fullTypeCheck && targetType !== unknownType) {
- var widenedType = getWidenedType(exprType);
+ var widenedType = getWidenedType(exprType, /*supressNoImplicitAnyErrors*/ true);
if (!(isTypeAssignableTo(targetType, widenedType))) {
checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
}
@@ -4342,7 +4348,7 @@ module ts {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(func, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
@@ -4364,7 +4370,7 @@ module ts {
var widenedType = getWidenedType(commonType);
// Check and report for noImplicitAny if the best common type implicitly gets widened to an 'any'/arrays-of-'any' type.
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
var typeName = typeToString(widenedType);
if (func.name) {
@@ -4782,6 +4788,23 @@ module ts {
// have the wildcard function type; this form of type check is used during overload resolution to exclude
// contextually typed function and arrow expressions in the initial phase.
function checkExpression(node: Expression, contextualMapper?: TypeMapper): Type {
+ var type = checkExpressionNode(node, contextualMapper);
+ if (contextualMapper && contextualMapper !== identityMapper) {
+ var signature = getSingleCallSignature(type);
+ if (signature && signature.typeParameters) {
+ var contextualType = getContextualType(node);
+ if (contextualType) {
+ var contextualSignature = getSingleCallSignature(contextualType);
+ if (contextualSignature && !contextualSignature.typeParameters) {
+ type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
+ }
+ }
+ }
+ }
+ return type;
+ }
+
+ function checkExpressionNode(node: Expression, contextualMapper: TypeMapper): Type {
switch (node.kind) {
case SyntaxKind.Identifier:
return checkIdentifier(node);
@@ -4909,7 +4932,7 @@ module ts {
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollistionWithRequireExportsInGeneratedCode(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
- if (program.getCompilerOptions().noImplicitAny && !node.type) {
+ if (compilerOptions.noImplicitAny && !node.type) {
switch (node.kind) {
case SyntaxKind.ConstructSignature:
error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -5465,7 +5488,7 @@ module ts {
}
// If there is no body and no explicit return type, then report an error.
- if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
+ if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) {
// Ignore privates within ambient contexts; they exist purely for documentative purposes to avoid name clashing.
// (e.g. privates within .d.ts files do not expose type information)
if (!isPrivateWithinAmbient(node)) {
@@ -7099,7 +7122,7 @@ module ts {
function shouldEmitDeclarations() {
// If the declaration emit and there are no errors being reported in program or by checker
// declarations can be emitted
- return program.getCompilerOptions().declaration &&
+ return compilerOptions.declaration &&
!program.getDiagnostics().length &&
!getDiagnostics().length;
}
diff --git a/src/compiler/core.ts b/src/compiler/core.ts
index fbf767b91a9..c549231eacc 100644
--- a/src/compiler/core.ts
+++ b/src/compiler/core.ts
@@ -198,6 +198,9 @@ module ts {
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
+
var text = getLocaleSpecificMessage(message.key);
if (arguments.length > 4) {
@@ -252,6 +255,9 @@ module ts {
}
export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic {
+ Debug.assert(start >= 0, "start must be non-negative, is " + start);
+ Debug.assert(length >= 0, "length must be non-negative, is " + length);
+
var code = diagnosticChain.code;
var category = diagnosticChain.category;
var messageText = "";
diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts
index c589fb40323..dde11576817 100644
--- a/src/compiler/parser.ts
+++ b/src/compiler/parser.ts
@@ -81,7 +81,7 @@ module ts {
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
node = getErrorSpanForNode(node);
var file = getSourceFileOfNode(node);
- var start = skipTrivia(file.text, node.pos);
+ var start = node.kind === SyntaxKind.Missing ? node.pos : skipTrivia(file.text, node.pos);
var length = node.end - start;
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
@@ -2977,10 +2977,11 @@ module ts {
parseExpected(SyntaxKind.VarKeyword);
node.declarations = parseVariableDeclarationList(flags, /*noIn*/false);
parseSemicolon();
+ finishNode(node);
if (!node.declarations.length && file.syntacticErrors.length === errorCountBeforeVarStatement) {
grammarErrorOnNode(node, Diagnostics.Variable_declaration_list_cannot_be_empty);
}
- return finishNode(node);
+ return node;
}
function parseFunctionDeclaration(pos?: number, flags?: NodeFlags): FunctionDeclaration {
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 58a9bf8db60..715d01926f0 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -631,12 +631,10 @@ module ts {
}
export enum TypeFormatFlags {
- None = 0x00000000,
-
- /** writes Array instead T[] */
- WriteArrayAsGenericType = 0x00000001, // Declarations
-
- UseTypeOfFunction = 0x00000002, // instead of writing signature type of function use typeof
+ None = 0x00000000,
+ WriteArrayAsGenericType = 0x00000001, // Write Array instead T[]
+ UseTypeOfFunction = 0x00000002, // Write typeof instead of function type literal
+ NoTruncation = 0x00000004, // Don't truncate typeToString result
}
export enum SymbolAccessibility {
@@ -957,6 +955,7 @@ module ts {
locale?: string;
mapRoot?: string;
module?: ModuleKind;
+ noErrorTruncation?: boolean;
noImplicitAny?: boolean;
noLib?: boolean;
noLibCheck?: boolean;
@@ -969,7 +968,6 @@ module ts {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
-
[option: string]: any;
}
diff --git a/src/harness/harness.ts b/src/harness/harness.ts
index 654f240b4b5..5ee3139d8f7 100644
--- a/src/harness/harness.ts
+++ b/src/harness/harness.ts
@@ -622,6 +622,7 @@ module Harness {
options = options || { noResolve: false };
options.target = options.target || ts.ScriptTarget.ES3;
options.module = options.module || ts.ModuleKind.None;
+ options.noErrorTruncation = true;
if (settingsCallback) {
settingsCallback(null);
@@ -725,6 +726,10 @@ module Harness {
options.emitBOM = !!setting.value;
break;
+ case 'errortruncation':
+ options.noErrorTruncation = setting.value === 'false';
+ break;
+
default:
throw new Error('Unsupported compiler setting ' + setting.flag);
}
@@ -1030,7 +1035,7 @@ module Harness {
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
// List of allowed metadata names
- var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom"];
+ var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation"];
function extractCompilerSettings(content: string): CompilerSetting[] {
diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts
index a3b23d10f14..8fac5e45dab 100644
--- a/src/harness/typeWriter.ts
+++ b/src/harness/typeWriter.ts
@@ -86,7 +86,7 @@ class TypeWriterWalker {
column: lineAndCharacter.character,
syntaxKind: ts.SyntaxKind[node.kind],
sourceText: sourceText,
- type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.None)
+ type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation)
});
}
diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts
index 3a093bcfaf4..53f21708b3f 100644
--- a/src/lib/dom.generated.d.ts
+++ b/src/lib/dom.generated.d.ts
@@ -1886,6 +1886,23 @@ declare var HTMLCollection: {
new(): HTMLCollection;
}
+interface BlobPropertyBag {
+ type?: string;
+ endings?: string;
+}
+
+interface Blob {
+ type: string;
+ size: number;
+ msDetachStream(): any;
+ slice(start?: number, end?: number, contentType?: string): Blob;
+ msClose(): void;
+}
+declare var Blob: {
+ prototype: Blob;
+ new (blobParts?: any[], options?: BlobPropertyBag): Blob;
+}
+
interface NavigatorID {
appVersion: string;
appName: string;
@@ -10027,18 +10044,6 @@ declare var FileReader: {
new(): FileReader;
}
-interface Blob {
- type: string;
- size: number;
- msDetachStream(): any;
- slice(start?: number, end?: number, contentType?: string): Blob;
- msClose(): void;
-}
-declare var Blob: {
- prototype: Blob;
- new(): Blob;
-}
-
interface ApplicationCache extends EventTarget {
status: number;
ondownloading: (ev: Event) => any;
diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts
index 5dfaa2f646f..a6119989164 100644
--- a/src/lib/webworker.generated.d.ts
+++ b/src/lib/webworker.generated.d.ts
@@ -614,6 +614,11 @@ declare var FileReader: {
new(): FileReader;
}
+interface BlobPropertyBag {
+ type?: string;
+ endings?: string;
+}
+
interface Blob {
type: string;
size: number;
@@ -623,7 +628,7 @@ interface Blob {
}
declare var Blob: {
prototype: Blob;
- new(): Blob;
+ new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface MSStream {
diff --git a/tests/baselines/reference/commentsClassMembers.js b/tests/baselines/reference/commentsClassMembers.js
index a0cf8f2b631..298991c2eef 100644
--- a/tests/baselines/reference/commentsClassMembers.js
+++ b/tests/baselines/reference/commentsClassMembers.js
@@ -557,11 +557,11 @@ declare var i1_ncf: (b: number) => number;
declare var i1_ncr: number;
declare var i1_ncprop: number;
declare var i1_s_p: number;
-declare var i1_s_f: typeof s2;
+declare var i1_s_f: typeof c1.s2;
declare var i1_s_r: number;
declare var i1_s_prop: number;
declare var i1_s_nc_p: number;
-declare var i1_s_ncf: typeof nc_s2;
+declare var i1_s_ncf: typeof c1.nc_s2;
declare var i1_s_ncr: number;
declare var i1_s_ncprop: number;
declare var i1_c: typeof c1;
@@ -577,111 +577,3 @@ declare class cProperties {
private y;
}
declare var cProperties_i: cProperties;
-
-
-//// [DtsFileErrors]
-
-
-==== tests/cases/compiler/commentsClassMembers.d.ts (2 errors) ====
- /** This is comment for c1*/
- declare class c1 {
- /** p1 is property of c1*/
- p1: number;
- /** sum with property*/
- p2(/** number to add*/ b: number): number;
- /** getter property*/
- /** setter property*/
- p3: number;
- /** pp1 is property of c1*/
- private pp1;
- /** sum with property*/
- private pp2(/** number to add*/ b);
- /** getter property*/
- /** setter property*/
- private pp3;
- /** Constructor method*/
- constructor();
- /** s1 is static property of c1*/
- static s1: number;
- /** static sum with property*/
- static s2(/** number to add*/ b: number): number;
- /** static getter property*/
- /** setter property*/
- static s3: number;
- nc_p1: number;
- nc_p2(b: number): number;
- nc_p3: number;
- private nc_pp1;
- private nc_pp2(b);
- private nc_pp3;
- static nc_s1: number;
- static nc_s2(b: number): number;
- static nc_s3: number;
- a_p1: number;
- a_p2(b: number): number;
- a_p3: number;
- private a_pp1;
- private a_pp2(b);
- private a_pp3;
- static a_s1: number;
- static a_s2(b: number): number;
- static a_s3: number;
- /** p1 is property of c1 */
- b_p1: number;
- /** sum with property */
- b_p2(b: number): number;
- /** getter property */
- /** setter property */
- b_p3: number;
- /** pp1 is property of c1 */
- private b_pp1;
- /** sum with property */
- private b_pp2(b);
- /** getter property */
- /** setter property */
- private b_pp3;
- /** s1 is static property of c1 */
- static b_s1: number;
- /** static sum with property */
- static b_s2(b: number): number;
- /** static getter property
- */
- /** setter property
- */
- static b_s3: number;
- }
- declare var i1: c1;
- declare var i1_p: number;
- declare var i1_f: (b: number) => number;
- declare var i1_r: number;
- declare var i1_prop: number;
- declare var i1_nc_p: number;
- declare var i1_ncf: (b: number) => number;
- declare var i1_ncr: number;
- declare var i1_ncprop: number;
- declare var i1_s_p: number;
- declare var i1_s_f: typeof s2;
- ~~
-!!! Cannot find name 's2'.
- declare var i1_s_r: number;
- declare var i1_s_prop: number;
- declare var i1_s_nc_p: number;
- declare var i1_s_ncf: typeof nc_s2;
- ~~~~~
-!!! Cannot find name 'nc_s2'.
- declare var i1_s_ncr: number;
- declare var i1_s_ncprop: number;
- declare var i1_c: typeof c1;
- declare class cProperties {
- private val;
- /** getter only property*/
- p1: number;
- nc_p1: number;
- /**setter only property*/
- p2: number;
- nc_p2: number;
- x: number;
- private y;
- }
- declare var cProperties_i: cProperties;
-
\ No newline at end of file
diff --git a/tests/baselines/reference/errorWithTruncatedType.errors.txt b/tests/baselines/reference/errorWithTruncatedType.errors.txt
new file mode 100644
index 00000000000..7d3cab5f3c5
--- /dev/null
+++ b/tests/baselines/reference/errorWithTruncatedType.errors.txt
@@ -0,0 +1,15 @@
+==== tests/cases/compiler/errorWithTruncatedType.ts (1 errors) ====
+
+ var x: {
+ propertyWithAnExceedinglyLongName1: string;
+ propertyWithAnExceedinglyLongName2: string;
+ propertyWithAnExceedinglyLongName3: string;
+ propertyWithAnExceedinglyLongName4: string;
+ propertyWithAnExceedinglyLongName5: string;
+ };
+
+ // String representation of type of 'x' should be truncated in error message
+ var s: string = x;
+ ~
+!!! Type '{ propertyWithAnExceedinglyLongName1: string; propertyWithAnExceedinglyLongName2: string; propert...' is not assignable to type 'string'.
+
\ No newline at end of file
diff --git a/tests/baselines/reference/errorWithTruncatedType.js b/tests/baselines/reference/errorWithTruncatedType.js
new file mode 100644
index 00000000000..5fd45579a29
--- /dev/null
+++ b/tests/baselines/reference/errorWithTruncatedType.js
@@ -0,0 +1,18 @@
+//// [errorWithTruncatedType.ts]
+
+var x: {
+ propertyWithAnExceedinglyLongName1: string;
+ propertyWithAnExceedinglyLongName2: string;
+ propertyWithAnExceedinglyLongName3: string;
+ propertyWithAnExceedinglyLongName4: string;
+ propertyWithAnExceedinglyLongName5: string;
+};
+
+// String representation of type of 'x' should be truncated in error message
+var s: string = x;
+
+
+//// [errorWithTruncatedType.js]
+var x;
+// String representation of type of 'x' should be truncated in error message
+var s = x;
diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt
index c185756667a..8de5453e2af 100644
--- a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt
+++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt
@@ -10,9 +10,9 @@
// more args not allowed
var r2 = foo({ cb: (x: T, y: T) => '' }); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: any) => string; }'.
+!!! Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'.
!!! Types of property 'cb' are incompatible:
-!!! Type '(x: T, y: T) => string' is not assignable to type '(t: any) => string'.
+!!! Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'.
var r3 = foo({ cb: (x: string, y: number) => '' }); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'.
diff --git a/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types b/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types
index 0596081ade3..c411dd00514 100644
--- a/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types
+++ b/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types
@@ -20,10 +20,10 @@ declare function identity(y: V): V;
>V : V
var s = map("", () => { return { x: identity }; });
->s : any
->map("", () => { return { x: identity }; }) : any
+>s : string
+>map("", () => { return { x: identity }; }) : string
>map : (x: T, f: () => { x: (s: T) => U; }) => U
->() => { return { x: identity }; } : () => { x: (y: V) => V; }
+>() => { return { x: identity }; } : () => { x: (y: string) => string; }
>{ x: identity } : { x: (y: V) => V; }
>x : (y: V) => V
>identity : (y: V) => V
diff --git a/tests/baselines/reference/noImplicitAnyInCastExpression.errors.txt b/tests/baselines/reference/noImplicitAnyInCastExpression.errors.txt
new file mode 100644
index 00000000000..bc7542df511
--- /dev/null
+++ b/tests/baselines/reference/noImplicitAnyInCastExpression.errors.txt
@@ -0,0 +1,20 @@
+==== tests/cases/compiler/noImplicitAnyInCastExpression.ts (1 errors) ====
+
+ // verify no noImplictAny errors reported with cast expression
+
+ interface IFoo {
+ a: number;
+ b: string;
+ }
+
+ // Expr type not assignable to target type
+ ({ a: null });
+
+ // Expr type assignable to target type
+ ({ a: 2, b: undefined });
+
+ // Neither types is assignable to each other
+ ({ c: null });
+ ~~~~~~~~~~~~~~~~~
+!!! Neither type '{ c: null; }' nor type 'IFoo' is assignable to the other:
+!!! Property 'a' is missing in type '{ c: null; }'.
\ No newline at end of file
diff --git a/tests/baselines/reference/noImplicitAnyInCastExpression.js b/tests/baselines/reference/noImplicitAnyInCastExpression.js
new file mode 100644
index 00000000000..1b7cc59c7c0
--- /dev/null
+++ b/tests/baselines/reference/noImplicitAnyInCastExpression.js
@@ -0,0 +1,26 @@
+//// [noImplicitAnyInCastExpression.ts]
+
+// verify no noImplictAny errors reported with cast expression
+
+interface IFoo {
+ a: number;
+ b: string;
+}
+
+// Expr type not assignable to target type
+({ a: null });
+
+// Expr type assignable to target type
+({ a: 2, b: undefined });
+
+// Neither types is assignable to each other
+({ c: null });
+
+//// [noImplicitAnyInCastExpression.js]
+// verify no noImplictAny errors reported with cast expression
+// Expr type not assignable to target type
+{ a: null };
+// Expr type assignable to target type
+{ a: 2, b: undefined };
+// Neither types is assignable to each other
+{ c: null };
diff --git a/tests/baselines/reference/parserEqualsGreaterThanAfterFunction1.errors.txt b/tests/baselines/reference/parserEqualsGreaterThanAfterFunction1.errors.txt
index e3ff187a00e..9f428d7fea7 100644
--- a/tests/baselines/reference/parserEqualsGreaterThanAfterFunction1.errors.txt
+++ b/tests/baselines/reference/parserEqualsGreaterThanAfterFunction1.errors.txt
@@ -2,5 +2,5 @@
function =>
~~
!!! Identifier expected.
-
+
!!! Function implementation is missing or not immediately following the declaration.
\ No newline at end of file
diff --git a/tests/baselines/reference/parserEqualsGreaterThanAfterFunction2.errors.txt b/tests/baselines/reference/parserEqualsGreaterThanAfterFunction2.errors.txt
index 24866e9e424..4e9b5fbaa86 100644
--- a/tests/baselines/reference/parserEqualsGreaterThanAfterFunction2.errors.txt
+++ b/tests/baselines/reference/parserEqualsGreaterThanAfterFunction2.errors.txt
@@ -8,5 +8,5 @@
!!! ',' expected.
!!! ')' expected.
-
+
!!! Function implementation is missing or not immediately following the declaration.
\ No newline at end of file
diff --git a/tests/baselines/reference/parserVariableDeclaration6.errors.txt b/tests/baselines/reference/parserVariableDeclaration6.errors.txt
index 01f3935495d..466384c7e0c 100644
--- a/tests/baselines/reference/parserVariableDeclaration6.errors.txt
+++ b/tests/baselines/reference/parserVariableDeclaration6.errors.txt
@@ -1,4 +1,4 @@
==== tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration6.ts (1 errors) ====
var
-
+ ~~~
!!! Variable declaration list cannot be empty.
\ No newline at end of file
diff --git a/tests/baselines/reference/parserVariableDeclaration8.errors.txt b/tests/baselines/reference/parserVariableDeclaration8.errors.txt
index 5e7f335a920..9e2f8edfd25 100644
--- a/tests/baselines/reference/parserVariableDeclaration8.errors.txt
+++ b/tests/baselines/reference/parserVariableDeclaration8.errors.txt
@@ -1,4 +1,4 @@
==== tests/cases/conformance/parser/ecmascript5/VariableDeclarations/parserVariableDeclaration8.ts (1 errors) ====
var ;
-
+ ~~~~~
!!! Variable declaration list cannot be empty.
\ No newline at end of file
diff --git a/tests/baselines/reference/recursiveFunctionTypes1.types b/tests/baselines/reference/recursiveFunctionTypes1.types
index 535555ef13d..b78494ba24c 100644
--- a/tests/baselines/reference/recursiveFunctionTypes1.types
+++ b/tests/baselines/reference/recursiveFunctionTypes1.types
@@ -3,8 +3,8 @@ class C {
>C : C
static g(t: typeof C.g){ }
->g : (t: typeof g) => void
->t : (t: typeof g) => void
+>g : (t: typeof C.g) => void
+>t : (t: typeof C.g) => void
>C : typeof C
->g : (t: typeof g) => void
+>g : (t: typeof C.g) => void
}
diff --git a/tests/cases/compiler/errorWithTruncatedType.ts b/tests/cases/compiler/errorWithTruncatedType.ts
new file mode 100644
index 00000000000..307ff642ed9
--- /dev/null
+++ b/tests/cases/compiler/errorWithTruncatedType.ts
@@ -0,0 +1,12 @@
+// @errortruncation: true
+
+var x: {
+ propertyWithAnExceedinglyLongName1: string;
+ propertyWithAnExceedinglyLongName2: string;
+ propertyWithAnExceedinglyLongName3: string;
+ propertyWithAnExceedinglyLongName4: string;
+ propertyWithAnExceedinglyLongName5: string;
+};
+
+// String representation of type of 'x' should be truncated in error message
+var s: string = x;
diff --git a/tests/cases/compiler/noImplicitAnyInCastExpression.ts b/tests/cases/compiler/noImplicitAnyInCastExpression.ts
new file mode 100644
index 00000000000..5566b898a07
--- /dev/null
+++ b/tests/cases/compiler/noImplicitAnyInCastExpression.ts
@@ -0,0 +1,17 @@
+//@noImplicitAny: true
+
+// verify no noImplictAny errors reported with cast expression
+
+interface IFoo {
+ a: number;
+ b: string;
+}
+
+// Expr type not assignable to target type
+({ a: null });
+
+// Expr type assignable to target type
+({ a: 2, b: undefined });
+
+// Neither types is assignable to each other
+({ c: null });
\ No newline at end of file
diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts
index 05cf7a10f20..40e347fed50 100644
--- a/tests/webTestServer.ts
+++ b/tests/webTestServer.ts
@@ -227,11 +227,15 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons
send('success', res, null);
break;
case RequestType.DeleteFile:
- fs.unlinkSync(reqPath);
+ if (fs.existsSync(reqPath)) {
+ fs.unlinkSync(reqPath);
+ }
send('success', res, null);
break;
case RequestType.DeleteDir:
- fs.rmdirSync(reqPath);
+ if (fs.existsSync(reqPath)) {
+ fs.rmdirSync(reqPath);
+ }
send('success', res, null);
break;
case RequestType.AppendFile: