From 59a31acca1887e92cccc5f65558a36267a924650 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 10 Dec 2014 14:03:14 -0800 Subject: [PATCH 01/93] conditionals are now introduce indentation scope --- src/services/formatting/smartIndenter.ts | 1 + .../cases/fourslash/formattingConditionals.ts | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/cases/fourslash/formattingConditionals.ts diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 8da1ef0c93b..6288f0b07f3 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -341,6 +341,7 @@ module ts.formatting { case SyntaxKind.VariableDeclaration: case SyntaxKind.ExportAssignment: case SyntaxKind.ReturnStatement: + case SyntaxKind.ConditionalExpression: return true; } return false; diff --git a/tests/cases/fourslash/formattingConditionals.ts b/tests/cases/fourslash/formattingConditionals.ts new file mode 100644 index 00000000000..65029134b87 --- /dev/null +++ b/tests/cases/fourslash/formattingConditionals.ts @@ -0,0 +1,23 @@ +/// + + +////var v = +/////*0*/a === b +/////*1*/? c +/////*2*/: d; + +////var v = a === b +/////*3*/? c +/////*4*/: d; + +function verifyLine(marker: string, content: string) { + goTo.marker(marker); + verify.currentLineContentIs(content); +} + +format.document(); +verifyLine("0", " a === b"); +verifyLine("1", " ? c"); +verifyLine("2", " : d;"); +verifyLine("3", " ? c"); +verifyLine("4", " : d;"); From 6b438c22fda219d0adb8f63f784d057468f131ee Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 10 Dec 2014 22:01:34 -0800 Subject: [PATCH 02/93] added test for inherited indentation --- .../cases/fourslash/formattingConditionals.ts | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/cases/fourslash/formattingConditionals.ts b/tests/cases/fourslash/formattingConditionals.ts index 65029134b87..cb6edfcd56b 100644 --- a/tests/cases/fourslash/formattingConditionals.ts +++ b/tests/cases/fourslash/formattingConditionals.ts @@ -10,14 +10,35 @@ /////*3*/? c /////*4*/: d; +////var x = +/////*5*/a +/////*6*/? function(){ +/////*7*/var z = 1 +/////*8*/} +/////*9*/: function(){ +/////*10*/var z = 2 +/////*11*/} + + + + function verifyLine(marker: string, content: string) { goTo.marker(marker); verify.currentLineContentIs(content); } format.document(); -verifyLine("0", " a === b"); -verifyLine("1", " ? c"); -verifyLine("2", " : d;"); -verifyLine("3", " ? c"); -verifyLine("4", " : d;"); +verifyLine("0", " a === b"); +verifyLine("1", " ? c"); +verifyLine("2", " : d;"); + +verifyLine("3", " ? c"); +verifyLine("4", " : d;"); + +verifyLine("5", " a"); +verifyLine("6", " ? function() {"); +verifyLine("7", " var z = 1"); +verifyLine("8", " }"); +verifyLine("9", " : function() {"); +verifyLine("10", " var z = 2"); +verifyLine("11", " }"); From ed9234ed320ed8708c88daf4d32317f7a6b3dd12 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 10 Dec 2014 15:08:26 -0800 Subject: [PATCH 03/93] do not indent leading comments that attached to tokens with errors --- src/services/formatting/formatting.ts | 13 +++++++++--- .../formattingCommentsBeforeErrors.ts | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/formattingCommentsBeforeErrors.ts diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 22f90a0cdee..74ffa11bfb7 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -622,14 +622,21 @@ module ts.formatting { var tokenStart = sourceFile.getLineAndCharacterFromPosition(currentTokenInfo.token.pos); if (isTokenInRange) { + var rangeHasError = rangeContainsError(currentTokenInfo.token); // save prevStartLine since processRange will overwrite this value with current ones var prevStartLine = previousRangeStartLine; lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); - if (lineAdded !== undefined) { - indentToken = lineAdded; + if (rangeHasError) { + // do not indent comments\token if token range overlaps with some error + indentToken = false; } else { - indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine; + if (lineAdded !== undefined) { + indentToken = lineAdded; + } + else { + indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine; + } } } diff --git a/tests/cases/fourslash/formattingCommentsBeforeErrors.ts b/tests/cases/fourslash/formattingCommentsBeforeErrors.ts new file mode 100644 index 00000000000..bb7e616b267 --- /dev/null +++ b/tests/cases/fourslash/formattingCommentsBeforeErrors.ts @@ -0,0 +1,20 @@ +/// + +////module A { +//// interface B { +//// // a +//// // b +//// baz(); +/////*0*/ // d /*1*/asd a +//// // e +//// foo(); +//// // f asd +//// // g as +//// bar(); +//// } +////} + +goTo.marker("1"); +edit.insert("\n"); +goTo.marker("0"); +verify.currentLineContentIs(" // d "); \ No newline at end of file From 2155b6dea86431436e526c929b4494180363ff7a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 12 Dec 2014 16:17:30 -0800 Subject: [PATCH 04/93] Preserve const enums in typeScriptServices.js --- Jakefile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Jakefile b/Jakefile index 7c58800c79d..057ba227289 100644 --- a/Jakefile +++ b/Jakefile @@ -181,7 +181,7 @@ var compilerFilename = "tsc.js"; * @param keepComments: false to compile using --removeComments * @param callback: a function to execute after the compilation process ends */ -function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, keepComments, noResolve, callback) { +function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, callback) { file(outFile, prereqs, function() { var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory; var options = "--module commonjs -noImplicitAny"; @@ -194,7 +194,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu options += " --declaration"; } - if (useDebugMode) { + if (useDebugMode || preserveConstEnums) { options += " --preserveConstEnums"; } @@ -310,7 +310,15 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename); compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false); var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js"); -compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler*/ true); +compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), + /*prefixes*/ [copyright], + /*useBuiltCompiler*/ true, + /*noOutFile*/ false, + /*generateDeclarations*/ false, + /*outDir*/ undefined, + /*preserveConstEnums*/ true, + /*keepComments*/ false, + /*noResolve*/ false); var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts"); var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts"); @@ -321,6 +329,7 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright /*noOutFile*/ true, /*generateDeclarations*/ true, /*outDir*/ tempDirPath, + /*preserveConstEnums*/ true, /*keepComments*/ true, /*noResolve*/ true, /*callback*/ function () { From b552613fb5270a3e163d4287b888a9e0a2165a14 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 12 Dec 2014 14:13:46 -0800 Subject: [PATCH 05/93] Switch parsePrimaryExpression to if-else style --- src/compiler/parser.ts | 62 +++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b490b1d6826..1a3a87952d1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2669,35 +2669,41 @@ module ts { } function parsePrimaryExpression(): PrimaryExpression { - switch (token) { - case SyntaxKind.ThisKeyword: - case SyntaxKind.SuperKeyword: - case SyntaxKind.NullKeyword: - case SyntaxKind.TrueKeyword: - case SyntaxKind.FalseKeyword: - return parseTokenNode(); - case SyntaxKind.NumericLiteral: - case SyntaxKind.StringLiteral: - case SyntaxKind.NoSubstitutionTemplateLiteral: + if (token === SyntaxKind.ThisKeyword || + token === SyntaxKind.SuperKeyword || + token === SyntaxKind.NullKeyword || + token === SyntaxKind.TrueKeyword || + token === SyntaxKind.FalseKeyword) { + return parseTokenNode(); + } + else if (token === SyntaxKind.NumericLiteral || + token === SyntaxKind.StringLiteral || + token === SyntaxKind.NoSubstitutionTemplateLiteral) { + return parseLiteralNode(); + } + else if (token === SyntaxKind.OpenParenToken) { + return parseParenthesizedExpression(); + } + else if (token === SyntaxKind.OpenBracketToken) { + return parseArrayLiteralExpression(); + } + else if (token === SyntaxKind.OpenBraceToken) { + return parseObjectLiteralExpression(); + } + else if (token === SyntaxKind.FunctionKeyword) { + return parseFunctionExpression(); + } + else if (token === SyntaxKind.NewKeyword) { + return parseNewExpression(); + } + else if (token === SyntaxKind.SlashToken || + token === SyntaxKind.SlashEqualsToken) { + if (reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { return parseLiteralNode(); - case SyntaxKind.OpenParenToken: - return parseParenthesizedExpression(); - case SyntaxKind.OpenBracketToken: - return parseArrayLiteralExpression(); - case SyntaxKind.OpenBraceToken: - return parseObjectLiteralExpression(); - case SyntaxKind.FunctionKeyword: - return parseFunctionExpression(); - case SyntaxKind.NewKeyword: - return parseNewExpression(); - case SyntaxKind.SlashToken: - case SyntaxKind.SlashEqualsToken: - if (reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { - return parseLiteralNode(); - } - break; - case SyntaxKind.TemplateHead: - return parseTemplateExpression(); + } + } + else if (token === SyntaxKind.TemplateHead) { + return parseTemplateExpression(); } return parseIdentifier(Diagnostics.Expression_expected); From b65a422c7a53528916eea9b43cb57e7ff91e886b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 15 Dec 2014 14:11:21 -0800 Subject: [PATCH 06/93] Fixed contextual typing for tagged template expressions. --- src/compiler/checker.ts | 27 +++- .../taggedTemplateContextualTyping.js | 45 +++++++ .../taggedTemplateContextualTyping.types | 124 ++++++++++++++++++ .../taggedTemplateContextualTyping.ts | 22 ++++ ...TypedFunctionInTaggedTemplateExpression.ts | 44 +++++++ 5 files changed, 255 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/taggedTemplateContextualTyping.js create mode 100644 tests/baselines/reference/taggedTemplateContextualTyping.types create mode 100644 tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts create mode 100644 tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 889b387d4f4..502b87c0c9d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4813,17 +4813,25 @@ module ts { return undefined; } - // In a typed function call, an argument expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(node: Expression): Type { - var callExpression = node.parent; - var argIndex = indexOf(callExpression.arguments, node); + // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. + function getContextualTypeForArgument(callTarget: CallLikeExpression, arg: Expression): Type { + var args = getEffectiveCallArguments(callTarget); + var argIndex = indexOf(args, arg); if (argIndex >= 0) { - var signature = getResolvedSignature(callExpression); + var signature = getResolvedSignature(callTarget); return getTypeAtPosition(signature, argIndex); } return undefined; } + function getContextualTypeForSubstitutionExpression(template: TemplateExpression, substitutionExpression: Expression) { + if (template.parent.kind === SyntaxKind.TaggedTemplateExpression) { + return getContextualTypeForArgument(template.parent, substitutionExpression); + } + + return undefined; + } + function getContextualTypeForBinaryOperand(node: Expression): Type { var binaryExpression = node.parent; var operator = binaryExpression.operator; @@ -4959,7 +4967,7 @@ module ts { return getContextualTypeForReturnExpression(node); case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: - return getContextualTypeForArgument(node); + return getContextualTypeForArgument(parent, node); case SyntaxKind.TypeAssertionExpression: return getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: @@ -4970,6 +4978,11 @@ module ts { return getContextualTypeForElementExpression(node); case SyntaxKind.ConditionalExpression: return getContextualTypeForConditionalOperand(node); + case SyntaxKind.TemplateExpression: + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case SyntaxKind.TemplateSpan: + Debug.assert(parent.parent.kind === SyntaxKind.TemplateExpression); + return getContextualTypeForSubstitutionExpression(parent.parent, node); } return undefined; } @@ -5571,7 +5584,7 @@ module ts { } /** - * Returns the effective arguments for an expression that works like a function invokation. + * Returns the effective arguments for an expression that works like a function invocation. * * If 'node' is a CallExpression or a NewExpression, then its argument list is returned. * If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution diff --git a/tests/baselines/reference/taggedTemplateContextualTyping.js b/tests/baselines/reference/taggedTemplateContextualTyping.js new file mode 100644 index 00000000000..64b43031c76 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateContextualTyping.js @@ -0,0 +1,45 @@ +//// [taggedTemplateContextualTyping.ts] + +function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; +function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; +function tempTag1(...rest: any[]): T { + return undefined; +} + +tempTag1 `${ x => x }${ 10 }`; +tempTag1 `${ x => x }${ y => y }${ 10 }`; +tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; +tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +function tempTag2(...rest: any[]): any { + return undefined; +} + +tempTag2 `${ x => x }${ 0 }`; +tempTag2 `${ x => x }${ y => y }${ "hello" }`; +tempTag2 `${ x => x }${ 0 }`; + +//// [taggedTemplateContextualTyping.js] +function tempTag1() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + return undefined; +} +tempTag1 `${function (x) { return x; }}${10}`; +tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${10}`; +tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${undefined}`; +tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${undefined}`; +function tempTag2() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + return undefined; +} +tempTag2 `${function (x) { return x; }}${0}`; +tempTag2 `${function (x) { return x; }}${function (y) { return y; }}${"hello"}`; +tempTag2 `${function (x) { return x; }}${0}`; diff --git a/tests/baselines/reference/taggedTemplateContextualTyping.types b/tests/baselines/reference/taggedTemplateContextualTyping.types new file mode 100644 index 00000000000..d8d050e4643 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateContextualTyping.types @@ -0,0 +1,124 @@ +=== tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts === + +function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>templateStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>f : (x: T) => T +>x : T +>T : T +>T : T +>x : T +>T : T +>T : T + +function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>templateStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>f : (x: T) => T +>x : T +>T : T +>T : T +>h : (y: T) => T +>y : T +>T : T +>T : T +>x : T +>T : T +>T : T + +function tempTag1(...rest: any[]): T { +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>rest : any[] +>T : T + + return undefined; +>undefined : undefined +} + +tempTag1 `${ x => x }${ 10 }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: number) => number +>x : number +>x : number + +tempTag1 `${ x => x }${ y => y }${ 10 }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: number) => number +>x : number +>x : number +>y => y : (y: number) => number +>y : number +>y : number + +tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: number) => number +>x : number +>x : number +>(y: number) => y : (y: number) => number +>y : number +>y : number +>undefined : undefined + +tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>(x: number) => x : (x: number) => number +>x : number +>x : number +>y => y : (y: number) => number +>y : number +>y : number +>undefined : undefined + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>templateStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>f : (x: number) => number +>x : number +>x : number + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>templateStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>f : (x: string) => string +>x : string +>h : (y: string) => string +>y : string +>x : string + +function tempTag2(...rest: any[]): any { +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>rest : any[] + + return undefined; +>undefined : undefined +} + +tempTag2 `${ x => x }${ 0 }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>x => x : (x: number) => number +>x : number +>x : number + +tempTag2 `${ x => x }${ y => y }${ "hello" }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>x => x : (x: string) => string +>x : string +>x : string +>y => y : (y: string) => string +>y : string +>y : string + +tempTag2 `${ x => x }${ 0 }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>x => x : (x: number) => number +>x : number +>x : number + diff --git a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts new file mode 100644 index 00000000000..5d6137a13ac --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts @@ -0,0 +1,22 @@ +// @target: ES6 + +function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; +function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; +function tempTag1(...rest: any[]): T { + return undefined; +} + +tempTag1 `${ x => x }${ 10 }`; +tempTag1 `${ x => x }${ y => y }${ 10 }`; +tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; +tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +function tempTag2(...rest: any[]): any { + return undefined; +} + +tempTag2 `${ x => x }${ 0 }`; +tempTag2 `${ x => x }${ y => y }${ "hello" }`; +tempTag2 `${ x => x }${ 0 }`; \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts b/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts new file mode 100644 index 00000000000..6d30d59ebd9 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts @@ -0,0 +1,44 @@ +/// + +////function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; +////function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; +////function tempTag1(...rest: any[]): T { +//// return undefined; +////} +//// +////tempTag1 `${ x => /*0*/x }${ 10 }`; +////tempTag1 `${ x => /*1*/x }${ x => /*2*/x }${ 10 }`; +////tempTag1 `${ x => /*3*/x }${ (x: number) => /*4*/x }${ undefined }`; +////tempTag1 `${ (x: number) => /*5*/x }${ x => /*6*/x }${ undefined }`; +//// +////function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +////function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +////function tempTag2(...rest: any[]): any { +//// return undefined; +////} +//// +////tempTag2 `${ x => /*7*/x }${ 0 }`; +////tempTag2 `${ x => /*8*/x }${ undefined }`; +////tempTag2 `${ x => /*9*/x }${ x => /*10*/x }${ "hello" }`; +////tempTag2 `${ x => /*11*/x }${ undefined }${ "hello" }`; + +// The first group of parameters, [0, 8], should all be contextually typed as 'number'. +// The second group, [9, 11], should be typed as 'string'. +var numTypedVariableCount = 9; +var strTypedVariableCount = 3; + +var markers = test.markers(); + +if (numTypedVariableCount + strTypedVariableCount !== markers.length) { + throw "Unexpected number of markers in file."; +} + +for (var i = 0; i < numTypedVariableCount; i++) { + goTo.marker("" + i); + verify.quickInfoIs("(parameter) x: number"); +} + +for (var i = 0; i < strTypedVariableCount; i++) { + goTo.marker("" + (i + numTypedVariableCount)); + verify.quickInfoIs("(parameter) x: string"); +} \ No newline at end of file From e43e5c3cde7bd6619e4c5133ea76152e2241bfb7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 15 Dec 2014 14:13:31 -0800 Subject: [PATCH 07/93] Removed unnecessary case; substitution expressions only occur in TemplateSpans. --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 502b87c0c9d..dcbe7162b76 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4978,8 +4978,6 @@ module ts { return getContextualTypeForElementExpression(node); case SyntaxKind.ConditionalExpression: return getContextualTypeForConditionalOperand(node); - case SyntaxKind.TemplateExpression: - return getContextualTypeForSubstitutionExpression(parent.parent, node); case SyntaxKind.TemplateSpan: Debug.assert(parent.parent.kind === SyntaxKind.TemplateExpression); return getContextualTypeForSubstitutionExpression(parent.parent, node); From e68c53f708c69e7ea509f2240b318de03c9e7b39 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 15 Dec 2014 14:55:46 -0800 Subject: [PATCH 08/93] Separated fourslash test to two files. --- ...TypedFunctionInTaggedTemplateExpression.ts | 44 ------------------- ...ypedFunctionInTaggedTemplateExpression1.ts | 19 ++++++++ ...ypedFunctionInTaggedTemplateExpression2.ts | 31 +++++++++++++ 3 files changed, 50 insertions(+), 44 deletions(-) delete mode 100644 tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts create mode 100644 tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression1.ts create mode 100644 tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression2.ts diff --git a/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts b/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts deleted file mode 100644 index 6d30d59ebd9..00000000000 --- a/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -////function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; -////function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; -////function tempTag1(...rest: any[]): T { -//// return undefined; -////} -//// -////tempTag1 `${ x => /*0*/x }${ 10 }`; -////tempTag1 `${ x => /*1*/x }${ x => /*2*/x }${ 10 }`; -////tempTag1 `${ x => /*3*/x }${ (x: number) => /*4*/x }${ undefined }`; -////tempTag1 `${ (x: number) => /*5*/x }${ x => /*6*/x }${ undefined }`; -//// -////function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; -////function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; -////function tempTag2(...rest: any[]): any { -//// return undefined; -////} -//// -////tempTag2 `${ x => /*7*/x }${ 0 }`; -////tempTag2 `${ x => /*8*/x }${ undefined }`; -////tempTag2 `${ x => /*9*/x }${ x => /*10*/x }${ "hello" }`; -////tempTag2 `${ x => /*11*/x }${ undefined }${ "hello" }`; - -// The first group of parameters, [0, 8], should all be contextually typed as 'number'. -// The second group, [9, 11], should be typed as 'string'. -var numTypedVariableCount = 9; -var strTypedVariableCount = 3; - -var markers = test.markers(); - -if (numTypedVariableCount + strTypedVariableCount !== markers.length) { - throw "Unexpected number of markers in file."; -} - -for (var i = 0; i < numTypedVariableCount; i++) { - goTo.marker("" + i); - verify.quickInfoIs("(parameter) x: number"); -} - -for (var i = 0; i < strTypedVariableCount; i++) { - goTo.marker("" + (i + numTypedVariableCount)); - verify.quickInfoIs("(parameter) x: string"); -} \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression1.ts b/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression1.ts new file mode 100644 index 00000000000..ce6b454843a --- /dev/null +++ b/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression1.ts @@ -0,0 +1,19 @@ +/// + +////function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; +////function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; +////function tempTag1(...rest: any[]): T { +//// return undefined; +////} +//// +////tempTag1 `${ x => /*0*/x }${ 10 }`; +////tempTag1 `${ x => /*1*/x }${ x => /*2*/x }${ 10 }`; +////tempTag1 `${ x => /*3*/x }${ (x: number) => /*4*/x }${ undefined }`; +////tempTag1 `${ (x: number) => /*5*/x }${ x => /*6*/x }${ undefined }`; + +var markers = test.markers(); + +markers.forEach(marker => { + goTo.position(marker.position); + verify.quickInfoIs("(parameter) x: number"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression2.ts b/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression2.ts new file mode 100644 index 00000000000..d878d601416 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForContextuallyTypedFunctionInTaggedTemplateExpression2.ts @@ -0,0 +1,31 @@ +/// + +////function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +////function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +////function tempTag2(...rest: any[]): any { +//// return undefined; +////} +//// +////tempTag2 `${ x => /*0*/x }${ 0 }`; +////tempTag2 `${ /*1*/x => /*2*/x }${ undefined }`; +////tempTag2 `${ x => /*3*/x }${ x => /*4*/x }${ "hello" }`; +////tempTag2 `${ x => /*5*/x }${ undefined }${ "hello" }`; + +// The first group of parameters, [0, 2], should all be contextually typed as 'number'. +// The second group, [3, 5], should be typed as 'string'. +var numTypedVariableCount = 3; +var strTypedVariableCount = 3; + +if (numTypedVariableCount + strTypedVariableCount !== test.markers().length) { + throw "Unexpected number of markers in file."; +} + +for (var i = 0; i < numTypedVariableCount; i++) { + goTo.marker("" + i); + verify.quickInfoIs("(parameter) x: number"); +} + +for (var i = 0; i < strTypedVariableCount; i++) { + goTo.marker("" + (i + numTypedVariableCount)); + verify.quickInfoIs("(parameter) x: string"); +} \ No newline at end of file From 0263d6007198ba9b4db19946cbee97197212efc3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 15 Dec 2014 15:01:33 -0800 Subject: [PATCH 09/93] Split contextual typing test for substitution expressions into two tests. --- ....js => taggedTemplateContextualTyping1.js} | 25 ++-------- ... => taggedTemplateContextualTyping1.types} | 49 +------------------ .../taggedTemplateContextualTyping2.js | 23 +++++++++ .../taggedTemplateContextualTyping2.types | 49 +++++++++++++++++++ ....ts => taggedTemplateContextualTyping1.ts} | 10 ---- .../taggedTemplateContextualTyping2.ts | 11 +++++ 6 files changed, 87 insertions(+), 80 deletions(-) rename tests/baselines/reference/{taggedTemplateContextualTyping.js => taggedTemplateContextualTyping1.js} (51%) rename tests/baselines/reference/{taggedTemplateContextualTyping.types => taggedTemplateContextualTyping1.types} (51%) create mode 100644 tests/baselines/reference/taggedTemplateContextualTyping2.js create mode 100644 tests/baselines/reference/taggedTemplateContextualTyping2.types rename tests/cases/conformance/expressions/contextualTyping/{taggedTemplateContextualTyping.ts => taggedTemplateContextualTyping1.ts} (52%) create mode 100644 tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts diff --git a/tests/baselines/reference/taggedTemplateContextualTyping.js b/tests/baselines/reference/taggedTemplateContextualTyping1.js similarity index 51% rename from tests/baselines/reference/taggedTemplateContextualTyping.js rename to tests/baselines/reference/taggedTemplateContextualTyping1.js index 64b43031c76..1ac371a8ae4 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping.js +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.js @@ -1,4 +1,4 @@ -//// [taggedTemplateContextualTyping.ts] +//// [taggedTemplateContextualTyping1.ts] function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; @@ -10,18 +10,9 @@ tempTag1 `${ x => x }${ 10 }`; tempTag1 `${ x => x }${ y => y }${ 10 }`; tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; - -function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; -function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; -function tempTag2(...rest: any[]): any { - return undefined; -} - -tempTag2 `${ x => x }${ 0 }`; -tempTag2 `${ x => x }${ y => y }${ "hello" }`; -tempTag2 `${ x => x }${ 0 }`; -//// [taggedTemplateContextualTyping.js] + +//// [taggedTemplateContextualTyping1.js] function tempTag1() { var rest = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -33,13 +24,3 @@ tempTag1 `${function (x) { return x; }}${10}`; tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${10}`; tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${undefined}`; tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${undefined}`; -function tempTag2() { - var rest = []; - for (var _i = 0; _i < arguments.length; _i++) { - rest[_i - 0] = arguments[_i]; - } - return undefined; -} -tempTag2 `${function (x) { return x; }}${0}`; -tempTag2 `${function (x) { return x; }}${function (y) { return y; }}${"hello"}`; -tempTag2 `${function (x) { return x; }}${0}`; diff --git a/tests/baselines/reference/taggedTemplateContextualTyping.types b/tests/baselines/reference/taggedTemplateContextualTyping1.types similarity index 51% rename from tests/baselines/reference/taggedTemplateContextualTyping.types rename to tests/baselines/reference/taggedTemplateContextualTyping1.types index d8d050e4643..bb8e6a1a87c 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping.types +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts === +=== tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts === function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; >tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } @@ -75,50 +75,3 @@ tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; >y : number >undefined : undefined -function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->templateStrs : TemplateStringsArray ->TemplateStringsArray : TemplateStringsArray ->f : (x: number) => number ->x : number ->x : number - -function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->templateStrs : TemplateStringsArray ->TemplateStringsArray : TemplateStringsArray ->f : (x: string) => string ->x : string ->h : (y: string) => string ->y : string ->x : string - -function tempTag2(...rest: any[]): any { ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->rest : any[] - - return undefined; ->undefined : undefined -} - -tempTag2 `${ x => x }${ 0 }`; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->x => x : (x: number) => number ->x : number ->x : number - -tempTag2 `${ x => x }${ y => y }${ "hello" }`; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->x => x : (x: string) => string ->x : string ->x : string ->y => y : (y: string) => string ->y : string ->y : string - -tempTag2 `${ x => x }${ 0 }`; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->x => x : (x: number) => number ->x : number ->x : number - diff --git a/tests/baselines/reference/taggedTemplateContextualTyping2.js b/tests/baselines/reference/taggedTemplateContextualTyping2.js new file mode 100644 index 00000000000..c24f5fffb59 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateContextualTyping2.js @@ -0,0 +1,23 @@ +//// [taggedTemplateContextualTyping2.ts] + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +function tempTag2(...rest: any[]): any { + return undefined; +} + +tempTag2 `${ x => x }${ 0 }`; +tempTag2 `${ x => x }${ y => y }${ "hello" }`; +tempTag2 `${ x => x }${ 0 }`; + +//// [taggedTemplateContextualTyping2.js] +function tempTag2() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + return undefined; +} +tempTag2 `${function (x) { return x; }}${0}`; +tempTag2 `${function (x) { return x; }}${function (y) { return y; }}${"hello"}`; +tempTag2 `${function (x) { return x; }}${0}`; diff --git a/tests/baselines/reference/taggedTemplateContextualTyping2.types b/tests/baselines/reference/taggedTemplateContextualTyping2.types new file mode 100644 index 00000000000..d7088735bc3 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateContextualTyping2.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts === + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>templateStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>f : (x: number) => number +>x : number +>x : number + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>templateStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>f : (x: string) => string +>x : string +>h : (y: string) => string +>y : string +>x : string + +function tempTag2(...rest: any[]): any { +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>rest : any[] + + return undefined; +>undefined : undefined +} + +tempTag2 `${ x => x }${ 0 }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>x => x : (x: number) => number +>x : number +>x : number + +tempTag2 `${ x => x }${ y => y }${ "hello" }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>x => x : (x: string) => string +>x : string +>x : string +>y => y : (y: string) => string +>y : string +>y : string + +tempTag2 `${ x => x }${ 0 }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>x => x : (x: number) => number +>x : number +>x : number + diff --git a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts similarity index 52% rename from tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts rename to tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts index 5d6137a13ac..1e35b3c9b4b 100644 --- a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping.ts +++ b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts @@ -10,13 +10,3 @@ tempTag1 `${ x => x }${ 10 }`; tempTag1 `${ x => x }${ y => y }${ 10 }`; tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; - -function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; -function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; -function tempTag2(...rest: any[]): any { - return undefined; -} - -tempTag2 `${ x => x }${ 0 }`; -tempTag2 `${ x => x }${ y => y }${ "hello" }`; -tempTag2 `${ x => x }${ 0 }`; \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts new file mode 100644 index 00000000000..260a3bc0741 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts @@ -0,0 +1,11 @@ +// @target: ES6 + +function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; +function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +function tempTag2(...rest: any[]): any { + return undefined; +} + +tempTag2 `${ x => x }${ 0 }`; +tempTag2 `${ x => x }${ y => y }${ "hello" }`; +tempTag2 `${ x => x }${ 0 }`; \ No newline at end of file From 17c822966dae2f6eaa90e3f380ab6c08cdc8c2e8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 15 Dec 2014 16:39:12 -0800 Subject: [PATCH 10/93] Added tests for erroneous function expressions in both tagged/untagged template expressions. --- ...pressionsInSubstitutionExpression.errors.txt | 12 ++++++++++++ ...ionExpressionsInSubstitutionExpressionES6.js | 17 +++++++++++++++++ ...ExpressionsInSubstitutionExpressionES6.types | 14 ++++++++++++++ ...nctionExpressionsInSubstitutionExpression.js | 9 +++++++++ ...ionExpressionsInSubstitutionExpression.types | 9 +++++++++ ...ionExpressionsInSubstitutionExpressionES6.js | 8 ++++++++ ...ExpressionsInSubstitutionExpressionES6.types | 8 ++++++++ ...nctionExpressionsInSubstitutionExpression.ts | 6 ++++++ ...ionExpressionsInSubstitutionExpressionES6.ts | 6 ++++++ ...nctionExpressionsInSubstitutionExpression.ts | 3 +++ ...ionExpressionsInSubstitutionExpressionES6.ts | 3 +++ 11 files changed, 95 insertions(+) create mode 100644 tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js create mode 100644 tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types create mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js create mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types create mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js create mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types create mode 100644 tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts create mode 100644 tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts create mode 100644 tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts create mode 100644 tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt new file mode 100644 index 00000000000..e14ffc481f5 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ==== + + + function foo(...rest: any[]) { + } + + foo `${function (x: number) { x = "bad"; } }`; + ~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js new file mode 100644 index 00000000000..a1d3479f5c2 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js @@ -0,0 +1,17 @@ +//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts] + +function foo(...rest: any[]) { +} + +foo `${function (x: number) { x = "bad"; } }`; + +//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js] +function foo() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +} +foo `${function (x) { + x = "bad"; +}}`; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types new file mode 100644 index 00000000000..9d7e44f27de --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts === + +function foo(...rest: any[]) { +>foo : (...rest: any[]) => void +>rest : any[] +} + +foo `${function (x: number) { x = "bad"; } }`; +>foo : (...rest: any[]) => void +>function (x: number) { x = "bad"; } : (x: number) => void +>x : number +>x = "bad" : string +>x : number + diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js new file mode 100644 index 00000000000..ef113312060 --- /dev/null +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js @@ -0,0 +1,9 @@ +//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts] + + +`${function (x: number) { x = "bad"; } }`; + +//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js] +"" + function (x) { + x = "bad"; +}; diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types new file mode 100644 index 00000000000..1afa1592ec2 --- /dev/null +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts === + + +`${function (x: number) { x = "bad"; } }`; +>function (x: number) { x = "bad"; } : (x: number) => void +>x : number +>x = "bad" : string +>x : number + diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js new file mode 100644 index 00000000000..9ce47348dc1 --- /dev/null +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js @@ -0,0 +1,8 @@ +//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts] + +`${function (x: number) { x = "bad"; } }`; + +//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js] +`${function (x) { + x = "bad"; +}}`; diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types new file mode 100644 index 00000000000..0a15a491413 --- /dev/null +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts === + +`${function (x: number) { x = "bad"; } }`; +>function (x: number) { x = "bad"; } : (x: number) => void +>x : number +>x = "bad" : string +>x : number + diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts new file mode 100644 index 00000000000..210f3eebbd7 --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts @@ -0,0 +1,6 @@ + + +function foo(...rest: any[]) { +} + +foo `${function (x: number) { x = "bad"; } }`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts new file mode 100644 index 00000000000..0a51fea491f --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts @@ -0,0 +1,6 @@ +//@target: es6 + +function foo(...rest: any[]) { +} + +foo `${function (x: number) { x = "bad"; } }`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts b/tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts new file mode 100644 index 00000000000..26995f21e58 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts @@ -0,0 +1,3 @@ + + +`${function (x: number) { x = "bad"; } }`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts b/tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts new file mode 100644 index 00000000000..4803285a24a --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts @@ -0,0 +1,3 @@ +//@target: es6 + +`${function (x: number) { x = "bad"; } }`; \ No newline at end of file From e3848b98b1717d7170e419d5b28c5babfc041826 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 15 Dec 2014 16:45:17 -0800 Subject: [PATCH 11/93] Fixed bug where function expressions were not getting checked in template expressions. --- src/compiler/checker.ts | 2 ++ ...nExpressionsInSubstitutionExpression.errors.txt | 7 +++++-- ...pressionsInSubstitutionExpressionES6.errors.txt | 11 +++++++++++ ...ionExpressionsInSubstitutionExpressionES6.types | 14 -------------- ...nExpressionsInSubstitutionExpression.errors.txt | 9 +++++++++ ...nctionExpressionsInSubstitutionExpression.types | 9 --------- ...pressionsInSubstitutionExpressionES6.errors.txt | 8 ++++++++ ...ionExpressionsInSubstitutionExpressionES6.types | 8 -------- 8 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt delete mode 100644 tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types create mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt delete mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types create mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt delete mode 100644 tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dcbe7162b76..b0c0305670e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8647,6 +8647,8 @@ module ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.TemplateExpression: + case SyntaxKind.TemplateSpan: case SyntaxKind.TypeAssertionExpression: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.TypeOfExpression: diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt index e14ffc481f5..b38a70ca18b 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt @@ -1,7 +1,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,31): error TS2322: Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (2 errors) ==== function foo(...rest: any[]) { @@ -9,4 +10,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFuncti foo `${function (x: number) { x = "bad"; } }`; ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt new file mode 100644 index 00000000000..6b0f4b642ff --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(5,31): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ==== + + function foo(...rest: any[]) { + } + + foo `${function (x: number) { x = "bad"; } }`; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types deleted file mode 100644 index 9d7e44f27de..00000000000 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts === - -function foo(...rest: any[]) { ->foo : (...rest: any[]) => void ->rest : any[] -} - -foo `${function (x: number) { x = "bad"; } }`; ->foo : (...rest: any[]) => void ->function (x: number) { x = "bad"; } : (x: number) => void ->x : number ->x = "bad" : string ->x : number - diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt new file mode 100644 index 00000000000..7204f32dba2 --- /dev/null +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(3,27): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ==== + + + `${function (x: number) { x = "bad"; } }`; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types deleted file mode 100644 index 1afa1592ec2..00000000000 --- a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts === - - -`${function (x: number) { x = "bad"; } }`; ->function (x: number) { x = "bad"; } : (x: number) => void ->x : number ->x = "bad" : string ->x : number - diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt new file mode 100644 index 00000000000..9fece57ef5e --- /dev/null +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(2,27): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ==== + + `${function (x: number) { x = "bad"; } }`; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types deleted file mode 100644 index 0a15a491413..00000000000 --- a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts === - -`${function (x: number) { x = "bad"; } }`; ->function (x: number) { x = "bad"; } : (x: number) => void ->x : number ->x = "bad" : string ->x : number - From 1f6cd941fdaa37c25da86eb86601b46037773e35 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 15 Dec 2014 17:09:56 -0800 Subject: [PATCH 12/93] Changed tests to error when actual contextual typing is broken. --- .../taggedTemplateContextualTyping1.js | 46 +++++-- .../taggedTemplateContextualTyping1.types | 121 +++++++++++------- .../taggedTemplateContextualTyping2.js | 39 ++++-- .../taggedTemplateContextualTyping2.types | 93 +++++++++----- .../taggedTemplateContextualTyping1.ts | 17 ++- .../taggedTemplateContextualTyping2.ts | 17 ++- 6 files changed, 228 insertions(+), 105 deletions(-) diff --git a/tests/baselines/reference/taggedTemplateContextualTyping1.js b/tests/baselines/reference/taggedTemplateContextualTyping1.js index 1ac371a8ae4..1d8b79e4c32 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping1.js +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.js @@ -1,15 +1,20 @@ //// [taggedTemplateContextualTyping1.ts] -function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; -function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; +type FuncType = (x: (p: T) => T) => typeof x; + +function tempTag1(templateStrs: TemplateStringsArray, f: FuncType, x: T): T; +function tempTag1(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T; function tempTag1(...rest: any[]): T { return undefined; } -tempTag1 `${ x => x }${ 10 }`; -tempTag1 `${ x => x }${ y => y }${ 10 }`; -tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; -tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; +tempTag1 `${ x => { x(undefined); return x; } }${ (y: (p: T) => T) => { y(undefined); return y } }${ undefined }`; +tempTag1 `${ (x: (p: T) => T) => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ undefined }`; //// [taggedTemplateContextualTyping1.js] @@ -20,7 +25,28 @@ function tempTag1() { } return undefined; } -tempTag1 `${function (x) { return x; }}${10}`; -tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${10}`; -tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${undefined}`; -tempTag1 `${function (x) { return x; }}${function (y) { return y; }}${undefined}`; +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag1 `${function (x) { + x(undefined); + return x; +}}${function (y) { + y(undefined); + return y; +}}${10}`; +tempTag1 `${function (x) { + x(undefined); + return x; +}}${function (y) { + y(undefined); + return y; +}}${undefined}`; +tempTag1 `${function (x) { + x(undefined); + return x; +}}${function (y) { + y(undefined); + return y; +}}${undefined}`; diff --git a/tests/baselines/reference/taggedTemplateContextualTyping1.types b/tests/baselines/reference/taggedTemplateContextualTyping1.types index bb8e6a1a87c..a87d5eaa7a4 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping1.types +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.types @@ -1,37 +1,40 @@ === tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts === -function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; ->tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +type FuncType = (x: (p: T) => T) => typeof x; +>FuncType : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>T : T +>p : T +>T : T +>T : T +>x : (p: T) => T + +function tempTag1(templateStrs: TemplateStringsArray, f: FuncType, x: T): T; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } >T : T >templateStrs : TemplateStringsArray >TemplateStringsArray : TemplateStringsArray ->f : (x: T) => T ->x : T ->T : T ->T : T +>f : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T >x : T >T : T >T : T -function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; ->tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +function tempTag1(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } >T : T >templateStrs : TemplateStringsArray >TemplateStringsArray : TemplateStringsArray ->f : (x: T) => T ->x : T ->T : T ->T : T ->h : (y: T) => T ->y : T ->T : T ->T : T +>f : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T +>h : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T >x : T >T : T >T : T function tempTag1(...rest: any[]): T { ->tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } >T : T >rest : any[] >T : T @@ -40,38 +43,62 @@ function tempTag1(...rest: any[]): T { >undefined : undefined } -tempTag1 `${ x => x }${ 10 }`; ->tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } ->x => x : (x: number) => number ->x : number ->x : number +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>y => { y(undefined); return y; } : (y: (p: T) => T) => (p: T) => T +>y : (p: T) => T +>y(undefined) : number +>y : (p: T) => T +>undefined : undefined +>y : (p: T) => T -tempTag1 `${ x => x }${ y => y }${ 10 }`; ->tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } ->x => x : (x: number) => number ->x : number ->x : number ->y => y : (y: number) => number ->y : number ->y : number - -tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; ->tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } ->x => x : (x: number) => number ->x : number ->x : number ->(y: number) => y : (y: number) => number ->y : number ->y : number +tempTag1 `${ x => { x(undefined); return x; } }${ (y: (p: T) => T) => { y(undefined); return y } }${ undefined }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>(y: (p: T) => T) => { y(undefined); return y } : (y: (p: T) => T) => (p: T) => T +>y : (p: T) => T +>T : T +>p : T +>T : T +>T : T +>y(undefined) : number +>y : (p: T) => T +>undefined : undefined +>y : (p: T) => T >undefined : undefined -tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; ->tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; } ->(x: number) => x : (x: number) => number ->x : number ->x : number ->y => y : (y: number) => number ->y : number ->y : number +tempTag1 `${ (x: (p: T) => T) => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ undefined }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(x: (p: T) => T) => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>T : T +>p : T +>T : T +>T : T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>y => { y(undefined); return y; } : (y: (p: T) => T) => (p: T) => T +>y : (p: T) => T +>y(undefined) : number +>y : (p: T) => T +>undefined : undefined +>y : (p: T) => T >undefined : undefined diff --git a/tests/baselines/reference/taggedTemplateContextualTyping2.js b/tests/baselines/reference/taggedTemplateContextualTyping2.js index c24f5fffb59..df026399c10 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping2.js +++ b/tests/baselines/reference/taggedTemplateContextualTyping2.js @@ -1,14 +1,21 @@ //// [taggedTemplateContextualTyping2.ts] -function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; -function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +type FuncType1 = (x: (p: T) => T) => typeof x; +type FuncType2 = (x: (p: T) => T) => typeof x; + +function tempTag2(templateStrs: TemplateStringsArray, f: FuncType1, x: number): number; +function tempTag2(templateStrs: TemplateStringsArray, f: FuncType2, h: FuncType2, x: string): string; function tempTag2(...rest: any[]): any { return undefined; } -tempTag2 `${ x => x }${ 0 }`; -tempTag2 `${ x => x }${ y => y }${ "hello" }`; -tempTag2 `${ x => x }${ 0 }`; +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag2 `${ x => { x(undefined); return x; } }${ 0 }`; +tempTag2 `${ x => { x(undefined); return x; } }${ y => { y(null); return y; } }${ "hello" }`; +tempTag2 `${ x => { x(undefined); return x; } }${ undefined }${ "hello" }`; //// [taggedTemplateContextualTyping2.js] function tempTag2() { @@ -18,6 +25,22 @@ function tempTag2() { } return undefined; } -tempTag2 `${function (x) { return x; }}${0}`; -tempTag2 `${function (x) { return x; }}${function (y) { return y; }}${"hello"}`; -tempTag2 `${function (x) { return x; }}${0}`; +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag2 `${function (x) { + x(undefined); + return x; +}}${0}`; +tempTag2 `${function (x) { + x(undefined); + return x; +}}${function (y) { + y(null); + return y; +}}${"hello"}`; +tempTag2 `${function (x) { + x(undefined); + return x; +}}${undefined}${"hello"}`; diff --git a/tests/baselines/reference/taggedTemplateContextualTyping2.types b/tests/baselines/reference/taggedTemplateContextualTyping2.types index d7088735bc3..9ca7386dc34 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping2.types +++ b/tests/baselines/reference/taggedTemplateContextualTyping2.types @@ -1,49 +1,84 @@ === tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts === -function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +type FuncType1 = (x: (p: T) => T) => typeof x; +>FuncType1 : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>T : T +>p : T +>T : T +>T : T +>x : (p: T) => T + +type FuncType2 = (x: (p: T) => T) => typeof x; +>FuncType2 : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>S : S +>T : T +>p : T +>T : T +>T : T +>x : (p: T) => T + +function tempTag2(templateStrs: TemplateStringsArray, f: FuncType1, x: number): number; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: string): string; } >templateStrs : TemplateStringsArray >TemplateStringsArray : TemplateStringsArray ->f : (x: number) => number ->x : number +>f : (x: (p: T) => T) => (p: T) => T +>FuncType1 : (x: (p: T) => T) => (p: T) => T >x : number -function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +function tempTag2(templateStrs: TemplateStringsArray, f: FuncType2, h: FuncType2, x: string): string; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: string): string; } >templateStrs : TemplateStringsArray >TemplateStringsArray : TemplateStringsArray ->f : (x: string) => string ->x : string ->h : (y: string) => string ->y : string +>f : (x: (p: T) => T) => (p: T) => T +>FuncType2 : (x: (p: T) => T) => (p: T) => T +>h : (x: (p: T) => T) => (p: T) => T +>FuncType2 : (x: (p: T) => T) => (p: T) => T >x : string function tempTag2(...rest: any[]): any { ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: string): string; } >rest : any[] return undefined; >undefined : undefined } -tempTag2 `${ x => x }${ 0 }`; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->x => x : (x: number) => number ->x : number ->x : number +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag2 `${ x => { x(undefined); return x; } }${ 0 }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: string): string; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T -tempTag2 `${ x => x }${ y => y }${ "hello" }`; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->x => x : (x: string) => string ->x : string ->x : string ->y => y : (y: string) => string ->y : string ->y : string +tempTag2 `${ x => { x(undefined); return x; } }${ y => { y(null); return y; } }${ "hello" }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: string): string; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : string +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>y => { y(null); return y; } : (y: (p: T) => T) => (p: T) => T +>y : (p: T) => T +>y(null) : number +>y : (p: T) => T +>y : (p: T) => T -tempTag2 `${ x => x }${ 0 }`; ->tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; (templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; } ->x => x : (x: number) => number ->x : number ->x : number +tempTag2 `${ x => { x(undefined); return x; } }${ undefined }${ "hello" }`; +>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: string): string; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : string +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>undefined : undefined diff --git a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts index 1e35b3c9b4b..c15d911ee52 100644 --- a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts +++ b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts @@ -1,12 +1,17 @@ // @target: ES6 -function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T; -function tempTag1(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T; +type FuncType = (x: (p: T) => T) => typeof x; + +function tempTag1(templateStrs: TemplateStringsArray, f: FuncType, x: T): T; +function tempTag1(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T; function tempTag1(...rest: any[]): T { return undefined; } -tempTag1 `${ x => x }${ 10 }`; -tempTag1 `${ x => x }${ y => y }${ 10 }`; -tempTag1 `${ x => x }${ (y: number) => y }${ undefined }`; -tempTag1 `${ (x: number) => x }${ y => y }${ undefined }`; +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; +tempTag1 `${ x => { x(undefined); return x; } }${ (y: (p: T) => T) => { y(undefined); return y } }${ undefined }`; +tempTag1 `${ (x: (p: T) => T) => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ undefined }`; diff --git a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts index 260a3bc0741..24fcf4a04df 100644 --- a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts +++ b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts @@ -1,11 +1,18 @@ // @target: ES6 -function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number; -function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string; +type FuncType1 = (x: (p: T) => T) => typeof x; +type FuncType2 = (x: (p: T) => T) => typeof x; + +function tempTag2(templateStrs: TemplateStringsArray, f: FuncType1, x: number): number; +function tempTag2(templateStrs: TemplateStringsArray, f: FuncType2, h: FuncType2, x: string): string; function tempTag2(...rest: any[]): any { return undefined; } -tempTag2 `${ x => x }${ 0 }`; -tempTag2 `${ x => x }${ y => y }${ "hello" }`; -tempTag2 `${ x => x }${ 0 }`; \ No newline at end of file +// If contextual typing takes place, these functions should work. +// Otherwise, the arrow functions' parameters will be typed as 'any', +// and it is an error to invoke an any-typed value with type arguments, +// so this test will error. +tempTag2 `${ x => { x(undefined); return x; } }${ 0 }`; +tempTag2 `${ x => { x(undefined); return x; } }${ y => { y(null); return y; } }${ "hello" }`; +tempTag2 `${ x => { x(undefined); return x; } }${ undefined }${ "hello" }`; \ No newline at end of file From 42c05453bd5f2b1c4e75cd2fff1d2b55434119c0 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 15 Dec 2014 21:09:57 -0800 Subject: [PATCH 13/93] Add internal definitions to a diffrent .d.ts files --- Jakefile | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/Jakefile b/Jakefile index 057ba227289..ee0f0e6bcaf 100644 --- a/Jakefile +++ b/Jakefile @@ -95,6 +95,13 @@ var definitionsRoots = [ "services/services.d.ts", ]; +var internalDefinitionsRoots = [ + "compiler/core.d.ts", + "compiler/sys.d.ts", + "compiler/utilities.d.ts", + "services/utilities.d.ts", +]; + var harnessSources = [ "harness.ts", "sourceMapRecorder.ts", @@ -322,6 +329,8 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts"); var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts"); +var internalNodeDefinitionsFile = path.join(builtLocalDirectory, "typescript_internal.d.ts"); +var internalStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices_internal.d.ts"); var tempDirPath = path.join(builtLocalDirectory, "temptempdir"); compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), /*prefixes*/ undefined, @@ -333,16 +342,25 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright /*keepComments*/ true, /*noResolve*/ true, /*callback*/ function () { - concatenateFiles(standaloneDefinitionsFile, definitionsRoots.map(function (f) { - return path.join(tempDirPath, f); - })); - prependFile(copyright, standaloneDefinitionsFile); + function makeDefinitionFiles(definitionsRoots, standaloneDefinitionsFile, nodeDefinitionsFile) { + // Create the standalone definition file + concatenateFiles(standaloneDefinitionsFile, definitionsRoots.map(function (f) { + return path.join(tempDirPath, f); + })); + prependFile(copyright, standaloneDefinitionsFile); - // Create the node definition file by replacing 'ts' module with '"typescript"' as a module. - jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); - var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); - definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"'); - fs.writeFileSync(nodeDefinitionsFile, definitionFileContents); + // Create the node definition file by replacing 'ts' module with '"typescript"' as a module. + jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); + var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); + definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"'); + fs.writeFileSync(nodeDefinitionsFile, definitionFileContents); + } + + // Create the public definition files + makeDefinitionFiles(definitionsRoots, standaloneDefinitionsFile, nodeDefinitionsFile); + + // Create the internal definition files + makeDefinitionFiles(internalDefinitionsRoots, internalStandaloneDefinitionsFile, internalNodeDefinitionsFile); // Delete the temp dir jake.rmRf(tempDirPath, {silent: true}); @@ -401,7 +419,7 @@ task("generate-spec", [specMd]) // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory desc("Makes a new LKG out of the built js files"); task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() { - var expectedFiles = [tscFile, servicesFile, nodeDefinitionsFile, standaloneDefinitionsFile].concat(libraryTargets); + var expectedFiles = [tscFile, servicesFile, nodeDefinitionsFile, standaloneDefinitionsFile, internalNodeDefinitionsFile, internalStandaloneDefinitionsFile].concat(libraryTargets); var missingFiles = expectedFiles.filter(function (f) { return !fs.existsSync(f); }); From ef71290f002346b2fa18aef2fd9456ad0b1d0d7e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 15 Dec 2014 22:21:17 -0800 Subject: [PATCH 14/93] Update LKG --- bin/lib.core.d.ts | 87 +- bin/lib.core.es6.d.ts | 4801 ++++++++++ bin/lib.d.ts | 96 +- bin/lib.dom.d.ts | 7 +- bin/lib.es6.d.ts | 17195 ++++++++++++++++++++++++++++++++++ bin/lib.webworker.d.ts | 7 +- bin/tsc.js | 5594 ++++++----- bin/typescript.d.ts | 1849 ++++ bin/typescriptServices.d.ts | 1849 ++++ bin/typescriptServices.js | 8721 ++++++++++------- 10 files changed, 34165 insertions(+), 6041 deletions(-) create mode 100644 bin/lib.core.es6.d.ts create mode 100644 bin/lib.es6.d.ts create mode 100644 bin/typescript.d.ts create mode 100644 bin/typescriptServices.d.ts diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts index 00dc83fa80a..c04cfcf18ca 100644 --- a/bin/lib.core.d.ts +++ b/bin/lib.core.d.ts @@ -124,10 +124,7 @@ interface Object { propertyIsEnumerable(v: string): boolean; } -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { +interface ObjectConstructor { new (value?: any): Object; (): any; (value: any): any; @@ -221,6 +218,11 @@ declare var Object: { keys(o: any): string[]; } +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + /** * Creates a new function. */ @@ -255,8 +257,8 @@ interface Function { caller: Function; } -declare var Function: { - /** +interface FunctionConstructor { + /** * Creates a new function. * @param args A list of arguments the function accepts. */ @@ -265,6 +267,8 @@ declare var Function: { prototype: Function; } +declare var Function: FunctionConstructor; + interface IArguments { [index: number]: any; length: number; @@ -424,24 +428,29 @@ interface String { [index: number]: string; } -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { +interface StringConstructor { new (value?: any): String; (value?: any): string; prototype: String; fromCharCode(...codes: number[]): string; } +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + interface Boolean { } -declare var Boolean: { + +interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; prototype: Boolean; } +declare var Boolean: BooleanConstructor; + interface Number { /** * Returns a string representation of an object. @@ -468,8 +477,7 @@ interface Number { toPrecision(precision?: number): string; } -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { +interface NumberConstructor { new (value?: any): Number; (value?: any): number; prototype: Number; @@ -499,6 +507,9 @@ declare var Number: { POSITIVE_INFINITY: number; } +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + interface TemplateStringsArray extends Array { raw: string[]; } @@ -768,7 +779,7 @@ interface Date { toJSON(key?: any): string; } -declare var Date: { +interface DateConstructor { new (): Date; new (value: number): Date; new (value: string): Date; @@ -794,6 +805,8 @@ declare var Date: { now(): number; } +declare var Date: DateConstructor; + interface RegExpMatchArray extends Array { index?: number; input?: string; @@ -834,9 +847,11 @@ interface RegExp { // Non-standard extensions compile(): RegExp; } -declare var RegExp: { + +interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; + prototype: RegExp; // Non-standard extensions $1: string; @@ -851,64 +866,87 @@ declare var RegExp: { lastMatch: string; } +declare var RegExp: RegExpConstructor; + interface Error { name: string; message: string; } -declare var Error: { + +interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; prototype: Error; } +declare var Error: ErrorConstructor; + interface EvalError extends Error { } -declare var EvalError: { + +interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; prototype: EvalError; } +declare var EvalError: EvalErrorConstructor; + interface RangeError extends Error { } -declare var RangeError: { + +interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; prototype: RangeError; } +declare var RangeError: RangeErrorConstructor; + interface ReferenceError extends Error { } -declare var ReferenceError: { + +interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; prototype: ReferenceError; } +declare var ReferenceError: ReferenceErrorConstructor; + interface SyntaxError extends Error { } -declare var SyntaxError: { + +interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; prototype: SyntaxError; } +declare var SyntaxError: SyntaxErrorConstructor; + interface TypeError extends Error { } -declare var TypeError: { + +interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; prototype: TypeError; } +declare var TypeError: TypeErrorConstructor; + interface URIError extends Error { } -declare var URIError: { + +interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; prototype: URIError; } +declare var URIError: URIErrorConstructor; + interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. @@ -1111,7 +1149,8 @@ interface Array { [n: number]: T; } -declare var Array: { + +interface ArrayConstructor { new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; @@ -1121,3 +1160,5 @@ declare var Array: { isArray(arg: any): boolean; prototype: Array; } + +declare var Array: ArrayConstructor; diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts new file mode 100644 index 00000000000..3fa50358008 --- /dev/null +++ b/bin/lib.core.es6.d.ts @@ -0,0 +1,4801 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +interface ObjectConstructor { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +interface FunctionConstructor { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +declare var Function: FunctionConstructor; + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): RegExpMatchArray; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): RegExpMatchArray; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +interface StringConstructor { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + +interface Boolean { +} + +interface BooleanConstructor { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +declare var Boolean: BooleanConstructor; + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +interface NumberConstructor { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + +interface TemplateStringsArray extends Array { + raw: string[]; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +declare var Date: DateConstructor; + +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + +interface RegExpExecArray extends Array { + index: number; + input: string; +} + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ + source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} + +interface RegExpConstructor { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + prototype: RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +declare var RegExp: RegExpConstructor; + +interface Error { + name: string; + message: string; +} + +interface ErrorConstructor { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +declare var Error: ErrorConstructor; + +interface EvalError extends Error { +} + +interface EvalErrorConstructor { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +declare var EvalError: EvalErrorConstructor; + +interface RangeError extends Error { +} + +interface RangeErrorConstructor { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +declare var RangeError: RangeErrorConstructor; + +interface ReferenceError extends Error { +} + +interface ReferenceErrorConstructor { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +declare var ReferenceError: ReferenceErrorConstructor; + +interface SyntaxError extends Error { +} + +interface SyntaxErrorConstructor { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +declare var SyntaxError: SyntaxErrorConstructor; + +interface TypeError extends Error { +} + +interface TypeErrorConstructor { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +declare var TypeError: TypeErrorConstructor; + +interface URIError extends Error { +} + +interface URIErrorConstructor { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +declare var URIError: URIErrorConstructor; + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + [n: number]: T; +} + +interface ArrayConstructor { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + +declare var Array: ArrayConstructor; +declare type PropertyKey = string | number | Symbol; + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + // [Symbol.toStringTag]: string; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string|number): Symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): Symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: Symbol): string; + + // Well-known Symbols + + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + hasInstance: Symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + isConcatSpreadable: Symbol; + + /** + * A Boolean value that if true indicates that an object may be used as a regular expression. + */ + isRegExp: Symbol; + + /** + * A method that returns the default iterator for an object.Called by the semantics of the + * for-of statement. + */ + iterator: Symbol; + + /** + * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive + * abstract operation. + */ + toPrimitive: Symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built- in method Object.prototype.toString. + */ + toStringTag: Symbol; + + /** + * An Object whose own property names are property names that are excluded from the with + * environment bindings of the associated objects. + */ + unscopables: Symbol; +} +declare var Symbol: SymbolConstructor; + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects to copy properties from. + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): Symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface Function { + /** + * Returns a new function object that is identical to the argument object in all ways except + * for its identity and the value of its HomeObject internal slot. + */ + toMethod(newHome: Object): Function; + + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + name: string; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + +interface Array { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): T[]; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): T[]; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface String { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + contains(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface Iterator { + //[Symbol.iterator](): Iterator; + next(): IteratorResult; +} + +interface Iterable { + //[Symbol.iterator](): Iterator; +} + +interface GeneratorFunction extends Function { + +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + (...args: string[]): GeneratorFunction; + prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + +interface Generator extends Iterator { + next(value?: any): IteratorResult; + throw (exception: any): IteratorResult; + return (value: T): IteratorResult; + // [Symbol.toStringTag]: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; + + // [Symbol.toStringTag]: string; +} + +interface RegExp { + // [Symbol.isRegExp]: boolean; + + /** + * Matches a string with a regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + match(string: string): string[]; + + /** + * Replaces text in a string, using a regular expression. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of rgExp in stringObj. + */ + replace(string: string, replaceValue: string): string; + + search(string: string): number; + + /** + * Returns an Array object into which substrings of the result of converting string to a String + * have been stored. The substrings are determined by searching from left to right for matches + * of the this value regular expression; these occurrences are not part of any substring in the + * returned array, but serve to divide up the String value. + * + * If the regular expression that contains capturing parentheses, then each time separator is + * matched the results (including any undefined results) of the capturing parentheses are spliced. + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than limit elements. + */ + split(string: string, limit?: number): string[]; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + unicode: boolean; +} + +interface Map { + clear(): void; + delete(key: K): boolean; + entries(): Iterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): Iterator; + set(key: K, value?: V): Map; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator<[K,V]>; + // [Symbol.toStringTag]: string; +} + +interface MapConstructor { + new (): Map; + new (iterable: Iterable<[K, V]>): Map; + prototype: Map; +} +declare var Map: MapConstructor; + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; + // [Symbol.toStringTag]: string; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; + prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): Iterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): Iterator; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator; + // [Symbol.toStringTag]: string; +} + +interface SetConstructor { + new (): Set; + new (iterable: Iterable): Set; + prototype: Set; +} +declare var Set: SetConstructor; + +interface WeakSet { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + // [Symbol.toStringTag]: string; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (iterable: Iterable): WeakSet; + prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + +interface JSON { + // [Symbol.toStringTag]: string; +} + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin: number, end?: number): ArrayBuffer; + + // [Symbol.toStringTag]: string; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + + // [Symbol.toStringTag]: string; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: Uint8ClampedArray): Uint8ClampedArray; + new (array: number[]): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; +} +declare var Uint16Array: Uint16ArrayConstructor; + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): any; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, thisArg: any, argArray?: any): any; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handeler: ProxyHandler): T +} +declare var Proxy: ProxyConstructor; + +declare var Reflect: { + apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + construct(target: Function, argumentsList: ArrayLike): any; + defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + deleteProperty(target: any, propertyKey: PropertyKey): boolean; + enumerate(target: any): Iterator; + get(target: any, propertyKey: PropertyKey, receiver?: any): any; + getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + getPrototypeOf(target: any): any; + has(target: any, propertyKey: string): boolean; + has(target: any, propertyKey: Symbol): boolean; + isExtensible(target: any): boolean; + ownKeys(target: any): Array; + preventExtensions(target: any): boolean; + set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean; + setPrototypeOf(target: any, proto: any): boolean; +}; + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | Promise): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param init A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: (T | Promise)[]): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of values. + * @returns A new Promise. + */ + all(values: Promise[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | Promise)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | Promise): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} \ No newline at end of file diff --git a/bin/lib.d.ts b/bin/lib.d.ts index c18bd4ff8b4..bd8e2ccc991 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -124,10 +124,7 @@ interface Object { propertyIsEnumerable(v: string): boolean; } -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { +interface ObjectConstructor { new (value?: any): Object; (): any; (value: any): any; @@ -221,6 +218,11 @@ declare var Object: { keys(o: any): string[]; } +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + /** * Creates a new function. */ @@ -255,8 +257,8 @@ interface Function { caller: Function; } -declare var Function: { - /** +interface FunctionConstructor { + /** * Creates a new function. * @param args A list of arguments the function accepts. */ @@ -265,6 +267,8 @@ declare var Function: { prototype: Function; } +declare var Function: FunctionConstructor; + interface IArguments { [index: number]: any; length: number; @@ -424,24 +428,29 @@ interface String { [index: number]: string; } -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { +interface StringConstructor { new (value?: any): String; (value?: any): string; prototype: String; fromCharCode(...codes: number[]): string; } +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + interface Boolean { } -declare var Boolean: { + +interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; prototype: Boolean; } +declare var Boolean: BooleanConstructor; + interface Number { /** * Returns a string representation of an object. @@ -468,8 +477,7 @@ interface Number { toPrecision(precision?: number): string; } -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { +interface NumberConstructor { new (value?: any): Number; (value?: any): number; prototype: Number; @@ -499,6 +507,9 @@ declare var Number: { POSITIVE_INFINITY: number; } +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + interface TemplateStringsArray extends Array { raw: string[]; } @@ -768,7 +779,7 @@ interface Date { toJSON(key?: any): string; } -declare var Date: { +interface DateConstructor { new (): Date; new (value: number): Date; new (value: string): Date; @@ -794,6 +805,8 @@ declare var Date: { now(): number; } +declare var Date: DateConstructor; + interface RegExpMatchArray extends Array { index?: number; input?: string; @@ -834,9 +847,11 @@ interface RegExp { // Non-standard extensions compile(): RegExp; } -declare var RegExp: { + +interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; + prototype: RegExp; // Non-standard extensions $1: string; @@ -851,64 +866,87 @@ declare var RegExp: { lastMatch: string; } +declare var RegExp: RegExpConstructor; + interface Error { name: string; message: string; } -declare var Error: { + +interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; prototype: Error; } +declare var Error: ErrorConstructor; + interface EvalError extends Error { } -declare var EvalError: { + +interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; prototype: EvalError; } +declare var EvalError: EvalErrorConstructor; + interface RangeError extends Error { } -declare var RangeError: { + +interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; prototype: RangeError; } +declare var RangeError: RangeErrorConstructor; + interface ReferenceError extends Error { } -declare var ReferenceError: { + +interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; prototype: ReferenceError; } +declare var ReferenceError: ReferenceErrorConstructor; + interface SyntaxError extends Error { } -declare var SyntaxError: { + +interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; prototype: SyntaxError; } +declare var SyntaxError: SyntaxErrorConstructor; + interface TypeError extends Error { } -declare var TypeError: { + +interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; prototype: TypeError; } +declare var TypeError: TypeErrorConstructor; + interface URIError extends Error { } -declare var URIError: { + +interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; prototype: URIError; } +declare var URIError: URIErrorConstructor; + interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. @@ -1111,7 +1149,8 @@ interface Array { [n: number]: T; } -declare var Array: { + +interface ArrayConstructor { new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; @@ -1122,6 +1161,8 @@ declare var Array: { prototype: Array; } +declare var Array: ArrayConstructor; + ///////////////////////////// /// IE10 ECMAScript Extensions ///////////////////////////// @@ -1489,7 +1530,7 @@ interface Uint32Array extends ArrayBufferView { set(array: number[], offset?: number): void; /** - * Gets a new Uint32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ @@ -1754,6 +1795,7 @@ interface Map { } declare var Map: { new (): Map; + prototype: Map; } interface WeakMap { @@ -1765,6 +1807,7 @@ interface WeakMap { } declare var WeakMap: { new (): WeakMap; + prototype: WeakMap; } interface Set { @@ -1777,10 +1820,13 @@ interface Set { } declare var Set: { new (): Set; + prototype: Set; } +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// declare module Intl { - interface CollatorOptions { usage?: string; localeMatcher?: string; diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index 26d30d3a027..1fedb4e266f 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -647,6 +647,7 @@ interface Map { } declare var Map: { new (): Map; + prototype: Map; } interface WeakMap { @@ -658,6 +659,7 @@ interface WeakMap { } declare var WeakMap: { new (): WeakMap; + prototype: WeakMap; } interface Set { @@ -670,10 +672,13 @@ interface Set { } declare var Set: { new (): Set; + prototype: Set; } +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// declare module Intl { - interface CollatorOptions { usage?: string; localeMatcher?: string; diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts new file mode 100644 index 00000000000..f328148aa6b --- /dev/null +++ b/bin/lib.es6.d.ts @@ -0,0 +1,17195 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +interface ObjectConstructor { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +interface FunctionConstructor { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +declare var Function: FunctionConstructor; + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): RegExpMatchArray; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): RegExpMatchArray; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +interface StringConstructor { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + +interface Boolean { +} + +interface BooleanConstructor { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +declare var Boolean: BooleanConstructor; + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +interface NumberConstructor { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + +interface TemplateStringsArray extends Array { + raw: string[]; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +declare var Date: DateConstructor; + +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + +interface RegExpExecArray extends Array { + index: number; + input: string; +} + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ + source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} + +interface RegExpConstructor { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + prototype: RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +declare var RegExp: RegExpConstructor; + +interface Error { + name: string; + message: string; +} + +interface ErrorConstructor { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +declare var Error: ErrorConstructor; + +interface EvalError extends Error { +} + +interface EvalErrorConstructor { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +declare var EvalError: EvalErrorConstructor; + +interface RangeError extends Error { +} + +interface RangeErrorConstructor { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +declare var RangeError: RangeErrorConstructor; + +interface ReferenceError extends Error { +} + +interface ReferenceErrorConstructor { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +declare var ReferenceError: ReferenceErrorConstructor; + +interface SyntaxError extends Error { +} + +interface SyntaxErrorConstructor { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +declare var SyntaxError: SyntaxErrorConstructor; + +interface TypeError extends Error { +} + +interface TypeErrorConstructor { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +declare var TypeError: TypeErrorConstructor; + +interface URIError extends Error { +} + +interface URIErrorConstructor { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +declare var URIError: URIErrorConstructor; + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + [n: number]: T; +} + +interface ArrayConstructor { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + +declare var Array: ArrayConstructor; +declare type PropertyKey = string | number | Symbol; + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + // [Symbol.toStringTag]: string; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string|number): Symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): Symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: Symbol): string; + + // Well-known Symbols + + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + hasInstance: Symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + isConcatSpreadable: Symbol; + + /** + * A Boolean value that if true indicates that an object may be used as a regular expression. + */ + isRegExp: Symbol; + + /** + * A method that returns the default iterator for an object.Called by the semantics of the + * for-of statement. + */ + iterator: Symbol; + + /** + * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive + * abstract operation. + */ + toPrimitive: Symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built- in method Object.prototype.toString. + */ + toStringTag: Symbol; + + /** + * An Object whose own property names are property names that are excluded from the with + * environment bindings of the associated objects. + */ + unscopables: Symbol; +} +declare var Symbol: SymbolConstructor; + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects to copy properties from. + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): Symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface Function { + /** + * Returns a new function object that is identical to the argument object in all ways except + * for its identity and the value of its HomeObject internal slot. + */ + toMethod(newHome: Object): Function; + + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + name: string; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + +interface Array { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): T[]; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): T[]; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface String { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + contains(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface Iterator { + //[Symbol.iterator](): Iterator; + next(): IteratorResult; +} + +interface Iterable { + //[Symbol.iterator](): Iterator; +} + +interface GeneratorFunction extends Function { + +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + (...args: string[]): GeneratorFunction; + prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + +interface Generator extends Iterator { + next(value?: any): IteratorResult; + throw (exception: any): IteratorResult; + return (value: T): IteratorResult; + // [Symbol.toStringTag]: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; + + // [Symbol.toStringTag]: string; +} + +interface RegExp { + // [Symbol.isRegExp]: boolean; + + /** + * Matches a string with a regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + match(string: string): string[]; + + /** + * Replaces text in a string, using a regular expression. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of rgExp in stringObj. + */ + replace(string: string, replaceValue: string): string; + + search(string: string): number; + + /** + * Returns an Array object into which substrings of the result of converting string to a String + * have been stored. The substrings are determined by searching from left to right for matches + * of the this value regular expression; these occurrences are not part of any substring in the + * returned array, but serve to divide up the String value. + * + * If the regular expression that contains capturing parentheses, then each time separator is + * matched the results (including any undefined results) of the capturing parentheses are spliced. + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than limit elements. + */ + split(string: string, limit?: number): string[]; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + unicode: boolean; +} + +interface Map { + clear(): void; + delete(key: K): boolean; + entries(): Iterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): Iterator; + set(key: K, value?: V): Map; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator<[K,V]>; + // [Symbol.toStringTag]: string; +} + +interface MapConstructor { + new (): Map; + new (iterable: Iterable<[K, V]>): Map; + prototype: Map; +} +declare var Map: MapConstructor; + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; + // [Symbol.toStringTag]: string; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; + prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): Iterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): Iterator; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator; + // [Symbol.toStringTag]: string; +} + +interface SetConstructor { + new (): Set; + new (iterable: Iterable): Set; + prototype: Set; +} +declare var Set: SetConstructor; + +interface WeakSet { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + // [Symbol.toStringTag]: string; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (iterable: Iterable): WeakSet; + prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + +interface JSON { + // [Symbol.toStringTag]: string; +} + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin: number, end?: number): ArrayBuffer; + + // [Symbol.toStringTag]: string; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + + // [Symbol.toStringTag]: string; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: Uint8ClampedArray): Uint8ClampedArray; + new (array: number[]): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; +} +declare var Uint16Array: Uint16ArrayConstructor; + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): any; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, thisArg: any, argArray?: any): any; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handeler: ProxyHandler): T +} +declare var Proxy: ProxyConstructor; + +declare var Reflect: { + apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + construct(target: Function, argumentsList: ArrayLike): any; + defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + deleteProperty(target: any, propertyKey: PropertyKey): boolean; + enumerate(target: any): Iterator; + get(target: any, propertyKey: PropertyKey, receiver?: any): any; + getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + getPrototypeOf(target: any): any; + has(target: any, propertyKey: string): boolean; + has(target: any, propertyKey: Symbol): boolean; + isExtensible(target: any): boolean; + ownKeys(target: any): Array; + preventExtensions(target: any): boolean; + set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean; + setPrototypeOf(target: any, proto: any): boolean; +}; + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | Promise): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param init A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: (T | Promise)[]): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of values. + * @returns A new Promise. + */ + all(values: Promise[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | Promise)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | Promise): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +}///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// + +declare module Intl { + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): Collator; + new (locale?: string, options?: NumberFormatOptions): Collator; + (locales?: string[], options?: NumberFormatOptions): Collator; + (locale?: string, options?: NumberFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date: number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): Collator; + new (locale?: string, options?: DateTimeFormatOptions): Collator; + (locales?: string[], options?: DateTimeFormatOptions): Collator; + (locale?: string, options?: DateTimeFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + /** + * Converts a number to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; + + /** + * Converts a number to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; +} + +interface Date { + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; +} + +///////////////////////////// +/// IE DOM APIs +///////////////////////////// + + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: string[]; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: string[]; +} + +interface AlgorithmParameters { +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: string[]; +} + +interface PointerEventInit extends MouseEventInit { + pointerId?: number; + width?: number; + height?: number; + pressure?: number; + tiltX?: number; + tiltY?: number; + pointerType?: string; + isPrimary?: boolean; +} + +interface ExceptionInformation { + domain?: string; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface Algorithm { + name?: string; + params?: AlgorithmParameters; +} + +interface MouseEventInit { + bubbles?: boolean; + cancelable?: boolean; + view?: Window; + detail?: number; + screenX?: number; + screenY?: number; + clientX?: number; + clientY?: number; + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + button?: number; + buttons?: number; + relatedTarget?: EventTarget; +} + +interface WebGLContextAttributes { + alpha?: boolean; + depth?: boolean; + stencil?: boolean; + antialias?: boolean; + premultipliedAlpha?: boolean; + preserveDrawingBuffer?: boolean; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { + hidden: any; + readyState: any; + onmouseleave: (ev: MouseEvent) => any; + onbeforecut: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + onmove: (ev: MSEventObj) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onhelp: (ev: Event) => any; + ondragleave: (ev: DragEvent) => any; + className: string; + onfocusin: (ev: FocusEvent) => any; + onseeked: (ev: Event) => any; + recordNumber: any; + title: string; + parentTextEdit: Element; + outerHTML: string; + ondurationchange: (ev: Event) => any; + offsetHeight: number; + all: HTMLCollection; + onblur: (ev: FocusEvent) => any; + dir: string; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + ondeactivate: (ev: UIEvent) => any; + ondatasetchanged: (ev: MSEventObj) => any; + onrowsdelete: (ev: MSEventObj) => any; + sourceIndex: number; + onloadstart: (ev: Event) => any; + onlosecapture: (ev: MSEventObj) => any; + ondragenter: (ev: DragEvent) => any; + oncontrolselect: (ev: MSEventObj) => any; + onsubmit: (ev: Event) => any; + behaviorUrns: MSBehaviorUrnsCollection; + scopeName: string; + onchange: (ev: Event) => any; + id: string; + onlayoutcomplete: (ev: MSEventObj) => any; + uniqueID: string; + onbeforeactivate: (ev: UIEvent) => any; + oncanplaythrough: (ev: Event) => any; + onbeforeupdate: (ev: MSEventObj) => any; + onfilterchange: (ev: MSEventObj) => any; + offsetParent: Element; + ondatasetcomplete: (ev: MSEventObj) => any; + onsuspend: (ev: Event) => any; + onmouseenter: (ev: MouseEvent) => any; + innerText: string; + onerrorupdate: (ev: MSEventObj) => any; + onmouseout: (ev: MouseEvent) => any; + parentElement: HTMLElement; + onmousewheel: (ev: MouseWheelEvent) => any; + onvolumechange: (ev: Event) => any; + oncellchange: (ev: MSEventObj) => any; + onrowexit: (ev: MSEventObj) => any; + onrowsinserted: (ev: MSEventObj) => any; + onpropertychange: (ev: MSEventObj) => any; + filters: any; + children: HTMLCollection; + ondragend: (ev: DragEvent) => any; + onbeforepaste: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + offsetTop: number; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + onbeforecopy: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + innerHTML: string; + onmouseover: (ev: MouseEvent) => any; + lang: string; + uniqueNumber: number; + onpause: (ev: Event) => any; + tagUrn: string; + onmousedown: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + onwaiting: (ev: Event) => any; + onresizestart: (ev: MSEventObj) => any; + offsetLeft: number; + isTextEdit: boolean; + isDisabled: boolean; + onpaste: (ev: DragEvent) => any; + canHaveHTML: boolean; + onmoveend: (ev: MSEventObj) => any; + language: string; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + style: MSStyleCSSProperties; + isContentEditable: boolean; + onbeforeeditfocus: (ev: MSEventObj) => any; + onratechange: (ev: Event) => any; + contentEditable: string; + tabIndex: number; + document: Document; + onprogress: (ev: ProgressEvent) => any; + ondblclick: (ev: MouseEvent) => any; + oncontextmenu: (ev: MouseEvent) => any; + onloadedmetadata: (ev: Event) => any; + onafterupdate: (ev: MSEventObj) => any; + onerror: (ev: ErrorEvent) => any; + onplay: (ev: Event) => any; + onresizeend: (ev: MSEventObj) => any; + onplaying: (ev: Event) => any; + isMultiLine: boolean; + onfocusout: (ev: FocusEvent) => any; + onabort: (ev: UIEvent) => any; + ondataavailable: (ev: MSEventObj) => any; + hideFocus: boolean; + onreadystatechange: (ev: Event) => any; + onkeypress: (ev: KeyboardEvent) => any; + onloadeddata: (ev: Event) => any; + onbeforedeactivate: (ev: UIEvent) => any; + outerText: string; + disabled: boolean; + onactivate: (ev: UIEvent) => any; + accessKey: string; + onmovestart: (ev: MSEventObj) => any; + onselectstart: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + oncut: (ev: DragEvent) => any; + onselect: (ev: UIEvent) => any; + ondrop: (ev: DragEvent) => any; + offsetWidth: number; + oncopy: (ev: DragEvent) => any; + onended: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + onrowenter: (ev: MSEventObj) => any; + onload: (ev: Event) => any; + canHaveChildren: boolean; + oninput: (ev: Event) => any; + onmscontentzoom: (ev: MSEventObj) => any; + oncuechange: (ev: Event) => any; + spellcheck: boolean; + classList: DOMTokenList; + onmsmanipulationstatechanged: (ev: any) => any; + draggable: boolean; + dataset: DOMStringMap; + dragDrop(): boolean; + scrollIntoView(top?: boolean): void; + addFilter(filter: any): void; + setCapture(containerCapture?: boolean): void; + focus(): void; + getAdjacentText(where: string): string; + insertAdjacentText(where: string, text: string): void; + getElementsByClassName(classNames: string): NodeList; + setActive(): void; + removeFilter(filter: any): void; + blur(): void; + clearAttributes(): void; + releaseCapture(): void; + createControlRange(): ControlRangeCollection; + removeBehavior(cookie: number): boolean; + contains(child: HTMLElement): boolean; + click(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; + replaceAdjacentText(where: string, newText: string): string; + applyElement(apply: Element, where?: string): Element; + addBehavior(bstrUrl: string, factory?: any): number; + insertAdjacentHTML(where: string, html: string): void; + msGetInputContext(): MSInputMethodContext; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLElement: { + prototype: HTMLElement; + new(): HTMLElement; +} + +interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions, MSDocumentExtensions, GlobalEventHandlers { + /** + * Gets a reference to the root node of the document. + */ + documentElement: HTMLElement; + /** + * Retrieves the collection of user agents and versions declared in the X-UA-Compatible + */ + compatible: MSCompatibleInfoCollection; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (ev: KeyboardEvent) => any; + /** + * Gets the implementation object of the current document. + */ + implementation: DOMImplementation; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (ev: Event) => any; + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollection; + /** + * Fires when the user presses the F1 key while the browser is the active window. + * @param ev The event. + */ + onhelp: (ev: Event) => any; + /** + * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. + * @param ev The drag event. + */ + ondragleave: (ev: DragEvent) => any; + /** + * Gets or sets the character set used to encode the object. + */ + charset: string; + /** + * Fires for an element just prior to setting focus on that element. + * @param ev The focus event + */ + onfocusin: (ev: FocusEvent) => any; + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (ev: Event) => any; + security: string; + /** + * Contains the title of the document. + */ + title: string; + /** + * Retrieves a collection of namespace objects. + */ + namespaces: MSNamespaceInfoCollection; + /** + * Gets the default character set from the current regional language settings. + */ + defaultCharset: string; + /** + * Retrieves a collection of all embed objects in the document. + */ + embeds: HTMLCollection; + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + styleSheets: StyleSheetList; + /** + * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. + */ + frames: Window; + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (ev: Event) => any; + /** + * Returns a reference to the collection of elements contained by the object. + */ + all: HTMLCollection; + /** + * Retrieves a collection, in source order, of all form objects in the document. + */ + forms: HTMLCollection; + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (ev: FocusEvent) => any; + /** + * Sets or retrieves a value that indicates the reading order of the object. + */ + dir: string; + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (ev: Event) => any; + /** + * Sets or gets a value that indicates whether the document can be edited. + */ + designMode: string; + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (ev: Event) => any; + /** + * Fires when the activeElement is changed from the current object to another object in the parent document. + * @param ev The UI Event + */ + ondeactivate: (ev: UIEvent) => any; + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (ev: Event) => any; + /** + * Fires when the data set exposed by a data source object changes. + * @param ev The event. + */ + ondatasetchanged: (ev: MSEventObj) => any; + /** + * Fires when rows are about to be deleted from the recordset. + * @param ev The event + */ + onrowsdelete: (ev: MSEventObj) => any; + Script: MSScriptHost; + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (ev: Event) => any; + /** + * Gets the URL for the document, stripped of any character encoding. + */ + URLUnencoded: string; + defaultView: Window; + /** + * Fires when the user is about to make a control selection of the object. + * @param ev The event. + */ + oncontrolselect: (ev: MSEventObj) => any; + /** + * Fires on the target element when the user drags the object to a valid drop target. + * @param ev The drag event. + */ + ondragenter: (ev: DragEvent) => any; + onsubmit: (ev: Event) => any; + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + inputEncoding: string; + /** + * Gets the object that has the focus when the parent document has focus. + */ + activeElement: Element; + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (ev: Event) => any; + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + */ + links: HTMLCollection; + /** + * Retrieves an autogenerated, unique identifier for the object. + */ + uniqueID: string; + /** + * Sets or gets the URL for the current document. + */ + URL: string; + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (ev: UIEvent) => any; + head: HTMLHeadElement; + cookie: string; + xmlEncoding: string; + oncanplaythrough: (ev: Event) => any; + /** + * Retrieves the document compatibility mode of the document. + */ + documentMode: number; + characterSet: string; + /** + * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. + */ + anchors: HTMLCollection; + onbeforeupdate: (ev: MSEventObj) => any; + /** + * Fires to indicate that all data is available from the data source object. + * @param ev The event. + */ + ondatasetcomplete: (ev: MSEventObj) => any; + plugins: HTMLCollection; + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (ev: Event) => any; + /** + * Gets the root svg element in the document hierarchy. + */ + rootElement: SVGSVGElement; + /** + * Retrieves a value that indicates the current state of the object. + */ + readyState: string; + /** + * Gets the URL of the location that referred the user to the current page. + */ + referrer: string; + /** + * Sets or gets the color of all active links in the document. + */ + alinkColor: string; + /** + * Fires on a databound object when an error occurs while updating the associated data in the data source object. + * @param ev The event. + */ + onerrorupdate: (ev: MSEventObj) => any; + /** + * Gets a reference to the container object of the window. + */ + parentWindow: Window; + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (ev: MouseEvent) => any; + /** + * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. + * @param ev The event. + */ + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (ev: MouseWheelEvent) => any; + /** + * Occurs when the volume is changed, or playback is muted or unmuted. + * @param ev The event. + */ + onvolumechange: (ev: Event) => any; + /** + * Fires when data changes in the data provider. + * @param ev The event. + */ + oncellchange: (ev: MSEventObj) => any; + /** + * Fires just before the data source control changes the current row in the object. + * @param ev The event. + */ + onrowexit: (ev: MSEventObj) => any; + /** + * Fires just after new rows are inserted in the current recordset. + * @param ev The event. + */ + onrowsinserted: (ev: MSEventObj) => any; + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string; + msCapsLockWarningOff: boolean; + /** + * Fires when a property changes on the object. + * @param ev The event. + */ + onpropertychange: (ev: MSEventObj) => any; + /** + * Fires on the source object when the user releases the mouse at the close of a drag operation. + * @param ev The event. + */ + ondragend: (ev: DragEvent) => any; + /** + * Gets an object representing the document type declaration associated with the current document. + */ + doctype: DocumentType; + /** + * Fires on the target element continuously while the user drags the object over a valid drop target. + * @param ev The event. + */ + ondragover: (ev: DragEvent) => any; + /** + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + */ + bgColor: string; + /** + * Fires on the source object when the user starts to drag a text selection or selected object. + * @param ev The event. + */ + ondragstart: (ev: DragEvent) => any; + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (ev: MouseEvent) => any; + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (ev: DragEvent) => any; + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (ev: MouseEvent) => any; + /** + * Sets or gets the color of the document links. + */ + linkColor: string; + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (ev: Event) => any; + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (ev: MouseEvent) => any; + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (ev: MouseEvent) => any; + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (ev: Event) => any; + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (ev: Event) => any; + /** + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * @param ev The event. + */ + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollection; + /** + * Specifies the beginning and end of the document body. + */ + body: HTMLElement; + /** + * Sets or gets the security domain of the document. + */ + domain: string; + xmlStandalone: boolean; + /** + * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. + */ + selection: MSSelection; + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (ev: Event) => any; + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (ev: MouseEvent) => any; + /** + * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. + * @param ev The event. + */ + onbeforeeditfocus: (ev: MSEventObj) => any; + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (ev: Event) => any; + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (ev: ProgressEvent) => any; + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (ev: MouseEvent) => any; + /** + * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * @param ev The mouse event. + */ + oncontextmenu: (ev: MouseEvent) => any; + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (ev: Event) => any; + media: string; + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (ev: ErrorEvent) => any; + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (ev: Event) => any; + onafterupdate: (ev: MSEventObj) => any; + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (ev: Event) => any; + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollection; + /** + * Contains information about the current URL. + */ + location: Location; + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (ev: UIEvent) => any; + /** + * Fires for the current element with focus immediately after moving focus to another element. + * @param ev The event. + */ + onfocusout: (ev: FocusEvent) => any; + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (ev: Event) => any; + /** + * Fires when a local DOM Storage area is written to disk. + * @param ev The event. + */ + onstoragecommit: (ev: StorageEvent) => any; + /** + * Fires periodically as data arrives from data source objects that asynchronously transmit their data. + * @param ev The event. + */ + ondataavailable: (ev: MSEventObj) => any; + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (ev: Event) => any; + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + lastModified: string; + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (ev: KeyboardEvent) => any; + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (ev: Event) => any; + /** + * Fires immediately before the activeElement is changed from the current object to another object in the parent document. + * @param ev The event. + */ + onbeforedeactivate: (ev: UIEvent) => any; + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (ev: UIEvent) => any; + onselectstart: (ev: Event) => any; + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (ev: FocusEvent) => any; + /** + * Sets or gets the foreground (text) color of the document. + */ + fgColor: string; + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (ev: Event) => any; + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (ev: UIEvent) => any; + ondrop: (ev: DragEvent) => any; + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (ev: Event) => any; + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + */ + compatMode: string; + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (ev: UIEvent) => any; + /** + * Fires to indicate that the current row has changed in the data source and new data values are available on the object. + * @param ev The event. + */ + onrowenter: (ev: MSEventObj) => any; + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (ev: Event) => any; + oninput: (ev: Event) => any; + onmspointerdown: (ev: any) => any; + msHidden: boolean; + msVisibilityState: string; + onmsgesturedoubletap: (ev: any) => any; + visibilityState: string; + onmsmanipulationstatechanged: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmscontentzoom: (ev: MSEventObj) => any; + onmspointermove: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + msCSSOMElementFloatMetrics: boolean; + onmspointerover: (ev: any) => any; + hidden: boolean; + onmspointerup: (ev: any) => any; + msFullscreenEnabled: boolean; + onmsfullscreenerror: (ev: any) => any; + onmspointerenter: (ev: any) => any; + msFullscreenElement: Element; + onmsfullscreenchange: (ev: any) => any; + onmspointerleave: (ev: any) => any; + /** + * Returns a reference to the first object with the specified value of the ID or NAME attribute. + * @param elementId String that specifies the ID value. Case-insensitive. + */ + getElementById(elementId: string): HTMLElement; + /** + * Returns the current value of the document, range, or current selection for the given command. + * @param commandId String that specifies a command identifier. + */ + queryCommandValue(commandId: string): string; + adoptNode(source: Node): Node; + /** + * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. + * @param commandId String that specifies a command identifier. + */ + queryCommandIndeterm(commandId: string): boolean; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + /** + * Executes a command on the current document, current selection, or the given range. + * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. + * @param showUI Display the user interface, defaults to false. + * @param value Value to assign. + */ + execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + /** + * Returns the element for the specified x coordinate and the specified y coordinate. + * @param x The x-offset + * @param y The y-offset + */ + elementFromPoint(x: number, y: number): Element; + createCDATASection(data: string): CDATASection; + /** + * Retrieves the string associated with a command. + * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. + */ + queryCommandText(commandId: string): string; + /** + * Writes one or more HTML expressions to a document in the specified window. + * @param content Specifies the text and HTML tags to write. + */ + write(...content: string[]): void; + /** + * Allows updating the print settings for the page. + */ + updateSettings(): void; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "a"): HTMLAnchorElement; + createElement(tagName: "abbr"): HTMLPhraseElement; + createElement(tagName: "acronym"): HTMLPhraseElement; + createElement(tagName: "address"): HTMLBlockElement; + createElement(tagName: "applet"): HTMLAppletElement; + createElement(tagName: "area"): HTMLAreaElement; + createElement(tagName: "article"): HTMLElement; + createElement(tagName: "aside"): HTMLElement; + createElement(tagName: "audio"): HTMLAudioElement; + createElement(tagName: "b"): HTMLPhraseElement; + createElement(tagName: "base"): HTMLBaseElement; + createElement(tagName: "basefont"): HTMLBaseFontElement; + createElement(tagName: "bdo"): HTMLPhraseElement; + createElement(tagName: "bgsound"): HTMLBGSoundElement; + createElement(tagName: "big"): HTMLPhraseElement; + createElement(tagName: "blockquote"): HTMLBlockElement; + createElement(tagName: "body"): HTMLBodyElement; + createElement(tagName: "br"): HTMLBRElement; + createElement(tagName: "button"): HTMLButtonElement; + createElement(tagName: "canvas"): HTMLCanvasElement; + createElement(tagName: "caption"): HTMLTableCaptionElement; + createElement(tagName: "center"): HTMLBlockElement; + createElement(tagName: "cite"): HTMLPhraseElement; + createElement(tagName: "code"): HTMLPhraseElement; + createElement(tagName: "col"): HTMLTableColElement; + createElement(tagName: "colgroup"): HTMLTableColElement; + createElement(tagName: "datalist"): HTMLDataListElement; + createElement(tagName: "dd"): HTMLDDElement; + createElement(tagName: "del"): HTMLModElement; + createElement(tagName: "dfn"): HTMLPhraseElement; + createElement(tagName: "dir"): HTMLDirectoryElement; + createElement(tagName: "div"): HTMLDivElement; + createElement(tagName: "dl"): HTMLDListElement; + createElement(tagName: "dt"): HTMLDTElement; + createElement(tagName: "em"): HTMLPhraseElement; + createElement(tagName: "embed"): HTMLEmbedElement; + createElement(tagName: "fieldset"): HTMLFieldSetElement; + createElement(tagName: "figcaption"): HTMLElement; + createElement(tagName: "figure"): HTMLElement; + createElement(tagName: "font"): HTMLFontElement; + createElement(tagName: "footer"): HTMLElement; + createElement(tagName: "form"): HTMLFormElement; + createElement(tagName: "frame"): HTMLFrameElement; + createElement(tagName: "frameset"): HTMLFrameSetElement; + createElement(tagName: "h1"): HTMLHeadingElement; + createElement(tagName: "h2"): HTMLHeadingElement; + createElement(tagName: "h3"): HTMLHeadingElement; + createElement(tagName: "h4"): HTMLHeadingElement; + createElement(tagName: "h5"): HTMLHeadingElement; + createElement(tagName: "h6"): HTMLHeadingElement; + createElement(tagName: "head"): HTMLHeadElement; + createElement(tagName: "header"): HTMLElement; + createElement(tagName: "hgroup"): HTMLElement; + createElement(tagName: "hr"): HTMLHRElement; + createElement(tagName: "html"): HTMLHtmlElement; + createElement(tagName: "i"): HTMLPhraseElement; + createElement(tagName: "iframe"): HTMLIFrameElement; + createElement(tagName: "img"): HTMLImageElement; + createElement(tagName: "input"): HTMLInputElement; + createElement(tagName: "ins"): HTMLModElement; + createElement(tagName: "isindex"): HTMLIsIndexElement; + createElement(tagName: "kbd"): HTMLPhraseElement; + createElement(tagName: "keygen"): HTMLBlockElement; + createElement(tagName: "label"): HTMLLabelElement; + createElement(tagName: "legend"): HTMLLegendElement; + createElement(tagName: "li"): HTMLLIElement; + createElement(tagName: "link"): HTMLLinkElement; + createElement(tagName: "listing"): HTMLBlockElement; + createElement(tagName: "map"): HTMLMapElement; + createElement(tagName: "mark"): HTMLElement; + createElement(tagName: "marquee"): HTMLMarqueeElement; + createElement(tagName: "menu"): HTMLMenuElement; + createElement(tagName: "meta"): HTMLMetaElement; + createElement(tagName: "nav"): HTMLElement; + createElement(tagName: "nextid"): HTMLNextIdElement; + createElement(tagName: "nobr"): HTMLPhraseElement; + createElement(tagName: "noframes"): HTMLElement; + createElement(tagName: "noscript"): HTMLElement; + createElement(tagName: "object"): HTMLObjectElement; + createElement(tagName: "ol"): HTMLOListElement; + createElement(tagName: "optgroup"): HTMLOptGroupElement; + createElement(tagName: "option"): HTMLOptionElement; + createElement(tagName: "p"): HTMLParagraphElement; + createElement(tagName: "param"): HTMLParamElement; + createElement(tagName: "plaintext"): HTMLBlockElement; + createElement(tagName: "pre"): HTMLPreElement; + createElement(tagName: "progress"): HTMLProgressElement; + createElement(tagName: "q"): HTMLQuoteElement; + createElement(tagName: "rt"): HTMLPhraseElement; + createElement(tagName: "ruby"): HTMLPhraseElement; + createElement(tagName: "s"): HTMLPhraseElement; + createElement(tagName: "samp"): HTMLPhraseElement; + createElement(tagName: "script"): HTMLScriptElement; + createElement(tagName: "section"): HTMLElement; + createElement(tagName: "select"): HTMLSelectElement; + createElement(tagName: "small"): HTMLPhraseElement; + createElement(tagName: "SOURCE"): HTMLSourceElement; + createElement(tagName: "span"): HTMLSpanElement; + createElement(tagName: "strike"): HTMLPhraseElement; + createElement(tagName: "strong"): HTMLPhraseElement; + createElement(tagName: "style"): HTMLStyleElement; + createElement(tagName: "sub"): HTMLPhraseElement; + createElement(tagName: "sup"): HTMLPhraseElement; + createElement(tagName: "table"): HTMLTableElement; + createElement(tagName: "tbody"): HTMLTableSectionElement; + createElement(tagName: "td"): HTMLTableDataCellElement; + createElement(tagName: "textarea"): HTMLTextAreaElement; + createElement(tagName: "tfoot"): HTMLTableSectionElement; + createElement(tagName: "th"): HTMLTableHeaderCellElement; + createElement(tagName: "thead"): HTMLTableSectionElement; + createElement(tagName: "title"): HTMLTitleElement; + createElement(tagName: "tr"): HTMLTableRowElement; + createElement(tagName: "track"): HTMLTrackElement; + createElement(tagName: "tt"): HTMLPhraseElement; + createElement(tagName: "u"): HTMLPhraseElement; + createElement(tagName: "ul"): HTMLUListElement; + createElement(tagName: "var"): HTMLPhraseElement; + createElement(tagName: "video"): HTMLVideoElement; + createElement(tagName: "wbr"): HTMLElement; + createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; + createElement(tagName: "xmp"): HTMLBlockElement; + createElement(tagName: string): HTMLElement; + /** + * Removes mouse capture from the object in the current document. + */ + releaseCapture(): void; + /** + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * @param content The text and HTML tags to write. + */ + writeln(...content: string[]): void; + createElementNS(namespaceURI: string, qualifiedName: string): Element; + /** + * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. + * @param url Specifies a MIME type for the document. + * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. + * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. + * @param replace Specifies whether the existing entry for the document is replaced in the history list. + */ + open(url?: string, name?: string, features?: string, replace?: boolean): any; + /** + * Returns a Boolean value that indicates whether the current command is supported on the current range. + * @param commandId Specifies a command identifier. + */ + queryCommandSupported(commandId: string): boolean; + /** + * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. + * @param filter A custom NodeFilter function to use. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + /** + * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. + * @param commandId Specifies a command identifier. + */ + queryCommandEnabled(commandId: string): boolean; + /** + * Causes the element to receive the focus and executes the code specified by the onfocus event. + */ + focus(): void; + /** + * Closes an output stream and forces the sent data to display. + */ + close(): void; + getElementsByClassName(classNames: string): NodeList; + importNode(importedNode: Node, deep: boolean): Node; + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + */ + createRange(): Range; + /** + * Fires a specified event on the object. + * @param eventName Specifies the name of the event to fire. + * @param eventObj Object that specifies the event object from which to obtain event object properties. + */ + fireEvent(eventName: string, eventObj?: any): boolean; + /** + * Creates a comment object with the specified data. + * @param data Sets the comment object's data. + */ + createComment(data: string): Comment; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "acronym"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "applet"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "basefont"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "bgsound"): NodeListOf; + getElementsByTagName(name: "big"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "center"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "dir"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "font"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "frame"): NodeListOf; + getElementsByTagName(name: "frameset"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "isindex"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "keygen"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "listing"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "marquee"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "nextid"): NodeListOf; + getElementsByTagName(name: "nobr"): NodeListOf; + getElementsByTagName(name: "noframes"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "plaintext"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "SOURCE"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strike"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "tt"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: "x-ms-webview"): NodeListOf; + getElementsByTagName(name: "xmp"): NodeListOf; + getElementsByTagName(name: string): NodeList; + /** + * Creates a new document. + */ + createDocumentFragment(): DocumentFragment; + /** + * Creates a style sheet for the document. + * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. + * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. + */ + createStyleSheet(href?: string, index?: number): CSSStyleSheet; + /** + * Gets a collection of objects based on the value of the NAME or ID attribute. + * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. + */ + getElementsByName(elementName: string): NodeList; + /** + * Returns a Boolean value that indicates the current state of the command. + * @param commandId String that specifies a command identifier. + */ + queryCommandState(commandId: string): boolean; + /** + * Gets a value indicating whether the object currently has focus. + */ + hasFocus(): boolean; + /** + * Displays help information for the given command identifier. + * @param commandId Displays help information for the given command identifier. + */ + execCommandShowHelp(commandId: string): boolean; + /** + * Creates an attribute object with a specified name. + * @param name String that sets the attribute object's name. + */ + createAttribute(name: string): Attr; + /** + * Creates a text string from the specified value. + * @param data String that specifies the nodeValue property of the text node. + */ + createTextNode(data: string): Text; + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list + * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; + /** + * Generates an event object to pass event context information when you use the fireEvent method. + * @param eventObj An object that specifies an existing event object on which to base the new object. + */ + createEventObject(eventObj?: any): MSEventObj; + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + clear(): void; + msExitFullscreen(): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storagecommit", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msfullscreenerror", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msfullscreenchange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Document: { + prototype: Document; + new(): Document; +} + +interface Console { + info(message?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; + error(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + profile(reportName?: string): void; + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + clear(): void; + dir(value?: any, ...optionalParams: any[]): void; + profileEnd(): void; + count(countTitle?: string): void; + groupEnd(): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(): void; + group(groupTitle?: string): void; + dirxml(value: any): void; + debug(message?: string, ...optionalParams: any[]): void; + groupCollapsed(groupTitle?: string): void; + select(element: Element): void; +} +declare var Console: { + prototype: Console; + new(): Console; +} + +interface MSEventObj extends Event { + nextPage: string; + keyCode: number; + toElement: Element; + returnValue: any; + dataFld: string; + y: number; + dataTransfer: DataTransfer; + propertyName: string; + url: string; + offsetX: number; + recordset: any; + screenX: number; + buttonID: number; + wheelDelta: number; + reason: number; + origin: string; + data: string; + srcFilter: any; + boundElements: HTMLCollection; + cancelBubble: boolean; + altLeft: boolean; + behaviorCookie: number; + bookmarks: BookmarkCollection; + type: string; + repeat: boolean; + srcElement: Element; + source: Window; + fromElement: Element; + offsetY: number; + x: number; + behaviorPart: number; + qualifier: string; + altKey: boolean; + ctrlKey: boolean; + clientY: number; + shiftKey: boolean; + shiftLeft: boolean; + contentOverflow: boolean; + screenY: number; + ctrlLeft: boolean; + button: number; + srcUrn: string; + clientX: number; + actionURL: string; + getAttribute(strAttributeName: string, lFlags?: number): any; + setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; + removeAttribute(strAttributeName: string, lFlags?: number): boolean; +} +declare var MSEventObj: { + prototype: MSEventObj; + new(): MSEventObj; +} + +interface HTMLCanvasElement extends HTMLElement { + /** + * Gets or sets the width of a canvas element on a document. + */ + width: number; + /** + * Gets or sets the height of a canvas element on a document. + */ + height: number; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); + */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); + */ + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); + */ + getContext(contextId: string, ...args: any[]): any; + /** + * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. + * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. + */ + toDataURL(type?: string, ...args: any[]): string; + /** + * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. + */ + msToBlob(): Blob; +} +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new(): HTMLCanvasElement; +} + +interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers, WindowBase64, IDBEnvironment, WindowConsole, GlobalEventHandlers { + ondragend: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + ondragover: (ev: DragEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + screenX: number; + onmouseover: (ev: MouseEvent) => any; + ondragleave: (ev: DragEvent) => any; + history: History; + pageXOffset: number; + name: string; + onafterprint: (ev: Event) => any; + onpause: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + top: Window; + onmousedown: (ev: MouseEvent) => any; + onseeked: (ev: Event) => any; + opener: Window; + onclick: (ev: MouseEvent) => any; + innerHeight: number; + onwaiting: (ev: Event) => any; + ononline: (ev: Event) => any; + ondurationchange: (ev: Event) => any; + frames: Window; + onblur: (ev: FocusEvent) => any; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + outerWidth: number; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + innerWidth: number; + onoffline: (ev: Event) => any; + length: number; + screen: Screen; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onratechange: (ev: Event) => any; + onstorage: (ev: StorageEvent) => any; + onloadstart: (ev: Event) => any; + ondragenter: (ev: DragEvent) => any; + onsubmit: (ev: Event) => any; + self: Window; + document: Document; + onprogress: (ev: ProgressEvent) => any; + ondblclick: (ev: MouseEvent) => any; + pageYOffset: number; + oncontextmenu: (ev: MouseEvent) => any; + onchange: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onplay: (ev: Event) => any; + onerror: ErrorEventHandler; + onplaying: (ev: Event) => any; + parent: Window; + location: Location; + oncanplaythrough: (ev: Event) => any; + onabort: (ev: UIEvent) => any; + onreadystatechange: (ev: Event) => any; + outerHeight: number; + onkeypress: (ev: KeyboardEvent) => any; + frameElement: Element; + onloadeddata: (ev: Event) => any; + onsuspend: (ev: Event) => any; + window: Window; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onselect: (ev: UIEvent) => any; + navigator: Navigator; + styleMedia: StyleMedia; + ondrop: (ev: DragEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onended: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onunload: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + screenY: number; + onmousewheel: (ev: MouseWheelEvent) => any; + onload: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + oninput: (ev: Event) => any; + performance: Performance; + onmspointerdown: (ev: any) => any; + animationStartTime: number; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + msAnimationStartTime: number; + applicationCache: ApplicationCache; + onmsinertiastart: (ev: any) => any; + onmspointerover: (ev: any) => any; + onpopstate: (ev: PopStateEvent) => any; + onmspointerup: (ev: any) => any; + onpageshow: (ev: PageTransitionEvent) => any; + ondevicemotion: (ev: DeviceMotionEvent) => any; + devicePixelRatio: number; + msCrypto: Crypto; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + doNotTrack: string; + onmspointerenter: (ev: any) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onmspointerleave: (ev: any) => any; + alert(message?: any): void; + scroll(x?: number, y?: number): void; + focus(): void; + scrollTo(x?: number, y?: number): void; + print(): void; + prompt(message?: string, _default?: string): string; + toString(): string; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + scrollBy(x?: number, y?: number): void; + confirm(message?: string): boolean; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; + showModalDialog(url?: string, argument?: any, options?: any): any; + blur(): void; + getSelection(): Selection; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + msCancelRequestAnimationFrame(handle: number): void; + matchMedia(mediaQuery: string): MediaQueryList; + cancelAnimationFrame(handle: number): void; + msIsStaticHTML(html: string): boolean; + msMatchMedia(mediaQuery: string): MediaQueryList; + requestAnimationFrame(callback: FrameRequestCallback): number; + msRequestAnimationFrame(callback: FrameRequestCallback): number; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Window: { + prototype: Window; + new(): Window; +} + +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 HTMLCollection: { + prototype: 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; + userAgent: string; + platform: string; + product: string; + vendor: string; +} + +interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the amount of space between cells in a table. + */ + cellSpacing: string; + /** + * Retrieves the tFoot object of the table. + */ + tFoot: HTMLTableSectionElement; + /** + * Sets or retrieves the way the border frame around the table is displayed. + */ + frame: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Sets or retrieves which dividing lines (inner borders) are displayed. + */ + rules: string; + /** + * Sets or retrieves the number of columns in the table. + */ + cols: number; + /** + * Sets or retrieves a description and/or structure of the object. + */ + summary: string; + /** + * Retrieves the caption object of a table. + */ + caption: HTMLTableCaptionElement; + /** + * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. + */ + tBodies: HTMLCollection; + /** + * Retrieves the tHead object of the table. + */ + tHead: HTMLTableSectionElement; + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Retrieves a collection of all cells in the table row or in the entire table. + */ + cells: HTMLCollection; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the amount of space between the border of the cell and the content of the cell. + */ + cellPadding: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Creates an empty tBody element in the table. + */ + createTBody(): HTMLElement; + /** + * Deletes the caption element and its contents from the table. + */ + deleteCaption(): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; + /** + * Deletes the tFoot element and its contents from the table. + */ + deleteTFoot(): void; + /** + * Returns the tHead element object if successful, or null otherwise. + */ + createTHead(): HTMLElement; + /** + * Deletes the tHead element and its contents from the table. + */ + deleteTHead(): void; + /** + * Creates an empty caption element in the table. + */ + createCaption(): HTMLElement; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): any; + /** + * Creates an empty tFoot element in the table. + */ + createTFoot(): HTMLElement; +} +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new(): HTMLTableElement; +} + +interface TreeWalker { + whatToShow: number; + filter: NodeFilter; + root: Node; + currentNode: Node; + expandEntityReferences: boolean; + previousSibling(): Node; + lastChild(): Node; + nextSibling(): Node; + nextNode(): Node; + parentNode(): Node; + firstChild(): Node; + previousNode(): Node; +} +declare var TreeWalker: { + prototype: TreeWalker; + new(): TreeWalker; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new(): SVGPathSegCurvetoQuadraticRel; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + getEntriesByType(entryType: string): any; + toJSON(): any; + getMeasures(measureName?: string): any; + clearMarks(markName?: string): void; + getMarks(markName?: string): any; + clearResourceTimings(): void; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + getEntriesByName(name: string, entryType?: string): any; + getEntries(): any; + clearMeasures(measureName?: string): void; + setResourceTimingBufferSize(maxSize: number): void; + now(): number; +} +declare var Performance: { + prototype: Performance; + new(): Performance; +} + +interface MSDataBindingTableExtensions { + dataPageSize: number; + nextPage(): void; + firstPage(): void; + refresh(): void; + previousPage(): void; + lastPage(): void; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} +declare var CompositionEvent: { + prototype: CompositionEvent; + new(): CompositionEvent; +} + +interface WindowTimers extends WindowTimersExtension { + clearTimeout(handle: number): void; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; + clearInterval(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { + orientType: SVGAnimatedEnumeration; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + markerHeight: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + refY: SVGAnimatedLength; + refX: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new(): SVGMarkerElement; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} + +interface CSSStyleDeclaration { + backgroundAttachment: string; + visibility: string; + textAlignLast: string; + borderRightStyle: string; + counterIncrement: string; + orphans: string; + cssText: string; + borderStyle: string; + pointerEvents: string; + borderTopColor: string; + markerEnd: string; + textIndent: string; + listStyleImage: string; + cursor: string; + listStylePosition: string; + wordWrap: string; + borderTopStyle: string; + alignmentBaseline: string; + opacity: string; + direction: string; + strokeMiterlimit: string; + maxWidth: string; + color: string; + clip: string; + borderRightWidth: string; + verticalAlign: string; + overflow: string; + mask: string; + borderLeftStyle: string; + emptyCells: string; + stopOpacity: string; + paddingRight: string; + parentRule: CSSRule; + background: string; + boxSizing: string; + textJustify: string; + height: string; + paddingTop: string; + length: number; + right: string; + baselineShift: string; + borderLeft: string; + widows: string; + lineHeight: string; + left: string; + textUnderlinePosition: string; + glyphOrientationHorizontal: string; + display: string; + textAnchor: string; + cssFloat: string; + strokeDasharray: string; + rubyAlign: string; + fontSizeAdjust: string; + borderLeftColor: string; + backgroundImage: string; + listStyleType: string; + strokeWidth: string; + textOverflow: string; + fillRule: string; + borderBottomColor: string; + zIndex: string; + position: string; + listStyle: string; + msTransformOrigin: string; + dominantBaseline: string; + overflowY: string; + fill: string; + captionSide: string; + borderCollapse: string; + boxShadow: string; + quotes: string; + tableLayout: string; + unicodeBidi: string; + borderBottomWidth: string; + backgroundSize: string; + textDecoration: string; + strokeDashoffset: string; + fontSize: string; + border: string; + pageBreakBefore: string; + borderTopRightRadius: string; + msTransform: string; + borderBottomLeftRadius: string; + textTransform: string; + rubyPosition: string; + strokeLinejoin: string; + clipPath: string; + borderRightColor: string; + fontFamily: string; + clear: string; + content: string; + backgroundClip: string; + marginBottom: string; + counterReset: string; + outlineWidth: string; + marginRight: string; + paddingLeft: string; + borderBottom: string; + wordBreak: string; + marginTop: string; + top: string; + fontWeight: string; + borderRight: string; + width: string; + kerning: string; + pageBreakAfter: string; + borderBottomStyle: string; + fontStretch: string; + padding: string; + strokeOpacity: string; + markerStart: string; + bottom: string; + borderLeftWidth: string; + clipRule: string; + backgroundPosition: string; + backgroundColor: string; + pageBreakInside: string; + backgroundOrigin: string; + strokeLinecap: string; + borderTopWidth: string; + outlineStyle: string; + borderTop: string; + outlineColor: string; + paddingBottom: string; + marginLeft: string; + font: string; + outline: string; + wordSpacing: string; + maxHeight: string; + fillOpacity: string; + letterSpacing: string; + borderSpacing: string; + backgroundRepeat: string; + borderRadius: string; + borderWidth: string; + borderBottomRightRadius: string; + whiteSpace: string; + fontStyle: string; + minWidth: string; + stopColor: string; + borderTopLeftRadius: string; + borderColor: string; + marker: string; + glyphOrientationVertical: string; + markerMid: string; + fontVariant: string; + minHeight: string; + stroke: string; + rubyOverhang: string; + overflowX: string; + textAlign: string; + margin: string; + animationFillMode: string; + floodColor: string; + animationIterationCount: string; + textShadow: string; + backfaceVisibility: string; + msAnimationIterationCount: string; + animationDelay: string; + animationTimingFunction: string; + columnWidth: any; + msScrollSnapX: string; + columnRuleColor: any; + columnRuleWidth: any; + transitionDelay: string; + transition: string; + msFlowFrom: string; + msScrollSnapType: string; + msContentZoomSnapType: string; + msGridColumns: string; + msAnimationName: string; + msGridRowAlign: string; + msContentZoomChaining: string; + msGridColumn: any; + msHyphenateLimitZone: any; + msScrollRails: string; + msAnimationDelay: string; + enableBackground: string; + msWrapThrough: string; + columnRuleStyle: string; + msAnimation: string; + msFlexFlow: string; + msScrollSnapY: string; + msHyphenateLimitLines: any; + msTouchAction: string; + msScrollLimit: string; + animation: string; + transform: string; + filter: string; + colorInterpolationFilters: string; + transitionTimingFunction: string; + msBackfaceVisibility: string; + animationPlayState: string; + transformOrigin: string; + msScrollLimitYMin: any; + msFontFeatureSettings: string; + msContentZoomLimitMin: any; + columnGap: any; + transitionProperty: string; + msAnimationDuration: string; + msAnimationFillMode: string; + msFlexDirection: string; + msTransitionDuration: string; + fontFeatureSettings: string; + breakBefore: string; + msFlexWrap: string; + perspective: string; + msFlowInto: string; + msTransformStyle: string; + msScrollTranslation: string; + msTransitionProperty: string; + msUserSelect: string; + msOverflowStyle: string; + msScrollSnapPointsY: string; + animationDirection: string; + animationDuration: string; + msFlex: string; + msTransitionTimingFunction: string; + animationName: string; + columnRule: string; + msGridColumnSpan: any; + msFlexNegative: string; + columnFill: string; + msGridRow: any; + msFlexOrder: string; + msFlexItemAlign: string; + msFlexPositive: string; + msContentZoomLimitMax: any; + msScrollLimitYMax: any; + msGridColumnAlign: string; + perspectiveOrigin: string; + lightingColor: string; + columns: string; + msScrollChaining: string; + msHyphenateLimitChars: string; + msTouchSelect: string; + floodOpacity: string; + msAnimationDirection: string; + msAnimationPlayState: string; + columnSpan: string; + msContentZooming: string; + msPerspective: string; + msFlexPack: string; + msScrollSnapPointsX: string; + msContentZoomSnapPoints: string; + msGridRowSpan: any; + msContentZoomSnap: string; + msScrollLimitXMin: any; + breakInside: string; + msHighContrastAdjust: string; + msFlexLinePack: string; + msGridRows: string; + transitionDuration: string; + msHyphens: string; + breakAfter: string; + msTransition: string; + msPerspectiveOrigin: string; + msContentZoomLimit: string; + msScrollLimitXMax: any; + msFlexAlign: string; + msWrapMargin: any; + columnCount: any; + msAnimationTimingFunction: string; + msTransitionDelay: string; + transformStyle: string; + msWrapFlow: string; + msFlexPreferredSize: string; + alignItems: string; + borderImageSource: string; + flexBasis: string; + borderImageWidth: string; + borderImageRepeat: string; + order: string; + flex: string; + alignContent: string; + msImeAlign: string; + flexShrink: string; + flexGrow: string; + borderImageSlice: string; + flexWrap: string; + borderImageOutset: string; + flexDirection: string; + touchAction: string; + flexFlow: string; + borderImage: string; + justifyContent: string; + alignSelf: string; + msTextCombineHorizontal: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + removeProperty(propertyName: string): string; + item(index: number): string; + [index: number]: string; + setProperty(propertyName: string, value: string, priority?: string): void; +} +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new(): CSSStyleDeclaration; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGGElement: { + prototype: SVGGElement; + new(): SVGGElement; +} + +interface MSStyleCSSProperties extends MSCSSProperties { + pixelWidth: number; + posHeight: number; + posLeft: number; + pixelTop: number; + pixelBottom: number; + textDecorationNone: boolean; + pixelLeft: number; + posTop: number; + posBottom: number; + textDecorationOverline: boolean; + posWidth: number; + textDecorationLineThrough: boolean; + pixelHeight: number; + textDecorationBlink: boolean; + posRight: number; + pixelRight: number; + textDecorationUnderline: boolean; +} +declare var MSStyleCSSProperties: { + prototype: MSStyleCSSProperties; + new(): MSStyleCSSProperties; +} + +interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils, MSFileSaver { + msMaxTouchPoints: number; + msPointerEnabled: boolean; + msManipulationViewsEnabled: boolean; + pointerEnabled: boolean; + maxTouchPoints: number; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; +} +declare var Navigator: { + prototype: Navigator; + new(): Navigator; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new(): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGZoomEvent extends UIEvent { + zoomRectScreen: SVGRect; + previousScale: number; + newScale: number; + previousTranslate: SVGPoint; + newTranslate: SVGPoint; +} +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new(): SVGZoomEvent; +} + +interface NodeSelector { + querySelectorAll(selectors: string): NodeList; + querySelector(selectors: string): Element; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new(): HTMLTableDataCellElement; +} + +interface HTMLBaseElement extends HTMLElement { + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Gets or sets the baseline URL on which relative links are based. + */ + href: string; +} +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new(): HTMLBaseElement; +} + +interface ClientRect { + left: number; + width: number; + right: number; + top: number; + bottom: number; + height: number; +} +declare var ClientRect: { + prototype: ClientRect; + new(): ClientRect; +} + +interface PositionErrorCallback { + (error: PositionError): void; +} + +interface DOMImplementation { + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + hasFeature(feature: string, version?: string): boolean; + createHTMLDocument(title: string): Document; +} +declare var DOMImplementation: { + prototype: DOMImplementation; + new(): DOMImplementation; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: SVGUnitTypes; + +interface Element extends Node, NodeSelector, ElementTraversal, GlobalEventHandlers { + scrollTop: number; + clientLeft: number; + scrollLeft: number; + tagName: string; + clientWidth: number; + scrollWidth: number; + clientHeight: number; + clientTop: number; + scrollHeight: number; + msRegionOverflow: string; + onmspointerdown: (ev: any) => any; + onmsgotpointercapture: (ev: any) => any; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + onmslostpointercapture: (ev: any) => any; + onmspointerover: (ev: any) => any; + msContentZoomFactor: number; + onmspointerup: (ev: any) => any; + onlostpointercapture: (ev: PointerEvent) => any; + onmspointerenter: (ev: any) => any; + ongotpointercapture: (ev: PointerEvent) => any; + onmspointerleave: (ev: any) => any; + getAttribute(name?: string): string; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + getBoundingClientRect(): ClientRect; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + msMatchesSelector(selectors: string): boolean; + hasAttribute(name: string): boolean; + removeAttribute(name?: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + getAttributeNode(name: string): Attr; + fireEvent(eventName: string, eventObj?: any): boolean; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "acronym"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "applet"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "basefont"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "bgsound"): NodeListOf; + getElementsByTagName(name: "big"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "center"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "dir"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "font"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "frame"): NodeListOf; + getElementsByTagName(name: "frameset"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "isindex"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "keygen"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "listing"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "marquee"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "nextid"): NodeListOf; + getElementsByTagName(name: "nobr"): NodeListOf; + getElementsByTagName(name: "noframes"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "plaintext"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "SOURCE"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strike"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "tt"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: "x-ms-webview"): NodeListOf; + getElementsByTagName(name: "xmp"): NodeListOf; + getElementsByTagName(name: string): NodeList; + getClientRects(): ClientRectList; + setAttributeNode(newAttr: Attr): Attr; + removeAttributeNode(oldAttr: Attr): Attr; + setAttribute(name?: string, value?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; + msGetRegionContent(): MSRangeCollection; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; + msZoomTo(args: MsZoomToOptions): void; + setPointerCapture(pointerId: number): void; + msGetUntransformedBounds(): ClientRect; + releasePointerCapture(pointerId: number): void; + msRequestFullscreen(): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Element: { + prototype: Element; + new(): Element; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new(): HTMLNextIdElement; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new(): SVGPathSegMovetoRel; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLineElement: { + prototype: SVGLineElement; + new(): SVGLineElement; +} + +interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; +} +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new(): HTMLParagraphElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + /** + * Removes an element from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + */ + add(element: HTMLElement, before?: any): void; +} +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new(): HTMLAreasCollection; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGDescElement: { + prototype: SVGDescElement; + new(): SVGDescElement; +} + +interface Node extends EventTarget { + nodeType: number; + previousSibling: Node; + localName: string; + namespaceURI: string; + textContent: string; + parentNode: Node; + nextSibling: Node; + nodeValue: string; + lastChild: Node; + childNodes: NodeList; + nodeName: string; + ownerDocument: Document; + attributes: NamedNodeMap; + firstChild: Node; + prefix: string; + removeChild(oldChild: Node): Node; + appendChild(newChild: Node): Node; + isSupported(feature: string, version: string): boolean; + isEqualNode(arg: Node): boolean; + lookupPrefix(namespaceURI: string): string; + isDefaultNamespace(namespaceURI: string): boolean; + compareDocumentPosition(other: Node): number; + normalize(): void; + isSameNode(other: Node): boolean; + hasAttributes(): boolean; + lookupNamespaceURI(prefix: string): string; + cloneNode(deep?: boolean): Node; + hasChildNodes(): boolean; + replaceChild(newChild: Node, oldChild: Node): Node; + insertBefore(newChild: Node, refChild?: Node): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} +declare var Node: { + prototype: Node; + new(): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new(): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface DOML2DeprecatedListSpaceReduction { + compact: boolean; +} + +interface MSScriptHost { +} +declare var MSScriptHost: { + prototype: MSScriptHost; + new(): MSScriptHost; +} + +interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + clipPathUnits: SVGAnimatedEnumeration; +} +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new(): SVGClipPathElement; +} + +interface MouseEvent extends UIEvent { + toElement: Element; + layerY: number; + fromElement: Element; + which: number; + pageX: number; + offsetY: number; + x: number; + y: number; + metaKey: boolean; + altKey: boolean; + ctrlKey: boolean; + offsetX: number; + screenX: number; + clientY: number; + shiftKey: boolean; + layerX: number; + screenY: number; + relatedTarget: EventTarget; + button: number; + pageY: number; + buttons: number; + clientX: number; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; + getModifierState(keyArg: string): boolean; +} +declare var MouseEvent: { + prototype: MouseEvent; + new(): MouseEvent; +} + +interface RangeException { + code: number; + message: string; + name: string; + toString(): string; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} +declare var RangeException: { + prototype: RangeException; + new(): RangeException; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + y: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + dy: SVGAnimatedLengthList; + x: SVGAnimatedLengthList; + dx: SVGAnimatedLengthList; +} +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new(): SVGTextPositioningElement; +} + +interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + width: number; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + object: string; + form: HTMLFormElement; + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. + */ + declare: boolean; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new(): HTMLAppletElement; +} + +interface TextMetrics { + width: number; +} +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +} + +interface DocumentEvent { + createEvent(eventInterface: "AnimationEvent"): AnimationEvent; + createEvent(eventInterface: "CloseEvent"): CloseEvent; + createEvent(eventInterface: "CompositionEvent"): CompositionEvent; + createEvent(eventInterface: "CustomEvent"): CustomEvent; + createEvent(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent; + createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent; + createEvent(eventInterface: "DragEvent"): DragEvent; + createEvent(eventInterface: "ErrorEvent"): ErrorEvent; + createEvent(eventInterface: "Event"): Event; + createEvent(eventInterface: "Events"): Event; + createEvent(eventInterface: "FocusEvent"): FocusEvent; + createEvent(eventInterface: "HTMLEvents"): Event; + createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface: "LongRunningScriptDetectedEvent"): LongRunningScriptDetectedEvent; + createEvent(eventInterface: "MessageEvent"): MessageEvent; + createEvent(eventInterface: "MouseEvent"): MouseEvent; + createEvent(eventInterface: "MouseEvents"): MouseEvent; + createEvent(eventInterface: "MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface: "MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface: "MSPointerEvent"): MSPointerEvent; + createEvent(eventInterface: "MutationEvent"): MutationEvent; + createEvent(eventInterface: "MutationEvents"): MutationEvent; + createEvent(eventInterface: "NavigationCompletedEvent"): NavigationCompletedEvent; + createEvent(eventInterface: "NavigationEvent"): NavigationEvent; + createEvent(eventInterface: "PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface: "PointerEvent"): MSPointerEvent; + createEvent(eventInterface: "PopStateEvent"): PopStateEvent; + createEvent(eventInterface: "ProgressEvent"): ProgressEvent; + createEvent(eventInterface: "StorageEvent"): StorageEvent; + createEvent(eventInterface: "SVGZoomEvents"): SVGZoomEvent; + createEvent(eventInterface: "TextEvent"): TextEvent; + createEvent(eventInterface: "TrackEvent"): TrackEvent; + createEvent(eventInterface: "TransitionEvent"): TransitionEvent; + createEvent(eventInterface: "UIEvent"): UIEvent; + createEvent(eventInterface: "UIEvents"): UIEvent; + createEvent(eventInterface: "UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; + createEvent(eventInterface: "WebGLContextEvent"): WebGLContextEvent; + createEvent(eventInterface: "WheelEvent"): WheelEvent; + createEvent(eventInterface: string): Event; +} + +interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * The starting number. + */ + start: number; +} +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new(): HTMLOListElement; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new(): SVGPathSegLinetoVerticalRel; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new(): SVGAnimatedString; +} + +interface CDATASection extends Text { +} +declare var CDATASection: { + prototype: CDATASection; + new(): CDATASection; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} +declare var StyleMedia: { + prototype: StyleMedia; + new(): StyleMedia; +} + +interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { + options: HTMLSelectElement; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the number of rows in the list box. + */ + size: number; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the index of the selected option in a select object. + */ + selectedIndex: number; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Retrieves the type of select control based on the value of the MULTIPLE attribute. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Removes an element from the collection. + * @param index Number that specifies the zero-based index of the element to remove from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. + * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. + */ + add(element: HTMLElement, before?: any): void; + /** + * Retrieves a select object or an object from an options collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a select object or an object from an options collection. + * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. + */ + namedItem(name: string): any; + [name: string]: any; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new(): HTMLSelectElement; +} + +interface TextRange { + boundingLeft: number; + htmlText: string; + offsetLeft: number; + boundingWidth: number; + boundingHeight: number; + boundingTop: number; + text: string; + offsetTop: number; + moveToPoint(x: number, y: number): void; + queryCommandValue(cmdID: string): any; + getBookmark(): string; + move(unit: string, count?: number): number; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(fStart?: boolean): void; + findText(string: string, count?: number, flags?: number): boolean; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + getBoundingClientRect(): ClientRect; + moveToBookmark(bookmark: string): boolean; + isEqual(range: TextRange): boolean; + duplicate(): TextRange; + collapse(start?: boolean): void; + queryCommandText(cmdID: string): string; + select(): void; + pasteHTML(html: string): void; + inRange(range: TextRange): boolean; + moveEnd(unit: string, count?: number): number; + getClientRects(): ClientRectList; + moveStart(unit: string, count?: number): number; + parentElement(): Element; + queryCommandState(cmdID: string): boolean; + compareEndPoints(how: string, sourceRange: TextRange): number; + execCommandShowHelp(cmdID: string): boolean; + moveToElementText(element: Element): void; + expand(Unit: string): boolean; + queryCommandSupported(cmdID: string): boolean; + setEndPoint(how: string, SourceRange: TextRange): void; + queryCommandEnabled(cmdID: string): boolean; +} +declare var TextRange: { + prototype: TextRange; + new(): TextRange; +} + +interface SVGTests { + requiredFeatures: SVGStringList; + requiredExtensions: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new(): HTMLBlockElement; +} + +interface CSSStyleSheet extends StyleSheet { + owningElement: Element; + imports: StyleSheetList; + isAlternate: boolean; + rules: MSCSSRuleList; + isPrefAlternate: boolean; + readOnly: boolean; + cssText: string; + ownerRule: CSSRule; + href: string; + cssRules: CSSRuleList; + id: string; + pages: StyleSheetPageList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + insertRule(rule: string, index?: number): number; + removeRule(lIndex: number): void; + deleteRule(index?: number): void; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + removeImport(lIndex: number): void; +} +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new(): CSSStyleSheet; +} + +interface MSSelection { + type: string; + typeDetail: string; + createRange(): TextRange; + clear(): void; + createRangeCollection(): TextRangeCollection; + empty(): void; +} +declare var MSSelection: { + prototype: MSSelection; + new(): MSSelection; +} + +interface HTMLMetaElement extends HTMLElement { + /** + * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. + */ + httpEquiv: string; + /** + * Sets or retrieves the value specified in the content attribute of the meta object. + */ + name: string; + /** + * Gets or sets meta-information to associate with httpEquiv or name. + */ + content: string; + /** + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + */ + url: string; + /** + * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. + */ + scheme: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; +} +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new(): HTMLMetaElement; +} + +interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { + patternUnits: SVGAnimatedEnumeration; + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + height: SVGAnimatedLength; +} +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new(): SVGPatternElement; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new(): SVGAnimatedAngle; +} + +interface Selection { + isCollapsed: boolean; + anchorNode: Node; + focusNode: Node; + anchorOffset: number; + focusOffset: number; + rangeCount: number; + addRange(range: Range): void; + collapseToEnd(): void; + toString(): string; + selectAllChildren(parentNode: Node): void; + getRangeAt(index: number): Range; + collapse(parentNode: Node, offset: number): void; + removeAllRanges(): void; + collapseToStart(): void; + deleteFromDocument(): void; + removeRange(range: Range): void; +} +declare var Selection: { + prototype: Selection; + new(): Selection; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; +} +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new(): SVGScriptElement; +} + +interface HTMLDDElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new(): HTMLDDElement; +} + +interface MSDataBindingRecordSetReadonlyExtensions { + recordset: any; + namedRecordset(dataMember: string, hierarchy?: any): any; +} + +interface CSSStyleRule extends CSSRule { + selectorText: string; + style: MSStyleCSSProperties; + readOnly: boolean; +} +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new(): CSSStyleRule; +} + +interface NodeIterator { + whatToShow: number; + filter: NodeFilter; + root: Node; + expandEntityReferences: boolean; + nextNode(): Node; + detach(): void; + previousNode(): Node; +} +declare var NodeIterator: { + prototype: NodeIterator; + new(): NodeIterator; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { + viewTarget: SVGStringList; +} +declare var SVGViewElement: { + prototype: SVGViewElement; + new(): SVGViewElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; +} +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new(): HTMLLinkElement; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getTransformToElement(element: SVGElement): SVGMatrix; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; +} +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new(): HTMLFontElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new(): SVGTitleElement; +} + +interface ControlRangeCollection { + length: number; + queryCommandValue(cmdID: string): any; + remove(index: number): void; + add(item: Element): void; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(varargStart?: any): void; + item(index: number): Element; + [index: number]: Element; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + addElement(item: Element): void; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandEnabled(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + select(): void; +} +declare var ControlRangeCollection: { + prototype: ControlRangeCollection; + new(): ControlRangeCollection; +} + +interface MSNamespaceInfo extends MSEventAttachmentTarget { + urn: string; + onreadystatechange: (ev: Event) => any; + name: string; + readyState: string; + doImport(implementationUrl: string): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSNamespaceInfo: { + prototype: MSNamespaceInfo; + new(): MSNamespaceInfo; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new(): SVGAnimatedTransformList; +} + +interface HTMLTableCaptionElement extends HTMLElement { + /** + * Sets or retrieves the alignment of the caption or legend. + */ + align: string; + /** + * Sets or retrieves whether the caption appears at the top or bottom of the table. + */ + vAlign: string; +} +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new(): HTMLTableCaptionElement; +} + +interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; +} +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new(): HTMLOptionElement; + create(): HTMLOptionElement; +} + +interface HTMLMapElement extends HTMLElement { + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves a collection of the area objects defined for the given map object. + */ + areas: HTMLAreasCollection; +} +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new(): HTMLMapElement; +} + +interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { + type: string; +} +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new(): HTMLMenuElement; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new(): MouseWheelEvent; +} + +interface SVGFitToViewBox { + viewBox: SVGAnimatedRect; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface SVGPointList { + numberOfItems: number; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; + getItem(index: number): SVGPoint; + clear(): void; + appendItem(newItem: SVGPoint): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + removeItem(index: number): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; +} +declare var SVGPointList: { + prototype: SVGPointList; + new(): SVGPointList; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new(): SVGAnimatedLengthList; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new(): SVGAnimatedPreserveAspectRatio; +} + +interface MSSiteModeEvent extends Event { + buttonID: number; + actionURL: string; +} +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new(): MSSiteModeEvent; +} + +interface DOML2DeprecatedTextFlowControl { + clear: string; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new(): StyleSheetPageList; +} + +interface MSCSSProperties extends CSSStyleDeclaration { + scrollbarShadowColor: string; + scrollbarHighlightColor: string; + layoutGridChar: string; + layoutGridType: string; + textAutospace: string; + textKashidaSpace: string; + writingMode: string; + scrollbarFaceColor: string; + backgroundPositionY: string; + lineBreak: string; + imeMode: string; + msBlockProgression: string; + layoutGridLine: string; + scrollbarBaseColor: string; + layoutGrid: string; + layoutFlow: string; + textKashida: string; + filter: string; + zoom: string; + scrollbarArrowColor: string; + behavior: string; + backgroundPositionX: string; + accelerator: string; + layoutGridMode: string; + textJustifyTrim: string; + scrollbar3dLightColor: string; + msInterpolationMode: string; + scrollbarTrackColor: string; + scrollbarDarkShadowColor: string; + styleFloat: string; + getAttribute(attributeName: string, flags?: number): any; + setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; + removeAttribute(attributeName: string, flags?: number): boolean; +} +declare var MSCSSProperties: { + prototype: MSCSSProperties; + new(): MSCSSProperties; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * The original height of the image resource before sizing. + */ + naturalHeight: number; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * The original width of the image resource before sizing. + */ + naturalWidth: number; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: number; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. + */ + longDesc: string; + /** + * Contains the hypertext reference (HREF) of the URL. + */ + href: string; + /** + * Sets or retrieves whether the image is a server-side image map. + */ + isMap: boolean; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + crossOrigin: string; + msPlayToPreferredSourceUri: string; +} +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new(): HTMLImageElement; + create(): HTMLImageElement; +} + +interface HTMLAreaElement extends HTMLElement { + /** + * Sets or retrieves the protocol portion of a URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Sets or retrieves the host name part of the location or URL. + */ + hostname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Sets or retrieves the file name or path specified by the object. + */ + pathname: string; + /** + * Sets or retrieves the hostname and port number of the location or URL. + */ + host: string; + /** + * Sets or retrieves the subsection of the href property that follows the number sign (#). + */ + hash: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or gets whether clicks in this region cause action. + */ + noHref: boolean; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new(): HTMLAreaElement; +} + +interface EventTarget { + removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; +} + +interface SVGAngle { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} +declare var SVGAngle: { + prototype: SVGAngle; + new(): SVGAngle; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} + +interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the default or selected value of the control. + */ + value: string; + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets the classification and default behavior of the button. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new(): HTMLButtonElement; +} + +interface HTMLSourceElement extends HTMLElement { + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the intended media type of the media source. + */ + media: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; + msKeySystem: string; +} +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new(): HTMLSourceElement; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} +declare var CanvasGradient: { + prototype: CanvasGradient; + new(): CanvasGradient; +} + +interface KeyboardEvent extends UIEvent { + location: number; + keyCode: number; + shiftKey: boolean; + which: number; + locale: string; + key: string; + altKey: boolean; + metaKey: boolean; + char: string; + ctrlKey: boolean; + repeat: boolean; + charCode: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new(): KeyboardEvent; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} + +interface MessageEvent extends Event { + source: Window; + origin: string; + data: any; + ports: any; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} +declare var MessageEvent: { + prototype: MessageEvent; + new(): MessageEvent; +} + +interface SVGElement extends Element { + onmouseover: (ev: MouseEvent) => any; + viewportElement: SVGElement; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + ondblclick: (ev: MouseEvent) => any; + onfocusout: (ev: FocusEvent) => any; + onfocusin: (ev: FocusEvent) => any; + xmlbase: string; + onmousedown: (ev: MouseEvent) => any; + onload: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + ownerSVGElement: SVGSVGElement; + id: string; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var SVGElement: { + prototype: SVGElement; + new(): SVGElement; +} + +interface HTMLScriptElement extends HTMLElement { + /** + * Sets or retrieves the status of the script. + */ + defer: boolean; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Retrieves the URL to an external file that contains the source code or data. + */ + src: string; + /** + * Sets or retrieves the object that is bound to the event script. + */ + htmlFor: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the MIME type for the associated scripting engine. + */ + type: string; + /** + * Sets or retrieves the event for which the script is written. + */ + event: string; + async: boolean; +} +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new(): HTMLScriptElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Retrieves the position of the object in the rows collection for the table. + */ + rowIndex: number; + /** + * Retrieves a collection of all cells in the table row. + */ + cells: HTMLCollection; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Retrieves the position of the object in the collection. + */ + sectionRowIndex: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified cell from the table row, as well as from the cells collection. + * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. + */ + deleteCell(index?: number): void; + /** + * Creates a new cell in the table row, and adds the cell to the cells collection. + * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. + */ + insertCell(index?: number): HTMLElement; +} +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new(): HTMLTableRowElement; +} + +interface CanvasRenderingContext2D { + miterLimit: number; + font: string; + globalCompositeOperation: string; + msFillRule: string; + lineCap: string; + msImageSmoothingEnabled: boolean; + lineDashOffset: number; + shadowColor: string; + lineJoin: string; + shadowOffsetX: number; + lineWidth: number; + canvas: HTMLCanvasElement; + strokeStyle: any; + globalAlpha: number; + shadowOffsetY: number; + fillStyle: any; + shadowBlur: number; + textAlign: string; + textBaseline: string; + restore(): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + save(): void; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + measureText(text: string): TextMetrics; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + rotate(angle: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + translate(x: number, y: number): void; + scale(x: number, y: number): void; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + lineTo(x: number, y: number): void; + getLineDash(): number[]; + fill(fillRule?: string): void; + createImageData(imageDataOrSw: any, sh?: number): ImageData; + createPattern(image: HTMLElement, repetition: string): CanvasPattern; + closePath(): void; + rect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + clearRect(x: number, y: number, w: number, h: number): void; + moveTo(x: number, y: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + fillRect(x: number, y: number, w: number, h: number): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + setLineDash(segments: number[]): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + beginPath(): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; +} +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new(): CanvasRenderingContext2D; +} + +interface MSCSSRuleList { + length: number; + item(index?: number): CSSStyleRule; + [index: number]: CSSStyleRule; +} +declare var MSCSSRuleList: { + prototype: MSCSSRuleList; + new(): MSCSSRuleList; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new(): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new(): SVGPathSegArcAbs; +} + +interface SVGTransformList { + numberOfItems: number; + getItem(index: number): SVGTransform; + consolidate(): SVGTransform; + clear(): void; + appendItem(newItem: SVGTransform): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + removeItem(index: number): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; +} +declare var SVGTransformList: { + prototype: SVGTransformList; + new(): SVGTransformList; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; +} +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new(): HTMLHtmlElement; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new(): SVGPathSegClosePath; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new(): HTMLFrameElement; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new(): SVGAnimatedLength; +} + +interface SVGAnimatedPoints { + points: SVGPointList; + animatedPoints: SVGPointList; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new(): SVGDefsElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new(): HTMLQuoteElement; +} + +interface CSSMediaRule extends CSSRule { + media: MediaList; + cssRules: CSSRuleList; + insertRule(rule: string, index?: number): number; + deleteRule(index?: number): void; +} +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new(): CSSMediaRule; +} + +interface WindowModal { + dialogArguments: any; + returnValue: any; +} + +interface XMLHttpRequest extends EventTarget { + responseBody: any; + status: number; + readyState: number; + responseText: string; + responseXML: any; + ontimeout: (ev: Event) => any; + statusText: string; + onreadystatechange: (ev: Event) => any; + timeout: number; + onload: (ev: Event) => any; + response: any; + withCredentials: boolean; + onprogress: (ev: ProgressEvent) => any; + onabort: (ev: UIEvent) => any; + responseType: string; + onloadend: (ev: ProgressEvent) => any; + upload: XMLHttpRequestEventTarget; + onerror: (ev: ErrorEvent) => any; + onloadstart: (ev: Event) => any; + msCaching: string; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + send(data?: any): void; + abort(): void; + getAllResponseHeaders(): string; + setRequestHeader(header: string, value: string): void; + getResponseHeader(header: string): string; + msCachingEnabled(): boolean; + overrideMimeType(mime: string): void; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; + create(): XMLHttpRequest; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; +} +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new(): HTMLTableHeaderCellElement; +} + +interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { +} +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new(): HTMLDListElement; +} + +interface MSDataBindingExtensions { + dataSrc: string; + dataFormatAs: string; + dataFld: string; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new(): SVGPathSegLinetoHorizontalRel; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + ry: SVGAnimatedLength; + cx: SVGAnimatedLength; + rx: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new(): SVGEllipseElement; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; +} +declare var SVGAElement: { + prototype: SVGAElement; + new(): SVGAElement; +} + +interface SVGStylable { + className: SVGAnimatedString; + style: CSSStyleDeclaration; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface HTMLFrameSetElement extends HTMLElement { + ononline: (ev: Event) => any; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + /** + * Sets or retrieves the frame widths of the object. + */ + cols: string; + /** + * Fires when the object loses the input focus. + */ + onblur: (ev: FocusEvent) => any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Fires when the object receives focus. + */ + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + onerror: (ev: ErrorEvent) => any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + onresize: (ev: UIEvent) => any; + name: string; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + border: string; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onstorage: (ev: StorageEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new(): HTMLFrameSetElement; +} + +interface Screen extends EventTarget { + width: number; + deviceXDPI: number; + fontSmoothingEnabled: boolean; + bufferDepth: number; + logicalXDPI: number; + systemXDPI: number; + availHeight: number; + height: number; + logicalYDPI: number; + systemYDPI: number; + updateInterval: number; + colorDepth: number; + availWidth: number; + deviceYDPI: number; + pixelDepth: number; + msOrientation: string; + onmsorientationchange: (ev: any) => any; + msLockOrientation(orientation: string): boolean; + msLockOrientation(orientations: string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: "msorientationchange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Screen: { + prototype: Screen; + new(): Screen; +} + +interface Coordinates { + altitudeAccuracy: number; + longitude: number; + latitude: number; + speed: number; + heading: number; + altitude: number; + accuracy: number; +} +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorContentUtils { +} + +interface EventListener { + (evt: Event): void; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface DataTransfer { + effectAllowed: string; + dropEffect: string; + types: DOMStringList; + files: FileList; + clearData(format?: string): boolean; + setData(format: string, data: string): boolean; + getData(format: string): string; +} +declare var DataTransfer: { + prototype: DataTransfer; + new(): DataTransfer; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} +declare var FocusEvent: { + prototype: FocusEvent; + new(): FocusEvent; +} + +interface Range { + startOffset: number; + collapsed: boolean; + endOffset: number; + startContainer: Node; + endContainer: Node; + commonAncestorContainer: Node; + setStart(refNode: Node, offset: number): void; + setEndBefore(refNode: Node): void; + setStartBefore(refNode: Node): void; + selectNode(refNode: Node): void; + detach(): void; + getBoundingClientRect(): ClientRect; + toString(): string; + compareBoundaryPoints(how: number, sourceRange: Range): number; + insertNode(newNode: Node): void; + collapse(toStart: boolean): void; + selectNodeContents(refNode: Node): void; + cloneContents(): DocumentFragment; + setEnd(refNode: Node, offset: number): void; + cloneRange(): Range; + getClientRects(): ClientRectList; + surroundContents(newParent: Node): void; + deleteContents(): void; + setStartAfter(refNode: Node): void; + extractContents(): DocumentFragment; + setEndAfter(refNode: Node): void; + createContextualFragment(fragment: string): DocumentFragment; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} +declare var Range: { + prototype: Range; + new(): Range; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} + +interface SVGPoint { + y: number; + x: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} +declare var SVGPoint: { + prototype: SVGPoint; + new(): SVGPoint; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new(): MSPluginsCollection; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new(): SVGAnimatedNumberList; +} + +interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { + width: SVGAnimatedLength; + x: SVGAnimatedLength; + contentStyleType: string; + onzoom: (ev: any) => any; + y: SVGAnimatedLength; + viewport: SVGRect; + onerror: (ev: ErrorEvent) => any; + pixelUnitToMillimeterY: number; + onresize: (ev: UIEvent) => any; + screenPixelToMillimeterY: number; + height: SVGAnimatedLength; + onabort: (ev: UIEvent) => any; + contentScriptType: string; + pixelUnitToMillimeterX: number; + currentTranslate: SVGPoint; + onunload: (ev: Event) => any; + currentScale: number; + onscroll: (ev: UIEvent) => any; + screenPixelToMillimeterX: number; + setCurrentTime(seconds: number): void; + createSVGLength(): SVGLength; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + unpauseAnimations(): void; + createSVGRect(): SVGRect; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + unsuspendRedrawAll(): void; + pauseAnimations(): void; + suspendRedraw(maxWaitMilliseconds: number): number; + deselectAll(): void; + createSVGAngle(): SVGAngle; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + createSVGTransform(): SVGTransform; + unsuspendRedraw(suspendHandleID: number): void; + forceRedraw(): void; + getCurrentTime(): number; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + createSVGMatrix(): SVGMatrix; + createSVGPoint(): SVGPoint; + createSVGNumber(): SVGNumber; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getElementById(elementId: string): Element; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "zoom", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new(): SVGSVGElement; +} + +interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new(): HTMLLabelElement; +} + +interface MSResourceMetadata { + protocol: string; + fileSize: string; + fileUpdatedDate: string; + nameProp: string; + fileCreatedDate: string; + fileModifiedDate: string; + mimeType: string; +} + +interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new(): HTMLLegendElement; +} + +interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new(): HTMLDirectoryElement; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new(): SVGAnimatedInteger; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +} +declare var SVGTextElement: { + prototype: SVGTextElement; + new(): SVGTextElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new(): SVGTSpanElement; +} + +interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * Sets or retrieves the value of a list item. + */ + value: number; +} +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new(): HTMLLIElement; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new(): SVGPathSegLinetoVerticalAbs; +} + +interface MSStorageExtensions { + remainingSpace: number; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + type: string; + title: string; +} +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new(): SVGStyleElement; +} + +interface MSCurrentStyleCSSProperties extends MSCSSProperties { + blockDirection: string; + clipBottom: string; + clipLeft: string; + clipRight: string; + clipTop: string; + hasLayout: string; +} +declare var MSCurrentStyleCSSProperties: { + prototype: MSCurrentStyleCSSProperties; + new(): MSCurrentStyleCSSProperties; +} + +interface MSHTMLCollectionExtensions { + urns(urn: any): any; + tags(tagName: any): any; +} + +interface Storage extends MSStorageExtensions { + length: number; + getItem(key: string): any; + [key: string]: any; + setItem(key: string, data: string): void; + clear(): void; + removeItem(key: string): void; + key(index: number): string; + [index: number]: string; +} +declare var Storage: { + prototype: Storage; + new(): Storage; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Sets or retrieves the horizontal margin for the object. + */ + hspace: number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + sandbox: DOMSettableTokenList; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new(): HTMLIFrameElement; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new(): TextRangeCollection; +} + +interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + scroll: string; + ononline: (ev: Event) => any; + onblur: (ev: FocusEvent) => any; + noWrap: boolean; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + text: any; + onerror: (ev: ErrorEvent) => any; + bgProperties: string; + onresize: (ev: UIEvent) => any; + link: any; + aLink: any; + bottomMargin: any; + topMargin: any; + onafterprint: (ev: Event) => any; + vLink: any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + rightMargin: any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + leftMargin: any; + onstorage: (ev: StorageEvent) => any; + onpopstate: (ev: PopStateEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; + createTextRange(): TextRange; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new(): HTMLBodyElement; +} + +interface DocumentType extends Node { + name: string; + notations: NamedNodeMap; + systemId: string; + internalSubset: string; + entities: NamedNodeMap; + publicId: string; +} +declare var DocumentType: { + prototype: DocumentType; + new(): DocumentType; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; +} +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new(): SVGRadialGradientElement; +} + +interface MutationEvent extends Event { + newValue: string; + attrChange: number; + attrName: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} +declare var MutationEvent: { + prototype: MutationEvent; + new(): MutationEvent; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; + msConvertURL(file: File, targetType: string, targetURL?: string): void; +} +declare var DragEvent: { + prototype: DragEvent; + new(): DragEvent; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): any; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; +} +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new(): HTMLTableSectionElement; +} + +interface DOML2DeprecatedListNumberingAndBulletStyle { + type: string; +} + +interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + status: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + indeterminate: boolean; + readOnly: boolean; + size: number; + loop: number; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. + */ + vrml: string; + /** + * Sets or retrieves a lower resolution image to display. + */ + lowsrc: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves a comma-separated list of content types. + */ + accept: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + defaultChecked: boolean; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Returns the value of the data at the cursor's current position. + */ + value: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + dynsrc: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + checked: boolean; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + start: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a FileList object on a file type input object. + */ + files: FileList; + /** + * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. + */ + max: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. + */ + step: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Returns the input field value as a number. + */ + valueAsNumber: number; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Specifies the ID of a pre-defined datalist of options for an input element. + */ + list: HTMLElement; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. + */ + min: string; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Gets or sets a string containing a regular expression that the user's input must match. + */ + pattern: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Makes the selection equal to the current object. + */ + select(): void; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. + * @param n Value to decrement the value by. + */ + stepDown(n?: number): void; + /** + * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. + * @param n Value to increment the value by. + */ + stepUp(n?: number): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new(): HTMLInputElement; +} + +interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Contains the protocol of the URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Contains the hostname of a URL. + */ + hostname: string; + /** + * Contains the pathname of the URL. + */ + pathname: string; + Methods: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + protocolLong: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Contains the hostname and port values of the URL. + */ + host: string; + /** + * Contains the anchor portion of the URL including the hash sign (#). + */ + hash: string; + nameProp: string; + urn: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + type: string; + mimeType: string; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new(): HTMLAnchorElement; +} + +interface HTMLParamElement extends HTMLElement { + /** + * Sets or retrieves the value of an input parameter for an element. + */ + value: string; + /** + * Sets or retrieves the name of an input parameter for an element. + */ + name: string; + /** + * Sets or retrieves the content type of the resource designated by the value attribute. + */ + type: string; + /** + * Sets or retrieves the data type of the value attribute. + */ + valueType: string; +} +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new(): HTMLParamElement; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGImageElement: { + prototype: SVGImageElement; + new(): SVGImageElement; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new(): SVGAnimatedNumber; +} + +interface PerformanceTiming { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + msFirstPaint: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + toJSON(): any; +} +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + +interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + /** + * Indicates a citation by rendering text in italic type. + */ + cite: string; +} +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new(): HTMLPreElement; +} + +interface EventException { + code: number; + message: string; + name: string; + toString(): string; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} +declare var EventException: { + prototype: EventException; + new(): EventException; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} + +interface MSNavigatorDoNotTrack { + msDoNotTrack: string; + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface SVGMetadataElement extends SVGElement { +} +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new(): SVGMetadataElement; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new(): SVGPathSegArcRel; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new(): SVGPathSegMovetoAbs; +} + +interface SVGStringList { + numberOfItems: number; + replaceItem(newItem: string, index: number): string; + getItem(index: number): string; + clear(): void; + appendItem(newItem: string): string; + initialize(newItem: string): string; + removeItem(index: number): string; + insertItemBefore(newItem: string, index: number): string; +} +declare var SVGStringList: { + prototype: SVGStringList; + new(): SVGStringList; +} + +interface XDomainRequest { + timeout: number; + onerror: (ev: ErrorEvent) => any; + onload: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + ontimeout: (ev: Event) => any; + responseText: string; + contentType: string; + open(method: string, url: string): void; + abort(): void; + send(data?: any): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XDomainRequest: { + prototype: XDomainRequest; + new(): XDomainRequest; + create(): XDomainRequest; +} + +interface DOML2DeprecatedBackgroundColorStyle { + bgColor: any; +} + +interface ElementTraversal { + childElementCount: number; + previousElementSibling: Element; + lastElementChild: Element; + nextElementSibling: Element; + firstElementChild: Element; +} + +interface SVGLength { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} +declare var SVGLength: { + prototype: SVGLength; + new(): SVGLength; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new(): SVGPolygonElement; +} + +interface HTMLPhraseElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new(): HTMLPhraseElement; +} + +interface NavigatorStorageUtils { +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new(): SVGPathSegCurvetoCubicRel; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + textLength: SVGAnimatedLength; + lengthAdjust: SVGAnimatedEnumeration; + getCharNumAtPosition(point: SVGPoint): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getComputedTextLength(): number; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getEndPositionOfChar(charnum: number): SVGPoint; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new(): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface Location { + hash: string; + protocol: string; + search: string; + href: string; + hostname: string; + port: string; + pathname: string; + host: string; + reload(flag?: boolean): void; + replace(url: string): void; + assign(url: string): void; + toString(): string; +} +declare var Location: { + prototype: Location; + new(): Location; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new(): HTMLTitleElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; +} +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new(): HTMLStyleElement; +} + +interface PerformanceEntry { + name: string; + startTime: number; + duration: number; + entryType: string; +} +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new(): PerformanceEntry; +} + +interface SVGTransform { + type: number; + angle: number; + matrix: SVGMatrix; + setTranslate(tx: number, ty: number): void; + setScale(sx: number, sy: number): void; + setMatrix(matrix: SVGMatrix): void; + setSkewY(angle: number): void; + setRotate(angle: number, cx: number, cy: number): void; + setSkewX(angle: number): void; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} +declare var SVGTransform: { + prototype: SVGTransform; + new(): SVGTransform; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} +declare var UIEvent: { + prototype: UIEvent; + new(): UIEvent; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new(): SVGPathSeg; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} + +interface WheelEvent extends MouseEvent { + deltaZ: number; + deltaX: number; + deltaMode: number; + deltaY: number; + initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; + getCurrentPoint(element: Element): void; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} +declare var WheelEvent: { + prototype: WheelEvent; + new(): WheelEvent; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} + +interface MSEventAttachmentTarget { + attachEvent(event: string, listener: EventListener): boolean; + detachEvent(event: string, listener: EventListener): void; +} + +interface SVGNumber { + value: number; +} +declare var SVGNumber: { + prototype: SVGNumber; + new(): SVGNumber; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + getTotalLength(): number; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; +} +declare var SVGPathElement: { + prototype: SVGPathElement; + new(): SVGPathElement; +} + +interface MSCompatibleInfo { + version: string; + userAgent: string; +} +declare var MSCompatibleInfo: { + prototype: MSCompatibleInfo; + new(): MSCompatibleInfo; +} + +interface Text extends CharacterData, MSNodeExtensions { + wholeText: string; + splitText(offset: number): Text; + replaceWholeText(content: string): Text; +} +declare var Text: { + prototype: Text; + new(): Text; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new(): SVGAnimatedRect; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new(): CSSNamespaceRule; +} + +interface SVGPathSegList { + numberOfItems: number; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; + getItem(index: number): SVGPathSeg; + clear(): void; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; +} +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new(): SVGPathSegList; +} + +interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { +} +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new(): HTMLUnknownElement; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new(): HTMLAudioElement; +} + +interface MSImageResourceExtensions { + dynsrc: string; + vrml: string; + lowsrc: string; + start: string; + loop: number; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves a list of header cells that provide information for the object. + */ + headers: string; + /** + * Retrieves the position of the object in the cells collection of a row. + */ + cellIndex: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the number columns in the table that the object should span. + */ + colSpan: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. + */ + axis: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; + /** + * Sets or retrieves abbreviated text for the object. + */ + abbr: string; + /** + * Sets or retrieves how many rows in a table the cell should span. + */ + rowSpan: number; + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; +} +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new(): HTMLTableCellElement; +} + +interface SVGElementInstance extends EventTarget { + previousSibling: SVGElementInstance; + parentNode: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + childNodes: SVGElementInstanceList; + correspondingUseElement: SVGUseElement; + correspondingElement: SVGElement; + firstChild: SVGElementInstance; +} +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new(): SVGElementInstance; +} + +interface MSNamespaceInfoCollection { + length: number; + add(namespace?: string, urn?: string, implementationUrl?: any): any; + item(index: any): any; + // [index: any]: any; +} +declare var MSNamespaceInfoCollection: { + prototype: MSNamespaceInfoCollection; + new(): MSNamespaceInfoCollection; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new(): SVGCircleElement; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} +declare var StyleSheetList: { + prototype: StyleSheetList; + new(): StyleSheetList; +} + +interface CSSImportRule extends CSSRule { + styleSheet: CSSStyleSheet; + href: string; + media: MediaList; +} +declare var CSSImportRule: { + prototype: CSSImportRule; + new(): CSSImportRule; +} + +interface CustomEvent extends Event { + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; +} +declare var CustomEvent: { + prototype: CustomEvent; + new(): CustomEvent; +} + +interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + /** + * Sets or retrieves the font size of the object. + */ + size: number; +} +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new(): HTMLBaseFontElement; +} + +interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves or sets the text in the entry field of the textArea element. + */ + value: string; + /** + * Sets or retrieves the value indicating whether the control is selected. + */ + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: number; + /** + * Sets or retrieves the width of the object. + */ + cols: number; + /** + * Sets or retrieves the value indicated whether the content of the object is read-only. + */ + readOnly: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Retrieves the type of control. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Highlights the input area of a form element. + */ + select(): void; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new(): HTMLTextAreaElement; +} + +interface Geolocation { + clearWatch(watchId: number): void; + getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; + watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; +} +declare var Geolocation: { + prototype: Geolocation; + new(): Geolocation; +} + +interface DOML2DeprecatedMarginStyle { + vspace: number; + hspace: number; +} + +interface MSWindowModeless { + dialogTop: any; + dialogLeft: any; + dialogWidth: any; + dialogHeight: any; + menuArguments: any; +} + +interface DOML2DeprecatedAlignmentStyle { + align: string; +} + +interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { + width: string; + onbounce: (ev: Event) => any; + vspace: number; + trueSpeed: boolean; + scrollAmount: number; + scrollDelay: number; + behavior: string; + height: string; + loop: number; + direction: string; + hspace: number; + onstart: (ev: Event) => any; + onfinish: (ev: Event) => any; + stop(): void; + start(): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new(): HTMLMarqueeElement; +} + +interface SVGRect { + y: number; + width: number; + x: number; + height: number; +} +declare var SVGRect: { + prototype: SVGRect; + new(): SVGRect; +} + +interface MSNodeExtensions { + swapNode(otherNode: Node): Node; + removeNode(deep?: boolean): Node; + replaceNode(replacement: Node): Node; +} + +interface History { + length: number; + state: any; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; + replaceState(statedata: any, title: string, url?: string): void; + pushState(statedata: any, title: string, url?: string): void; +} +declare var History: { + prototype: History; + new(): History; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new(): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new(): SVGPathSegCurvetoQuadraticAbs; +} + +interface TimeRanges { + length: number; + start(index: number): number; + end(index: number): number; +} +declare var TimeRanges: { + prototype: TimeRanges; + new(): TimeRanges; +} + +interface CSSRule { + cssText: string; + parentStyleSheet: CSSStyleSheet; + parentRule: CSSRule; + type: number; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} +declare var CSSRule: { + prototype: CSSRule; + new(): CSSRule; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new(): SVGPathSegLinetoAbs; +} + +interface HTMLModElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLModElement: { + prototype: HTMLModElement; + new(): HTMLModElement; +} + +interface SVGMatrix { + e: number; + c: number; + a: number; + b: number; + d: number; + f: number; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + flipY(): SVGMatrix; + skewY(angle: number): SVGMatrix; + inverse(): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + rotate(angle: number): SVGMatrix; + flipX(): SVGMatrix; + translate(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + skewX(angle: number): SVGMatrix; +} +declare var SVGMatrix: { + prototype: SVGMatrix; + new(): SVGMatrix; +} + +interface MSPopupWindow { + document: Document; + isOpen: boolean; + show(x: number, y: number, w: number, h: number, element?: any): void; + hide(): void; +} +declare var MSPopupWindow: { + prototype: MSPopupWindow; + new(): MSPopupWindow; +} + +interface BeforeUnloadEvent extends Event { + returnValue: string; +} +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new(): BeforeUnloadEvent; +} + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + animatedInstanceRoot: SVGElementInstance; + instanceRoot: SVGElementInstance; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGUseElement: { + prototype: SVGUseElement; + new(): SVGUseElement; +} + +interface Event { + timeStamp: number; + defaultPrevented: boolean; + isTrusted: boolean; + currentTarget: EventTarget; + cancelBubble: boolean; + target: EventTarget; + eventPhase: number; + cancelable: boolean; + type: string; + srcElement: Element; + bubbles: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + stopPropagation(): void; + stopImmediatePropagation(): void; + preventDefault(): void; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} +declare var Event: { + prototype: Event; + new(): Event; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} + +interface ImageData { + width: number; + data: number[]; + height: number; +} +declare var ImageData: { + prototype: ImageData; + new(): ImageData; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves the alignment of the object relative to the display or table. + */ + align: string; + /** + * Sets or retrieves the number of columns in the group. + */ + span: number; +} +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new(): HTMLTableColElement; +} + +interface SVGException { + code: number; + message: string; + name: string; + toString(): string; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} +declare var SVGException: { + prototype: SVGException; + new(): SVGException; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new(): SVGLinearGradientElement; +} + +interface HTMLTableAlignment { + /** + * Sets or retrieves a value that you can use to implement your own ch functionality for the object. + */ + ch: string; + /** + * Sets or retrieves how text and other content are vertically aligned within the object that contains them. + */ + vAlign: string; + /** + * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. + */ + chOff: string; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new(): SVGAnimatedEnumeration; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new(): HTMLUListElement; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + ry: SVGAnimatedLength; + rx: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGRectElement: { + prototype: SVGRectElement; + new(): SVGRectElement; +} + +interface ErrorEventHandler { + (event: Event, source: string, fileno: number, columnNumber: number): void; +} + +interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new(): HTMLDivElement; +} + +interface DOML2DeprecatedBorderStyle { + border: string; +} + +interface NamedNodeMap { + length: number; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + [index: number]: Attr; + removeNamedItem(name: string): Attr; + getNamedItem(name: string): Attr; + // [name: string]: Attr; + setNamedItem(arg: Attr): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItemNS(arg: Attr): Attr; +} +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new(): NamedNodeMap; +} + +interface MediaList { + length: number; + mediaText: string; + deleteMedium(oldMedium: string): void; + appendMedium(newMedium: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var MediaList: { + prototype: MediaList; + new(): MediaList; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new(): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new(): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGLengthList { + numberOfItems: number; + replaceItem(newItem: SVGLength, index: number): SVGLength; + getItem(index: number): SVGLength; + clear(): void; + appendItem(newItem: SVGLength): SVGLength; + initialize(newItem: SVGLength): SVGLength; + removeItem(index: number): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; +} +declare var SVGLengthList: { + prototype: SVGLengthList; + new(): SVGLengthList; +} + +interface ProcessingInstruction extends Node { + target: string; + data: string; +} +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new(): ProcessingInstruction; +} + +interface MSWindowExtensions { + status: string; + onmouseleave: (ev: MouseEvent) => any; + screenLeft: number; + offscreenBuffering: any; + maxConnectionsPerServer: number; + onmouseenter: (ev: MouseEvent) => any; + clipboardData: DataTransfer; + defaultStatus: string; + clientInformation: Navigator; + closed: boolean; + onhelp: (ev: Event) => any; + external: External; + event: MSEventObj; + onfocusout: (ev: FocusEvent) => any; + screenTop: number; + onfocusin: (ev: FocusEvent) => any; + showModelessDialog(url?: string, argument?: any, options?: any): Window; + navigate(url: string): void; + resizeBy(x?: number, y?: number): void; + item(index: any): any; + resizeTo(x?: number, y?: number): void; + createPopup(arguments?: any): MSPopupWindow; + toStaticHTML(html: string): string; + execScript(code: string, language?: string): any; + msWriteProfilerMark(profilerMarkName: string): void; + moveTo(x?: number, y?: number): void; + moveBy(x?: number, y?: number): void; + showHelp(url: string, helpArg?: any, features?: string): void; + captureEvents(): void; + releaseEvents(): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSBehaviorUrnsCollection { + length: number; + item(index: number): string; +} +declare var MSBehaviorUrnsCollection: { + prototype: MSBehaviorUrnsCollection; + new(): MSBehaviorUrnsCollection; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new(): CSSFontFaceRule; +} + +interface DOML2DeprecatedBackgroundStyle { + background: string; +} + +interface TextEvent extends UIEvent { + inputMethod: number; + data: string; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} +declare var TextEvent: { + prototype: TextEvent; + new(): TextEvent; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} + +interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { +} +declare var DocumentFragment: { + prototype: DocumentFragment; + new(): DocumentFragment; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new(): SVGPolylineElement; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface Position { + timestamp: Date; + coords: Coordinates; +} +declare var Position: { + prototype: Position; + new(): Position; +} + +interface BookmarkCollection { + length: number; + item(index: number): any; + [index: number]: any; +} +declare var BookmarkCollection: { + prototype: BookmarkCollection; + new(): BookmarkCollection; +} + +interface PerformanceMark extends PerformanceEntry { +} +declare var PerformanceMark: { + prototype: PerformanceMark; + new(): PerformanceMark; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selectorText: string; + selector: string; + style: CSSStyleDeclaration; +} +declare var CSSPageRule: { + prototype: CSSPageRule; + new(): CSSPageRule; +} + +interface HTMLBRElement extends HTMLElement { + /** + * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. + */ + clear: string; +} +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new(): HTMLBRElement; +} + +interface MSNavigatorExtensions { + userLanguage: string; + plugins: MSPluginsCollection; + cookieEnabled: boolean; + appCodeName: string; + cpuClass: string; + appMinorVersion: string; + connectionSpeed: number; + browserLanguage: string; + mimeTypes: MSMimeTypesCollection; + systemLanguage: string; + language: string; + javaEnabled(): boolean; + taintEnabled(): boolean; +} + +interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { +} +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new(): HTMLSpanElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new(): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; +} +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new(): HTMLHeadingElement; +} + +interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. + */ + acceptCharset: string; + /** + * Sets or retrieves the encoding type for the form. + */ + enctype: string; + /** + * Retrieves a collection, in source order, of all controls in a given form. + */ + elements: HTMLCollection; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves how to send the form data to the server. + */ + method: string; + /** + * Sets or retrieves the MIME encoding for the form. + */ + encoding: string; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Designates a form that is not validated when submitted. + */ + noValidate: boolean; + /** + * Fires when the user resets a form. + */ + reset(): void; + /** + * Retrieves a form object or an object from an elements collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Fires when a FORM is about to be submitted. + */ + submit(): void; + /** + * Retrieves a form object or an object from an elements collection. + */ + namedItem(name: string): any; + [name: string]: any; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; +} +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new(): HTMLFormElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} +declare var SVGZoomAndPan: SVGZoomAndPan; + +interface HTMLMediaElement extends HTMLElement { + /** + * Gets the earliest possible position, in seconds, that the playback can begin. + */ + initialTime: number; + /** + * Gets TimeRanges for the current media resource that has been played. + */ + played: TimeRanges; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + currentSrc: string; + readyState: any; + /** + * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. + */ + autobuffer: boolean; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + /** + * Gets information about whether the playback has ended or not. + */ + ended: boolean; + /** + * Gets a collection of buffered time ranges. + */ + buffered: TimeRanges; + /** + * Returns an object representing the current error state of the audio or video element. + */ + error: MediaError; + /** + * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + */ + seekable: TimeRanges; + /** + * Gets or sets a value that indicates whether to start playing the media automatically. + */ + autoplay: boolean; + /** + * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + */ + controls: boolean; + /** + * Gets or sets the volume level for audio portions of the media element. + */ + volume: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. + */ + playbackRate: number; + /** + * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + */ + duration: number; + /** + * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + */ + muted: boolean; + /** + * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. + */ + defaultPlaybackRate: number; + /** + * Gets a flag that specifies whether playback is paused. + */ + paused: boolean; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + seeking: boolean; + /** + * Gets or sets the current playback position, in seconds. + */ + currentTime: number; + /** + * Gets or sets the current playback position, in seconds. + */ + preload: string; + /** + * Gets the current network activity for the element. + */ + networkState: number; + /** + * Specifies the purpose of the audio or video media, such as background audio or alerts. + */ + msAudioCategory: string; + /** + * Specifies whether or not to enable low-latency playback on the media element. + */ + msRealTime: boolean; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + textTracks: TextTrackList; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + audioTracks: AudioTrackList; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Specifies the output device id that the audio will be sent to. + */ + msAudioDeviceType: string; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + msKeys: MSMediaKeys; + msGraphicsTrustStatus: MSGraphicsTrust; + /** + * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. + */ + pause(): void; + /** + * Loads and starts playback of a media resource. + */ + play(): void; + /** + * Fires immediately after the client loads the object. + */ + load(): void; + /** + * Returns a string that specifies whether the client can play a given media resource type. + */ + canPlayType(type: string): string; + /** + * Clears all effects from the media pipeline. + */ + msClearEffects(): void; + /** + * Specifies the media protection manager for a given media pipeline. + */ + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + /** + * Inserts the specified audio effect into media pipeline. + */ + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new(): HTMLMediaElement; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} + +interface ElementCSSInlineStyle { + runtimeStyle: MSStyleCSSProperties; + currentStyle: MSCurrentStyleCSSProperties; + doScroll(component?: any): void; + componentFromPoint(x: number, y: number): string; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} +declare var DOMParser: { + prototype: DOMParser; + new(): DOMParser; +} + +interface MSMimeTypesCollection { + length: number; +} +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new(): MSMimeTypesCollection; +} + +interface StyleSheet { + disabled: boolean; + ownerNode: Node; + parentStyleSheet: StyleSheet; + href: string; + media: MediaList; + type: string; + title: string; +} +declare var StyleSheet: { + prototype: StyleSheet; + new(): StyleSheet; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + startOffset: SVGAnimatedLength; + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new(): SVGTextPathElement; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} + +interface HTMLDTElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new(): HTMLDTElement; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} +declare var NodeList: { + prototype: NodeList; + new(): NodeList; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} +declare var XMLSerializer: { + prototype: XMLSerializer; + new(): XMLSerializer; +} + +interface PerformanceMeasure extends PerformanceEntry { +} +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new(): PerformanceMeasure; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { + spreadMethod: SVGAnimatedEnumeration; + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new(): SVGGradientElement; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} +declare var NodeFilter: NodeFilter; + +interface SVGNumberList { + numberOfItems: number; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; + getItem(index: number): SVGNumber; + clear(): void; + appendItem(newItem: SVGNumber): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + removeItem(index: number): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; +} +declare var SVGNumberList: { + prototype: SVGNumberList; + new(): SVGNumberList; +} + +interface MediaError { + code: number; + msExtendedCode: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} +declare var MediaError: { + prototype: MediaError; + new(): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} + +interface HTMLFieldSetElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new(): HTMLFieldSetElement; +} + +interface HTMLBGSoundElement extends HTMLElement { + /** + * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. + */ + balance: any; + /** + * Sets or gets the volume setting for the sound. + */ + volume: any; + /** + * Sets or gets the URL of a sound to play. + */ + src: string; + /** + * Sets or retrieves the number of times a sound or video clip will loop when activated. + */ + loop: number; +} +declare var HTMLBGSoundElement: { + prototype: HTMLBGSoundElement; + new(): HTMLBGSoundElement; +} + +interface Comment extends CharacterData { + text: string; +} +declare var Comment: { + prototype: Comment; + new(): Comment; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + redirectStart: number; + redirectEnd: number; + domainLookupEnd: number; + responseStart: number; + domainLookupStart: number; + fetchStart: number; + requestStart: number; + connectEnd: number; + connectStart: number; + initiatorType: string; + responseEnd: number; +} +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new(): PerformanceResourceTiming; +} + +interface CanvasPattern { +} +declare var CanvasPattern: { + prototype: CanvasPattern; + new(): CanvasPattern; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. + */ + noShade: boolean; +} +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new(): HTMLHRElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Retrieves the contained object. + */ + object: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL of the file containing the compiled Java class. + */ + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + declare: boolean; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + readyState: number; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new(): HTMLObjectElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Retrieves the palette used for the embedded document. + */ + palette: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + hidden: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + pluginspage: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the height and width units of the embed object. + */ + units: string; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + readyState: string; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; +} +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new(): HTMLEmbedElement; +} + +interface StorageEvent extends Event { + oldValue: any; + newValue: any; + url: string; + storageArea: Storage; + key: string; + initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; +} +declare var StorageEvent: { + prototype: StorageEvent; + new(): StorageEvent; +} + +interface CharacterData extends Node { + length: number; + data: string; + deleteData(offset: number, count: number): void; + replaceData(offset: number, count: number, arg: string): void; + appendData(arg: string): void; + insertData(offset: number, arg: string): void; + substringData(offset: number, count: number): string; +} +declare var CharacterData: { + prototype: CharacterData; + new(): CharacterData; +} + +interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; +} +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new(): HTMLOptGroupElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + prompt: string; +} +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new(): HTMLIsIndexElement; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new(): SVGPathSegLinetoRel; +} + +interface DOMException { + code: number; + message: string; + name: string; + toString(): string; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new(): SVGAnimatedBoolean; +} + +interface MSCompatibleInfoCollection { + length: number; + item(index: number): MSCompatibleInfo; +} +declare var MSCompatibleInfoCollection: { + prototype: MSCompatibleInfoCollection; + new(): MSCompatibleInfoCollection; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new(): SVGSwitchElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new(): SVGPreserveAspectRatio; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} + +interface Attr extends Node { + expando: boolean; + specified: boolean; + ownerElement: Element; + value: string; + name: string; +} +declare var Attr: { + prototype: Attr; + new(): Attr; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; +} +declare var SVGStopElement: { + prototype: SVGStopElement; + new(): SVGStopElement; +} + +interface PositionCallback { + (position: Position): void; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { +} +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new(): SVGSymbolElement; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new(): SVGElementInstanceList; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} +declare var CSSRuleList: { + prototype: CSSRuleList; + new(): CSSRuleList; +} + +interface MSDataBindingRecordSetExtensions { + recordset: any; + namedRecordset(dataMember: string, hierarchy?: any): any; +} + +interface LinkStyle { + styleSheet: StyleSheet; + sheet: StyleSheet; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the width of the video element. + */ + width: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoWidth: number; + /** + * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoHeight: number; + /** + * Gets or sets the height of the video element. + */ + height: number; + /** + * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. + */ + poster: string; + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + onMSVideoOptimalLayoutChanged: (ev: any) => any; + onMSVideoFrameStepCompleted: (ev: any) => any; + msStereo3DRenderMode: string; + msIsLayoutOptimalForPlayback: boolean; + msHorizontalMirror: boolean; + onMSVideoFormatChanged: (ev: any) => any; + msZoom: boolean; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + msFrameStep(forward: boolean): void; + getVideoPlaybackQuality(): VideoPlaybackQuality; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFormatChanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new(): HTMLVideoElement; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} +declare var ClientRectList: { + prototype: ClientRectList; + new(): ClientRectList; +} + +interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + maskUnits: SVGAnimatedEnumeration; + maskContentUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new(): SVGMaskElement; +} + +interface External { +} +declare var External: { + prototype: External; + new(): External; +} + +interface MSGestureEvent extends UIEvent { + offsetY: number; + translationY: number; + velocityExpansion: number; + velocityY: number; + velocityAngular: number; + translationX: number; + velocityX: number; + hwTimestamp: number; + offsetX: number; + screenX: number; + rotation: number; + expansion: number; + clientY: number; + screenY: number; + scale: number; + gestureObject: any; + clientX: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new(): MSGestureEvent; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface ErrorEvent extends Event { + colno: number; + filename: string; + error: any; + lineno: number; + message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} +declare var ErrorEvent: { + prototype: ErrorEvent; + new(): ErrorEvent; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + filterResX: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + primitiveUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + filterResY: SVGAnimatedInteger; + setFilterRes(filterResX: number, filterResY: number): void; +} +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new(): SVGFilterElement; +} + +interface TrackEvent extends Event { + track: any; +} +declare var TrackEvent: { + prototype: TrackEvent; + new(): TrackEvent; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new(): SVGFEMergeNodeElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new(): SVGFEFloodElement; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} +declare var MSGesture: { + prototype: MSGesture; + new(): MSGesture; +} + +interface TextTrackCue extends EventTarget { + onenter: (ev: Event) => any; + track: TextTrack; + endTime: number; + text: string; + pauseOnExit: boolean; + id: string; + startTime: number; + onexit: (ev: Event) => any; + getCueAsHTML(): DocumentFragment; + addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var TextTrackCue: { + prototype: TextTrackCue; + new(startTime: number, endTime: number, text: string): TextTrackCue; +} + +interface MSStreamReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; +} +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface DOMTokenList { + length: number; + contains(token: string): boolean; + remove(token: string): void; + toggle(token: string): boolean; + add(token: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var DOMTokenList: { + prototype: DOMTokenList; + new(): DOMTokenList; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new(): SVGFEFuncAElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new(): SVGFETileElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new(): SVGFEBlendElement; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} + +interface MessageChannel { + port2: MessagePort; + port1: MessagePort; +} +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new(): SVGFEMergeElement; +} + +interface TransitionEvent extends Event { + propertyName: string; + elapsedTime: number; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} +declare var TransitionEvent: { + prototype: TransitionEvent; + new(): TransitionEvent; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface DOMError { + name: string; + toString(): string; +} +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface CloseEvent extends Event { + wasClean: boolean; + reason: string; + code: number; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} +declare var CloseEvent: { + prototype: CloseEvent; + new(): CloseEvent; +} + +interface WebSocket extends EventTarget { + protocol: string; + readyState: number; + bufferedAmount: number; + onopen: (ev: Event) => any; + extensions: string; + onmessage: (ev: MessageEvent) => any; + onclose: (ev: CloseEvent) => any; + onerror: (ev: ErrorEvent) => any; + binaryType: string; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; + addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string): WebSocket; + new(url: string, protocols?: string[]): WebSocket; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} + +interface SVGFEPointLightElement extends SVGElement { + y: SVGAnimatedNumber; + x: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new(): SVGFEPointLightElement; +} + +interface ProgressEvent extends Event { + loaded: number; + lengthComputable: boolean; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} +declare var ProgressEvent: { + prototype: ProgressEvent; + new(): ProgressEvent; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + name: string; + transaction: IDBTransaction; + keyPath: string; + count(key?: any): IDBRequest; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + put(value: any, key?: any): IDBRequest; + openCursor(range?: any, direction?: string): IDBRequest; + deleteIndex(indexName: string): void; + index(name: string): IDBIndex; + get(key: any): IDBRequest; + delete(key: any): IDBRequest; +} +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + stdDeviationX: SVGAnimatedNumber; + in1: SVGAnimatedString; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; +} +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new(): SVGFEGaussianBlurElement; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + result: SVGAnimatedString; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface IDBIndex { + unique: boolean; + name: string; + keyPath: string; + objectStore: IDBObjectStore; + count(key?: any): IDBRequest; + getKey(key: any): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + get(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface IDBCursor { + source: any; + direction: string; + key: any; + primaryKey: any; + advance(count: number): void; + delete(): IDBRequest; + continue(key?: any): void; + update(value: any): IDBRequest; + PREV: string; + PREV_NO_DUPLICATE: string; + NEXT: string; + NEXT_NO_DUPLICATE: string; +} +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + PREV: string; + PREV_NO_DUPLICATE: string; + NEXT: string; + NEXT_NO_DUPLICATE: string; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; +} +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new(): SVGFESpecularLightingElement; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} +declare var File: { + prototype: File; + new(): File; +} + +interface URL { + revokeObjectURL(url: string): void; + createObjectURL(object: any, options?: ObjectURLOptions): string; +} +declare var URL: URL; + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface XMLHttpRequestEventTarget extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: Event) => any; + ontimeout: (ev: Event) => any; + onabort: (ev: UIEvent) => any; + onloadstart: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XMLHttpRequestEventTarget: { + prototype: XMLHttpRequestEventTarget; + new(): XMLHttpRequestEventTarget; +} + +interface IDBEnvironment { + msIndexedDB: IDBFactory; + indexedDB: IDBFactory; +} + +interface AudioTrackList extends EventTarget { + length: number; + onchange: (ev: Event) => any; + onaddtrack: (ev: TrackEvent) => any; + onremovetrack: (ev: any /*PluginArray*/) => any; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + [index: number]: AudioTrack; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: any /*PluginArray*/) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var AudioTrackList: { + prototype: AudioTrackList; + new(): AudioTrackList; +} + +interface MSBaseReader extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + readyState: number; + onabort: (ev: UIEvent) => any; + onloadend: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: Event) => any; + onloadstart: (ev: Event) => any; + result: any; + abort(): void; + LOADING: number; + EMPTY: number; + DONE: number; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new(): SVGFEMorphologyElement; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new(): SVGFEFuncRElement; +} + +interface WindowTimersExtension { + msSetImmediate(expression: any, ...args: any[]): number; + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + setImmediate(expression: any, ...args: any[]): number; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + scale: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new(): SVGFEDisplacementMapElement; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} +declare var AnimationEvent: { + prototype: AnimationEvent; + new(): AnimationEvent; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + tableValues: SVGAnimatedNumberList; + slope: SVGAnimatedNumber; + type: SVGAnimatedEnumeration; + exponent: SVGAnimatedNumber; + amplitude: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new(): SVGComponentTransferFunctionElement; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new(): MSRangeCollection; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new(): SVGFEDistantLightElement; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new(): SVGFEFuncBElement; +} + +interface IDBKeyRange { + upper: any; + upperOpen: boolean; + lower: any; + lowerOpen: boolean; +} +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface WindowConsole { + console: Console; +} + +interface IDBTransaction extends EventTarget { + oncomplete: (ev: Event) => any; + db: IDBDatabase; + mode: string; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: UIEvent) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + READ_ONLY: string; + VERSION_CHANGE: string; + READ_WRITE: string; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + READ_ONLY: string; + VERSION_CHANGE: string; + READ_WRITE: string; +} + +interface AudioTrack { + kind: string; + language: string; + id: string; + label: string; + enabled: boolean; + sourceBuffer: SourceBuffer; +} +declare var AudioTrack: { + prototype: AudioTrack; + new(): AudioTrack; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + orderY: SVGAnimatedInteger; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + kernelMatrix: SVGAnimatedNumberList; + edgeMode: SVGAnimatedEnumeration; + kernelUnitLengthX: SVGAnimatedNumber; + bias: SVGAnimatedNumber; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + divisor: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new(): SVGFEConvolveMatrixElement; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} + +interface TextTrackCueList { + length: number; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; + getCueById(id: string): TextTrackCue; +} +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new(): TextTrackCueList; +} + +interface CSSKeyframesRule extends CSSRule { + name: string; + cssRules: CSSRuleList; + findRule(rule: string): CSSKeyframeRule; + deleteRule(rule: string): void; + appendRule(rule: string): void; +} +declare var CSSKeyframesRule: { + prototype: CSSKeyframesRule; + new(): CSSKeyframesRule; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + type: SVGAnimatedEnumeration; + baseFrequencyY: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + seed: SVGAnimatedNumber; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new(): SVGFETurbulenceElement; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} + +interface TextTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + item(index: number): TextTrack; + [index: number]: TextTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var TextTrackList: { + prototype: TextTrackList; + new(): TextTrackList; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new(): SVGFEFuncGElement; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new(): SVGFEColorMatrixElement; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} + +interface SVGFESpotLightElement extends SVGElement { + pointsAtY: SVGAnimatedNumber; + y: SVGAnimatedNumber; + limitingConeAngle: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + z: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; +} +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new(): SVGFESpotLightElement; +} + +interface WindowBase64 { + btoa(rawString: string): string; + atob(encodedString: string): string; +} + +interface IDBDatabase extends EventTarget { + version: string; + name: string; + objectStoreNames: DOMStringList; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: UIEvent) => any; + createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + close(): void; + transaction(storeNames: any, mode?: string): IDBTransaction; + deleteObjectStore(name: string): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBDatabase: { + prototype: IDBDatabase; + new(): IDBDatabase; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface IDBOpenDBRequest extends IDBRequest { + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + onblocked: (ev: Event) => any; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. + */ + value: number; + /** + * Defines the maximum, or "done" value for a progress element. + */ + max: number; + /** + * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). + */ + position: number; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new(): HTMLProgressElement; +} + +interface MSLaunchUriCallback { + (): void; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + dx: SVGAnimatedNumber; +} +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new(): SVGFEOffsetElement; +} + +interface MSUnsafeFunctionCallback { + (): any; +} + +interface TextTrack extends EventTarget { + language: string; + mode: any; + readyState: number; + activeCues: TextTrackCueList; + cues: TextTrackCueList; + oncuechange: (ev: Event) => any; + kind: string; + onload: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + label: string; + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var TextTrack: { + prototype: TextTrack; + new(): TextTrack; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} + +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} + +interface IDBRequest extends EventTarget { + source: any; + onsuccess: (ev: Event) => any; + error: DOMError; + transaction: IDBTransaction; + onerror: (ev: ErrorEvent) => any; + readyState: string; + result: any; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface FileReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; +} +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface ApplicationCache extends EventTarget { + status: number; + ondownloading: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onupdateready: (ev: Event) => any; + oncached: (ev: Event) => any; + onobsolete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + onchecking: (ev: Event) => any; + onnoupdate: (ev: Event) => any; + swapCache(): void; + abort(): void; + update(): void; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; + addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var ApplicationCache: { + prototype: ApplicationCache; + new(): ApplicationCache; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} + +interface FrameRequestCallback { + (time: number): void; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} +declare var PopStateEvent: { + prototype: PopStateEvent; + new(): PopStateEvent; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new(): CSSKeyframeRule; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSStream { + type: string; + msDetachStream(): any; + msClose(): void; +} +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} +declare var DOMSettableTokenList: { + prototype: DOMSettableTokenList; + new(): DOMSettableTokenList; +} + +interface IDBFactory { + open(name: string, version?: number): IDBOpenDBRequest; + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; +} +declare var IDBFactory: { + prototype: IDBFactory; + new(): IDBFactory; +} + +interface MSPointerEvent extends MouseEvent { + width: number; + rotation: number; + pressure: number; + pointerType: any; + isPrimary: boolean; + tiltY: number; + height: number; + intermediatePoints: any; + currentPoint: any; + tiltX: number; + hwTimestamp: number; + pointerId: number; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} +declare var MSPointerEvent: { + prototype: MSPointerEvent; + new(): MSPointerEvent; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} + +interface MSManipulationEvent extends UIEvent { + lastState: number; + currentState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_CANCELLED: number; +} +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new(): MSManipulationEvent; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + 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; +} +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new(): HTMLDataListElement; +} + +interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new(): SVGFEImageElement; +} + +interface AbstractWorker extends EventTarget { + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + in2: SVGAnimatedString; + k2: SVGAnimatedNumber; + k1: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + in1: SVGAnimatedString; + k4: SVGAnimatedNumber; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new(): SVGFECompositeElement; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} + +interface ValidityState { + customError: boolean; + valueMissing: boolean; + stepMismatch: boolean; + rangeUnderflow: boolean; + rangeOverflow: boolean; + typeMismatch: boolean; + patternMismatch: boolean; + tooLong: boolean; + valid: boolean; +} +declare var ValidityState: { + prototype: ValidityState; + new(): ValidityState; +} + +interface HTMLTrackElement extends HTMLElement { + kind: string; + src: string; + srclang: string; + track: TextTrack; + label: string; + default: boolean; + readyState: number; + ERROR: number; + LOADING: number; + LOADED: number; + NONE: number; +} +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new(): HTMLTrackElement; + ERROR: number; + LOADING: number; + LOADED: number; + NONE: number; +} + +interface MSApp { + createFileFromStorageFile(storageFile: any): File; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + terminateApp(exceptionObject: any): void; + createDataPackage(object: any): any; + execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; + getHtmlPrintDocumentSource(htmlDoc: any): any; + addPublicLocalApplicationUri(uri: string): void; + createDataPackageFromSelection(): any; + getViewOpener(): MSAppView; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + createNewView(uri: string): MSAppView; + getCurrentPriority(): string; + NORMAL: string; + HIGH: string; + IDLE: string; + CURRENT: string; +} +declare var MSApp: MSApp; + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new(): SVGFEComponentTransferElement; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + diffuseConstant: SVGAnimatedNumber; +} +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new(): SVGFEDiffuseLightingElement; +} + +interface MSCSSMatrix { + m24: number; + m34: number; + a: number; + d: number; + m32: number; + m41: number; + m11: number; + f: number; + e: number; + m23: number; + m14: number; + m33: number; + m22: number; + m21: number; + c: number; + m12: number; + b: number; + m42: number; + m31: number; + m43: number; + m13: number; + m44: number; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + setMatrixValue(value: string): void; + inverse(): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + toString(): string; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + translate(x: number, y: number, z?: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + skewX(angle: number): MSCSSMatrix; +} +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new(text?: string): MSCSSMatrix; +} + +interface Worker extends AbstractWorker { + onmessage: (ev: MessageEvent) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Worker: { + prototype: Worker; + new(stringUrl: string): Worker; +} + +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} + +interface MSGraphicsTrust { + status: string; + constrictionActive: boolean; +} +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new(): MSGraphicsTrust; +} + +interface SubtleCrypto { + unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; + encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; + verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; + deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; + exportKey(format: string, key: Key): KeyOperation; + generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; +} +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new(): SubtleCrypto; +} + +interface Crypto extends RandomSource { + subtle: SubtleCrypto; +} +declare var Crypto: { + prototype: Crypto; + new(): Crypto; +} + +interface VideoPlaybackQuality { + totalFrameDelay: number; + creationTime: number; + totalVideoFrames: number; + droppedVideoFrames: number; +} +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new(): VideoPlaybackQuality; +} + +interface GlobalEventHandlers { + onpointerenter: (ev: PointerEvent) => any; + onpointerout: (ev: PointerEvent) => any; + onpointerdown: (ev: PointerEvent) => any; + onpointerup: (ev: PointerEvent) => any; + onpointercancel: (ev: PointerEvent) => any; + onpointerover: (ev: PointerEvent) => any; + onpointermove: (ev: PointerEvent) => any; + onpointerleave: (ev: PointerEvent) => any; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface Key { + algorithm: Algorithm; + type: string; + extractable: boolean; + keyUsage: string[]; +} +declare var Key: { + prototype: Key; + new(): Key; +} + +interface DeviceAcceleration { + y: number; + x: number; + z: number; +} +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new(): DeviceAcceleration; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; + // [name: string]: Element; +} +declare var HTMLAllCollection: { + prototype: HTMLAllCollection; + new(): HTMLAllCollection; +} + +interface AesGcmEncryptResult { + ciphertext: ArrayBuffer; + tag: ArrayBuffer; +} +declare var AesGcmEncryptResult: { + prototype: AesGcmEncryptResult; + new(): AesGcmEncryptResult; +} + +interface NavigationCompletedEvent extends NavigationEvent { + webErrorStatus: number; + isSuccess: boolean; +} +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new(): NavigationCompletedEvent; +} + +interface MutationRecord { + oldValue: string; + previousSibling: Node; + addedNodes: NodeList; + attributeName: string; + removedNodes: NodeList; + target: Node; + nextSibling: Node; + attributeNamespace: string; + type: string; +} +declare var MutationRecord: { + prototype: MutationRecord; + new(): MutationRecord; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(type: string): Plugin; + // [type: string]: Plugin; +} +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new(): MimeTypeArray; +} + +interface KeyOperation extends EventTarget { + oncomplete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + result: any; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var KeyOperation: { + prototype: KeyOperation; + new(): KeyOperation; +} + +interface DOMStringMap { +} +declare var DOMStringMap: { + prototype: DOMStringMap; + new(): DOMStringMap; +} + +interface DeviceOrientationEvent extends Event { + gamma: number; + alpha: number; + absolute: boolean; + beta: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new(): DeviceOrientationEvent; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; +} +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new(keySystem: string): MSMediaKeys; + isTypeSupported(keySystem: string, type?: string): boolean; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new(): MSMediaKeyMessageEvent; +} + +interface MSHTMLWebViewElement extends HTMLElement { + documentTitle: string; + width: number; + src: string; + canGoForward: boolean; + height: number; + canGoBack: boolean; + navigateWithHttpRequestMessage(requestMessage: any): void; + goBack(): void; + navigate(uri: string): void; + stop(): void; + navigateToString(contents: string): void; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + refresh(): void; + goForward(): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; +} +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new(): MSHTMLWebViewElement; +} + +interface NavigationEvent extends Event { + uri: string; +} +declare var NavigationEvent: { + prototype: NavigationEvent; + new(): NavigationEvent; +} + +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; + compositionStartOffset: number; + oncandidatewindowhide: (ev: any) => any; + oncandidatewindowupdate: (ev: any) => any; + compositionEndOffset: number; + getCompositionAlternatives(): string[]; + getCandidateWindowClientRect(): ClientRect; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: "candidatewindowshow", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "candidatewindowhide", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "candidatewindowupdate", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new(): MSInputMethodContext; +} + +interface DeviceRotationRate { + gamma: number; + alpha: number; + beta: number; +} +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new(): DeviceRotationRate; +} + +interface PluginArray { + length: number; + refresh(reload?: boolean): void; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(name: string): Plugin; + // [name: string]: Plugin; +} +declare var PluginArray: { + prototype: PluginArray; + new(): PluginArray; +} + +interface MSMediaKeyError { + systemCode: number; + code: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new(): MSMediaKeyError; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} + +interface Plugin { + length: number; + filename: string; + version: string; + name: string; + description: string; + item(index: number): MimeType; + [index: number]: MimeType; + namedItem(type: string): MimeType; + // [type: string]: MimeType; +} +declare var Plugin: { + prototype: Plugin; + new(): Plugin; +} + +interface MediaSource extends EventTarget { + sourceBuffers: SourceBufferList; + duration: number; + readyState: string; + activeSourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: string): void; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} +declare var MediaSource: { + prototype: MediaSource; + new(): MediaSource; + isTypeSupported(type: string): boolean; +} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} +declare var SourceBufferList: { + prototype: SourceBufferList; + new(): SourceBufferList; +} + +interface XMLDocument extends Document { +} +declare var XMLDocument: { + prototype: XMLDocument; + new(): XMLDocument; +} + +interface DeviceMotionEvent extends Event { + rotationRate: DeviceRotationRate; + acceleration: DeviceAcceleration; + interval: number; + accelerationIncludingGravity: DeviceAcceleration; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new(): DeviceMotionEvent; +} + +interface MimeType { + enabledPlugin: Plugin; + suffixes: string; + type: string; + description: string; +} +declare var MimeType: { + prototype: MimeType; + new(): MimeType; +} + +interface PointerEvent extends MouseEvent { + width: number; + rotation: number; + pressure: number; + pointerType: any; + isPrimary: boolean; + tiltY: number; + height: number; + intermediatePoints: any; + currentPoint: any; + tiltX: number; + hwTimestamp: number; + pointerId: number; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; +} +declare var PointerEvent: { + prototype: PointerEvent; + new(): PointerEvent; +} + +interface MSDocumentExtensions { + captureEvents(): void; + releaseEvents(): void; +} + +interface MutationObserver { + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; + disconnect(): void; +} +declare var MutationObserver: { + prototype: MutationObserver; + new (callback: (arr: MutationRecord[], observer: MutationObserver)=>any): MutationObserver; +} + +interface MSWebViewAsyncOperation extends EventTarget { + target: MSHTMLWebViewElement; + oncomplete: (ev: Event) => any; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + readyState: number; + type: number; + result: any; + start(): void; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new(): MSWebViewAsyncOperation; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} + +interface ScriptNotifyEvent extends Event { + value: string; + callingUri: string; +} +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new(): ScriptNotifyEvent; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + redirectCount: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + type: string; +} +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new(): PerformanceNavigationTiming; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new(): MSMediaKeyNeededEvent; +} + +interface LongRunningScriptDetectedEvent extends Event { + stopPageScriptExecution: boolean; + executionTime: number; +} +declare var LongRunningScriptDetectedEvent: { + prototype: LongRunningScriptDetectedEvent; + new(): LongRunningScriptDetectedEvent; +} + +interface MSAppView { + viewId: number; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; +} +declare var MSAppView: { + prototype: MSAppView; + new(): MSAppView; +} + +interface PerfWidgetExternal { + maxCpuSpeed: number; + independentRenderingEnabled: boolean; + irDisablingContentString: string; + irStatusAvailable: boolean; + performanceCounter: number; + averagePaintTime: number; + activeNetworkRequestCount: number; + paintRequestsPerSecond: number; + extraInformationEnabled: boolean; + performanceCounterFrequency: number; + averageFrameTime: number; + repositionWindow(x: number, y: number): void; + getRecentMemoryUsage(last: number): any; + getMemoryUsage(): number; + resizeWindow(width: number, height: number): void; + getProcessCpuUsage(): number; + removeEventListener(eventType: string, callback: (ev: any) => any): void; + getRecentCpuUsage(last: number): any; + addEventListener(eventType: string, callback: (ev: any) => any): void; + getRecentFrames(last: number): any; + getRecentPaintRequests(last: number): any; +} +declare var PerfWidgetExternal: { + prototype: PerfWidgetExternal; + new(): PerfWidgetExternal; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new(): PageTransitionEvent; +} + +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} + +interface HTMLDocument extends Document { +} +declare var HTMLDocument: { + prototype: HTMLDocument; + new(): HTMLDocument; +} + +interface KeyPair { + privateKey: Key; + publicKey: Key; +} +declare var KeyPair: { + prototype: KeyPair; + new(): KeyPair; +} + +interface MSMediaKeySession extends EventTarget { + sessionId: string; + error: MSMediaKeyError; + keySystem: string; + close(): void; + update(key: Uint8Array): void; +} +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new(): MSMediaKeySession; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEvent { + referrer: string; +} +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new(): UnviewableContentIdentifiedEvent; +} + +interface CryptoOperation extends EventTarget { + algorithm: Algorithm; + oncomplete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + onprogress: (ev: ProgressEvent) => any; + onabort: (ev: UIEvent) => any; + key: Key; + result: any; + abort(): void; + finish(): void; + process(buffer: ArrayBufferView): void; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var CryptoOperation: { + prototype: CryptoOperation; + new(): CryptoOperation; +} + +interface WebGLTexture extends WebGLObject { +} +declare var WebGLTexture: { + prototype: WebGLTexture; + new(): WebGLTexture; +} + +interface OES_texture_float { +} +declare var OES_texture_float: { + prototype: OES_texture_float; + new(): OES_texture_float; +} + +interface WebGLContextEvent extends Event { + statusMessage: string; +} +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(): WebGLContextEvent; +} + +interface WebGLRenderbuffer extends WebGLObject { +} +declare var WebGLRenderbuffer: { + prototype: WebGLRenderbuffer; + new(): WebGLRenderbuffer; +} + +interface WebGLUniformLocation { +} +declare var WebGLUniformLocation: { + prototype: WebGLUniformLocation; + new(): WebGLUniformLocation; +} + +interface WebGLActiveInfo { + name: string; + type: number; + size: number; +} +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +} + +interface WEBGL_compressed_texture_s3tc { + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} +declare var WEBGL_compressed_texture_s3tc: { + prototype: WEBGL_compressed_texture_s3tc; + new(): WEBGL_compressed_texture_s3tc; + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WebGLRenderingContext { + drawingBufferWidth: number; + drawingBufferHeight: number; + canvas: HTMLCanvasElement; + getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; + bindTexture(target: number, texture: WebGLTexture): void; + bufferData(target: number, data: ArrayBufferView, usage: number): void; + bufferData(target: number, data: ArrayBuffer, usage: number): void; + bufferData(target: number, size: number, usage: number): void; + depthMask(flag: boolean): void; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; + vertexAttrib3fv(indx: number, values: number[]): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; + linkProgram(program: WebGLProgram): void; + getSupportedExtensions(): string[]; + bufferSubData(target: number, offset: number, data: ArrayBuffer): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView): void; + vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + polygonOffset(factor: number, units: number): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + createTexture(): WebGLTexture; + hint(target: number, mode: number): void; + getVertexAttrib(index: number, pname: number): any; + enableVertexAttribArray(index: number): void; + depthRange(zNear: number, zFar: number): void; + cullFace(mode: number): void; + createFramebuffer(): WebGLFramebuffer; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + getExtension(name: string): any; + createProgram(): WebGLProgram; + deleteShader(shader: WebGLShader): void; + getAttachedShaders(program: WebGLProgram): WebGLShader[]; + enable(cap: number): void; + blendEquation(mode: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; + createBuffer(): WebGLBuffer; + deleteTexture(texture: WebGLTexture): void; + useProgram(program: WebGLProgram): void; + vertexAttrib2fv(indx: number, values: number[]): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; + checkFramebufferStatus(target: number): number; + frontFace(mode: number): void; + getBufferParameter(target: number, pname: number): any; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + getVertexAttribOffset(index: number, pname: number): number; + disableVertexAttribArray(index: number): void; + blendFunc(sfactor: number, dfactor: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + isFramebuffer(framebuffer: WebGLFramebuffer): boolean; + uniform3iv(location: WebGLUniformLocation, v: number[]): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; + lineWidth(width: number): void; + getShaderInfoLog(shader: WebGLShader): string; + getTexParameter(target: number, pname: number): any; + getParameter(pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; + getContextAttributes(): WebGLContextAttributes; + vertexAttrib1f(indx: number, x: number): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; + isContextLost(): boolean; + uniform1iv(location: WebGLUniformLocation, v: number[]): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; + getRenderbufferParameter(target: number, pname: number): any; + uniform2fv(location: WebGLUniformLocation, v: number[]): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; + isTexture(texture: WebGLTexture): boolean; + getError(): number; + shaderSource(shader: WebGLShader, source: string): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; + stencilMask(mask: number): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + getAttribLocation(program: WebGLProgram, name: string): number; + uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + clear(mask: number): void; + blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + scissor(x: number, y: number, width: number, height: number): void; + uniform2i(location: WebGLUniformLocation, x: number, y: number): void; + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getShaderSource(shader: WebGLShader): string; + generateMipmap(target: number): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + uniform1fv(location: WebGLUniformLocation, v: number[]): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform2iv(location: WebGLUniformLocation, v: number[]): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + uniform4fv(location: WebGLUniformLocation, v: number[]): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; + vertexAttrib1fv(indx: number, values: number[]): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; + flush(): void; + uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + deleteProgram(program: WebGLProgram): void; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + uniform1i(location: WebGLUniformLocation, x: number): void; + getProgramParameter(program: WebGLProgram, pname: number): any; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + stencilFunc(func: number, ref: number, mask: number): void; + pixelStorei(pname: number, param: number): void; + disable(cap: number): void; + vertexAttrib4fv(indx: number, values: number[]): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; + createRenderbuffer(): WebGLRenderbuffer; + isBuffer(buffer: WebGLBuffer): boolean; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; + uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + sampleCoverage(value: number, invert: boolean): void; + depthFunc(func: number): void; + texParameterf(target: number, pname: number, param: number): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + drawArrays(mode: number, first: number, count: number): void; + texParameteri(target: number, pname: number, param: number): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + getShaderParameter(shader: WebGLShader, pname: number): any; + clearDepth(depth: number): void; + activeTexture(texture: number): void; + viewport(x: number, y: number, width: number, height: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + uniform1f(location: WebGLUniformLocation, x: number): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + deleteBuffer(buffer: WebGLBuffer): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + uniform3fv(location: WebGLUniformLocation, v: number[]): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; + stencilMaskSeparate(face: number, mask: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + compileShader(shader: WebGLShader): void; + clearColor(red: number, green: number, blue: number, alpha: number): void; + isShader(shader: WebGLShader): boolean; + clearStencil(s: number): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + finish(): void; + uniform2f(location: WebGLUniformLocation, x: number, y: number): void; + renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; + uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; + getProgramInfoLog(program: WebGLProgram): string; + validateProgram(program: WebGLProgram): void; + isEnabled(cap: number): boolean; + vertexAttrib2f(indx: number, x: number, y: number): void; + isProgram(program: WebGLProgram): boolean; + createShader(type: number): WebGLShader; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; + uniform4iv(location: WebGLUniformLocation, v: number[]): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; + DEPTH_FUNC: number; + DEPTH_COMPONENT16: number; + REPLACE: number; + REPEAT: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + STENCIL_BUFFER_BIT: number; + RENDERER: number; + STENCIL_BACK_REF: number; + TEXTURE26: number; + RGB565: number; + DITHER: number; + CONSTANT_COLOR: number; + GENERATE_MIPMAP_HINT: number; + POINTS: number; + DECR: number; + INT_VEC3: number; + TEXTURE28: number; + ONE_MINUS_CONSTANT_ALPHA: number; + BACK: number; + RENDERBUFFER_STENCIL_SIZE: number; + UNPACK_FLIP_Y_WEBGL: number; + BLEND: number; + TEXTURE9: number; + ARRAY_BUFFER_BINDING: number; + MAX_VIEWPORT_DIMS: number; + INVALID_FRAMEBUFFER_OPERATION: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE31: number; + TEXTURE24: number; + HIGH_INT: number; + RENDERBUFFER_BINDING: number; + BLEND_COLOR: number; + FASTEST: number; + STENCIL_WRITEMASK: number; + ALIASED_POINT_SIZE_RANGE: number; + TEXTURE12: number; + DST_ALPHA: number; + BLEND_EQUATION_RGB: number; + FRAMEBUFFER_COMPLETE: number; + NEAREST_MIPMAP_NEAREST: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + TEXTURE3: number; + DEPTH_WRITEMASK: number; + CONTEXT_LOST_WEBGL: number; + INVALID_VALUE: number; + TEXTURE_MAG_FILTER: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + NOTEQUAL: number; + ALPHA: number; + DEPTH_STENCIL: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + DEPTH_COMPONENT: number; + RENDERBUFFER_RED_SIZE: number; + TEXTURE20: number; + RED_BITS: number; + RENDERBUFFER_BLUE_SIZE: number; + SCISSOR_BOX: number; + VENDOR: number; + FRONT_AND_BACK: number; + CONSTANT_ALPHA: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + NEAREST: number; + CULL_FACE: number; + ALIASED_LINE_WIDTH_RANGE: number; + TEXTURE19: number; + FRONT: number; + DEPTH_CLEAR_VALUE: number; + GREEN_BITS: number; + TEXTURE29: number; + TEXTURE23: number; + MAX_RENDERBUFFER_SIZE: number; + STENCIL_ATTACHMENT: number; + TEXTURE27: number; + BOOL_VEC2: number; + OUT_OF_MEMORY: number; + MIRRORED_REPEAT: number; + POLYGON_OFFSET_UNITS: number; + TEXTURE_MIN_FILTER: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + LINE_LOOP: number; + FLOAT_MAT3: number; + TEXTURE14: number; + LINEAR: number; + RGB5_A1: number; + ONE_MINUS_SRC_COLOR: number; + SAMPLE_COVERAGE_INVERT: number; + DONT_CARE: number; + FRAMEBUFFER_BINDING: number; + RENDERBUFFER_ALPHA_SIZE: number; + STENCIL_REF: number; + ZERO: number; + DECR_WRAP: number; + SAMPLE_COVERAGE: number; + STENCIL_BACK_FUNC: number; + TEXTURE30: number; + VIEWPORT: number; + STENCIL_BITS: number; + FLOAT: number; + COLOR_WRITEMASK: number; + SAMPLE_COVERAGE_VALUE: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + STENCIL_BACK_FAIL: number; + FLOAT_MAT4: number; + UNSIGNED_SHORT_4_4_4_4: number; + TEXTURE6: number; + RENDERBUFFER_WIDTH: number; + RGBA4: number; + ALWAYS: number; + BLEND_EQUATION_ALPHA: number; + COLOR_BUFFER_BIT: number; + TEXTURE_CUBE_MAP: number; + DEPTH_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + BLEND_EQUATION: number; + RENDERBUFFER_GREEN_SIZE: number; + NEAREST_MIPMAP_LINEAR: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + INCR_WRAP: number; + ONE_MINUS_DST_COLOR: number; + HIGH_FLOAT: number; + BYTE: number; + FRONT_FACE: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + CCW: number; + TEXTURE13: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_WRAP_T: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + FLOAT_VEC2: number; + LUMINANCE: number; + GREATER: number; + INT_VEC2: number; + VALIDATE_STATUS: number; + FRAMEBUFFER: number; + FRAMEBUFFER_UNSUPPORTED: number; + TEXTURE5: number; + FUNC_SUBTRACT: number; + BLEND_DST_ALPHA: number; + SAMPLER_CUBE: number; + ONE_MINUS_DST_ALPHA: number; + LESS: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + BLUE_BITS: number; + DEPTH_TEST: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + DELETE_STATUS: number; + TEXTURE18: number; + POLYGON_OFFSET_FACTOR: number; + UNSIGNED_INT: number; + TEXTURE_2D: number; + DST_COLOR: number; + FLOAT_MAT2: number; + COMPRESSED_TEXTURE_FORMATS: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + DEPTH_STENCIL_ATTACHMENT: number; + LUMINANCE_ALPHA: number; + CW: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + LINEAR_MIPMAP_LINEAR: number; + BUFFER_SIZE: number; + SAMPLE_BUFFERS: number; + TEXTURE15: number; + ACTIVE_TEXTURE: number; + VERTEX_SHADER: number; + TEXTURE22: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + INCR: number; + COMPILE_STATUS: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + TEXTURE7: number; + UNSIGNED_SHORT_5_5_5_1: number; + DEPTH_BITS: number; + RGBA: number; + TRIANGLE_STRIP: number; + COLOR_CLEAR_VALUE: number; + BROWSER_DEFAULT_WEBGL: number; + INVALID_ENUM: number; + SCISSOR_TEST: number; + LINE_STRIP: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + STENCIL_FUNC: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + RENDERBUFFER_HEIGHT: number; + TEXTURE8: number; + TRIANGLES: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + STENCIL_BACK_VALUE_MASK: number; + TEXTURE25: number; + RENDERBUFFER: number; + LEQUAL: number; + TEXTURE1: number; + STENCIL_INDEX8: number; + FUNC_ADD: number; + STENCIL_FAIL: number; + BLEND_SRC_ALPHA: number; + BOOL: number; + ALPHA_BITS: number; + LOW_INT: number; + TEXTURE10: number; + SRC_COLOR: number; + MAX_VARYING_VECTORS: number; + BLEND_DST_RGB: number; + TEXTURE_BINDING_CUBE_MAP: number; + STENCIL_INDEX: number; + TEXTURE_BINDING_2D: number; + MEDIUM_INT: number; + SHADER_TYPE: number; + POLYGON_OFFSET_FILL: number; + DYNAMIC_DRAW: number; + TEXTURE4: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STREAM_DRAW: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + TEXTURE17: number; + TRIANGLE_FAN: number; + UNPACK_ALIGNMENT: number; + CURRENT_PROGRAM: number; + LINES: number; + INVALID_OPERATION: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + LINEAR_MIPMAP_NEAREST: number; + CLAMP_TO_EDGE: number; + RENDERBUFFER_DEPTH_SIZE: number; + TEXTURE_WRAP_S: number; + ELEMENT_ARRAY_BUFFER: number; + UNSIGNED_SHORT_5_6_5: number; + ACTIVE_UNIFORMS: number; + FLOAT_VEC3: number; + NO_ERROR: number; + ATTACHED_SHADERS: number; + DEPTH_ATTACHMENT: number; + TEXTURE11: number; + STENCIL_TEST: number; + ONE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + STATIC_DRAW: number; + GEQUAL: number; + BOOL_VEC4: number; + COLOR_ATTACHMENT0: number; + PACK_ALIGNMENT: number; + MAX_TEXTURE_SIZE: number; + STENCIL_PASS_DEPTH_FAIL: number; + CULL_FACE_MODE: number; + TEXTURE16: number; + STENCIL_BACK_WRITEMASK: number; + SRC_ALPHA: number; + UNSIGNED_SHORT: number; + TEXTURE21: number; + FUNC_REVERSE_SUBTRACT: number; + SHADING_LANGUAGE_VERSION: number; + EQUAL: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + BOOL_VEC3: number; + SAMPLER_2D: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + MAX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + STENCIL_VALUE_MASK: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + ARRAY_BUFFER: number; + DEPTH_RANGE: number; + NICEST: number; + ACTIVE_ATTRIBUTES: number; + NEVER: number; + FLOAT_VEC4: number; + CURRENT_VERTEX_ATTRIB: number; + STENCIL_PASS_DEPTH_PASS: number; + INVERT: number; + LINK_STATUS: number; + RGB: number; + INT_VEC4: number; + TEXTURE2: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + MEDIUM_FLOAT: number; + SRC_ALPHA_SATURATE: number; + BUFFER_USAGE: number; + SHORT: number; + NONE: number; + UNSIGNED_BYTE: number; + INT: number; + SUBPIXEL_BITS: number; + KEEP: number; + SAMPLES: number; + FRAGMENT_SHADER: number; + LINE_WIDTH: number; + BLEND_SRC_RGB: number; + LOW_FLOAT: number; + VERSION: number; +} +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + DEPTH_FUNC: number; + DEPTH_COMPONENT16: number; + REPLACE: number; + REPEAT: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + STENCIL_BUFFER_BIT: number; + RENDERER: number; + STENCIL_BACK_REF: number; + TEXTURE26: number; + RGB565: number; + DITHER: number; + CONSTANT_COLOR: number; + GENERATE_MIPMAP_HINT: number; + POINTS: number; + DECR: number; + INT_VEC3: number; + TEXTURE28: number; + ONE_MINUS_CONSTANT_ALPHA: number; + BACK: number; + RENDERBUFFER_STENCIL_SIZE: number; + UNPACK_FLIP_Y_WEBGL: number; + BLEND: number; + TEXTURE9: number; + ARRAY_BUFFER_BINDING: number; + MAX_VIEWPORT_DIMS: number; + INVALID_FRAMEBUFFER_OPERATION: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE31: number; + TEXTURE24: number; + HIGH_INT: number; + RENDERBUFFER_BINDING: number; + BLEND_COLOR: number; + FASTEST: number; + STENCIL_WRITEMASK: number; + ALIASED_POINT_SIZE_RANGE: number; + TEXTURE12: number; + DST_ALPHA: number; + BLEND_EQUATION_RGB: number; + FRAMEBUFFER_COMPLETE: number; + NEAREST_MIPMAP_NEAREST: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + TEXTURE3: number; + DEPTH_WRITEMASK: number; + CONTEXT_LOST_WEBGL: number; + INVALID_VALUE: number; + TEXTURE_MAG_FILTER: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + NOTEQUAL: number; + ALPHA: number; + DEPTH_STENCIL: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + DEPTH_COMPONENT: number; + RENDERBUFFER_RED_SIZE: number; + TEXTURE20: number; + RED_BITS: number; + RENDERBUFFER_BLUE_SIZE: number; + SCISSOR_BOX: number; + VENDOR: number; + FRONT_AND_BACK: number; + CONSTANT_ALPHA: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + NEAREST: number; + CULL_FACE: number; + ALIASED_LINE_WIDTH_RANGE: number; + TEXTURE19: number; + FRONT: number; + DEPTH_CLEAR_VALUE: number; + GREEN_BITS: number; + TEXTURE29: number; + TEXTURE23: number; + MAX_RENDERBUFFER_SIZE: number; + STENCIL_ATTACHMENT: number; + TEXTURE27: number; + BOOL_VEC2: number; + OUT_OF_MEMORY: number; + MIRRORED_REPEAT: number; + POLYGON_OFFSET_UNITS: number; + TEXTURE_MIN_FILTER: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + LINE_LOOP: number; + FLOAT_MAT3: number; + TEXTURE14: number; + LINEAR: number; + RGB5_A1: number; + ONE_MINUS_SRC_COLOR: number; + SAMPLE_COVERAGE_INVERT: number; + DONT_CARE: number; + FRAMEBUFFER_BINDING: number; + RENDERBUFFER_ALPHA_SIZE: number; + STENCIL_REF: number; + ZERO: number; + DECR_WRAP: number; + SAMPLE_COVERAGE: number; + STENCIL_BACK_FUNC: number; + TEXTURE30: number; + VIEWPORT: number; + STENCIL_BITS: number; + FLOAT: number; + COLOR_WRITEMASK: number; + SAMPLE_COVERAGE_VALUE: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + STENCIL_BACK_FAIL: number; + FLOAT_MAT4: number; + UNSIGNED_SHORT_4_4_4_4: number; + TEXTURE6: number; + RENDERBUFFER_WIDTH: number; + RGBA4: number; + ALWAYS: number; + BLEND_EQUATION_ALPHA: number; + COLOR_BUFFER_BIT: number; + TEXTURE_CUBE_MAP: number; + DEPTH_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + BLEND_EQUATION: number; + RENDERBUFFER_GREEN_SIZE: number; + NEAREST_MIPMAP_LINEAR: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + INCR_WRAP: number; + ONE_MINUS_DST_COLOR: number; + HIGH_FLOAT: number; + BYTE: number; + FRONT_FACE: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + CCW: number; + TEXTURE13: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_WRAP_T: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + FLOAT_VEC2: number; + LUMINANCE: number; + GREATER: number; + INT_VEC2: number; + VALIDATE_STATUS: number; + FRAMEBUFFER: number; + FRAMEBUFFER_UNSUPPORTED: number; + TEXTURE5: number; + FUNC_SUBTRACT: number; + BLEND_DST_ALPHA: number; + SAMPLER_CUBE: number; + ONE_MINUS_DST_ALPHA: number; + LESS: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + BLUE_BITS: number; + DEPTH_TEST: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + DELETE_STATUS: number; + TEXTURE18: number; + POLYGON_OFFSET_FACTOR: number; + UNSIGNED_INT: number; + TEXTURE_2D: number; + DST_COLOR: number; + FLOAT_MAT2: number; + COMPRESSED_TEXTURE_FORMATS: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + DEPTH_STENCIL_ATTACHMENT: number; + LUMINANCE_ALPHA: number; + CW: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + LINEAR_MIPMAP_LINEAR: number; + BUFFER_SIZE: number; + SAMPLE_BUFFERS: number; + TEXTURE15: number; + ACTIVE_TEXTURE: number; + VERTEX_SHADER: number; + TEXTURE22: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + INCR: number; + COMPILE_STATUS: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + TEXTURE7: number; + UNSIGNED_SHORT_5_5_5_1: number; + DEPTH_BITS: number; + RGBA: number; + TRIANGLE_STRIP: number; + COLOR_CLEAR_VALUE: number; + BROWSER_DEFAULT_WEBGL: number; + INVALID_ENUM: number; + SCISSOR_TEST: number; + LINE_STRIP: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + STENCIL_FUNC: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + RENDERBUFFER_HEIGHT: number; + TEXTURE8: number; + TRIANGLES: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + STENCIL_BACK_VALUE_MASK: number; + TEXTURE25: number; + RENDERBUFFER: number; + LEQUAL: number; + TEXTURE1: number; + STENCIL_INDEX8: number; + FUNC_ADD: number; + STENCIL_FAIL: number; + BLEND_SRC_ALPHA: number; + BOOL: number; + ALPHA_BITS: number; + LOW_INT: number; + TEXTURE10: number; + SRC_COLOR: number; + MAX_VARYING_VECTORS: number; + BLEND_DST_RGB: number; + TEXTURE_BINDING_CUBE_MAP: number; + STENCIL_INDEX: number; + TEXTURE_BINDING_2D: number; + MEDIUM_INT: number; + SHADER_TYPE: number; + POLYGON_OFFSET_FILL: number; + DYNAMIC_DRAW: number; + TEXTURE4: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STREAM_DRAW: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + TEXTURE17: number; + TRIANGLE_FAN: number; + UNPACK_ALIGNMENT: number; + CURRENT_PROGRAM: number; + LINES: number; + INVALID_OPERATION: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + LINEAR_MIPMAP_NEAREST: number; + CLAMP_TO_EDGE: number; + RENDERBUFFER_DEPTH_SIZE: number; + TEXTURE_WRAP_S: number; + ELEMENT_ARRAY_BUFFER: number; + UNSIGNED_SHORT_5_6_5: number; + ACTIVE_UNIFORMS: number; + FLOAT_VEC3: number; + NO_ERROR: number; + ATTACHED_SHADERS: number; + DEPTH_ATTACHMENT: number; + TEXTURE11: number; + STENCIL_TEST: number; + ONE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + STATIC_DRAW: number; + GEQUAL: number; + BOOL_VEC4: number; + COLOR_ATTACHMENT0: number; + PACK_ALIGNMENT: number; + MAX_TEXTURE_SIZE: number; + STENCIL_PASS_DEPTH_FAIL: number; + CULL_FACE_MODE: number; + TEXTURE16: number; + STENCIL_BACK_WRITEMASK: number; + SRC_ALPHA: number; + UNSIGNED_SHORT: number; + TEXTURE21: number; + FUNC_REVERSE_SUBTRACT: number; + SHADING_LANGUAGE_VERSION: number; + EQUAL: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + BOOL_VEC3: number; + SAMPLER_2D: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + MAX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + STENCIL_VALUE_MASK: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + ARRAY_BUFFER: number; + DEPTH_RANGE: number; + NICEST: number; + ACTIVE_ATTRIBUTES: number; + NEVER: number; + FLOAT_VEC4: number; + CURRENT_VERTEX_ATTRIB: number; + STENCIL_PASS_DEPTH_PASS: number; + INVERT: number; + LINK_STATUS: number; + RGB: number; + INT_VEC4: number; + TEXTURE2: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + MEDIUM_FLOAT: number; + SRC_ALPHA_SATURATE: number; + BUFFER_USAGE: number; + SHORT: number; + NONE: number; + UNSIGNED_BYTE: number; + INT: number; + SUBPIXEL_BITS: number; + KEEP: number; + SAMPLES: number; + FRAGMENT_SHADER: number; + LINE_WIDTH: number; + BLEND_SRC_RGB: number; + LOW_FLOAT: number; + VERSION: number; +} + +interface WebGLProgram extends WebGLObject { +} +declare var WebGLProgram: { + prototype: WebGLProgram; + new(): WebGLProgram; +} + +interface OES_standard_derivatives { + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} +declare var OES_standard_derivatives: { + prototype: OES_standard_derivatives; + new(): OES_standard_derivatives; + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +interface WebGLFramebuffer extends WebGLObject { +} +declare var WebGLFramebuffer: { + prototype: WebGLFramebuffer; + new(): WebGLFramebuffer; +} + +interface WebGLShader extends WebGLObject { +} +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +} + +interface OES_texture_float_linear { +} +declare var OES_texture_float_linear: { + prototype: OES_texture_float_linear; + new(): OES_texture_float_linear; +} + +interface WebGLObject { +} +declare var WebGLObject: { + prototype: WebGLObject; + new(): WebGLObject; +} + +interface WebGLBuffer extends WebGLObject { +} +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +} + +interface WebGLShaderPrecisionFormat { + rangeMin: number; + rangeMax: number; + precision: number; +} +declare var WebGLShaderPrecisionFormat: { + prototype: WebGLShaderPrecisionFormat; + new(): WebGLShaderPrecisionFormat; +} + +interface EXT_texture_filter_anisotropic { + TEXTURE_MAX_ANISOTROPY_EXT: number; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; +} +declare var EXT_texture_filter_anisotropic: { + prototype: EXT_texture_filter_anisotropic; + new(): EXT_texture_filter_anisotropic; + TEXTURE_MAX_ANISOTROPY_EXT: number; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +declare var Option: { new(text?: string, value?: string, defaultSelected?: boolean, selected?:boolean): HTMLOptionElement; }; +declare var Image: { new(width?: number, height?: number): HTMLImageElement; }; +declare var Audio: { new(src?: string): HTMLAudioElement; }; + +declare var ondragend: (ev: DragEvent) => any; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare var ondragover: (ev: DragEvent) => any; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare var onreset: (ev: Event) => any; +declare var onmouseup: (ev: MouseEvent) => any; +declare var ondragstart: (ev: DragEvent) => any; +declare var ondrag: (ev: DragEvent) => any; +declare var screenX: number; +declare var onmouseover: (ev: MouseEvent) => any; +declare var ondragleave: (ev: DragEvent) => any; +declare var history: History; +declare var pageXOffset: number; +declare var name: string; +declare var onafterprint: (ev: Event) => any; +declare var onpause: (ev: Event) => any; +declare var onbeforeprint: (ev: Event) => any; +declare var top: Window; +declare var onmousedown: (ev: MouseEvent) => any; +declare var onseeked: (ev: Event) => any; +declare var opener: Window; +declare var onclick: (ev: MouseEvent) => any; +declare var innerHeight: number; +declare var onwaiting: (ev: Event) => any; +declare var ononline: (ev: Event) => any; +declare var ondurationchange: (ev: Event) => any; +declare var frames: Window; +declare var onblur: (ev: FocusEvent) => any; +declare var onemptied: (ev: Event) => any; +declare var onseeking: (ev: Event) => any; +declare var oncanplay: (ev: Event) => any; +declare var outerWidth: number; +declare var onstalled: (ev: Event) => any; +declare var onmousemove: (ev: MouseEvent) => any; +declare var innerWidth: number; +declare var onoffline: (ev: Event) => any; +declare var length: number; +declare var screen: Screen; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare var onratechange: (ev: Event) => any; +declare var onstorage: (ev: StorageEvent) => any; +declare var onloadstart: (ev: Event) => any; +declare var ondragenter: (ev: DragEvent) => any; +declare var onsubmit: (ev: Event) => any; +declare var self: Window; +declare var document: Document; +declare var onprogress: (ev: ProgressEvent) => any; +declare var ondblclick: (ev: MouseEvent) => any; +declare var pageYOffset: number; +declare var oncontextmenu: (ev: MouseEvent) => any; +declare var onchange: (ev: Event) => any; +declare var onloadedmetadata: (ev: Event) => any; +declare var onplay: (ev: Event) => any; +declare var onerror: ErrorEventHandler; +declare var onplaying: (ev: Event) => any; +declare var parent: Window; +declare var location: Location; +declare var oncanplaythrough: (ev: Event) => any; +declare var onabort: (ev: UIEvent) => any; +declare var onreadystatechange: (ev: Event) => any; +declare var outerHeight: number; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare var frameElement: Element; +declare var onloadeddata: (ev: Event) => any; +declare var onsuspend: (ev: Event) => any; +declare var window: Window; +declare var onfocus: (ev: FocusEvent) => any; +declare var onmessage: (ev: MessageEvent) => any; +declare var ontimeupdate: (ev: Event) => any; +declare var onresize: (ev: UIEvent) => any; +declare var onselect: (ev: UIEvent) => any; +declare var navigator: Navigator; +declare var styleMedia: StyleMedia; +declare var ondrop: (ev: DragEvent) => any; +declare var onmouseout: (ev: MouseEvent) => any; +declare var onended: (ev: Event) => any; +declare var onhashchange: (ev: Event) => any; +declare var onunload: (ev: Event) => any; +declare var onscroll: (ev: UIEvent) => any; +declare var screenY: number; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onload: (ev: Event) => any; +declare var onvolumechange: (ev: Event) => any; +declare var oninput: (ev: Event) => any; +declare var performance: Performance; +declare var onmspointerdown: (ev: any) => any; +declare var animationStartTime: number; +declare var onmsgesturedoubletap: (ev: any) => any; +declare var onmspointerhover: (ev: any) => any; +declare var onmsgesturehold: (ev: any) => any; +declare var onmspointermove: (ev: any) => any; +declare var onmsgesturechange: (ev: any) => any; +declare var onmsgesturestart: (ev: any) => any; +declare var onmspointercancel: (ev: any) => any; +declare var onmsgestureend: (ev: any) => any; +declare var onmsgesturetap: (ev: any) => any; +declare var onmspointerout: (ev: any) => any; +declare var msAnimationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var onmsinertiastart: (ev: any) => any; +declare var onmspointerover: (ev: any) => any; +declare var onpopstate: (ev: PopStateEvent) => any; +declare var onmspointerup: (ev: any) => any; +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare var devicePixelRatio: number; +declare var msCrypto: Crypto; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare var doNotTrack: string; +declare var onmspointerenter: (ev: any) => any; +declare var onpagehide: (ev: PageTransitionEvent) => any; +declare var onmspointerleave: (ev: any) => any; +declare function alert(message?: any): void; +declare function scroll(x?: number, y?: number): void; +declare function focus(): void; +declare function scrollTo(x?: number, y?: number): void; +declare function print(): void; +declare function prompt(message?: string, _default?: string): string; +declare function toString(): string; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function scrollBy(x?: number, y?: number): void; +declare function confirm(message?: string): boolean; +declare function close(): void; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function showModalDialog(url?: string, argument?: any, options?: any): any; +declare function blur(): void; +declare function getSelection(): Selection; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function cancelAnimationFrame(handle: number): void; +declare function msIsStaticHTML(html: string): boolean; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function attachEvent(event: string, listener: EventListener): boolean; +declare function detachEvent(event: string, listener: EventListener): void; +declare var localStorage: Storage; +declare var status: string; +declare var onmouseleave: (ev: MouseEvent) => any; +declare var screenLeft: number; +declare var offscreenBuffering: any; +declare var maxConnectionsPerServer: number; +declare var onmouseenter: (ev: MouseEvent) => any; +declare var clipboardData: DataTransfer; +declare var defaultStatus: string; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var onhelp: (ev: Event) => any; +declare var external: External; +declare var event: MSEventObj; +declare var onfocusout: (ev: FocusEvent) => any; +declare var screenTop: number; +declare var onfocusin: (ev: FocusEvent) => any; +declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; +declare function navigate(url: string): void; +declare function resizeBy(x?: number, y?: number): void; +declare function item(index: any): any; +declare function resizeTo(x?: number, y?: number): void; +declare function createPopup(arguments?: any): MSPopupWindow; +declare function toStaticHTML(html: string): string; +declare function execScript(code: string, language?: string): any; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function moveTo(x?: number, y?: number): void; +declare function moveBy(x?: number, y?: number): void; +declare function showHelp(url: string, helpArg?: any, features?: string): void; +declare function captureEvents(): void; +declare function releaseEvents(): void; +declare var sessionStorage: Storage; +declare function clearTimeout(handle: number): void; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearInterval(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function msSetImmediate(expression: any, ...args: any[]): number; +declare function clearImmediate(handle: number): void; +declare function msClearImmediate(handle: number): void; +declare function setImmediate(expression: any, ...args: any[]): number; +declare function btoa(rawString: string): string; +declare function atob(encodedString: string): string; +declare var msIndexedDB: IDBFactory; +declare var indexedDB: IDBFactory; +declare var console: Console; +declare var onpointerenter: (ev: PointerEvent) => any; +declare var onpointerout: (ev: PointerEvent) => any; +declare var onpointerdown: (ev: PointerEvent) => any; +declare var onpointerup: (ev: PointerEvent) => any; +declare var onpointercancel: (ev: PointerEvent) => any; +declare var onpointerover: (ev: PointerEvent) => any; +declare var onpointermove: (ev: PointerEvent) => any; +declare var onpointerleave: (ev: PointerEvent) => any; +declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + +///////////////////////////// +/// WorkerGlobalScope APIs +///////////////////////////// +// These are only available in a Web Worker +declare function importScripts(...urls: string[]): void; + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// + +declare var ActiveXObject: { new (s: string): any; }; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +declare var WScript: { + Echo(s: any): void; + StdErr: ITextWriter; + StdOut: ITextWriter; + Arguments: { length: number; Item(n: number): string; }; + ScriptFullName: string; + Quit(exitCode?: number): number; +} diff --git a/bin/lib.webworker.d.ts b/bin/lib.webworker.d.ts index 8675d267aa4..eefa7a42014 100644 --- a/bin/lib.webworker.d.ts +++ b/bin/lib.webworker.d.ts @@ -647,6 +647,7 @@ interface Map { } declare var Map: { new (): Map; + prototype: Map; } interface WeakMap { @@ -658,6 +659,7 @@ interface WeakMap { } declare var WeakMap: { new (): WeakMap; + prototype: WeakMap; } interface Set { @@ -670,10 +672,13 @@ interface Set { } declare var Set: { new (): Set; + prototype: Set; } +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// declare module Intl { - interface CollatorOptions { usage?: string; localeMatcher?: string; diff --git a/bin/tsc.js b/bin/tsc.js index c1ce8cee83d..370b62f59bd 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -34,15 +34,15 @@ var ts; var ts; (function (ts) { function forEach(array, callback) { - var result; if (array) { for (var i = 0, len = array.length; i < len; i++) { - if (result = callback(array[i])) { - break; + var result = callback(array[i]); + if (result) { + return result; } } } - return result; + return undefined; } ts.forEach = forEach; function contains(array, value) { @@ -591,201 +591,204 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); -var sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; +var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1; + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - return { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return new ActiveXObject("WScript.Shell").CurrentDirectory; - }, - exit: function (exitCode) { + fileStream.Open(); try { - WScript.Quit(exitCode); + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + fileStream.Position = 0; + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + return fileStream.ReadText(); } catch (e) { + throw e; + } + finally { + fileStream.Close(); } } - }; - } - function getNodeSystem() { - var _fs = require("fs"); - var _path = require("path"); - var _os = require('os'); - var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; - function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { - return undefined; - } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; - if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { - len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } - if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { - return buffer.toString("utf16le", 2); - } - if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { - return buffer.toString("utf8", 3); - } - return buffer.toString("utf8"); - } - function writeFile(fileName, data, writeByteOrderMark) { - if (writeByteOrderMark) { - data = '\uFEFF' + data; - } - _fs.writeFileSync(fileName, data, "utf8"); - } - return { - args: process.argv.slice(2), - newLine: _os.EOL, - useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write: function (s) { - _fs.writeSync(1, s); - }, - readFile: readFile, - writeFile: writeFile, - watchFile: function (fileName, callback) { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); - return { - close: function () { - _fs.unwatchFile(fileName, fileChanged); + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + if (writeByteOrderMark) { + fileStream.Position = 0; } - }; - function fileChanged(curr, prev) { - if (+curr.mtime <= +prev.mtime) { - return; + else { + fileStream.Position = 3; } - callback(fileName); + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2); } - ; - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - _fs.mkdirSync(directoryName); + finally { + binaryStream.Close(); + fileStream.Close(); } - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - getCurrentDirectory: function () { - return process.cwd(); - }, - getMemoryUsage: function () { - if (global.gc) { - global.gc(); - } - return process.memoryUsage().heapUsed; - }, - exit: function (exitCode) { - process.exit(exitCode); } - }; - } - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); - } - else if (typeof module !== "undefined" && module.exports) { - return getNodeSystem(); - } - else { - return undefined; - } -})(); + return { + args: args, + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: function (s) { + WScript.StdOut.Write(s); + }, + readFile: readFile, + writeFile: writeFile, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require('os'); + var platform = _os.platform(); + var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + return buffer.toString("utf8", 3); + } + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + if (writeByteOrderMark) { + data = '\uFEFF' + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + _fs.writeSync(1, s); + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + return { + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + function fileChanged(curr, prev) { + if (+curr.mtime <= +prev.mtime) { + return; + } + callback(fileName); + } + ; + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWScriptSystem(); + } + else if (typeof module !== "undefined" && module.exports) { + return getNodeSystem(); + } + else { + return undefined; + } + })(); +})(ts || (ts = {})); var ts; (function (ts) { ts.Diagnostics = { @@ -893,8 +896,7 @@ var ts; Type_argument_expected: { code: 1140, category: 1 /* Error */, key: "Type argument expected." }, String_literal_expected: { code: 1141, category: 1 /* Error */, key: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: 1 /* Error */, key: "Line break not permitted here." }, - catch_or_finally_expected: { code: 1143, category: 1 /* Error */, key: "'catch' or 'finally' expected." }, - Block_or_expected: { code: 1144, category: 1 /* Error */, key: "Block or ';' expected." }, + or_expected: { code: 1144, category: 1 /* Error */, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1 /* Error */, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: 1 /* Error */, key: "Declaration expected." }, Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1 /* Error */, key: "Import declarations in an internal module cannot reference an external module." }, @@ -907,12 +909,27 @@ var ts; const_declarations_must_be_initialized: { code: 1155, category: 1 /* Error */, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1 /* Error */, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1 /* Error */, key: "'let' declarations can only be declared inside a block." }, - Invalid_template_literal_expected: { code: 1158, category: 1 /* Error */, key: "Invalid template literal; expected '}'" }, Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: 1 /* Error */, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: 1 /* Error */, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: 1 /* Error */, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: 1 /* Error */, key: "An object member cannot be declared optional." }, yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1 /* Error */, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1 /* Error */, key: "Computed property names are not allowed in enums." }, + Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: 1 /* Error */, key: "Computed property names are not allowed in an ambient context." }, + Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: 1 /* Error */, key: "Computed property names are not allowed in class property declarations." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1 /* Error */, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: 1 /* Error */, key: "Computed property names are not allowed in method overloads." }, + Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: 1 /* Error */, key: "Computed property names are not allowed in interfaces." }, + Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: 1 /* Error */, key: "Computed property names are not allowed in type literals." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1 /* Error */, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: 1 /* Error */, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: 1 /* Error */, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: 1 /* Error */, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: 1 /* Error */, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1 /* Error */, key: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: 1 /* Error */, key: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: 1 /* Error */, key: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: 1 /* Error */, key: "Unexpected token. '{' expected." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -1184,6 +1201,7 @@ var ts; Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: 1 /* Error */, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1 /* Error */, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2 /* Message */, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1 /* Error */, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1 /* Error */, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: 1 /* Error */, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1202,7 +1220,8 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: 1 /* Error */, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." }, yield_expressions_are_not_currently_supported: { code: 9000, category: 1 /* Error */, key: "'yield' expressions are not currently supported." }, - generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "'generators' are not currently supported." } + Generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "Generators are not currently supported." }, + Computed_property_names_are_not_currently_supported: { code: 9002, category: 1 /* Error */, key: "Computed property names are not currently supported." } }; })(ts || (ts = {})); var ts; @@ -1563,7 +1582,7 @@ var ts; 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, skipTrivia, text, onError, onComment) { + function createScanner(languageVersion, skipTrivia, text, onError) { var pos; var len; var startPos; @@ -1571,6 +1590,7 @@ var ts; var token; var tokenValue; var precedingLineBreak; + var tokenIsUnterminated; function error(message) { if (onError) { onError(message); @@ -1647,6 +1667,7 @@ var ts; while (true) { if (pos >= len) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1664,6 +1685,7 @@ var ts; } if (isLineBreak(ch)) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1680,6 +1702,7 @@ var ts; while (true) { if (pos >= len) { contents += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; break; @@ -1812,9 +1835,29 @@ var ts; } return token = 63 /* Identifier */; } + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48 /* _0 */; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + if (numberOfDigits === 0) { + return -1; + } + return value; + } function scan() { startPos = pos; precedingLineBreak = false; + tokenIsUnterminated = false; while (true) { tokenPos = pos; if (pos >= len) { @@ -1924,9 +1967,6 @@ var ts; } pos++; } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } @@ -1952,13 +1992,11 @@ var ts; if (!commentClosed) { error(ts.Diagnostics.Asterisk_Slash_expected); } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } else { + tokenIsUnterminated = !commentClosed; return token = 3 /* MultiLineCommentTrivia */; } } @@ -1977,6 +2015,26 @@ var ts; tokenValue = "" + value; return token = 6 /* NumericLiteral */; } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 6 /* NumericLiteral */; + } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 6 /* NumericLiteral */; + } if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); return token = 6 /* NumericLiteral */; @@ -2106,11 +2164,13 @@ var ts; var inCharacterClass = false; while (true) { if (p >= len) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -2146,7 +2206,7 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } - function tryScan(callback) { + function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; var saveTokenPos = tokenPos; @@ -2154,7 +2214,7 @@ var ts; var saveTokenValue = tokenValue; var savePrecedingLineBreak = precedingLineBreak; var result = callback(); - if (!result) { + if (!result || isLookahead) { pos = savePos; startPos = saveStartPos; tokenPos = saveTokenPos; @@ -2164,6 +2224,12 @@ var ts; } return result; } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } function setText(newText) { text = newText || ""; len = text.length; @@ -2187,34 +2253,87 @@ var ts; hasPrecedingLineBreak: function () { return precedingLineBreak; }, isIdentifier: function () { return token === 63 /* Identifier */ || token > 99 /* LastReservedWord */; }, isReservedWord: function () { return token >= 64 /* FirstReservedWord */ && token <= 99 /* LastReservedWord */; }, + isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, scan: scan, setText: setText, setTextPos: setTextPos, - tryScan: tryScan + tryScan: tryScan, + lookAhead: lookAhead }; } ts.createScanner = createScanner; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(200 /* Count */); - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + 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.getNodeConstructor = getNodeConstructor; - function createRootNode(kind, pos, end, flags) { - var node = new (getNodeConstructor(kind))(); - node.pos = pos; - node.end = end; - node.flags = flags; - return node; + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length == 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str += " "; }, + increaseIndent: function () { + }, + decreaseIndent: function () { + }, + clear: function () { return str = ""; }, + trackSymbol: function () { + } + }; + } + return stringWriters.pop(); } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + ts.hasFlag = hasFlag; + function containsParseError(node) { + if (!hasFlag(node.parserContextFlags, 32 /* HasPropagatedChildContainsErrorFlag */)) { + var val = hasFlag(node.parserContextFlags, 16 /* ContainsError */) || ts.forEachChild(node, containsParseError); + if (val) { + node.parserContextFlags |= 16 /* ContainsError */; + } + node.parserContextFlags |= 32 /* HasPropagatedChildContainsErrorFlag */; + } + return hasFlag(node.parserContextFlags, 16 /* ContainsError */); + } + ts.containsParseError = containsParseError; function getSourceFileOfNode(node) { - while (node && node.kind !== 197 /* SourceFile */) + while (node && node.kind !== 201 /* SourceFile */) { node = node.parent; + } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; @@ -2228,19 +2347,29 @@ var ts; return node.pos; } ts.getStartPosOfNode = getStartPosOfNode; + function isMissingNode(node) { + return node.pos === node.end && node.kind !== 1 /* EndOfFileToken */; + } + ts.isMissingNode = isMissingNode; function getTokenPosOfNode(node, sourceFile) { - if (node.pos === node.end) { + if (isMissingNode(node)) { return node.pos; } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + if (isMissingNode(node)) { + return ""; + } var text = sourceFile.text; return text.substring(ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { + if (isMissingNode(node)) { + return ""; + } return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; @@ -2257,13 +2386,13 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function declarationNameToString(name) { - return name.kind === 120 /* Missing */ ? "(Missing)" : getTextOfNode(name); + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); - var start = node.kind === 120 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); + var start = getTokenPosOfNode(node, file); var length = node.end - start; return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); } @@ -2279,12 +2408,12 @@ var ts; function getErrorSpanForNode(node) { var errorSpan; switch (node.kind) { - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: + case 183 /* VariableDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 189 /* ModuleDeclaration */: + case 188 /* EnumDeclaration */: + case 200 /* EnumMember */: errorSpan = node.name; break; } @@ -2300,7 +2429,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 191 /* EnumDeclaration */ && isConst(node); + return node.kind === 188 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -2312,16 +2441,9 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 165 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; + return node.kind === 166 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 63 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); - } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(isPrologueDirective(node)); - return node.expression.text === "use strict"; - } function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); if (node.kind === 123 /* Parameter */ || node.kind === 122 /* TypeParameter */) { @@ -2333,184 +2455,35 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); + return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; } } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - function forEachChild(node, cbNode, cbNodes) { - function child(node) { - if (node) - return cbNode(node); - } - function children(nodes) { - if (nodes) { - if (cbNodes) - return cbNodes(nodes); - var result; - for (var i = 0, len = nodes.length; i < len; i++) { - if (result = cbNode(nodes[i])) - break; - } - return result; - } - } - if (!node) - return; - switch (node.kind) { - case 121 /* QualifiedName */: - return child(node.left) || child(node.right); - case 122 /* TypeParameter */: - return child(node.name) || child(node.constraint); - case 123 /* Parameter */: - return child(node.name) || child(node.type) || child(node.initializer); - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - return child(node.name) || child(node.type) || child(node.initializer); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - return children(node.typeParameters) || children(node.parameters) || child(node.type); - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); - case 132 /* TypeReference */: - return child(node.typeName) || children(node.typeArguments); - case 135 /* TypeQuery */: - return child(node.exprName); - case 136 /* TypeLiteral */: - return children(node.members); - case 137 /* ArrayType */: - return child(node.elementType); - case 138 /* TupleType */: - return children(node.elementTypes); - case 139 /* UnionType */: - return children(node.types); - case 140 /* ParenType */: - return child(node.type); - case 141 /* ArrayLiteral */: - return children(node.elements); - case 142 /* ObjectLiteral */: - return children(node.properties); - case 145 /* PropertyAccess */: - return child(node.left) || child(node.right); - case 146 /* IndexedAccess */: - return child(node.object) || child(node.index); - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return child(node.func) || children(node.typeArguments) || children(node.arguments); - case 149 /* TaggedTemplateExpression */: - return child(node.tag) || child(node.template); - case 150 /* TypeAssertion */: - return child(node.type) || child(node.operand); - case 151 /* ParenExpression */: - return child(node.expression); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return child(node.operand); - case 156 /* BinaryExpression */: - return child(node.left) || child(node.right); - case 157 /* ConditionalExpression */: - return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 197 /* SourceFile */: - return children(node.statements); - case 163 /* VariableStatement */: - return children(node.declarations); - case 165 /* ExpressionStatement */: - return child(node.expression); - case 166 /* IfStatement */: - return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); - case 167 /* DoStatement */: - return child(node.statement) || child(node.expression); - case 168 /* WhileStatement */: - return child(node.expression) || child(node.statement); - case 169 /* ForStatement */: - return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); - case 170 /* ForInStatement */: - return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - return child(node.label); - case 173 /* ReturnStatement */: - return child(node.expression); - case 174 /* WithStatement */: - return child(node.expression) || child(node.statement); - case 175 /* SwitchStatement */: - return child(node.expression) || children(node.clauses); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - return child(node.expression) || children(node.statements); - case 178 /* LabeledStatement */: - return child(node.label) || child(node.statement); - case 179 /* ThrowStatement */: - return child(node.expression); - case 180 /* TryStatement */: - return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock); - case 182 /* CatchBlock */: - return child(node.variable) || children(node.statements); - case 185 /* VariableDeclaration */: - return child(node.name) || child(node.type) || child(node.initializer); - case 188 /* ClassDeclaration */: - return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members); - case 189 /* InterfaceDeclaration */: - return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members); - case 190 /* TypeAliasDeclaration */: - return child(node.name) || child(node.type); - case 191 /* EnumDeclaration */: - return child(node.name) || children(node.members); - case 196 /* EnumMember */: - return child(node.name) || child(node.initializer); - case 192 /* ModuleDeclaration */: - return child(node.name) || child(node.body); - case 194 /* ImportDeclaration */: - return child(node.name) || child(node.entityName) || child(node.externalModuleName); - case 195 /* ExportAssignment */: - return child(node.exportName); - case 158 /* TemplateExpression */: - return child(node.head) || children(node.templateSpans); - case 159 /* TemplateSpan */: - return child(node.expression) || child(node.literal); - } - } - ts.forEachChild = forEachChild; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* ReturnStatement */: + case 174 /* ReturnStatement */: return visitor(node); - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - return forEachChild(node, traverse); + case 163 /* Block */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: + case 177 /* LabeledStatement */: + case 179 /* TryStatement */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: + return ts.forEachChild(node, traverse); } } } @@ -2518,9 +2491,9 @@ var ts; function isAnyFunction(node) { if (node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: @@ -2531,6 +2504,14 @@ var ts; return false; } ts.isAnyFunction = isAnyFunction; + function isFunctionBlock(node) { + return node !== undefined && node.kind === 163 /* Block */ && isAnyFunction(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node !== undefined && node.kind === 125 /* Method */ && node.parent.kind === 142 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { while (true) { node = node.parent; @@ -2547,20 +2528,20 @@ var ts; return undefined; } switch (node.kind) { - case 153 /* ArrowFunction */: + case 151 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 192 /* ModuleDeclaration */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 189 /* ModuleDeclaration */: case 124 /* Property */: case 125 /* Method */: case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 191 /* EnumDeclaration */: - case 197 /* SourceFile */: + case 188 /* EnumDeclaration */: + case 201 /* SourceFile */: return node; } } @@ -2584,10 +2565,10 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { return node.tag; } - return node.func; + return node.expression; } ts.getInvokedExpression = getInvokedExpression; function isExpression(node) { @@ -2598,28 +2579,32 @@ var ts; case 93 /* TrueKeyword */: case 78 /* FalseKeyword */: case 8 /* RegularExpressionLiteral */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 158 /* TemplateExpression */: + case 141 /* ArrayLiteralExpression */: + case 142 /* ObjectLiteralExpression */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + case 147 /* TaggedTemplateExpression */: + case 148 /* TypeAssertionExpression */: + case 149 /* ParenthesizedExpression */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + case 154 /* VoidExpression */: + case 152 /* DeleteExpression */: + case 153 /* TypeOfExpression */: + case 155 /* PrefixUnaryExpression */: + case 156 /* PostfixUnaryExpression */: + case 157 /* BinaryExpression */: + case 158 /* ConditionalExpression */: + case 159 /* TemplateExpression */: case 9 /* NoSubstitutionTemplateLiteral */: case 161 /* OmittedExpression */: return true; - case 121 /* QualifiedName */: - while (node.parent.kind === 121 /* QualifiedName */) + case 120 /* QualifiedName */: + while (node.parent.kind === 120 /* QualifiedName */) { node = node.parent; + } return node.parent.kind === 135 /* TypeQuery */; case 63 /* Identifier */: if (node.parent.kind === 135 /* TypeQuery */) { @@ -2629,30 +2614,30 @@ var ts; case 7 /* StringLiteral */: var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 123 /* Parameter */: case 124 /* Property */: - case 196 /* EnumMember */: - case 143 /* PropertyAssignment */: + case 200 /* EnumMember */: + case 198 /* PropertyAssignment */: return parent.initializer === node; - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 179 /* ThrowStatement */: - case 175 /* SwitchStatement */: + case 166 /* ExpressionStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 174 /* ReturnStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 178 /* ThrowStatement */: + case 176 /* SwitchStatement */: return parent.expression === node; - case 169 /* ForStatement */: + case 170 /* ForStatement */: return parent.initializer === node || parent.condition === node || parent.iterator === node; - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return parent.variable === node || parent.expression === node; - case 150 /* TypeAssertion */: - return node === parent.operand; - case 159 /* TemplateSpan */: + case 148 /* TypeAssertionExpression */: + return node === parent.expression; + case 162 /* TemplateSpan */: return node === parent.expression; default: if (isExpression(parent)) { @@ -2663,8 +2648,41 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleImportDeclaration(node) { + return node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind === 193 /* ExternalModuleReference */; + } + ts.isExternalModuleImportDeclaration = isExternalModuleImportDeclaration; + function getExternalModuleImportDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportDeclarationExpression = getExternalModuleImportDeclarationExpression; + function isInternalModuleImportDeclaration(node) { + return node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind !== 193 /* ExternalModuleReference */; + } + ts.isInternalModuleImportDeclaration = isInternalModuleImportDeclaration; + function hasDotDotDotToken(node) { + return node && node.kind === 123 /* Parameter */ && node.dotDotDotToken !== undefined; + } + ts.hasDotDotDotToken = hasDotDotDotToken; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 123 /* Parameter */: + return node.questionToken !== undefined; + case 125 /* Method */: + return node.questionToken !== undefined; + case 199 /* ShorthandPropertyAssignment */: + case 198 /* PropertyAssignment */: + case 124 /* Property */: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & 8 /* Rest */) !== 0; + return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { @@ -2692,22 +2710,22 @@ var ts; switch (node.kind) { case 122 /* TypeParameter */: case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: + case 200 /* EnumMember */: case 125 /* Method */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: case 126 /* Constructor */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 188 /* EnumDeclaration */: + case 189 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: return true; } return false; @@ -2715,24 +2733,24 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 184 /* DebuggerStatement */: - case 167 /* DoStatement */: - case 165 /* ExpressionStatement */: - case 164 /* EmptyStatement */: - case 170 /* ForInStatement */: - case 169 /* ForStatement */: - case 166 /* IfStatement */: - case 178 /* LabeledStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: + case 173 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 182 /* DebuggerStatement */: + case 168 /* DoStatement */: + case 166 /* ExpressionStatement */: + case 165 /* EmptyStatement */: + case 171 /* ForInStatement */: + case 170 /* ForStatement */: + case 167 /* IfStatement */: + case 177 /* LabeledStatement */: + case 174 /* ReturnStatement */: + case 176 /* SwitchStatement */: case 92 /* ThrowKeyword */: - case 180 /* TryStatement */: - case 163 /* VariableStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 195 /* ExportAssignment */: + case 179 /* TryStatement */: + case 164 /* VariableStatement */: + case 169 /* WhileStatement */: + case 175 /* WithStatement */: + case 192 /* ExportAssignment */: return true; default: return false; @@ -2744,15 +2762,41 @@ var ts; return false; } var parent = name.parent; - if (isDeclaration(parent) || parent.kind === 152 /* FunctionExpression */) { + if (isDeclaration(parent) || parent.kind === 150 /* FunctionExpression */) { return parent.name === name; } - if (parent.kind === 182 /* CatchBlock */) { - return parent.variable === name; + if (parent.kind === 197 /* CatchClause */) { + return parent.name === name; } return false; } ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName; + function getClassBaseTypeNode(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 77 /* ExtendsKeyword */); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassBaseTypeNode = getClassBaseTypeNode; + function getClassImplementedTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 100 /* ImplementsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 77 /* ExtendsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var i = 0, n = clauses.length; i < n; i++) { + if (clauses[i].token === kind) { + return clauses[i]; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; function tryResolveScriptReference(program, sourceFile, reference) { if (!program.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.filename) ? reference.filename : ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename); @@ -2763,16 +2807,16 @@ var ts; ts.tryResolveScriptReference = tryResolveScriptReference; function getAncestor(node, kind) { switch (kind) { - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: while (node) { switch (node.kind) { - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return node; - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 188 /* EnumDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 189 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: return undefined; default: node = node.parent; @@ -2792,28 +2836,6 @@ var ts; return undefined; } ts.getAncestor = getAncestor; - function parsingContextErrors(context) { - switch (context) { - case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* BaseTypeReferences */: return ts.Diagnostics.Type_reference_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - } - } - ; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; @@ -2839,7 +2861,7 @@ var ts; } else { return { - diagnostic: ts.Diagnostics.Invalid_reference_directive_syntax, + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, isNoDefaultLib: false }; } @@ -2856,18 +2878,6 @@ var ts; return 2 /* FirstTriviaToken */ <= token && token <= 5 /* LastTriviaToken */; } ts.isTrivia = isTrivia; - function isUnterminatedTemplateEnd(node) { - ts.Debug.assert(isTemplateLiteralKind(node.kind)); - var sourceText = getSourceFileOfNode(node).text; - if (node.end !== sourceText.length) { - return false; - } - if (node.kind !== 12 /* TemplateTail */ && node.kind !== 9 /* NoSubstitutionTemplateLiteral */) { - return false; - } - return sourceText.charCodeAt(node.end - 1) !== 96 /* backtick */ || node.text.length === 0; - } - ts.isUnterminatedTemplateEnd = isUnterminatedTemplateEnd; function isModifier(token) { switch (token) { case 106 /* PublicKeyword */: @@ -2876,11 +2886,274 @@ var ts; case 107 /* StaticKeyword */: case 76 /* ExportKeyword */: case 112 /* DeclareKeyword */: + case 68 /* ConstKeyword */: return true; } return false; } ts.isModifier = isModifier; +})(ts || (ts = {})); +var ts; +(function (ts) { + var nodeConstructors = new Array(204 /* Count */); + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createRootNode(kind, pos, end, flags) { + var node = new (getNodeConstructor(kind))(); + node.pos = pos; + node.end = end; + node.flags = flags; + return node; + } + function forEachChild(node, cbNode, cbNodes) { + function child(node) { + if (node) { + return cbNode(node); + } + } + function children(nodes) { + if (nodes) { + if (cbNodes) { + return cbNodes(nodes); + } + for (var i = 0, len = nodes.length; i < len; i++) { + var result = cbNode(nodes[i]); + if (result) { + return result; + } + } + return undefined; + } + } + if (!node) { + return; + } + switch (node.kind) { + case 120 /* QualifiedName */: + return child(node.left) || child(node.right); + case 122 /* TypeParameter */: + return child(node.name) || child(node.constraint); + case 123 /* Parameter */: + return children(node.modifiers) || child(node.dotDotDotToken) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + case 124 /* Property */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: + return children(node.modifiers) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + case 133 /* FunctionType */: + case 134 /* ConstructorType */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: + return children(node.modifiers) || children(node.typeParameters) || children(node.parameters) || child(node.type); + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: + return children(node.modifiers) || child(node.name) || child(node.questionToken) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); + case 132 /* TypeReference */: + return child(node.typeName) || children(node.typeArguments); + case 135 /* TypeQuery */: + return child(node.exprName); + case 136 /* TypeLiteral */: + return children(node.members); + case 137 /* ArrayType */: + return child(node.elementType); + case 138 /* TupleType */: + return children(node.elementTypes); + case 139 /* UnionType */: + return children(node.types); + case 140 /* ParenthesizedType */: + return child(node.type); + case 141 /* ArrayLiteralExpression */: + return children(node.elements); + case 142 /* ObjectLiteralExpression */: + return children(node.properties); + case 143 /* PropertyAccessExpression */: + return child(node.expression) || child(node.name); + case 144 /* ElementAccessExpression */: + return child(node.expression) || child(node.argumentExpression); + case 145 /* CallExpression */: + case 146 /* NewExpression */: + return child(node.expression) || children(node.typeArguments) || children(node.arguments); + case 147 /* TaggedTemplateExpression */: + return child(node.tag) || child(node.template); + case 148 /* TypeAssertionExpression */: + return child(node.type) || child(node.expression); + case 149 /* ParenthesizedExpression */: + return child(node.expression); + case 152 /* DeleteExpression */: + return child(node.expression); + case 153 /* TypeOfExpression */: + return child(node.expression); + case 154 /* VoidExpression */: + return child(node.expression); + case 155 /* PrefixUnaryExpression */: + return child(node.operand); + case 156 /* PostfixUnaryExpression */: + return child(node.operand); + case 157 /* BinaryExpression */: + return child(node.left) || child(node.right); + case 158 /* ConditionalExpression */: + return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); + case 163 /* Block */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: + return children(node.statements); + case 201 /* SourceFile */: + return children(node.statements) || child(node.endOfFileToken); + case 164 /* VariableStatement */: + return children(node.modifiers) || children(node.declarations); + case 166 /* ExpressionStatement */: + return child(node.expression); + case 167 /* IfStatement */: + return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); + case 168 /* DoStatement */: + return child(node.statement) || child(node.expression); + case 169 /* WhileStatement */: + return child(node.expression) || child(node.statement); + case 170 /* ForStatement */: + return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); + case 171 /* ForInStatement */: + return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: + return child(node.label); + case 174 /* ReturnStatement */: + return child(node.expression); + case 175 /* WithStatement */: + return child(node.expression) || child(node.statement); + case 176 /* SwitchStatement */: + return child(node.expression) || children(node.clauses); + case 194 /* CaseClause */: + return child(node.expression) || children(node.statements); + case 195 /* DefaultClause */: + return children(node.statements); + case 177 /* LabeledStatement */: + return child(node.label) || child(node.statement); + case 178 /* ThrowStatement */: + return child(node.expression); + case 179 /* TryStatement */: + return child(node.tryBlock) || child(node.catchClause) || child(node.finallyBlock); + case 197 /* CatchClause */: + return child(node.name) || child(node.type) || child(node.block); + case 183 /* VariableDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.type) || child(node.initializer); + case 185 /* ClassDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 186 /* InterfaceDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 187 /* TypeAliasDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.type); + case 188 /* EnumDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.members); + case 200 /* EnumMember */: + return child(node.name) || child(node.initializer); + case 189 /* ModuleDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.body); + case 191 /* ImportDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.moduleReference); + case 192 /* ExportAssignment */: + return children(node.modifiers) || child(node.exportName); + case 159 /* TemplateExpression */: + return child(node.head) || children(node.templateSpans); + case 162 /* TemplateSpan */: + return child(node.expression) || child(node.literal); + case 121 /* ComputedPropertyName */: + return child(node.expression); + case 196 /* HeritageClause */: + return children(node.types); + case 193 /* ExternalModuleReference */: + return child(node.expression); + } + } + ts.forEachChild = forEachChild; + function createCompilerHost(options) { + var currentDirectory; + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(filename, languageVersion, onError) { + try { + var text = ts.sys.readFile(filename, options.charset); + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText : e.message); + } + text = ""; + } + return text !== undefined ? createSourceFile(filename, text, languageVersion, "0") : undefined; + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + try { + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + return { + getSourceFile: getSourceFile, + getDefaultLibFilename: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"); }, + writeFile: writeFile, + getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return ts.sys.newLine; } + }; + } + ts.createCompilerHost = createCompilerHost; + function parsingContextErrors(context) { + switch (context) { + case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; + case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 8 /* TypeReferences */: return ts.Diagnostics.Type_reference_expected; + case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 17 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + } + } + ; function modifierToFlag(token) { switch (token) { case 107 /* StaticKeyword */: return 128 /* Static */; @@ -2889,22 +3162,28 @@ var ts; case 104 /* PrivateKeyword */: return 32 /* Private */; case 76 /* ExportKeyword */: return 1 /* Export */; case 112 /* DeclareKeyword */: return 2 /* Ambient */; + case 68 /* ConstKeyword */: return 4096 /* Const */; } return 0; } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 63 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); + } + function isUseStrictPrologueDirective(sourceFile, node) { + ts.Debug.assert(ts.isPrologueDirective(node)); + var nodeText = ts.getSourceTextOfNodeFromSourceFile(sourceFile, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; + } function createSourceFile(filename, sourceText, languageVersion, version, isOpen) { if (isOpen === void 0) { isOpen = false; } - var file; - var scanner; var token; var parsingContext; - var commentRanges; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var lineStarts; - var lookAheadMode = 0 /* NotLookingAhead */; var contextFlags = 0; + var parseErrorBeforeNextFinishedNode = false; function setContextFlag(val, flag) { if (val) { contextFlags |= flag; @@ -2982,29 +3261,21 @@ var ts; function getPositionFromSourceLineAndCharacter(line, character) { return ts.getPositionFromLineAndCharacter(getLineStarts(), line, character); } - function error(message, arg0, arg1, arg2) { + function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var length = scanner.getTextPos() - start; - errorAtPos(start, length, message, arg0, arg1, arg2); + parseErrorAtPosition(start, length, message, arg0); } - function errorAtPos(start, length, message, arg0, arg1, arg2) { - var lastErrorPos = file.parseDiagnostics.length ? file.parseDiagnostics[file.parseDiagnostics.length - 1].start : -1; - if (start !== lastErrorPos) { - var diagnostic = ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); - diagnostic.isParseError = true; - file.parseDiagnostics.push(diagnostic); - } - if (lookAheadMode === 1 /* NoErrorYet */) { - lookAheadMode = 2 /* Error */; + function parseErrorAtPosition(start, length, message, arg0) { + var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); + if (!lastError || start !== lastError.start) { + sourceFile.parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); } + parseErrorBeforeNextFinishedNode = true; } function scanError(message) { var pos = scanner.getTextPos(); - errorAtPos(pos, 0, message); - } - function onComment(pos, end) { - if (commentRanges) - commentRanges.push({ pos: pos, end: end }); + parseErrorAtPosition(pos, 0, message); } function getNodePos() { return scanner.getStartPos(); @@ -3027,33 +3298,25 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } - function lookAheadHelper(callback, alwaysResetState) { + function speculationHelper(callback, isLookAhead) { var saveToken = token; - var saveSyntacticErrorsLength = file.parseDiagnostics.length; - var saveLookAheadMode = lookAheadMode; - lookAheadMode = 1 /* NoErrorYet */; - var result = callback(); - ts.Debug.assert(lookAheadMode === 2 /* Error */ || lookAheadMode === 1 /* NoErrorYet */); - if (lookAheadMode === 2 /* Error */) { - result = undefined; - } - lookAheadMode = saveLookAheadMode; - if (!result || alwaysResetState) { + var saveParseDiagnosticsLength = sourceFile.parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + var saveContextFlags = contextFlags; + var result = isLookAhead ? scanner.lookAhead(callback) : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + if (!result || isLookAhead) { token = saveToken; - file.parseDiagnostics.length = saveSyntacticErrorsLength; + sourceFile.parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; } return result; } function lookAhead(callback) { - var result; - scanner.tryScan(function () { - result = lookAheadHelper(callback, true); - return false; - }); - return result; + return speculationHelper(callback, true); } function tryParse(callback) { - return scanner.tryScan(function () { return lookAheadHelper(callback, false); }); + return speculationHelper(callback, false); } function isIdentifier() { if (token === 63 /* Identifier */) { @@ -3064,12 +3327,17 @@ var ts; } return inStrictModeContext() ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */; } - function parseExpected(t) { - if (token === t) { + function parseExpected(kind, diagnosticMessage, arg0) { + if (token === kind) { nextToken(); return true; } - error(ts.Diagnostics._0_expected, ts.tokenToString(t)); + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } return false; } function parseOptional(t) { @@ -3093,14 +3361,15 @@ var ts; } return token === 14 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } - function parseSemicolon() { + function parseSemicolon(diagnosticMessage) { if (canParseSemicolon()) { if (token === 21 /* SemicolonToken */) { nextToken(); } + return true; } else { - error(ts.Diagnostics._0_expected, ";"); + return parseExpected(21 /* SemicolonToken */, diagnosticMessage); } } function createNode(kind, pos) { @@ -3118,16 +3387,28 @@ var ts; if (contextFlags) { node.parserContextFlags = contextFlags; } + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16 /* ContainsError */; + } return node; } - function createMissingNode(pos) { - return createNode(120 /* Missing */, pos); + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); } function internIdentifier(text) { - text = escapeIdentifier(text); + text = ts.escapeIdentifier(text); return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); } - function createIdentifier(isIdentifier) { + function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { var node = createNode(63 /* Identifier */); @@ -3135,37 +3416,59 @@ var ts; nextToken(); return finishNode(node); } - error(ts.Diagnostics.Identifier_expected); - var node = createMissingNode(); - node.text = ""; - return node; + return createMissingNode(63 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } - function parseIdentifier() { - return createIdentifier(isIdentifier()); + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(token >= 63 /* Identifier */); + return createIdentifier(isIdentifierOrKeyword()); } - function isPropertyName() { - return token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; + function isLiteralPropertyName() { + return isIdentifierOrKeyword() || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; } function parsePropertyName() { if (token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { return parseLiteralNode(true); } + if (token === 17 /* OpenBracketToken */) { + return parseComputedPropertyName(); + } return parseIdentifierName(); } + function parseComputedPropertyName() { + var node = createNode(121 /* ComputedPropertyName */); + parseExpected(17 /* OpenBracketToken */); + var yieldContext = inYieldContext(); + if (inGeneratorParameterContext()) { + setYieldContext(false); + } + node.expression = allowInAnd(parseExpression); + if (inGeneratorParameterContext()) { + setYieldContext(yieldContext); + } + parseExpected(18 /* CloseBracketToken */); + return finishNode(node); + } function parseContextualModifier(t) { - return token === t && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || isPropertyName(); - }); + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + nextToken(); + return canFollowModifier(); } function parseAnyContextualModifier() { - return isModifier(token) && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isPropertyName(); - }); + return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); + } + function nextTokenCanFollowContextualModifier() { + if (token === 68 /* ConstKeyword */) { + return nextToken() === 75 /* EnumKeyword */; + } + nextToken(); + return canFollowModifier(); + } + function canFollowModifier() { + return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isLiteralPropertyName(); } function isListElement(kind, inErrorRecovery) { switch (kind) { @@ -3182,11 +3485,11 @@ var ts; case 6 /* ClassMembers */: return lookAhead(isClassMemberStart); case 7 /* EnumMembers */: - return isPropertyName(); + return token === 17 /* OpenBracketToken */ || isLiteralPropertyName(); case 11 /* ObjectLiteralMembers */: - return token === 34 /* AsteriskToken */ || isPropertyName(); - case 8 /* BaseTypeReferences */: - return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); + return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isLiteralPropertyName(); + case 8 /* TypeReferences */: + return isIdentifier() && !isNotHeritageClauseTypeName(); case 9 /* VariableDeclarations */: case 14 /* TypeParameters */: return isIdentifier(); @@ -3199,9 +3502,21 @@ var ts; case 15 /* TypeArguments */: case 16 /* TupleElementTypes */: return token === 22 /* CommaToken */ || isStartOfType(); + case 17 /* HeritageClauses */: + return isHeritageClause(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function isNotHeritageClauseTypeName() { + if (token === 100 /* ImplementsKeyword */ || token === 77 /* ExtendsKeyword */) { + return lookAhead(nextTokenIsIdentifier); + } + return false; + } function isListTerminator(kind) { if (token === 1 /* EndOfFileToken */) { return true; @@ -3217,7 +3532,7 @@ var ts; return token === 14 /* CloseBraceToken */; case 4 /* SwitchClauseStatements */: return token === 14 /* CloseBraceToken */ || token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; - case 8 /* BaseTypeReferences */: + case 8 /* TypeReferences */: return token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; case 9 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); @@ -3232,6 +3547,8 @@ var ts; return token === 16 /* CloseParenToken */ || token === 18 /* CloseBracketToken */ || token === 13 /* OpenBraceToken */; case 15 /* TypeArguments */: return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */; + case 17 /* HeritageClauses */: + return token === 13 /* OpenBraceToken */ || token === 14 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -3247,7 +3564,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 17 /* Count */; kind++) { + for (var kind = 0; kind < 18 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -3266,9 +3583,9 @@ var ts; if (isListElement(kind, false)) { var element = parseElement(); result.push(element); - if (!inStrictModeContext() && checkForStrictMode) { - if (isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { + if (checkForStrictMode && !inStrictModeContext()) { + if (ts.isPrologueDirective(element)) { + if (isUseStrictPrologueDirective(sourceFile, element)) { setStrictModeContext(true); checkForStrictMode = false; } @@ -3277,13 +3594,10 @@ var ts; checkForStrictMode = false; } } + continue; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } setStrictModeContext(savedStrictModeContext); @@ -3291,6 +3605,14 @@ var ts; parsingContext = saveParsingContext; return result; } + function abortParsingListOrMoveToNextToken(kind) { + parseErrorAtCurrentToken(parsingContextErrors(kind)); + if (isInSomeParsingContext()) { + return true; + } + nextToken(); + return false; + } function parseDelimitedList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; @@ -3308,17 +3630,14 @@ var ts; if (isListTerminator(kind)) { break; } - error(ts.Diagnostics._0_expected, ","); + parseExpected(22 /* CommaToken */); + continue; } - else if (isListTerminator(kind)) { + if (isListTerminator(kind)) { break; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } if (commaStart >= 0) { @@ -3343,23 +3662,32 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords) { - var entity = parseIdentifier(); + function parseEntityName(allowReservedWords, diagnosticMessage) { + var entity = parseIdentifier(diagnosticMessage); while (parseOptional(19 /* DotToken */)) { - var node = createNode(121 /* QualifiedName */, entity.pos); + var node = createNode(120 /* QualifiedName */, entity.pos); node.left = entity; - node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); + node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); } return entity; } + function parseRightSideOfDot(allowIdentifierNames) { + if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + return createMissingNode(63 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } function parseTokenNode() { var node = createNode(token); nextToken(); return finishNode(node); } function parseTemplateExpression() { - var template = createNode(158 /* TemplateExpression */); + var template = createNode(159 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 10 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -3372,7 +3700,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(159 /* TemplateSpan */); + var span = createNode(162 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 14 /* CloseBraceToken */) { @@ -3380,9 +3708,7 @@ var ts; literal = parseLiteralNode(); } else { - error(ts.Diagnostics.Invalid_template_literal_expected); - literal = createMissingNode(); - literal.text = ""; + literal = createMissingNode(12 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(14 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -3391,6 +3717,9 @@ var ts; var node = createNode(token); var text = scanner.getTokenValue(); node.text = internName ? internIdentifier(text) : text; + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); @@ -3399,18 +3728,11 @@ var ts; } return node; } - function parseStringLiteral() { - if (token === 7 /* StringLiteral */) { - return parseLiteralNode(true); - } - error(ts.Diagnostics.String_literal_expected); - return createMissingNode(); - } function parseTypeReference() { var node = createNode(132 /* TypeReference */); - node.typeName = parseEntityName(false); + node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 23 /* LessThanToken */) { - node.typeArguments = parseTypeArguments(); + node.typeArguments = parseBracketedList(15 /* TypeArguments */, parseType, 23 /* LessThanToken */, 24 /* GreaterThanToken */); } return finishNode(node); } @@ -3428,7 +3750,7 @@ var ts; node.constraint = parseType(); } else { - node.expression = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); } } return finishNode(node); @@ -3439,10 +3761,13 @@ var ts; } } function parseParameterType() { - return parseOptional(50 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; + if (parseOptional(50 /* ColonToken */)) { + return token === 7 /* StringLiteral */ ? parseLiteralNode(true) : parseType(); + } + return undefined; } function isStartOfParameter() { - return token === 20 /* DotDotDotToken */ || isIdentifier() || isModifier(token); + return token === 20 /* DotDotDotToken */ || isIdentifier() || ts.isModifier(token); } function setModifiers(node, modifiers) { if (modifiers) { @@ -3452,18 +3777,13 @@ var ts; } function parseParameter() { var node = createNode(123 /* Parameter */); - var modifiers = parseModifiers(); - setModifiers(node, modifiers); - if (parseOptional(20 /* DotDotDotToken */)) { - node.flags |= 8 /* Rest */; - } + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(20 /* DotDotDotToken */); node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifier) : parseIdentifier(); - if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) { + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - if (parseOptional(49 /* QuestionToken */)) { - node.flags |= 4 /* QuestionMark */; - } + node.questionToken = parseOptionalToken(49 /* QuestionToken */); node.type = parseParameterType(); node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); return finishNode(node); @@ -3471,17 +3791,10 @@ var ts; function parseParameterInitializer() { return parseInitializer(true); } - function parseSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext) { - var signature = {}; - fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature); - return signature; - } - function fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature) { - if (kind === 130 /* ConstructSignature */) { - parseExpected(86 /* NewKeyword */); - } + function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 31 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext); + signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -3490,55 +3803,95 @@ var ts; signature.type = parseType(); } } - function parseParameterList(yieldAndGeneratorParameterContext) { + function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { if (parseExpected(15 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); var result = parseDelimitedList(13 /* Parameters */, parseParameter); - parseExpected(16 /* CloseParenToken */); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); + if (!parseExpected(16 /* CloseParenToken */) && requireCompleteParameterList) { + return undefined; + } return result; } - return createMissingList(); + return requireCompleteParameterList ? undefined : createMissingList(); } - function parseSignatureMember(kind, returnToken) { + function parseTypeMemberSemicolon() { + if (parseSemicolon()) { + return; + } + parseOptional(22 /* CommaToken */); + } + function parseSignatureMember(kind) { var node = createNode(kind); - fillSignature(kind, returnToken, false, false, node); - parseSemicolon(); + if (kind === 130 /* ConstructSignature */) { + parseExpected(86 /* NewKeyword */); + } + fillSignature(50 /* ColonToken */, false, false, node); + parseTypeMemberSemicolon(); return finishNode(node); } - function parseIndexSignatureMember(fullStart, modifiers) { + function isIndexSignature() { + if (token !== 17 /* OpenBracketToken */) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + nextToken(); + if (token === 20 /* DotDotDotToken */ || token === 18 /* CloseBracketToken */) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + nextToken(); + } + if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */) { + return true; + } + if (token !== 49 /* QuestionToken */) { + return false; + } + nextToken(); + return token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 18 /* CloseBracketToken */; + } + function parseIndexSignatureDeclaration(fullStart, modifiers) { var node = createNode(131 /* IndexSignature */, fullStart); setModifiers(node, modifiers); node.parameters = parseBracketedList(13 /* Parameters */, parseParameter, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); node.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethod() { + function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var flags = 0; - if (parseOptional(49 /* QuestionToken */)) { - flags = 4 /* QuestionMark */; - } + var questionToken = parseOptionalToken(49 /* QuestionToken */); if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { var method = createNode(125 /* Method */, fullStart); method.name = name; - method.flags = flags; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, method); - parseSemicolon(); + method.questionToken = questionToken; + fillSignature(50 /* ColonToken */, false, false, method); + parseTypeMemberSemicolon(); return finishNode(method); } else { var property = createNode(124 /* Property */, fullStart); property.name = name; - property.flags = flags; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(property); } } @@ -3549,35 +3902,43 @@ var ts; case 17 /* OpenBracketToken */: return true; default: - return isPropertyName() && lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); }); + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); } } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); + } function parseTypeMember() { switch (token) { case 15 /* OpenParenToken */: case 23 /* LessThanToken */: - return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */); + return parseSignatureMember(129 /* CallSignature */); case 17 /* OpenBracketToken */: - return parseIndexSignatureMember(scanner.getStartPos(), undefined); + return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined) : parsePropertyOrMethodSignature(); case 86 /* NewKeyword */: - if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) { - return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */); + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(130 /* ConstructSignature */); } case 7 /* StringLiteral */: case 6 /* NumericLiteral */: - return parsePropertyOrMethod(); + return parsePropertyOrMethodSignature(); default: - if (token >= 63 /* Identifier */) { - return parsePropertyOrMethod(); + if (isIdentifierOrKeyword()) { + return parsePropertyOrMethodSignature(); } } } + function isStartOfConstructSignature() { + nextToken(); + return token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; + } function parseTypeLiteral() { var node = createNode(136 /* TypeLiteral */); - node.members = parseObjectType(); + node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseObjectType() { + function parseObjectTypeMembers() { var members; if (parseExpected(13 /* OpenBraceToken */)) { members = parseList(5 /* TypeMembers */, false, parseTypeMember); @@ -3593,16 +3954,19 @@ var ts; node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); return finishNode(node); } - function parseParenType() { - var node = createNode(140 /* ParenType */); + function parseParenthesizedType() { + var node = createNode(140 /* ParenthesizedType */); parseExpected(15 /* OpenParenToken */); node.type = parseType(); parseExpected(16 /* CloseParenToken */); return finishNode(node); } - function parseFunctionType(typeKind) { - var node = createNode(typeKind); - fillSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true, false, node); + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 134 /* ConstructorType */) { + parseExpected(86 /* NewKeyword */); + } + fillSignature(31 /* EqualsGreaterThanToken */, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -3615,9 +3979,10 @@ var ts; case 118 /* StringKeyword */: case 116 /* NumberKeyword */: case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); + case 97 /* VoidKeyword */: + return parseTokenNode(); case 95 /* TypeOfKeyword */: return parseTypeQuery(); case 13 /* OpenBraceToken */: @@ -3625,14 +3990,10 @@ var ts; case 17 /* OpenBracketToken */: return parseTupleType(); case 15 /* OpenParenToken */: - return parseParenType(); + return parseParenthesizedType(); default: - if (isIdentifier()) { - return parseTypeReference(); - } + return parseTypeReference(); } - error(ts.Diagnostics.Type_expected); - return createMissingNode(); } function isStartOfType() { switch (token) { @@ -3648,15 +4009,16 @@ var ts; case 86 /* NewKeyword */: return true; case 15 /* OpenParenToken */: - return lookAhead(function () { - nextToken(); - return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); - }); + return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } } - function parsePrimaryType() { + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(17 /* OpenBracketToken */)) { parseExpected(18 /* CloseBracketToken */); @@ -3666,13 +4028,13 @@ var ts; } return type; } - function parseUnionType() { - var type = parsePrimaryType(); + function parseUnionTypeOrHigher() { + var type = parseArrayTypeOrHigher(); if (token === 43 /* BarToken */) { var types = [type]; types.pos = type.pos; while (parseOptional(43 /* BarToken */)) { - types.push(parsePrimaryType()); + types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); var node = createNode(139 /* UnionType */, type.pos); @@ -3682,25 +4044,29 @@ var ts; return type; } function isStartOfFunctionType() { - return token === 23 /* LessThanToken */ || token === 15 /* OpenParenToken */ && lookAhead(function () { + if (token === 23 /* LessThanToken */) { + return true; + } + return token === 15 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { + return true; + } + if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { + if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { return true; } - if (isIdentifier() || isModifier(token)) { + if (token === 16 /* CloseParenToken */) { nextToken(); - if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || isModifier(token)) { + if (token === 31 /* EqualsGreaterThanToken */) { return true; } - if (token === 16 /* CloseParenToken */) { - nextToken(); - if (token === 31 /* EqualsGreaterThanToken */) { - return true; - } - } } - return false; - }); + } + return false; } function parseType() { var savedYieldContext = inYieldContext(); @@ -3714,12 +4080,12 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionType(133 /* FunctionType */); + return parseFunctionOrConstructorType(133 /* FunctionType */); } if (token === 86 /* NewKeyword */) { - return parseFunctionType(134 /* ConstructorType */); + return parseFunctionOrConstructorType(134 /* ConstructorType */); } - return parseUnionType(); + return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { return parseOptional(50 /* ColonToken */) ? parseType() : undefined; @@ -3756,6 +4122,9 @@ var ts; case 108 /* YieldKeyword */: return true; default: + if (isBinaryOperator()) { + return true; + } return isIdentifier(); } } @@ -3763,9 +4132,9 @@ var ts; return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression(); } function parseExpression() { - var expr = parseAssignmentExpression(); + var expr = parseAssignmentExpressionOrHigher(); while (parseOptional(22 /* CommaToken */)) { - expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression()); + expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpressionOrHigher()); } return expr; } @@ -3776,9 +4145,9 @@ var ts; } } parseExpected(51 /* EqualsToken */); - return parseAssignmentExpression(); + return parseAssignmentExpressionOrHigher(); } - function parseAssignmentExpression() { + function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { return parseYieldExpression(); } @@ -3786,16 +4155,16 @@ var ts; if (arrowExpression) { return arrowExpression; } - var expr = parseConditionalExpression(); + var expr = parseBinaryExpressionOrHigher(0); if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } - if (isLeftHandSideExpression(expr) && isAssignmentOperator(token)) { + if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { var operator = token; nextToken(); - return makeBinaryExpression(expr, operator, parseAssignmentExpression()); + return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher()); } - return expr; + return parseConditionalExpressionRest(expr); } function isYieldExpression() { if (token === 108 /* YieldKeyword */) { @@ -3805,19 +4174,20 @@ var ts; if (inStrictModeContext()) { return true; } - return lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - }); + return lookAhead(nextTokenIsIdentifierOnSameLine); } return false; } + function nextTokenIsIdentifierOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } function parseYieldExpression() { var node = createNode(160 /* YieldExpression */); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 34 /* AsteriskToken */ || isStartOfExpression())) { node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - node.expression = parseAssignmentExpression(); + node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } else { @@ -3826,131 +4196,138 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - parseExpected(31 /* EqualsGreaterThanToken */); + var node = createNode(151 /* ArrowFunction */, identifier.pos); var parameter = createNode(123 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); - var parameters = []; - parameters.push(parameter); - parameters.pos = parameter.pos; - parameters.end = parameter.end; - var signature = { parameters: parameters }; - return parseArrowExpressionTail(identifier.pos, signature); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + parseExpected(31 /* EqualsGreaterThanToken */); + node.body = parseArrowFunctionExpressionBody(); + return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); if (triState === 0 /* False */) { return undefined; } - var pos = getNodePos(); - if (triState === 1 /* True */) { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { - return parseArrowExpressionTail(pos, sig); - } - else { - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, createMissingNode()); - } - } - var sig = tryParseSignatureIfArrowOrBraceFollows(); - if (sig) { - parseExpected(31 /* EqualsGreaterThanToken */); - return parseArrowExpressionTail(pos, sig); - } - else { + var arrowFunction = triState === 1 /* True */ ? parseParenthesizedArrowFunctionExpressionHead(true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { return undefined; } + if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { + arrowFunction.body = parseArrowFunctionExpressionBody(); + } + else { + arrowFunction.body = parseIdentifier(); + } + return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - return lookAhead(function () { - var first = token; - var second = nextToken(); - if (first === 15 /* OpenParenToken */) { - if (second === 16 /* CloseParenToken */) { - var third = nextToken(); - switch (third) { - case 31 /* EqualsGreaterThanToken */: - case 50 /* ColonToken */: - case 13 /* OpenBraceToken */: - return 1 /* True */; - default: - return 0 /* False */; - } - } - if (second === 20 /* DotDotDotToken */) { - return 1 /* True */; - } - if (!isIdentifier()) { - return 0 /* False */; - } - if (nextToken() === 50 /* ColonToken */) { - return 1 /* True */; - } - return 2 /* Unknown */; - } - else { - ts.Debug.assert(first === 23 /* LessThanToken */); - if (!isIdentifier()) { - return 0 /* False */; - } - return 2 /* Unknown */; - } - }); + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 31 /* EqualsGreaterThanToken */) { return 1 /* True */; } return 0 /* False */; } - function tryParseSignatureIfArrowOrBraceFollows() { - return tryParse(function () { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) { - return sig; + function isParenthesizedArrowFunctionExpressionWorker() { + var first = token; + var second = nextToken(); + if (first === 15 /* OpenParenToken */) { + if (second === 16 /* CloseParenToken */) { + var third = nextToken(); + switch (third) { + case 31 /* EqualsGreaterThanToken */: + case 50 /* ColonToken */: + case 13 /* OpenBraceToken */: + return 1 /* True */; + default: + return 0 /* False */; + } } - return undefined; - }); - } - function parseArrowExpressionTail(pos, sig) { - var body; - if (token === 13 /* OpenBraceToken */) { - body = parseFunctionBlock(false, false); - } - else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { - body = parseFunctionBlock(false, true); + if (second === 20 /* DotDotDotToken */) { + return 1 /* True */; + } + if (!isIdentifier()) { + return 0 /* False */; + } + if (nextToken() === 50 /* ColonToken */) { + return 1 /* True */; + } + return 2 /* Unknown */; } else { - body = parseAssignmentExpression(); + ts.Debug.assert(first === 23 /* LessThanToken */); + if (!isIdentifier()) { + return 0 /* False */; + } + return 2 /* Unknown */; } - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, body); } - function parseConditionalExpression() { - var expr = parseBinaryOperators(parseUnaryExpression(), 0); - while (parseOptional(49 /* QuestionToken */)) { - var node = createNode(157 /* ConditionalExpression */, expr.pos); - node.condition = expr; - node.whenTrue = allowInAnd(parseAssignmentExpression); - parseExpected(50 /* ColonToken */); - node.whenFalse = parseAssignmentExpression(); - expr = finishNode(node); + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(151 /* ArrowFunction */); + fillSignature(50 /* ColonToken */, false, !allowAmbiguity, node); + if (!node.parameters) { + return undefined; } - return expr; + if (!allowAmbiguity && token !== 31 /* EqualsGreaterThanToken */ && token !== 13 /* OpenBraceToken */) { + return undefined; + } + return node; } - function parseBinaryOperators(expr, minPrecedence) { + function parseArrowFunctionExpressionBody() { + if (token === 13 /* OpenBraceToken */) { + return parseFunctionBlock(false, false); + } + if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { + return parseFunctionBlock(false, true); + } + return parseAssignmentExpressionOrHigher(); + } + function parseConditionalExpressionRest(leftOperand) { + if (!parseOptional(49 /* QuestionToken */)) { + return leftOperand; + } + var node = createNode(158 /* ConditionalExpression */, leftOperand.pos); + node.condition = leftOperand; + node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(50 /* ColonToken */); + node.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); - var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== 84 /* InKeyword */)) { - var operator = token; - nextToken(); - expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence)); - continue; + var newPrecedence = getBinaryOperatorPrecedence(); + if (newPrecedence <= precedence) { + break; } - return expr; + if (token === 84 /* InKeyword */ && inDisallowInContext()) { + break; + } + var operator = token; + nextToken(); + leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence)); } + return leftOperand; } - function getOperatorPrecedence() { + function isBinaryOperator() { + if (inDisallowInContext() && token === 84 /* InKeyword */) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { switch (token) { case 48 /* BarBarToken */: return 1; @@ -3986,137 +4363,200 @@ var ts; case 36 /* PercentToken */: return 10; } - return undefined; + return -1; } function makeBinaryExpression(left, operator, right) { - var node = createNode(156 /* BinaryExpression */, left.pos); + var node = createNode(157 /* BinaryExpression */, left.pos); node.left = left; node.operator = operator; node.right = right; return finishNode(node); } - function parseUnaryExpression() { - var pos = getNodePos(); + function parsePrefixUnaryExpression() { + var node = createNode(155 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(152 /* DeleteExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(153 /* TypeOfExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(154 /* VoidExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseUnaryExpressionOrHigher() { switch (token) { case 32 /* PlusToken */: case 33 /* MinusToken */: case 46 /* TildeToken */: case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: - case 95 /* TypeOfKeyword */: - case 97 /* VoidKeyword */: case 37 /* PlusPlusToken */: case 38 /* MinusMinusToken */: - var operator = token; - nextToken(); - return makeUnaryExpression(154 /* PrefixOperator */, pos, operator, parseUnaryExpression()); + return parsePrefixUnaryExpression(); + case 72 /* DeleteKeyword */: + return parseDeleteExpression(); + case 95 /* TypeOfKeyword */: + return parseTypeOfExpression(); + case 97 /* VoidKeyword */: + return parseVoidExpression(); case 23 /* LessThanToken */: return parseTypeAssertion(); + default: + return parsePostfixExpressionOrHigher(); } - var primaryExpression = parsePrimaryExpression(); - var illegalUsageOfSuperKeyword = primaryExpression.kind === 89 /* SuperKeyword */ && token !== 15 /* OpenParenToken */ && token !== 19 /* DotToken */; - if (illegalUsageOfSuperKeyword) { - error(ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - } - var expr = parseCallAndAccess(primaryExpression, false); - ts.Debug.assert(isLeftHandSideExpression(expr)); + } + function parsePostfixExpressionOrHigher() { + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(isLeftHandSideExpression(expression)); if ((token === 37 /* PlusPlusToken */ || token === 38 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var operator = token; + var node = createNode(156 /* PostfixUnaryExpression */, expression.pos); + node.operand = expression; + node.operator = token; nextToken(); - expr = makeUnaryExpression(155 /* PostfixOperator */, expr.pos, operator, expr); + return finishNode(node); } - return expr; + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + var expression = token === 89 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 15 /* OpenParenToken */ || token === 19 /* DotToken */) { + return expression; + } + var node = createNode(143 /* PropertyAccessExpression */, expression.pos); + node.expression = expression; + parseExpected(19 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(true); + return finishNode(node); } function parseTypeAssertion() { - var node = createNode(150 /* TypeAssertion */); + var node = createNode(148 /* TypeAssertionExpression */); parseExpected(23 /* LessThanToken */); node.type = parseType(); parseExpected(24 /* GreaterThanToken */); - node.operand = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function makeUnaryExpression(kind, pos, operator, operand) { - var node = createNode(kind, pos); - node.operator = operator; - node.operand = operand; - return finishNode(node); - } - function parseCallAndAccess(expr, inNewExpression) { + function parseMemberExpressionRest(expression) { while (true) { var dotOrBracketStart = scanner.getTokenPos(); if (parseOptional(19 /* DotToken */)) { - var propertyAccess = createNode(145 /* PropertyAccess */, expr.pos); - var id; - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { - var matchesPattern = lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (scanner.isIdentifier() || scanner.isReservedWord); - }); - if (matchesPattern) { - errorAtPos(dotOrBracketStart + 1, 0, ts.Diagnostics.Identifier_expected); - id = createMissingNode(); - } - } - propertyAccess.left = expr; - propertyAccess.right = id || parseIdentifierName(); - expr = finishNode(propertyAccess); + var propertyAccess = createNode(143 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); continue; } if (parseOptional(17 /* OpenBracketToken */)) { - var indexedAccess = createNode(146 /* IndexedAccess */, expr.pos); - indexedAccess.object = expr; - if (inNewExpression && parseOptional(18 /* CloseBracketToken */)) { - indexedAccess.index = createMissingNode(); - } - else { - indexedAccess.index = allowInAnd(parseExpression); - if (indexedAccess.index.kind === 7 /* StringLiteral */ || indexedAccess.index.kind === 6 /* NumericLiteral */) { - var literal = indexedAccess.index; + var indexedAccess = createNode(144 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + if (token !== 18 /* CloseBracketToken */) { + indexedAccess.argumentExpression = allowInAnd(parseExpression); + if (indexedAccess.argumentExpression.kind === 7 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 6 /* NumericLiteral */) { + var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } - parseExpected(18 /* CloseBracketToken */); } - expr = finishNode(indexedAccess); - continue; - } - if ((token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) && !inNewExpression) { - var callExpr = createNode(147 /* CallExpression */, expr.pos); - callExpr.func = expr; - if (token === 23 /* LessThanToken */) { - if (!(callExpr.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) - return expr; - } - else { - parseExpected(15 /* OpenParenToken */); - } - callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); - expr = finishNode(callExpr); + parseExpected(18 /* CloseBracketToken */); + expression = finishNode(indexedAccess); continue; } if (token === 9 /* NoSubstitutionTemplateLiteral */ || token === 10 /* TemplateHead */) { - var tagExpression = createNode(149 /* TaggedTemplateExpression */, expr.pos); - tagExpression.tag = expr; + var tagExpression = createNode(147 /* TaggedTemplateExpression */, expression.pos); + tagExpression.tag = expression; tagExpression.template = token === 9 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); - expr = finishNode(tagExpression); + expression = finishNode(tagExpression); continue; } - return expr; + return expression; } } - function parseTypeArgumentsAndOpenParen() { - var result = parseTypeArguments(); + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 23 /* LessThanToken */) { + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(145 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 15 /* OpenParenToken */) { + var callExpr = createNode(145 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { parseExpected(15 /* OpenParenToken */); + var result = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); + parseExpected(16 /* CloseParenToken */); return result; } - function parseTypeArguments() { - return parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 23 /* LessThanToken */, 24 /* GreaterThanToken */); + function parseTypeArgumentsInExpression() { + if (!parseOptional(23 /* LessThanToken */)) { + return undefined; + } + var typeArguments = parseDelimitedList(15 /* TypeArguments */, parseType); + if (!parseExpected(24 /* GreaterThanToken */)) { + return undefined; + } + return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined; } - function parseSingleTypeArgument() { - if (token === 22 /* CommaToken */) { - return createNode(120 /* Missing */); + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 15 /* OpenParenToken */: + case 19 /* DotToken */: + case 16 /* CloseParenToken */: + case 18 /* CloseBracketToken */: + case 50 /* ColonToken */: + case 21 /* SemicolonToken */: + case 22 /* CommaToken */: + case 49 /* QuestionToken */: + case 27 /* EqualsEqualsToken */: + case 29 /* EqualsEqualsEqualsToken */: + case 28 /* ExclamationEqualsToken */: + case 30 /* ExclamationEqualsEqualsToken */: + case 47 /* AmpersandAmpersandToken */: + case 48 /* BarBarToken */: + case 44 /* CaretToken */: + case 42 /* AmpersandToken */: + case 43 /* BarToken */: + case 14 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + return true; + default: + return false; } - return parseType(); } function parsePrimaryExpression() { switch (token) { @@ -4131,11 +4571,11 @@ var ts; case 9 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); case 15 /* OpenParenToken */: - return parseParenExpression(); + return parseParenthesizedExpression(); case 17 /* OpenBracketToken */: - return parseArrayLiteral(); + return parseArrayLiteralExpression(); case 13 /* OpenBraceToken */: - return parseObjectLiteral(); + return parseObjectLiteralExpression(); case 81 /* FunctionKeyword */: return parseFunctionExpression(); case 86 /* NewKeyword */: @@ -4148,23 +4588,18 @@ var ts; break; case 10 /* TemplateHead */: return parseTemplateExpression(); - default: - if (isIdentifier()) { - return parseIdentifier(); - } } - error(ts.Diagnostics.Expression_expected); - return createMissingNode(); + return parseIdentifier(ts.Diagnostics.Expression_expected); } - function parseParenExpression() { - var node = createNode(151 /* ParenExpression */); + function parseParenthesizedExpression() { + var node = createNode(149 /* ParenthesizedExpression */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(16 /* CloseParenToken */); return finishNode(node); } function parseAssignmentExpressionOrOmittedExpression() { - return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpression(); + return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArrayLiteralElement() { return parseAssignmentExpressionOrOmittedExpression(); @@ -4172,8 +4607,8 @@ var ts; function parseArgumentExpression() { return allowInAnd(parseAssignmentExpressionOrOmittedExpression); } - function parseArrayLiteral() { - var node = createNode(141 /* ArrayLiteral */); + function parseArrayLiteralExpression() { + var node = createNode(141 /* ArrayLiteralExpression */); parseExpected(17 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; @@ -4181,92 +4616,70 @@ var ts; parseExpected(18 /* CloseBracketToken */); return finishNode(node); } - function parsePropertyAssignment() { - var nodePos = scanner.getStartPos(); + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var initialToken = token; + if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { + var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; + return parseAccessorDeclaration(kind, fullStart, undefined); + } var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var node; if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, asteriskToken, undefined, sig, body); - return finishNode(node); - } - var flags = 0; - if (token === 49 /* QuestionToken */) { - flags |= 4 /* QuestionMark */; - nextToken(); + return parseMethodDeclaration(fullStart, undefined, asteriskToken, propertyName, undefined, true); } + var questionToken = parseOptionalToken(49 /* QuestionToken */); if ((token === 22 /* CommaToken */ || token === 14 /* CloseBraceToken */) && tokenIsIdentifier) { - node = createNode(144 /* ShorthandPropertyAssignment */, nodePos); - node.name = propertyName; + var shorthandDeclaration = createNode(199 /* ShorthandPropertyAssignment */, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + return finishNode(shorthandDeclaration); } else { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; + var propertyAssignment = createNode(198 /* PropertyAssignment */, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; parseExpected(50 /* ColonToken */); - node.initializer = allowInAnd(parseAssignmentExpression); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); } - node.flags = flags; - return finishNode(node); } - function parseObjectLiteralMember() { - var initialPos = getNodePos(); - var initialToken = token; - if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { - var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; - return parseMemberAccessorDeclaration(kind, initialPos, undefined); - } - return parsePropertyAssignment(); - } - function parseObjectLiteral() { - var node = createNode(142 /* ObjectLiteral */); + function parseObjectLiteralExpression() { + var node = createNode(142 /* ObjectLiteralExpression */); parseExpected(13 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } - node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember); + node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralElement); parseExpected(14 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { - var pos = getNodePos(); + var node = createNode(150 /* FunctionExpression */); parseExpected(81 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - var name = asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - return makeFunctionExpression(152 /* FunctionExpression */, pos, asteriskToken, name, sig, body); + node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); + fillSignature(50 /* ColonToken */, !!node.asteriskToken, false, node); + node.body = parseFunctionBlock(!!node.asteriskToken, false); + return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } - function makeFunctionExpression(kind, pos, asteriskToken, name, sig, body) { - var node = createNode(kind, pos); - node.asteriskToken = asteriskToken; - node.name = name; - node.typeParameters = sig.typeParameters; - node.parameters = sig.parameters; - node.type = sig.type; - node.body = body; - return finishNode(node); - } function parseNewExpression() { - var node = createNode(148 /* NewExpression */); + var node = createNode(146 /* NewExpression */); parseExpected(86 /* NewKeyword */); - node.func = parseCallAndAccess(parsePrimaryExpression(), true); - if (parseOptional(15 /* OpenParenToken */) || token === 23 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { - node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 15 /* OpenParenToken */) { + node.arguments = parseArgumentList(); } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) { - var node = createNode(162 /* Block */); + function parseBlock(kind, ignoreMissingOpenBrace, checkForStrictMode) { + var node = createNode(kind); if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); parseExpected(14 /* CloseBraceToken */); @@ -4279,18 +4692,17 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); - var block = parseBlock(ignoreMissingOpenBrace, true); - block.kind = 187 /* FunctionBlock */; + var block = parseBlock(163 /* Block */, ignoreMissingOpenBrace, true); setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(164 /* EmptyStatement */); + var node = createNode(165 /* EmptyStatement */); parseExpected(21 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(166 /* IfStatement */); + var node = createNode(167 /* IfStatement */); parseExpected(82 /* IfKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4300,7 +4712,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(167 /* DoStatement */); + var node = createNode(168 /* DoStatement */); parseExpected(73 /* DoKeyword */); node.statement = parseStatement(); parseExpected(98 /* WhileKeyword */); @@ -4311,7 +4723,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(168 /* WhileStatement */); + var node = createNode(169 /* WhileStatement */); parseExpected(98 /* WhileKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4339,7 +4751,7 @@ var ts; } var forOrForInStatement; if (parseOptional(84 /* InKeyword */)) { - var forInStatement = createNode(170 /* ForInStatement */, pos); + var forInStatement = createNode(171 /* ForInStatement */, pos); if (declarations) { forInStatement.declarations = declarations; } @@ -4351,7 +4763,7 @@ var ts; forOrForInStatement = forInStatement; } else { - var forStatement = createNode(169 /* ForStatement */, pos); + var forStatement = createNode(170 /* ForStatement */, pos); if (declarations) { forStatement.declarations = declarations; } @@ -4374,7 +4786,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); + parseExpected(kind === 173 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -4382,7 +4794,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(173 /* ReturnStatement */); + var node = createNode(174 /* ReturnStatement */); parseExpected(88 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -4391,7 +4803,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(174 /* WithStatement */); + var node = createNode(175 /* WithStatement */); parseExpected(99 /* WithKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4400,7 +4812,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(176 /* CaseClause */); + var node = createNode(194 /* CaseClause */); parseExpected(65 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(50 /* ColonToken */); @@ -4408,7 +4820,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(177 /* DefaultClause */); + var node = createNode(195 /* DefaultClause */); parseExpected(71 /* DefaultKeyword */); parseExpected(50 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); @@ -4418,7 +4830,7 @@ var ts; return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(175 /* SwitchStatement */); + var node = createNode(176 /* SwitchStatement */); parseExpected(90 /* SwitchKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4429,69 +4841,57 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(179 /* ThrowStatement */); + var node = createNode(178 /* ThrowStatement */); parseExpected(92 /* ThrowKeyword */); - if (scanner.hasPrecedingLineBreak()) { - error(ts.Diagnostics.Line_break_not_permitted_here); - } - node.expression = allowInAnd(parseExpression); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(180 /* TryStatement */); - node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 181 /* TryBlock */); - if (token === 66 /* CatchKeyword */) { - node.catchBlock = parseCatchBlock(); - } - if (token === 79 /* FinallyKeyword */) { - node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 183 /* FinallyBlock */); - } - if (!(node.catchBlock || node.finallyBlock)) { - error(ts.Diagnostics.catch_or_finally_expected); - } + var node = createNode(179 /* TryStatement */); + node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */); + node.catchClause = token === 66 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.finallyBlock = !node.catchClause || token === 79 /* FinallyKeyword */ ? parseTokenAndBlock(79 /* FinallyKeyword */) : undefined; return finishNode(node); } - function parseTokenAndBlock(token, kind) { + function parseTokenAndBlock(token) { var pos = getNodePos(); parseExpected(token); - var result = parseBlock(false, false); - result.kind = kind; + var result = parseBlock(token === 94 /* TryKeyword */ ? 180 /* TryBlock */ : 181 /* FinallyBlock */, false, false); result.pos = pos; return result; } - function parseCatchBlock() { - var pos = getNodePos(); + function parseCatchClause() { + var result = createNode(197 /* CatchClause */); parseExpected(66 /* CatchKeyword */); parseExpected(15 /* OpenParenToken */); - var variable = parseIdentifier(); - var typeAnnotation = parseTypeAnnotation(); + result.name = parseIdentifier(); + result.type = parseTypeAnnotation(); parseExpected(16 /* CloseParenToken */); - var result = parseBlock(false, false); - result.kind = 182 /* CatchBlock */; - result.pos = pos; - result.variable = variable; - result.type = typeAnnotation; - return result; + result.block = parseBlock(163 /* Block */, false, false); + return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(184 /* DebuggerStatement */); + var node = createNode(182 /* DebuggerStatement */); parseExpected(70 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } function isLabel() { - return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; }); + return isIdentifier() && lookAhead(nextTokenIsColonToken); + } + function nextTokenIsColonToken() { + return nextToken() === 50 /* ColonToken */; } function parseLabeledStatement() { - var node = createNode(178 /* LabeledStatement */); + var node = createNode(177 /* LabeledStatement */); node.label = parseIdentifier(); parseExpected(50 /* ColonToken */); node.statement = parseStatement(); return finishNode(node); } function parseExpressionStatement() { - var node = createNode(165 /* ExpressionStatement */); + var node = createNode(166 /* ExpressionStatement */); node.expression = allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); @@ -4520,7 +4920,7 @@ var ts; case 79 /* FinallyKeyword */: return true; case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; case 101 /* InterfaceKeyword */: case 67 /* ClassKeyword */: @@ -4534,19 +4934,26 @@ var ts; case 104 /* PrivateKeyword */: case 105 /* ProtectedKeyword */: case 107 /* StaticKeyword */: - if (lookAhead(function () { return nextToken() >= 63 /* Identifier */; })) { + if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } default: return isStartOfExpression(); } } + function nextTokenIsEnumKeyword() { + nextToken(); + return token === 75 /* EnumKeyword */; + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + } function parseStatement() { switch (token) { case 13 /* OpenBraceToken */: - return parseBlock(false, false); + return parseBlock(163 /* Block */, false, false); case 96 /* VarKeyword */: - case 102 /* LetKeyword */: case 68 /* ConstKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined); case 81 /* FunctionKeyword */: @@ -4562,9 +4969,9 @@ var ts; case 80 /* ForKeyword */: return parseForOrForInStatement(); case 69 /* ContinueKeyword */: - return parseBreakOrContinueStatement(171 /* ContinueStatement */); + return parseBreakOrContinueStatement(172 /* ContinueStatement */); case 64 /* BreakKeyword */: - return parseBreakOrContinueStatement(172 /* BreakStatement */); + return parseBreakOrContinueStatement(173 /* BreakStatement */); case 88 /* ReturnKeyword */: return parseReturnStatement(); case 99 /* WithKeyword */: @@ -4579,6 +4986,10 @@ var ts; return parseTryStatement(); case 70 /* DebuggerKeyword */: return parseDebuggerStatement(); + case 102 /* LetKeyword */: + if (isLetDeclaration()) { + return parseVariableStatement(scanner.getStartPos(), undefined); + } default: return isLabel() ? parseLabeledStatement() : parseExpressionStatement(); } @@ -4587,14 +4998,11 @@ var ts; if (token === 13 /* OpenBraceToken */) { return parseFunctionBlock(isGenerator, false); } - if (canParseSemicolon()) { - parseSemicolon(); - return undefined; - } - error(ts.Diagnostics.Block_or_expected); + parseSemicolon(ts.Diagnostics.or_expected); + return undefined; } function parseVariableDeclaration() { - var node = createNode(185 /* VariableDeclaration */); + var node = createNode(183 /* VariableDeclaration */); node.name = parseIdentifier(); node.type = parseTypeAnnotation(); node.initializer = parseInitializer(false); @@ -4610,7 +5018,7 @@ var ts; return parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); } function parseVariableStatement(fullStart, modifiers) { - var node = createNode(163 /* VariableStatement */, fullStart); + var node = createNode(164 /* VariableStatement */, fullStart); setModifiers(node, modifiers); if (token === 102 /* LetKeyword */) { node.flags |= 2048 /* Let */; @@ -4628,12 +5036,12 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(186 /* FunctionDeclaration */, fullStart); + var node = createNode(184 /* FunctionDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(81 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); node.name = parseIdentifier(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!node.asteriskToken, node); + fillSignature(50 /* ColonToken */, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken); return finishNode(node); } @@ -4641,60 +5049,59 @@ var ts; var node = createNode(126 /* Constructor */, pos); setModifiers(node, modifiers); parseExpected(111 /* ConstructorKeyword */); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + fillSignature(50 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } - function parsePropertyMemberDeclaration(fullStart, modifiers) { - var flags = modifiers ? modifiers.flags : 0; + function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, requireBlock) { + var method = createNode(125 /* Method */, fullStart); + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + fillSignature(50 /* ColonToken */, !!asteriskToken, false, method); + method.body = requireBlock ? parseFunctionBlock(!!asteriskToken, false) : parseFunctionBlockOrSemicolon(!!asteriskToken); + return finishNode(method); + } + function parsePropertyOrMethodDeclaration(fullStart, modifiers) { var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); var name = parsePropertyName(); - if (parseOptional(49 /* QuestionToken */)) { - flags |= 4 /* QuestionMark */; - } + var questionToken = parseOptionalToken(49 /* QuestionToken */); if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - var method = createNode(125 /* Method */, fullStart); - setModifiers(method, modifiers); - if (flags) { - method.flags = flags; - } - method.asteriskToken = asteriskToken; - method.name = name; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken); - return finishNode(method); + return parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, false); } else { var property = createNode(124 /* Property */, fullStart); setModifiers(property, modifiers); - if (flags) { - property.flags = flags; - } property.name = name; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(function () { return parseInitializer(false); }); + property.initializer = allowInAnd(parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } } - function parseMemberAccessorDeclaration(kind, fullStart, modifiers) { + function parseNonParameterInitializer() { + return parseInitializer(false); + } + function parseAccessorDeclaration(kind, fullStart, modifiers) { var node = createNode(kind, fullStart); setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + fillSignature(50 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } function isClassMemberStart() { var idToken; - while (isModifier(token)) { + while (ts.isModifier(token)) { idToken = token; nextToken(); } if (token === 34 /* AsteriskToken */) { return true; } - if (isPropertyName()) { + if (isLiteralPropertyName()) { idToken = token; nextToken(); } @@ -4702,7 +5109,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { return true; } switch (token) { @@ -4722,52 +5129,51 @@ var ts; var flags = 0; var modifiers; while (true) { - var modifierStart = scanner.getTokenPos(); + var modifierStart = scanner.getStartPos(); var modifierKind = token; if (!parseAnyContextualModifier()) { break; } if (!modifiers) { modifiers = []; + modifiers.pos = modifierStart; } flags |= modifierToFlag(modifierKind); modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } if (modifiers) { modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); } return modifiers; } - function parseClassMemberDeclaration() { + function parseClassElement() { var fullStart = getNodePos(); var modifiers = parseModifiers(); if (parseContextualModifier(113 /* GetKeyword */)) { - return parseMemberAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers); + return parseAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers); } if (parseContextualModifier(117 /* SetKeyword */)) { - return parseMemberAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers); + return parseAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers); } if (token === 111 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, modifiers); } - if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */) { - return parsePropertyMemberDeclaration(fullStart, modifiers); + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, modifiers); } - if (token === 17 /* OpenBracketToken */) { - return parseIndexSignatureMember(fullStart, modifiers); + if (isIdentifierOrKeyword() || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */ || token === 17 /* OpenBracketToken */) { + return parsePropertyOrMethodDeclaration(fullStart, modifiers); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(188 /* ClassDeclaration */, fullStart); + var node = createNode(185 /* ClassDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(67 /* ClassKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.baseType = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassBaseType) : parseClassBaseType(); - if (parseOptional(100 /* ImplementsKeyword */)) { - node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } + node.heritageClauses = parseHeritageClauses(true); if (parseExpected(13 /* OpenBraceToken */)) { node.members = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassMembers) : parseClassMembers(); parseExpected(14 /* CloseBraceToken */); @@ -4777,26 +5183,43 @@ var ts; } return finishNode(node); } - function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration); + function parseHeritageClauses(isClassHeritageClause) { + if (isHeritageClause()) { + return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) : parseHeritageClausesWorker(); + } + return undefined; } - function parseClassBaseType() { - return parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined; + function parseHeritageClausesWorker() { + return parseList(17 /* HeritageClauses */, false, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */) { + var node = createNode(196 /* HeritageClause */); + node.token = token; + nextToken(); + node.types = parseDelimitedList(8 /* TypeReferences */, parseTypeReference); + return finishNode(node); + } + return undefined; + } + function isHeritageClause() { + return token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; + } + function parseClassMembers() { + return parseList(6 /* ClassMembers */, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(189 /* InterfaceDeclaration */, fullStart); + var node = createNode(186 /* InterfaceDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(101 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - if (parseOptional(77 /* ExtendsKeyword */)) { - node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } - node.members = parseObjectType(); + node.heritageClauses = parseHeritageClauses(false); + node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(190 /* TypeAliasDeclaration */, fullStart); + var node = createNode(187 /* TypeAliasDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(119 /* TypeKeyword */); node.name = parseIdentifier(); @@ -4806,17 +5229,14 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(196 /* EnumMember */, scanner.getStartPos()); + var node = createNode(200 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); - node.initializer = allowInAnd(function () { return parseInitializer(false); }); + node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseAndCheckEnumDeclaration(fullStart, flags) { - var node = createNode(191 /* EnumDeclaration */, fullStart); - node.flags = flags; - if (flags & 4096 /* Const */) { - parseExpected(68 /* ConstKeyword */); - } + function parseEnumDeclaration(fullStart, modifiers) { + var node = createNode(188 /* EnumDeclaration */, fullStart); + setModifiers(node, modifiers); parseExpected(75 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(13 /* OpenBraceToken */)) { @@ -4828,8 +5248,8 @@ var ts; } return finishNode(node); } - function parseModuleBody() { - var node = createNode(193 /* ModuleBlock */, scanner.getStartPos()); + function parseModuleBlock() { + var node = createNode(190 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(13 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); parseExpected(14 /* CloseBraceToken */); @@ -4839,76 +5259,110 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; + function parseInternalModuleTail(fullStart, modifiers, flags) { + var node = createNode(189 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), 1 /* Export */) : parseModuleBody(); + node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; - node.name = parseStringLiteral(); - node.body = parseModuleBody(); + function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { + var node = createNode(189 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.name = parseLiteralNode(true); + node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, flags) { + function parseModuleDeclaration(fullStart, modifiers) { parseExpected(114 /* ModuleKeyword */); - return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, flags) : parseInternalModuleTail(fullStart, flags); + return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + } + function isExternalModuleReference() { + return token === 115 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 15 /* OpenParenToken */; } function parseImportDeclaration(fullStart, modifiers) { - var node = createNode(194 /* ImportDeclaration */, fullStart); + var node = createNode(191 /* ImportDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(83 /* ImportKeyword */); node.name = parseIdentifier(); parseExpected(51 /* EqualsToken */); - var entityName = parseEntityName(false); - if (entityName.kind === 63 /* Identifier */ && entityName.text === "require" && parseOptional(15 /* OpenParenToken */)) { - node.externalModuleName = parseStringLiteral(); - parseExpected(16 /* CloseParenToken */); - } - else { - node.entityName = entityName; - } + node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); } + function parseModuleReference() { + return isExternalModuleReference() ? parseExternalModuleReference() : parseEntityName(false); + } + function parseExternalModuleReference() { + var node = createNode(193 /* ExternalModuleReference */); + parseExpected(115 /* RequireKeyword */); + parseExpected(15 /* OpenParenToken */); + node.expression = parseExpression(); + if (node.expression.kind === 7 /* StringLiteral */) { + internIdentifier(node.expression.text); + } + parseExpected(16 /* CloseParenToken */); + return finishNode(node); + } function parseExportAssignmentTail(fullStart, modifiers) { - var node = createNode(195 /* ExportAssignment */, fullStart); + var node = createNode(192 /* ExportAssignment */, fullStart); setModifiers(node, modifiers); node.exportName = parseIdentifier(); parseSemicolon(); return finishNode(node); } + function isLetDeclaration() { + return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOnSameLine); + } function isDeclarationStart() { switch (token) { case 96 /* VarKeyword */: - case 102 /* LetKeyword */: case 68 /* ConstKeyword */: case 81 /* FunctionKeyword */: return true; + case 102 /* LetKeyword */: + return isLetDeclaration(); case 67 /* ClassKeyword */: case 101 /* InterfaceKeyword */: case 75 /* EnumKeyword */: case 83 /* ImportKeyword */: case 119 /* TypeKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */; }); + return lookAhead(nextTokenIsIdentifierOrKeyword); case 114 /* ModuleKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */ || token === 7 /* StringLiteral */; }); + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); case 76 /* ExportKeyword */: - return lookAhead(function () { return nextToken() === 51 /* EqualsToken */ || isDeclarationStart(); }); + return lookAhead(nextTokenIsEqualsTokenOrDeclarationStart); case 112 /* DeclareKeyword */: case 106 /* PublicKeyword */: case 104 /* PrivateKeyword */: case 105 /* ProtectedKeyword */: case 107 /* StaticKeyword */: - return lookAhead(function () { - nextToken(); - return isDeclarationStart(); - }); + return lookAhead(nextTokenIsDeclarationStart); } } + function isIdentifierOrKeyword() { + return token >= 63 /* Identifier */; + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } + function nextTokenIsIdentifierOrKeywordOrStringLiteral() { + nextToken(); + return isIdentifierOrKeyword() || token === 7 /* StringLiteral */; + } + function nextTokenIsEqualsTokenOrDeclarationStart() { + nextToken(); + return token === 51 /* EqualsToken */ || isDeclarationStart(); + } + function nextTokenIsDeclarationStart() { + nextToken(); + return isDeclarationStart(); + } function parseDeclaration() { var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -4918,50 +5372,28 @@ var ts; return parseExportAssignmentTail(fullStart, modifiers); } } - var flags = modifiers ? modifiers.flags : 0; - var result; switch (token) { case 96 /* VarKeyword */: case 102 /* LetKeyword */: - result = parseVariableStatement(fullStart, modifiers); - break; case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); - if (isConstEnum) { - result = parseAndCheckEnumDeclaration(fullStart, flags | 4096 /* Const */); - } - else { - result = parseVariableStatement(fullStart, modifiers); - } - break; + return parseVariableStatement(fullStart, modifiers); case 81 /* FunctionKeyword */: - result = parseFunctionDeclaration(fullStart, modifiers); - break; + return parseFunctionDeclaration(fullStart, modifiers); case 67 /* ClassKeyword */: - result = parseClassDeclaration(fullStart, modifiers); - break; + return parseClassDeclaration(fullStart, modifiers); case 101 /* InterfaceKeyword */: - result = parseInterfaceDeclaration(fullStart, modifiers); - break; + return parseInterfaceDeclaration(fullStart, modifiers); case 119 /* TypeKeyword */: - result = parseTypeAliasDeclaration(fullStart, modifiers); - break; + return parseTypeAliasDeclaration(fullStart, modifiers); case 75 /* EnumKeyword */: - result = parseAndCheckEnumDeclaration(fullStart, flags); - break; + return parseEnumDeclaration(fullStart, modifiers); case 114 /* ModuleKeyword */: - result = parseModuleDeclaration(fullStart, flags); - break; + return parseModuleDeclaration(fullStart, modifiers); case 83 /* ImportKeyword */: - result = parseImportDeclaration(fullStart, modifiers); - break; + return parseImportDeclaration(fullStart, modifiers); default: - error(ts.Diagnostics.Declaration_expected); + ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } - if (modifiers) { - result.modifiers = modifiers; - } - return result; } function isSourceElement(inErrorRecovery) { return isDeclarationStart() || isStatement(inErrorRecovery); @@ -4976,24 +5408,30 @@ var ts; return isDeclarationStart() ? parseDeclaration() : parseStatement(); } function processReferenceComments() { + var triviaScanner = ts.createScanner(languageVersion, false, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; - commentRanges = []; - token = scanner.scan(); - for (var i = 0; i < commentRanges.length; i++) { - var range = commentRanges[i]; + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { + continue; + } + if (kind !== 2 /* SingleLineCommentTrivia */) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos() }; var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = getFileReferenceFromReferencePath(comment, range); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { var fileReference = referencePathMatchResult.fileReference; - file.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnostic = referencePathMatchResult.diagnostic; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; if (fileReference) { referencedFiles.push(fileReference); } - if (diagnostic) { - errorAtPos(range.pos, range.end - range.pos, diagnostic); + if (diagnosticMessage) { + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); } } else { @@ -5001,7 +5439,7 @@ var ts; var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment); if (amdModuleNameMatchResult) { if (amdModuleName) { - errorAtPos(range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments); + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments)); } amdModuleName = amdModuleNameMatchResult[2]; } @@ -5012,7 +5450,6 @@ var ts; } } } - commentRanges = undefined; return { referencedFiles: referencedFiles, amdDependencies: amdDependencies, @@ -5020,71 +5457,74 @@ var ts; }; } function getExternalModuleIndicator() { - return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 194 /* ImportDeclaration */ && node.externalModuleName || node.kind === 195 /* ExportAssignment */ ? node : undefined; }); + return ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind === 193 /* ExternalModuleReference */ || node.kind === 192 /* ExportAssignment */ ? node : undefined; }); } var syntacticDiagnostics; function getSyntacticDiagnostics() { if (syntacticDiagnostics === undefined) { - if (file.parseDiagnostics.length > 0) { - syntacticDiagnostics = file.parseDiagnostics; + if (sourceFile.parseDiagnostics.length > 0) { + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics); } else { - syntacticDiagnostics = file.grammarDiagnostics; - checkGrammar(sourceText, languageVersion, file); + checkGrammar(sourceText, languageVersion, sourceFile); + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.grammarDiagnostics); } } ts.Debug.assert(syntacticDiagnostics !== undefined); return syntacticDiagnostics; } - scanner = ts.createScanner(languageVersion, true, sourceText, scanError, onComment); var rootNodeFlags = 0; if (ts.fileExtensionIs(filename, ".d.ts")) { rootNodeFlags = 1024 /* DeclarationFile */; } - file = createRootNode(197 /* SourceFile */, 0, sourceText.length, rootNodeFlags); - file.filename = ts.normalizePath(filename); - file.text = sourceText; - file.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; - file.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; - file.getLineStarts = getLineStarts; - file.getSyntacticDiagnostics = getSyntacticDiagnostics; - file.parseDiagnostics = []; - file.grammarDiagnostics = []; - file.semanticDiagnostics = []; + var sourceFile = createRootNode(201 /* SourceFile */, 0, sourceText.length, rootNodeFlags); + sourceFile.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; + sourceFile.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; + sourceFile.getLineStarts = getLineStarts; + sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics; + sourceFile.filename = ts.normalizePath(filename); + sourceFile.text = sourceText; + sourceFile.referenceDiagnostics = []; + sourceFile.parseDiagnostics = []; + sourceFile.grammarDiagnostics = []; + sourceFile.semanticDiagnostics = []; var referenceComments = processReferenceComments(); - file.referencedFiles = referenceComments.referencedFiles; - file.amdDependencies = referenceComments.amdDependencies; - file.amdModuleName = referenceComments.amdModuleName; - file.statements = parseList(0 /* SourceElements */, true, parseSourceElement); - file.externalModuleIndicator = getExternalModuleIndicator(); - file.nodeCount = nodeCount; - file.identifierCount = identifierCount; - file.version = version; - file.isOpen = isOpen; - file.languageVersion = languageVersion; - file.identifiers = identifiers; - return file; + sourceFile.referencedFiles = referenceComments.referencedFiles; + sourceFile.amdDependencies = referenceComments.amdDependencies; + sourceFile.amdModuleName = referenceComments.amdModuleName; + var scanner = ts.createScanner(languageVersion, true, sourceText, scanError); + nextToken(); + sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + ts.Debug.assert(token === 1 /* EndOfFileToken */); + sourceFile.endOfFileToken = parseTokenNode(); + sourceFile.externalModuleIndicator = getExternalModuleIndicator(); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.version = version; + sourceFile.isOpen = isOpen; + sourceFile.languageVersion = languageVersion; + sourceFile.identifiers = identifiers; + return sourceFile; } ts.createSourceFile = createSourceFile; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 148 /* NewExpression */: - case 147 /* CallExpression */: - case 149 /* TaggedTemplateExpression */: - case 141 /* ArrayLiteral */: - case 151 /* ParenExpression */: - case 142 /* ObjectLiteral */: - case 152 /* FunctionExpression */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 146 /* NewExpression */: + case 145 /* CallExpression */: + case 147 /* TaggedTemplateExpression */: + case 141 /* ArrayLiteralExpression */: + case 149 /* ParenthesizedExpression */: + case 142 /* ObjectLiteralExpression */: + case 150 /* FunctionExpression */: case 63 /* Identifier */: - case 120 /* Missing */: case 8 /* RegularExpressionLiteral */: case 6 /* NumericLiteral */: case 7 /* StringLiteral */: case 9 /* NoSubstitutionTemplateLiteral */: - case 158 /* TemplateExpression */: + case 159 /* TemplateExpression */: case 78 /* FalseKeyword */: case 87 /* NullKeyword */: case 91 /* ThisKeyword */: @@ -5111,7 +5551,7 @@ var ts; parent = node; if (!checkModifiers(node)) { var savedInFunctionBlock = inFunctionBlock; - if (node.kind === 187 /* FunctionBlock */) { + if (ts.isFunctionBlock(node)) { inFunctionBlock = true; } var savedInAmbientContext = inAmbientContext; @@ -5136,67 +5576,80 @@ var ts; } function checkNode(node, nodeKind) { switch (nodeKind) { - case 153 /* ArrowFunction */: + case 151 /* ArrowFunction */: case 129 /* CallSignature */: case 134 /* ConstructorType */: case 130 /* ConstructSignature */: case 133 /* FunctionType */: - return checkAnyParsedSignature(node); - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: + return checkAnySignatureDeclaration(node); + case 173 /* BreakStatement */: + case 172 /* ContinueStatement */: return checkBreakOrContinueStatement(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return checkCallOrNewExpression(node); - case 191 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 156 /* BinaryExpression */: return checkBinaryExpression(node); - case 182 /* CatchBlock */: return checkCatchBlock(node); - case 188 /* ClassDeclaration */: return checkClassDeclaration(node); + case 188 /* EnumDeclaration */: return checkEnumDeclaration(node); + case 157 /* BinaryExpression */: return checkBinaryExpression(node); + case 197 /* CatchClause */: return checkCatchClause(node); + case 185 /* ClassDeclaration */: return checkClassDeclaration(node); + case 121 /* ComputedPropertyName */: return checkComputedPropertyName(node); case 126 /* Constructor */: return checkConstructor(node); - case 195 /* ExportAssignment */: return checkExportAssignment(node); - case 170 /* ForInStatement */: return checkForInStatement(node); - case 169 /* ForStatement */: return checkForStatement(node); - case 186 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 152 /* FunctionExpression */: return checkFunctionExpression(node); + case 152 /* DeleteExpression */: return checkDeleteExpression(node); + case 144 /* ElementAccessExpression */: return checkElementAccessExpression(node); + case 192 /* ExportAssignment */: return checkExportAssignment(node); + case 193 /* ExternalModuleReference */: return checkExternalModuleReference(node); + case 171 /* ForInStatement */: return checkForInStatement(node); + case 170 /* ForStatement */: return checkForStatement(node); + case 184 /* FunctionDeclaration */: return checkFunctionDeclaration(node); + case 150 /* FunctionExpression */: return checkFunctionExpression(node); case 127 /* GetAccessor */: return checkGetAccessor(node); - case 146 /* IndexedAccess */: return checkIndexedAccess(node); + case 196 /* HeritageClause */: return checkHeritageClause(node); case 131 /* IndexSignature */: return checkIndexSignature(node); - case 189 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 178 /* LabeledStatement */: return checkLabeledStatement(node); + case 186 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); + case 177 /* LabeledStatement */: return checkLabeledStatement(node); + case 198 /* PropertyAssignment */: return checkPropertyAssignment(node); case 125 /* Method */: return checkMethod(node); - case 192 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 142 /* ObjectLiteral */: return checkObjectLiteral(node); + case 189 /* ModuleDeclaration */: return checkModuleDeclaration(node); + case 142 /* ObjectLiteralExpression */: return checkObjectLiteralExpression(node); case 6 /* NumericLiteral */: return checkNumericLiteral(node); case 123 /* Parameter */: return checkParameter(node); - case 155 /* PostfixOperator */: return checkPostfixOperator(node); - case 154 /* PrefixOperator */: return checkPrefixOperator(node); + case 156 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); + case 155 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); case 124 /* Property */: return checkProperty(node); - case 143 /* PropertyAssignment */: return checkPropertyAssignment(node); - case 173 /* ReturnStatement */: return checkReturnStatement(node); + case 174 /* ReturnStatement */: return checkReturnStatement(node); case 128 /* SetAccessor */: return checkSetAccessor(node); - case 197 /* SourceFile */: return checkSourceFile(node); - case 144 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); - case 175 /* SwitchStatement */: return checkSwitchStatement(node); - case 149 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); + case 201 /* SourceFile */: return checkSourceFile(node); + case 199 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); + case 176 /* SwitchStatement */: return checkSwitchStatement(node); + case 147 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); + case 178 /* ThrowStatement */: return checkThrowStatement(node); case 138 /* TupleType */: return checkTupleType(node); case 122 /* TypeParameter */: return checkTypeParameter(node); case 132 /* TypeReference */: return checkTypeReference(node); - case 185 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 163 /* VariableStatement */: return checkVariableStatement(node); - case 174 /* WithStatement */: return checkWithStatement(node); + case 183 /* VariableDeclaration */: return checkVariableDeclaration(node); + case 164 /* VariableStatement */: return checkVariableStatement(node); + case 175 /* WithStatement */: return checkWithStatement(node); case 160 /* YieldExpression */: return checkYieldExpression(node); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var start = ts.skipTrivia(sourceText, node.pos); + function scanToken(pos) { + var start = ts.skipTrivia(sourceText, pos); scanner.setTextPos(start); scanner.scan(); - var end = scanner.getTextPos(); - grammarDiagnostics.push(ts.createFileDiagnostic(file, start, end - start, message, arg0, arg1, arg2)); + return start; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var start = scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); + return true; + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); return true; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var span = getErrorSpanForNode(node); + var span = ts.getErrorSpanForNode(node); var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos; var length = span.end - start; grammarDiagnostics.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); @@ -5212,27 +5665,27 @@ var ts; } function checkForStatementInAmbientContext(node, kind) { switch (kind) { - case 162 /* Block */: - case 164 /* EmptyStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 184 /* DebuggerStatement */: - case 178 /* LabeledStatement */: - case 165 /* ExpressionStatement */: + case 163 /* Block */: + case 165 /* EmptyStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: + case 174 /* ReturnStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 178 /* ThrowStatement */: + case 179 /* TryStatement */: + case 182 /* DebuggerStatement */: + case 177 /* LabeledStatement */: + case 166 /* ExpressionStatement */: return grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } - function checkAnyParsedSignature(node) { + function checkAnySignatureDeclaration(node) { return checkTypeParameterList(node.typeParameters) || checkParameterList(node.parameters); } function checkBinaryExpression(node) { @@ -5246,12 +5699,12 @@ var ts; } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: return true; - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -5259,11 +5712,11 @@ var ts; function checkLabeledStatement(node) { var current = node.parent; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { break; } - if (current.kind === 178 /* LabeledStatement */ && current.label.text === node.label.text) { - return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); + if (current.kind === 177 /* LabeledStatement */ && current.label.text === node.label.text) { + return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceText, node.label)); } current = current.parent; } @@ -5271,21 +5724,21 @@ var ts; function checkBreakOrContinueStatement(node) { var current = node; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 171 /* ContinueStatement */ && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 172 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 175 /* SwitchStatement */: - if (node.kind === 172 /* BreakStatement */ && !node.label) { + case 176 /* SwitchStatement */: + if (node.kind === 173 /* BreakStatement */ && !node.label) { return false; } break; @@ -5298,11 +5751,11 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; + var message = node.kind === 173 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; + var message = node.kind === 173 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } } @@ -5313,7 +5766,7 @@ var ts; return checkForDisallowedTrailingComma(arguments) || checkForOmittedArgument(arguments); } function checkTypeArguments(typeArguments) { - return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments) || checkForMissingTypeArgument(typeArguments); + return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments); } function checkForOmittedArgument(arguments) { if (arguments) { @@ -5325,16 +5778,6 @@ var ts; } } } - function checkForMissingTypeArgument(typeArguments) { - if (typeArguments) { - for (var i = 0, n = typeArguments.length; i < n; i++) { - var arg = typeArguments[i]; - if (arg.kind === 120 /* Missing */) { - return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Type_expected); - } - } - } - } function checkForAtLeastOneTypeArgument(typeArguments) { if (typeArguments && typeArguments.length === 0) { var start = typeArguments.pos - "<".length; @@ -5349,17 +5792,47 @@ var ts; return grammarErrorAtPos(start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkCatchBlock(node) { + function checkCatchClause(node) { if (node.type) { - var colonStart = ts.skipTrivia(sourceText, node.variable.end); + var colonStart = ts.skipTrivia(sourceText, node.name.end); return grammarErrorAtPos(colonStart, ":".length, ts.Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); } - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) { - return reportInvalidUseInStrictMode(node.variable); + if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { + return reportInvalidUseInStrictMode(node.name); } } function checkClassDeclaration(node) { - return checkForDisallowedTrailingComma(node.implementedTypes) || checkForAtLeastOneHeritageClause(node.implementedTypes, "implements"); + return checkClassDeclarationHeritageClauses(node); + } + function checkClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 77 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 100 /* ImplementsKeyword */); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + } + } + return false; } function checkForAtLeastOneHeritageClause(types, listType) { if (types && types.length === 0) { @@ -5367,7 +5840,7 @@ var ts; } } function checkConstructor(node) { - return checkAnyParsedSignature(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); + return checkAnySignatureDeclaration(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); } function checkConstructorTypeParameters(node) { if (node.typeParameters) { @@ -5379,6 +5852,11 @@ var ts; return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); } } + function checkDeleteExpression(node) { + if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 63 /* Identifier */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); + } + } function checkEnumDeclaration(enumDecl) { var enumIsConst = (enumDecl.flags & 4096 /* Const */) !== 0; var hasError = false; @@ -5386,7 +5864,10 @@ var ts; var inConstantEnumMemberSection = true; for (var i = 0, n = enumDecl.members.length; i < n; i++) { var node = enumDecl.members[i]; - if (inAmbientContext) { + if (node.name.kind === 121 /* ComputedPropertyName */) { + hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (inAmbientContext) { if (node.initializer && !isIntegerLiteral(node.initializer)) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; } @@ -5405,7 +5886,7 @@ var ts; function isInteger(literalExpression) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); } - if (expression.kind === 154 /* PrefixOperator */) { + if (expression.kind === 155 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 32 /* PlusToken */ || unaryExpression.operator === 33 /* MinusToken */) { expression = unaryExpression.operand; @@ -5421,6 +5902,11 @@ var ts; return grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } } + function checkExternalModuleReference(node) { + if (node.expression.kind !== 7 /* StringLiteral */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.String_literal_expected); + } + } function checkForInStatement(node) { return checkVariableDeclarations(node.declarations) || checkForMoreThanOneDeclaration(node.declarations); } @@ -5433,15 +5919,15 @@ var ts; } } function checkFunctionDeclaration(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); } function checkForGenerator(node) { if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.generators_are_not_currently_supported); + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_currently_supported); } } function checkFunctionExpression(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForGenerator(node); } function checkFunctionName(name) { if (name && name.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(name)) { @@ -5449,15 +5935,25 @@ var ts; } } function checkGetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } - function checkIndexedAccess(node) { - if (node.index.kind === 120 /* Missing */ && node.parent.kind === 148 /* NewExpression */ && node.parent.func === node) { - var start = ts.skipTrivia(sourceText, node.parent.pos); - var end = node.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + function checkElementAccessExpression(node) { + if (!node.argumentExpression) { + if (node.parent.kind === 146 /* NewExpression */ && node.parent.expression === node) { + var start = ts.skipTrivia(sourceText, node.expression.end); + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.Expression_expected); + } } } + function checkHeritageClause(node) { + return checkForDisallowedTrailingComma(node.types) || checkForAtLeastOneHeritageClause(node.types, ts.tokenToString(node.token)); + } function checkIndexSignature(node) { return checkIndexSignatureParameters(node) || checkForIndexSignatureModifiers(node); } @@ -5476,14 +5972,14 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); } } - else if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + else if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); } else if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); @@ -5499,13 +5995,52 @@ var ts; } } function checkInterfaceDeclaration(node) { - return checkForDisallowedTrailingComma(node.baseTypes) || checkForAtLeastOneHeritageClause(node.baseTypes, "extends"); + return checkInterfaceDeclarationHeritageClauses(node); + } + function checkInterfaceDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 77 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 100 /* ImplementsKeyword */); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + } + } + return false; } function checkMethod(node) { - return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForGenerator(node); + if (checkAnySignatureDeclaration(node) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node)) { + return true; + } + if (node.parent.kind === 185 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + if (inAmbientContext) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + } + else if (!node.body) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); + } + } + else if (node.parent.kind === 186 /* InterfaceDeclaration */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); + } + else if (node.parent.kind === 136 /* TypeLiteral */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); + } } function checkForBodyInAmbientContext(body, isConstructor) { - if (inAmbientContext && body && body.kind === 187 /* FunctionBlock */) { + if (inAmbientContext && body && body.kind === 163 /* Block */) { var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; return grammarErrorOnFirstToken(body, diagnostic); } @@ -5519,20 +6054,20 @@ var ts; } } function checkModuleDeclarationStatements(node) { - if (node.name.kind === 63 /* Identifier */ && node.body.kind === 193 /* ModuleBlock */) { + if (node.name.kind === 63 /* Identifier */ && node.body.kind === 190 /* ModuleBlock */) { var statements = node.body.statements; for (var i = 0, n = statements.length; i < n; i++) { var statement = statements[i]; - if (statement.kind === 195 /* ExportAssignment */) { + if (statement.kind === 192 /* ExportAssignment */) { return grammarErrorOnNode(statement, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); } - else if (statement.kind === 194 /* ImportDeclaration */ && statement.externalModuleName) { - return grammarErrorOnNode(statement.externalModuleName, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + else if (ts.isExternalModuleImportDeclaration(statement)) { + return grammarErrorOnNode(ts.getExternalModuleImportDeclarationExpression(statement), ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } } } } - function checkObjectLiteral(node) { + function checkObjectLiteralExpression(node) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -5541,26 +6076,22 @@ var ts; var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var i = 0, n = node.properties.length; i < n; i++) { var prop = node.properties[i]; - if (prop.kind === 161 /* OmittedExpression */) { + var name = prop.name; + if (prop.kind === 161 /* OmittedExpression */ || name.kind === 121 /* ComputedPropertyName */) { continue; } - var p = prop; - var name = p.name; var currentKind; - if (p.kind === 143 /* PropertyAssignment */) { + if (prop.kind === 198 /* PropertyAssignment */ || prop.kind === 199 /* ShorthandPropertyAssignment */ || prop.kind === 125 /* Method */) { currentKind = Property; } - else if (p.kind === 144 /* ShorthandPropertyAssignment */) { - currentKind = Property; - } - else if (p.kind === 127 /* GetAccessor */) { + else if (prop.kind === 127 /* GetAccessor */) { currentKind = GetAccessor; } - else if (p.kind === 128 /* SetAccessor */) { + else if (prop.kind === 128 /* SetAccessor */) { currentKind = SetAccesor; } else { - ts.Debug.fail("Unexpected syntax kind:" + p.kind); + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } if (!ts.hasProperty(seen, name.text)) { seen[name.text] = currentKind; @@ -5604,15 +6135,15 @@ var ts; case 124 /* Property */: case 125 /* Method */: case 131 /* IndexSignature */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 195 /* ExportAssignment */: - case 163 /* VariableStatement */: - case 186 /* FunctionDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 194 /* ImportDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 189 /* ModuleDeclaration */: + case 188 /* EnumDeclaration */: + case 192 /* ExportAssignment */: + case 164 /* VariableStatement */: + case 184 /* FunctionDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 191 /* ImportDeclaration */: case 123 /* Parameter */: break; default: @@ -5647,7 +6178,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 190 /* ModuleBlock */ || node.parent.kind === 201 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= modifierToFlag(modifier.kind); @@ -5656,7 +6187,7 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 190 /* ModuleBlock */ || node.parent.kind === 201 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } else if (node.kind === 123 /* Parameter */) { @@ -5672,7 +6203,7 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 123 /* Parameter */) { @@ -5684,13 +6215,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 123 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (inAmbientContext && node.parent.kind === 193 /* ModuleBlock */) { + else if (inAmbientContext && node.parent.kind === 190 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -5709,10 +6240,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if (node.kind === 194 /* ImportDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 191 /* ImportDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 189 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 186 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } } @@ -5739,20 +6270,20 @@ var ts; var parameterCount = parameters.length; for (var i = 0; i < parameterCount; i++) { var parameter = parameters[i]; - if (parameter.flags & 8 /* Rest */) { + if (parameter.dotDotDotToken) { if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); } if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.flags & 4 /* QuestionMark */ || parameter.initializer) { + else if (parameter.questionToken || parameter.initializer) { seenOptionalParameter = true; - if (parameter.flags & 4 /* QuestionMark */ && parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -5763,23 +6294,49 @@ var ts; } } } - function checkPostfixOperator(node) { + function checkPostfixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } } - function checkPrefixOperator(node) { + function checkPrefixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */) { if ((node.operator === 37 /* PlusPlusToken */ || node.operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } - else if (node.operator === 72 /* DeleteKeyword */ && node.operand.kind === 63 /* Identifier */) { - return grammarErrorOnNode(node.operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } } } function checkProperty(node) { - return (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node); + if (node.parent.kind === 185 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { + return true; + } + } + else if (node.parent.kind === 186 /* InterfaceDeclaration */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { + return true; + } + } + else if (node.parent.kind === 136 /* TypeLiteral */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { + return true; + } + } + return checkForInitializerInAmbientContext(node); + } + function checkComputedPropertyName(node) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_not_currently_supported); + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + else if (node.expression.kind === 157 /* BinaryExpression */ && node.expression.operator === 22 /* CommaToken */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkForDisallowedComputedProperty(node, message) { + if (node.kind === 121 /* ComputedPropertyName */) { + return grammarErrorOnNode(node, message); + } } function checkForInitializerInAmbientContext(node) { if (inAmbientContext && node.initializer) { @@ -5787,12 +6344,11 @@ var ts; } } function checkPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } - function checkForInvalidQuestionMark(node, message) { - if (node.flags & 4 /* QuestionMark */) { - var pos = ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(pos, "?".length, message); + function checkForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); } } function checkReturnStatement(node) { @@ -5801,7 +6357,7 @@ var ts; } } function checkSetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } function checkAccessor(accessor) { var kind = accessor.kind; @@ -5829,14 +6385,14 @@ var ts; } else { var parameter = accessor.parameters[0]; - if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); } else if (parameter.initializer) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); @@ -5850,7 +6406,7 @@ var ts; function checkTopLevelElementsForRequiredDeclareModifier(file) { for (var i = 0, n = file.statements.length; i < n; i++) { var decl = file.statements[i]; - if (isDeclaration(decl) || decl.kind === 163 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 164 /* VariableStatement */) { if (checkTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -5858,19 +6414,19 @@ var ts; } } function checkTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 194 /* ImportDeclaration */ || node.kind === 195 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { + if (node.kind === 186 /* InterfaceDeclaration */ || node.kind === 191 /* ImportDeclaration */ || node.kind === 192 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); } function checkShorthandPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } function checkSwitchStatement(node) { var firstDefaultClause; for (var i = 0, n = node.clauses.length; i < n; i++) { var clause = node.clauses[i]; - if (clause.kind === 177 /* DefaultClause */) { + if (clause.kind === 195 /* DefaultClause */) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -5887,6 +6443,11 @@ var ts; return grammarErrorOnFirstToken(node.template, ts.Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); } } + function checkThrowStatement(node) { + if (node.expression === undefined) { + return grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } function checkTupleType(node) { return checkForDisallowedTrailingComma(node.elementTypes) || checkForAtLeastOneType(node); } @@ -5908,7 +6469,7 @@ var ts; var equalsPos = node.type ? ts.skipTrivia(sourceText, node.type.end) : ts.skipTrivia(sourceText, node.name.end); return grammarErrorAtPos(equalsPos, "=".length, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!inAmbientContext && !node.initializer && isConst(node)) { + if (!inAmbientContext && !node.initializer && ts.isConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { @@ -5925,10 +6486,10 @@ var ts; } var decl = declarations[0]; if (languageVersion < 2 /* ES6 */) { - if (isLet(decl)) { + if (ts.isLet(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } - else if (isConst(decl)) { + else if (ts.isConst(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } } @@ -5939,24 +6500,24 @@ var ts; } function checkForDisallowedLetOrConstStatement(node) { if (!allowLetAndConstDeclarations(node.parent)) { - if (isLet(node)) { + if (ts.isLet(node)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (isConst(node)) { + else if (ts.isConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 175 /* WithStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: return false; - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -5982,7 +6543,7 @@ var ts; var commonSourceDirectory; ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { - processRootFile(host.getDefaultLibFilename(), true); + processRootFile(host.getDefaultLibFilename(options), true); } verifyCompilerOptions(); errors.sort(ts.compareDiagnostics); @@ -6020,7 +6581,7 @@ var ts; } var diagnostic; if (hasExtension(filename)) { - if (!ts.fileExtensionIs(filename, ".ts")) { + if (!options.allowNonTsExtensions && !ts.fileExtensionIs(filename, ".ts")) { diagnostic = ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts; } else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { @@ -6098,8 +6659,8 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchPath = basePath; @@ -6116,10 +6677,10 @@ var ts; } } } - else if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { + else if (node.kind === 189 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { forEachChild(node.body, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); @@ -6146,9 +6707,9 @@ var ts; } return; } - var firstExternalModule = ts.forEach(files, function (f) { return isExternalModule(f) ? f : undefined; }); + var firstExternalModule = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModule && options.module === 0 /* None */) { - var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator); + var externalModuleErrorSpan = ts.getErrorSpanForNode(firstExternalModule.externalModuleIndicator); var errorStart = ts.skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos); var errorLength = externalModuleErrorSpan.end - errorStart; errors.push(ts.createFileDiagnostic(firstExternalModule, errorStart, errorLength, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); @@ -6191,16 +6752,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 186 /* InterfaceDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if (node.kind === 194 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { + else if (node.kind === 191 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 193 /* ModuleBlock */) { + else if (node.kind === 190 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -6216,7 +6777,7 @@ var ts; }); return state; } - else if (node.kind === 192 /* ModuleDeclaration */) { + else if (node.kind === 189 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -6224,6 +6785,10 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + function hasComputedNameButNotSymbol(declaration) { + return declaration.name && declaration.name.kind === 121 /* ComputedPropertyName */; + } + ts.hasComputedNameButNotSymbol = hasComputedNameButNotSymbol; function bindSourceFile(file) { var parent; var container; @@ -6256,9 +6821,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 189 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { return '"' + node.name.text + '"'; } + ts.Debug.assert(!hasComputedNameButNotSymbol(node)); return node.name.text; } switch (node.kind) { @@ -6278,6 +6844,9 @@ var ts; return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); } function declareSymbol(symbols, parent, node, includes, excludes) { + if (hasComputedNameButNotSymbol(node)) { + return undefined; + } var name = getDeclarationName(node); if (name !== undefined) { var symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); @@ -6298,7 +6867,7 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if (node.kind === 188 /* ClassDeclaration */ && symbol.exports) { + if (node.kind === 185 /* ClassDeclaration */ && symbol.exports) { var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { @@ -6330,7 +6899,7 @@ var ts; if (symbolKind & 1536 /* Namespace */) { exportKind |= 16777216 /* ExportNamespace */; } - if (node.flags & 1 /* Export */ || (node.kind !== 194 /* ImportDeclaration */ && isAmbientContext(container))) { + if (node.flags & 1 /* Export */ || (node.kind !== 191 /* ImportDeclaration */ && isAmbientContext(container))) { if (exportKind) { var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); @@ -6371,10 +6940,10 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; @@ -6388,22 +6957,22 @@ var ts; case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } case 136 /* TypeLiteral */: - case 142 /* ObjectLiteral */: - case 189 /* InterfaceDeclaration */: + case 142 /* ObjectLiteralExpression */: + case 186 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -6453,7 +7022,7 @@ var ts; bindChildren(node, symbolKind, isBlockScopeContainer); } function bindCatchVariableDeclaration(node) { - var symbol = createSymbol(1 /* FunctionScopedVariable */, node.variable.text || "__missing"); + var symbol = createSymbol(1 /* FunctionScopedVariable */, node.name.text || "__missing"); addDeclarationToSymbol(symbol, node, 1 /* FunctionScopedVariable */); var saveParent = parent; var savedBlockScopeContainer = blockScopeContainer; @@ -6464,10 +7033,10 @@ var ts; } function bindBlockScopedVariableDeclaration(node) { switch (blockScopeContainer.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; @@ -6489,7 +7058,7 @@ var ts; case 123 /* Parameter */: bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); break; - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: if (node.flags & 6144 /* BlockScoped */) { bindBlockScopedVariableDeclaration(node); } @@ -6498,11 +7067,11 @@ var ts; } break; case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 196 /* EnumMember */: + case 200 /* EnumMember */: bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; case 129 /* CallSignature */: @@ -6512,12 +7081,12 @@ var ts; bindDeclaration(node, 262144 /* ConstructSignature */, 0, true); break; case 125 /* Method */: - bindDeclaration(node, 8192 /* Method */, 99263 /* MethodExcludes */, true); + bindDeclaration(node, 8192 /* Method */, ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */, true); break; case 131 /* IndexSignature */: bindDeclaration(node, 524288 /* IndexSignature */, 0, false); break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; case 126 /* Constructor */: @@ -6536,26 +7105,26 @@ var ts; case 136 /* TypeLiteral */: bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 142 /* ObjectLiteral */: + case 142 /* ObjectLiteralExpression */: bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 182 /* CatchBlock */: + case 197 /* CatchClause */: bindCatchVariableDeclaration(node); break; - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false); break; - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false); break; - case 190 /* TypeAliasDeclaration */: + case 187 /* TypeAliasDeclaration */: bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: if (ts.isConst(node)) { bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false); } @@ -6563,24 +7132,24 @@ var ts; bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false); } break; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false); break; - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); break; } - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 175 /* SwitchStatement */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 176 /* SwitchStatement */: bindChildren(node, 0, true); break; default: @@ -6775,19 +7344,33 @@ var ts; var firstAccessor; var getAccessor; var setAccessor; - ts.forEach(node.members, function (member) { - if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 127 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 128 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } + if (accessor.name.kind === 121 /* ComputedPropertyName */) { + firstAccessor = accessor; + if (accessor.kind === 127 /* GetAccessor */) { + getAccessor = accessor; } - }); + else if (accessor.kind === 128 /* SetAccessor */) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(node.members, function (member) { + if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if (!firstAccessor) { + firstAccessor = member; + } + if (member.kind === 127 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 128 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + }); + } return { firstAccessor: firstAccessor, getAccessor: getAccessor, @@ -6889,14 +7472,14 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } - function writeTypeAtLocation(location, type, getSymbolAccessibilityDiagnostic) { + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); if (type) { emitType(type); } else { - resolver.writeTypeAtLocation(location, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -6934,7 +7517,7 @@ var ts; emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); } } - function emitTypeWithNewGetSymbolAccessibilityDiangostic(type, getSymbolAccessibilityDiagnostic) { + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; emitType(type); } @@ -6957,7 +7540,7 @@ var ts; return emitTupleType(type); case 139 /* UnionType */: return emitUnionType(type); - case 140 /* ParenType */: + case 140 /* ParenthesizedType */: return emitParenType(type); case 133 /* FunctionType */: case 134 /* ConstructorType */: @@ -6966,13 +7549,13 @@ var ts; return emitTypeLiteral(type); case 63 /* Identifier */: return emitEntityName(type); - case 121 /* QualifiedName */: + case 120 /* QualifiedName */: return emitEntityName(type); default: ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 194 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 191 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -7043,7 +7626,7 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.kind !== 189 /* InterfaceDeclaration */) { + if (node.kind !== 186 /* InterfaceDeclaration */) { write("declare "); } } @@ -7079,13 +7662,13 @@ var ts; write("import "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - if (node.entityName) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.entityName, getImportEntityNameVisibilityError); + if (ts.isInternalModuleImportDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); write(";"); } else { write("require("); - writeTextOfNode(currentSourceFile, node.externalModuleName); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportDeclarationExpression(node)); write(");"); } writer.writeLine(); @@ -7103,7 +7686,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 193 /* ModuleBlock */) { + while (node.body.kind !== 190 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -7127,7 +7710,7 @@ var ts; write("type "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.type, getTypeAliasDeclarationVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); } @@ -7181,16 +7764,16 @@ var ts; emitType(node.constraint); } else { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.constraint, getTypeParameterConstraintVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 130 /* ConstructSignature */: @@ -7203,14 +7786,14 @@ var ts; if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7235,10 +7818,10 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node, getHeritageClauseVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.kind === 188 /* ClassDeclaration */) { + if (node.parent.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } else { @@ -7247,7 +7830,7 @@ var ts; return { diagnosticMessage: diagnosticMessage, errorNode: node, - typeName: node.parent.name + typeName: node.parent.parent.name }; } } @@ -7270,10 +7853,11 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - if (node.baseType) { - emitHeritageClause([node.baseType], false); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } - emitHeritageClause(node.implementedTypes, true); + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); write(" {"); writeLine(); increaseIndent(); @@ -7294,7 +7878,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(node.baseTypes, false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); write(" {"); writeLine(); increaseIndent(); @@ -7313,28 +7897,28 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 185 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 183 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { writeTextOfNode(currentSourceFile, node.name); - if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + if (node.kind === 124 /* Property */ && ts.hasQuestionToken(node)) { write("?"); } if (node.kind === 124 /* Property */ && node.parent.kind === 136 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getVariableDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 185 /* VariableDeclaration */) { + if (node.kind === 183 /* VariableDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } else if (node.kind === 124 /* Property */) { if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { @@ -7390,7 +7974,7 @@ var ts; accessorWithTypeAnnotation = anotherAccessor; } } - writeTypeAtLocation(node, type, getAccessorDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); } write(";"); writeLine(); @@ -7431,15 +8015,15 @@ var ts; } } function emitFunctionDeclaration(node) { - if ((node.kind !== 186 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + if ((node.kind !== 184 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 184 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 125 /* Method */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 184 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } @@ -7448,7 +8032,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, node.name); - if (node.flags & 4 /* QuestionMark */) { + if (ts.hasQuestionToken(node)) { write("?"); } } @@ -7510,14 +8094,14 @@ var ts; if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: @@ -7532,11 +8116,11 @@ var ts; function emitParameterDeclaration(node) { increaseIndent(); emitJsDocComments(node); - if (node.flags & 8 /* Rest */) { + if (node.dotDotDotToken) { write("..."); } writeTextOfNode(currentSourceFile, node.name); - if (node.initializer || (node.flags & 4 /* QuestionMark */)) { + if (node.initializer || ts.hasQuestionToken(node)) { write("?"); } decreaseIndent(); @@ -7544,7 +8128,7 @@ var ts; emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getParameterDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; @@ -7562,14 +8146,14 @@ var ts; if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7585,7 +8169,7 @@ var ts; function emitNode(node) { switch (node.kind) { case 126 /* Constructor */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: return emitFunctionDeclaration(node); case 130 /* ConstructSignature */: @@ -7595,27 +8179,27 @@ var ts; case 127 /* GetAccessor */: case 128 /* SetAccessor */: return emitAccessorDeclaration(node); - case 163 /* VariableStatement */: + case 164 /* VariableStatement */: return emitVariableStatement(node); case 124 /* Property */: return emitPropertyDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return emitClassDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 187 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 196 /* EnumMember */: + case 200 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: return emitImportDeclaration(node); - case 195 /* ExportAssignment */: + case 192 /* ExportAssignment */: return emitExportAssignment(node); - case 197 /* SourceFile */: + case 201 /* SourceFile */: return emitSourceFile(node); } } @@ -7842,7 +8426,7 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */) { + else if (node.kind === 184 /* FunctionDeclaration */ || node.kind === 150 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 189 /* ModuleDeclaration */ || node.kind === 185 /* ClassDeclaration */ || node.kind === 188 /* EnumDeclaration */) { if (node.name) { scopeName = node.name.text; } @@ -7924,7 +8508,7 @@ var ts; } function emitNodeWithMap(node) { if (node) { - if (node.kind != 197 /* SourceFile */) { + if (node.kind != 201 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNode(node); recordEmitNodeEndSpan(node); @@ -8010,11 +8594,23 @@ var ts; emit(nodes[i]); } } + function isBinaryOrOctalIntegerLiteral(text) { + if (text.length <= 0) { + return false; + } + if (text.charCodeAt(1) === 66 /* B */ || text.charCodeAt(1) === 98 /* b */ || text.charCodeAt(1) === 79 /* O */ || text.charCodeAt(1) === 111 /* o */) { + return true; + } + return false; + } function emitLiteral(node) { var text = getLiteralText(); if (compilerOptions.sourceMap && (node.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } + else if (compilerOptions.target < 2 /* ES6 */ && node.kind === 6 /* NumericLiteral */ && isBinaryOrOctalIntegerLiteral(text)) { + write(node.text); + } else { write(text); } @@ -8033,14 +8629,14 @@ var ts; ts.forEachChild(node, emit); return; } - ts.Debug.assert(node.parent.kind !== 149 /* TaggedTemplateExpression */); + ts.Debug.assert(node.parent.kind !== 147 /* TaggedTemplateExpression */); var emitOuterParens = ts.isExpression(node.parent) && templateNeedsParens(node, node.parent); if (emitOuterParens) { write("("); } emitLiteral(node.head); ts.forEach(node.templateSpans, function (templateSpan) { - var needsParens = templateSpan.expression.kind !== 151 /* ParenExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + var needsParens = templateSpan.expression.kind !== 149 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; write(" + "); if (needsParens) { write("("); @@ -8059,12 +8655,12 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.func === template; - case 151 /* ParenExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + return parent.expression === template; + case 149 /* ParenthesizedExpression */: return false; - case 149 /* TaggedTemplateExpression */: + case 147 /* TaggedTemplateExpression */: ts.Debug.fail("Path should be unreachable; tagged templates not supported pre-ES6."); default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -8073,7 +8669,7 @@ var ts; function comparePrecedenceToBinaryPlus(expression) { ts.Debug.assert(compilerOptions.target <= 1 /* ES5 */); switch (expression.kind) { - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: switch (expression.operator) { case 34 /* AsteriskToken */: case 35 /* SlashToken */: @@ -8084,7 +8680,7 @@ var ts; default: return -1 /* LessThan */; } - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -8099,6 +8695,9 @@ var ts; if (node.kind === 7 /* StringLiteral */) { emitLiteral(node); } + else if (node.kind === 121 /* ComputedPropertyName */) { + emit(node.expression); + } else { write("\""); if (node.kind === 6 /* NumericLiteral */) { @@ -8114,30 +8713,30 @@ var ts; var parent = node.parent; switch (parent.kind) { case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: + case 200 /* EnumMember */: case 125 /* Method */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 150 /* FunctionExpression */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: + case 189 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: return parent.name === node; - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 195 /* ExportAssignment */: + case 173 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 192 /* ExportAssignment */: return false; - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return node.parent.label === node; - case 182 /* CatchBlock */: - return node.parent.variable === node; + case 197 /* CatchClause */: + return node.parent.name === node; } } function emitExpressionIdentifier(node) { @@ -8209,6 +8808,31 @@ var ts; write(" }"); } } + function emitComputedPropertyName(node) { + write("["); + emit(node.expression); + write("]"); + } + function emitDownlevelMethod(node) { + if (!ts.isObjectLiteralMethod(node)) { + return; + } + emitLeadingComments(node); + emit(node.name); + write(": "); + write("function "); + emitSignatureAndBody(node); + emitTrailingComments(node); + } + function emitMethod(node) { + if (!ts.isObjectLiteralMethod(node)) { + return; + } + emitLeadingComments(node); + emit(node.name); + emitSignatureAndBody(node); + emitTrailingComments(node); + } function emitPropertyAssignment(node) { emitLeadingComments(node); emit(node.name); @@ -8216,33 +8840,28 @@ var ts; emit(node.initializer); emitTrailingComments(node); } - function emitShortHandPropertyAssignment(node) { - function emitAsNormalPropertyAssignment() { + function emitDownlevelShorthandPropertyAssignment(node) { + emitLeadingComments(node); + emit(node.name); + write(": "); + emitExpressionIdentifier(node.name); + emitTrailingComments(node); + } + function emitShorthandPropertyAssignment(node) { + var prefix = resolver.getExpressionNamePrefix(node.name); + if (prefix) { + emitDownlevelShorthandPropertyAssignment(node); + } + else { emitLeadingComments(node); emit(node.name); - write(": "); - emitExpressionIdentifier(node.name); emitTrailingComments(node); } - if (compilerOptions.target < 2 /* ES6 */) { - emitAsNormalPropertyAssignment(); - } - else if (compilerOptions.target >= 2 /* ES6 */) { - var prefix = resolver.getExpressionNamePrefix(node.name); - if (prefix) { - emitAsNormalPropertyAssignment(); - } - else { - emitLeadingComments(node); - emit(node.name); - emitTrailingComments(node); - } - } } function tryEmitConstantValue(node) { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - var propertyName = node.kind === 145 /* PropertyAccess */ ? ts.declarationNameToString(node.right) : ts.getTextOfNode(node.index); + var propertyName = node.kind === 143 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(constantValue.toString() + " /* " + propertyName + " */"); return true; } @@ -8252,6 +8871,11 @@ var ts; if (tryEmitConstantValue(node)) { return; } + emit(node.expression); + write("."); + emit(node.name); + } + function emitQualifiedName(node) { emit(node.left); write("."); emit(node.right); @@ -8260,24 +8884,24 @@ var ts; if (tryEmitConstantValue(node)) { return; } - emit(node.object); + emit(node.expression); write("["); - emit(node.index); + emit(node.argumentExpression); write("]"); } function emitCallExpression(node) { var superCall = false; - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 89 /* SuperKeyword */) { write("_super"); superCall = true; } else { - emit(node.func); - superCall = node.func.kind === 145 /* PropertyAccess */ && node.func.left.kind === 89 /* SuperKeyword */; + emit(node.expression); + superCall = node.expression.kind === 143 /* PropertyAccessExpression */ && node.expression.expression.kind === 89 /* SuperKeyword */; } if (superCall) { write(".call("); - emitThis(node.func); + emitThis(node.expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments, false); @@ -8292,7 +8916,7 @@ var ts; } function emitNewExpression(node) { write("new "); - emit(node.func); + emit(node.expression); if (node.arguments) { write("("); emitCommaList(node.arguments, false); @@ -8306,12 +8930,12 @@ var ts; emit(node.template); } function emitParenExpression(node) { - if (node.expression.kind === 150 /* TypeAssertion */) { - var operand = node.expression.operand; - while (operand.kind == 150 /* TypeAssertion */) { - operand = operand.operand; + if (node.expression.kind === 148 /* TypeAssertionExpression */) { + var operand = node.expression.expression; + while (operand.kind == 148 /* TypeAssertionExpression */) { + operand = operand.expression; } - if (operand.kind !== 154 /* PrefixOperator */ && operand.kind !== 155 /* PostfixOperator */ && operand.kind !== 148 /* NewExpression */ && !(operand.kind === 147 /* CallExpression */ && node.parent.kind === 148 /* NewExpression */) && !(operand.kind === 152 /* FunctionExpression */ && node.parent.kind === 147 /* CallExpression */)) { + if (operand.kind !== 155 /* PrefixUnaryExpression */ && operand.kind !== 154 /* VoidExpression */ && operand.kind !== 153 /* TypeOfExpression */ && operand.kind !== 152 /* DeleteExpression */ && operand.kind !== 156 /* PostfixUnaryExpression */ && operand.kind !== 146 /* NewExpression */ && !(operand.kind === 145 /* CallExpression */ && node.parent.kind === 146 /* NewExpression */) && !(operand.kind === 150 /* FunctionExpression */ && node.parent.kind === 145 /* CallExpression */)) { emit(operand); return; } @@ -8320,14 +8944,24 @@ var ts; emit(node.expression); write(")"); } - function emitUnaryExpression(node) { - if (node.kind === 154 /* PrefixOperator */) { - write(ts.tokenToString(node.operator)); - } - if (node.operator >= 63 /* Identifier */) { - write(" "); - } - else if (node.kind === 154 /* PrefixOperator */ && node.operand.kind === 154 /* PrefixOperator */) { + function emitDeleteExpression(node) { + write(ts.tokenToString(72 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(97 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(95 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function emitPrefixUnaryExpression(node) { + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 155 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 32 /* PlusToken */ && (operand.operator === 32 /* PlusToken */ || operand.operator === 37 /* PlusPlusToken */)) { write(" "); @@ -8337,9 +8971,10 @@ var ts; } } emit(node.operand); - if (node.kind === 155 /* PostfixOperator */) { - write(ts.tokenToString(node.operator)); - } + } + function emitPostfixUnaryExpression(node) { + emit(node.operand); + write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { emit(node.left); @@ -8360,8 +8995,8 @@ var ts; emitToken(13 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 193 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 192 /* ModuleDeclaration */); + if (node.kind === 190 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 189 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); @@ -8371,7 +9006,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 162 /* Block */) { + if (node.kind === 163 /* Block */) { write(" "); emit(node); } @@ -8383,7 +9018,7 @@ var ts; } } function emitExpressionStatement(node) { - var isArrowExpression = node.expression.kind === 153 /* ArrowFunction */; + var isArrowExpression = node.expression.kind === 151 /* ArrowFunction */; emitLeadingComments(node); if (isArrowExpression) write("("); @@ -8404,7 +9039,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(74 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 166 /* IfStatement */) { + if (node.elseStatement.kind === 167 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -8417,7 +9052,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 162 /* Block */) { + if (node.statement.kind === 163 /* Block */) { write(" "); } else { @@ -8486,7 +9121,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 173 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -8521,7 +9156,7 @@ var ts; return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 176 /* CaseClause */) { + if (node.kind === 194 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -8547,22 +9182,22 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchBlock); + emit(node.catchClause); if (node.finallyBlock) { writeLine(); write("finally "); emit(node.finallyBlock); } } - function emitCatchBlock(node) { + function emitCatchClause(node) { writeLine(); var endPos = emitToken(66 /* CatchKeyword */, node.pos); write(" "); emitToken(15 /* OpenParenToken */, endPos); - emit(node.variable); - emitToken(16 /* CloseParenToken */, node.variable.end); + emit(node.name); + emitToken(16 /* CloseParenToken */, node.name.end); write(" "); - emitBlock(node); + emitBlock(node.block); } function emitDebuggerStatement(node) { emitToken(70 /* DebuggerKeyword */, node.pos); @@ -8576,7 +9211,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 192 /* ModuleDeclaration */); + } while (node && node.kind !== 189 /* ModuleDeclaration */); return node; } function emitModuleMemberName(node) { @@ -8688,7 +9323,7 @@ var ts; emitLeadingComments(node); } write("function "); - if (node.kind === 186 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) { + if (node.kind === 184 /* FunctionDeclaration */ || (node.kind === 150 /* FunctionExpression */ && node.name)) { emit(node.name); } emitSignatureAndBody(node); @@ -8718,16 +9353,16 @@ var ts; write(" {"); scopeEmitStart(node); increaseIndent(); - emitDetachedComments(node.body.kind === 187 /* FunctionBlock */ ? node.body.statements : node.body); + emitDetachedComments(node.body.kind === 163 /* Block */ ? node.body.statements : node.body); var startIndex = 0; - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 163 /* Block */) { startIndex = emitDirectivePrologues(node.body.statements, true); } var outPos = writer.getTextPos(); emitCaptureThisForNodeIfNecessary(node); emitDefaultValueAssignments(node); emitRestParameter(node); - if (node.body.kind !== 187 /* FunctionBlock */ && outPos === writer.getTextPos()) { + if (node.body.kind !== 163 /* Block */ && outPos === writer.getTextPos()) { decreaseIndent(); write(" "); emitStart(node.body); @@ -8740,7 +9375,7 @@ var ts; emitEnd(node.body); } else { - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 163 /* Block */) { emitLinesStartingAt(node.body.statements, startIndex); } else { @@ -8752,7 +9387,7 @@ var ts; emitTrailingComments(node.body); } writeLine(); - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 163 /* Block */) { emitLeadingCommentsOfPosition(node.body.statements.end); decreaseIndent(); emitToken(14 /* CloseBraceToken */, node.body.statements.end); @@ -8778,10 +9413,10 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 165 /* ExpressionStatement */) { + if (statement && statement.kind === 166 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 147 /* CallExpression */) { - var func = expr.func; + if (expr && expr.kind === 145 /* CallExpression */) { + var func = expr.expression; if (func && func.kind === 89 /* SuperKeyword */) { return statement; } @@ -8805,12 +9440,15 @@ var ts; } }); } - function emitMemberAccess(memberName) { + function emitMemberAccessForPropertyName(memberName) { if (memberName.kind === 7 /* StringLiteral */ || memberName.kind === 6 /* NumericLiteral */) { write("["); emitNode(memberName); write("]"); } + else if (memberName.kind === 121 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } else { write("."); emitNode(memberName); @@ -8829,7 +9467,7 @@ var ts; else { write("this"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emit(member.initializer); @@ -8853,7 +9491,7 @@ var ts; if (!(member.flags & 128 /* Static */)) { write(".prototype"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emitStart(member); @@ -8918,19 +9556,20 @@ var ts; write("var "); emit(node.name); write(" = (function ("); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { write("_super"); } write(") {"); increaseIndent(); scopeEmitStart(node); - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("__extends("); emit(node.name); write(", _super);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } writeLine(); emitConstructorOfClass(); @@ -8949,8 +9588,8 @@ var ts; scopeEmitEnd(); emitStart(node); write(")("); - if (node.baseType) { - emit(node.baseType.typeName); + if (baseTypeNode) { + emit(baseTypeNode.typeName); } write(");"); emitEnd(node); @@ -8988,7 +9627,7 @@ var ts; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); - if (node.baseType) { + if (baseTypeNode) { var superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); @@ -8998,11 +9637,11 @@ var ts; emitParameterPropertyAssignments(ctor); } else { - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("_super.apply(this, arguments);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } } emitMemberAssignments(node, 0); @@ -9098,7 +9737,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 189 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -9121,7 +9760,7 @@ var ts; write(resolver.getLocalNameOfContainer(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 193 /* ModuleBlock */) { + if (node.body.kind === 190 /* ModuleBlock */) { emit(node.body); } else { @@ -9155,7 +9794,7 @@ var ts; emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); } if (emitImportDeclaration) { - if (node.externalModuleName && node.parent.kind === 197 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { + if (ts.isExternalModuleImportDeclaration(node) && node.parent.kind === 201 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { if (node.flags & 1 /* Export */) { writeLine(); emitLeadingComments(node); @@ -9176,15 +9815,16 @@ var ts; write("var "); emitModuleMemberName(node); write(" = "); - if (node.entityName) { - emit(node.entityName); + if (ts.isInternalModuleImportDeclaration(node)) { + emit(node.moduleReference); } else { + var literal = ts.getExternalModuleImportDeclarationExpression(node); write("require("); - emitStart(node.externalModuleName); - emitLiteral(node.externalModuleName); - emitEnd(node.externalModuleName); - emitToken(16 /* CloseParenToken */, node.externalModuleName.end); + emitStart(literal); + emitLiteral(literal); + emitEnd(literal); + emitToken(16 /* CloseParenToken */, literal.end); } write(";"); emitEnd(node); @@ -9194,16 +9834,16 @@ var ts; } function getExternalImportDeclarations(node) { var result = []; - ts.forEach(node.statements, function (stat) { - if (stat.kind === 194 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { - result.push(stat); + ts.forEach(node.statements, function (statement) { + if (ts.isExternalModuleImportDeclaration(statement) && resolver.isReferencedImportDeclaration(statement)) { + result.push(statement); } }); return result; } function getFirstExportAssignment(sourceFile) { return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 192 /* ExportAssignment */) { return node; } }); @@ -9218,7 +9858,7 @@ var ts; write("[\"require\", \"exports\""); ts.forEach(imports, function (imp) { write(", "); - emitLiteral(imp.externalModuleName); + emitLiteral(ts.getExternalModuleImportDeclarationExpression(imp)); }); ts.forEach(node.amdDependencies, function (amdDependency) { var text = "\"" + amdDependency + "\""; @@ -9314,6 +9954,7 @@ var ts; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); } + emitLeadingComments(node.endOfFileToken); } function emitNode(node) { if (!node) { @@ -9348,106 +9989,129 @@ var ts; case 11 /* TemplateMiddle */: case 12 /* TemplateTail */: return emitLiteral(node); - case 158 /* TemplateExpression */: + case 159 /* TemplateExpression */: return emitTemplateExpression(node); - case 159 /* TemplateSpan */: + case 162 /* TemplateSpan */: return emitTemplateSpan(node); - case 121 /* QualifiedName */: - return emitPropertyAccess(node); - case 141 /* ArrayLiteral */: + case 120 /* QualifiedName */: + return emitQualifiedName(node); + case 141 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 142 /* ObjectLiteral */: + case 142 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 143 /* PropertyAssignment */: + case 198 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 144 /* ShorthandPropertyAssignment */: - return emitShortHandPropertyAssignment(node); - case 145 /* PropertyAccess */: + case 121 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 143 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 146 /* IndexedAccess */: + case 144 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 147 /* CallExpression */: + case 145 /* CallExpression */: return emitCallExpression(node); - case 148 /* NewExpression */: + case 146 /* NewExpression */: return emitNewExpression(node); - case 149 /* TaggedTemplateExpression */: + case 147 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: - return emit(node.operand); - case 151 /* ParenExpression */: + case 148 /* TypeAssertionExpression */: + return emit(node.expression); + case 149 /* ParenthesizedExpression */: return emitParenExpression(node); - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return emitUnaryExpression(node); - case 156 /* BinaryExpression */: + case 152 /* DeleteExpression */: + return emitDeleteExpression(node); + case 153 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 154 /* VoidExpression */: + return emitVoidExpression(node); + case 155 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 156 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 157 /* BinaryExpression */: return emitBinaryExpression(node); - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return emitConditionalExpression(node); case 161 /* OmittedExpression */: return; - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: return emitBlock(node); - case 163 /* VariableStatement */: + case 164 /* VariableStatement */: return emitVariableStatement(node); - case 164 /* EmptyStatement */: + case 165 /* EmptyStatement */: return write(";"); - case 165 /* ExpressionStatement */: + case 166 /* ExpressionStatement */: return emitExpressionStatement(node); - case 166 /* IfStatement */: + case 167 /* IfStatement */: return emitIfStatement(node); - case 167 /* DoStatement */: + case 168 /* DoStatement */: return emitDoStatement(node); - case 168 /* WhileStatement */: + case 169 /* WhileStatement */: return emitWhileStatement(node); - case 169 /* ForStatement */: + case 170 /* ForStatement */: return emitForStatement(node); - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return emitForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 174 /* ReturnStatement */: return emitReturnStatement(node); - case 174 /* WithStatement */: + case 175 /* WithStatement */: return emitWithStatement(node); - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: return emitSwitchStatement(node); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return emitLabelledStatement(node); - case 179 /* ThrowStatement */: + case 178 /* ThrowStatement */: return emitThrowStatement(node); - case 180 /* TryStatement */: + case 179 /* TryStatement */: return emitTryStatement(node); - case 182 /* CatchBlock */: - return emitCatchBlock(node); - case 184 /* DebuggerStatement */: + case 197 /* CatchClause */: + return emitCatchClause(node); + case 182 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return emitClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: return emitImportDeclaration(node); - case 197 /* SourceFile */: + case 201 /* SourceFile */: return emitSourceFile(node); } + if (compilerOptions.target < 2 /* ES6 */) { + switch (node.kind) { + case 199 /* ShorthandPropertyAssignment */: + return emitDownlevelShorthandPropertyAssignment(node); + case 125 /* Method */: + return emitDownlevelMethod(node); + } + } + else { + ts.Debug.assert(compilerOptions.target >= 2 /* ES6 */, "Invalid ScriptTarget. We should emit as ES6 or above"); + switch (node.kind) { + case 199 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 125 /* Method */: + return emitMethod(node); + } + } } function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; @@ -9463,7 +10127,7 @@ var ts; return leadingComments; } function getLeadingCommentsToEmit(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 201 /* SourceFile */ || node.pos !== node.parent.pos) { var leadingComments; if (hasDetachedComments(node.pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -9480,7 +10144,7 @@ var ts; emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingDeclarationComments(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 201 /* SourceFile */ || node.end !== node.parent.end) { var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } @@ -9574,17 +10238,11 @@ var ts; writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } - var hasSemanticErrors = resolver.hasSemanticErrors(); - var isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); - function emitFile(jsFilePath, sourceFile) { - if (!isEmitBlocked) { - emitJavaScript(jsFilePath, sourceFile); - if (!hasSemanticErrors && compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); - } - } - } + var hasSemanticErrors = false; + var isEmitBlocked = false; if (targetSourceFile === undefined) { + hasSemanticErrors = resolver.hasSemanticErrors(); + isEmitBlocked = resolver.isEmitBlocked(); ts.forEach(program.getSourceFiles(), function (sourceFile) { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js"); @@ -9597,13 +10255,29 @@ var ts; } else { if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + hasSemanticErrors = resolver.hasSemanticErrors(targetSourceFile); + isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (!shouldEmitToOwnFile(sourceFile, compilerOptions)) { + hasSemanticErrors = hasSemanticErrors || resolver.hasSemanticErrors(sourceFile); + isEmitBlocked = isEmitBlocked || resolver.isEmitBlocked(sourceFile); + } + }); emitFile(compilerOptions.out); } } + function emitFile(jsFilePath, sourceFile) { + if (!isEmitBlocked) { + emitJavaScript(jsFilePath, sourceFile); + if (!hasSemanticErrors && compilerOptions.declaration) { + writeDeclarationFile(jsFilePath, sourceFile); + } + } + } diagnostics.sort(ts.compareDiagnostics); diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); var hasEmitterError = ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1 /* Error */; }); @@ -9636,44 +10310,6 @@ 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; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length == 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str += " "; }, - increaseIndent: function () { - }, - decreaseIndent: function () { - }, - clear: function () { return str = ""; }, - trackSymbol: function () { - } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; function createTypeChecker(program, fullTypeCheck) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -9694,9 +10330,7 @@ var ts; getDiagnostics: getDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - checkProgram: checkProgram, - getParentOfSymbol: getParentOfSymbol, - getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol, + getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -9704,9 +10338,9 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, - getSymbolInfo: getSymbolInfo, + getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeOfNode: getTypeOfNode, + getTypeAtLocation: getTypeAtLocation, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -9900,10 +10534,10 @@ var ts; return nodeLinks[node.id] || (nodeLinks[node.id] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 197 /* SourceFile */); + return ts.getAncestor(node, 201 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 197 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 201 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -9944,21 +10578,21 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) { break loop; } break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; case 124 /* Property */: - if (location.parent.kind === 188 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (location.parent.kind === 185 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -9967,8 +10601,8 @@ var ts; } } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -9981,14 +10615,14 @@ var ts; case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 152 /* FunctionExpression */: + case 150 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -9999,8 +10633,8 @@ var ts; break loop; } break; - case 182 /* CatchBlock */: - var id = location.variable; + case 197 /* CatchClause */: + var id = location.name; if (name === id.text) { result = location.symbol; break loop; @@ -10040,8 +10674,8 @@ var ts; var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; - var node = getDeclarationOfKind(symbol, 194 /* ImportDeclaration */); - var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node); + var node = ts.getDeclarationOfKind(symbol, 191 /* ImportDeclaration */); + var target = node.moduleReference.kind === 193 /* ExternalModuleReference */ ? resolveExternalModuleName(node, ts.getExternalModuleImportDeclarationExpression(node)) : getSymbolOfPartOfRightHandSideOfImport(node.moduleReference, node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -10056,17 +10690,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 194 /* ImportDeclaration */); + importDeclaration = ts.getAncestor(entityName, 191 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { + if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 120 /* QualifiedName */) { return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */); } else { - ts.Debug.assert(entityName.parent.kind === 194 /* ImportDeclaration */); + ts.Debug.assert(entityName.parent.kind === 191 /* ImportDeclaration */); return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */); } } @@ -10074,15 +10708,18 @@ var ts; return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } function resolveEntityName(location, name, meaning) { + if (ts.getFullWidth(name) === 0) { + return undefined; + } if (name.kind === 63 /* Identifier */) { var symbol = resolveName(location, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return; } } - else if (name.kind === 121 /* QualifiedName */) { + else if (name.kind === 120 /* QualifiedName */) { var namespace = resolveEntityName(location, name.left, 1536 /* Namespace */); - if (!namespace || namespace === unknownSymbol || name.right.kind === 120 /* Missing */) + if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) return; var symbol = getSymbol(namespace.exports, name.right.text, meaning); if (!symbol) { @@ -10090,18 +10727,19 @@ var ts; return; } } - else { - return; - } ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveImport(symbol); } function isExternalModuleNameRelative(moduleName) { return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } - function resolveExternalModuleName(location, moduleLiteral) { + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 7 /* StringLiteral */) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).filename); - var moduleName = moduleLiteral.text; + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); if (!moduleName) return; var isRelative = isExternalModuleNameRelative(moduleName); @@ -10125,10 +10763,10 @@ var ts; if (sourceFile.symbol) { return getResolvedExportSymbol(sourceFile.symbol); } - error(moduleLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); return; } - error(moduleLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } function getResolvedExportSymbol(moduleSymbol) { var symbol = getExportAssignmentSymbol(moduleSymbol); @@ -10171,9 +10809,9 @@ var ts; var seenExportedMember = false; var result = []; ts.forEach(symbol.declarations, function (declaration) { - var block = (declaration.kind === 197 /* SourceFile */ ? declaration : declaration.body); + var block = (declaration.kind === 201 /* SourceFile */ ? declaration : declaration.body); ts.forEach(block.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 192 /* ExportAssignment */) { result.push(node); } else { @@ -10269,7 +10907,7 @@ var ts; return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function isOptionalProperty(propertySymbol) { - return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; + return propertySymbol.valueDeclaration && ts.hasQuestionToken(propertySymbol.valueDeclaration) && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -10280,17 +10918,17 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location).members)) { return result; } @@ -10321,7 +10959,7 @@ var ts; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 33554432 /* Import */) { - if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 194 /* ImportDeclaration */ && declaration.externalModuleName; })) { + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportDeclaration)) { var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { return [symbolFromSymbolTable]; @@ -10403,7 +11041,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 192 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 197 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 189 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 201 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10413,7 +11051,7 @@ var ts; return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 194 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + if (declaration.kind === 191 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { if (!ts.contains(aliasesToMakeVisible, declaration)) { @@ -10435,7 +11073,7 @@ var ts; if (entityName.parent.kind === 135 /* TypeQuery */) { meaning = 107455 /* Value */ | 4194304 /* ExportValue */; } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 194 /* ImportDeclaration */) { + else if (entityName.kind === 120 /* QualifiedName */ || entityName.parent.kind === 191 /* ImportDeclaration */) { meaning = 1536 /* Namespace */; } else { @@ -10443,40 +11081,33 @@ var ts; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); - return hasVisibleDeclarations(symbol) || { + return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } function writeKeyword(writer, kind) { writer.writeKeyword(ts.tokenToString(kind)); } function writePunctuation(writer, kind) { writer.writePunctuation(ts.tokenToString(kind)); } - function writeOperator(writer, kind) { - writer.writeOperator(ts.tokenToString(kind)); - } function writeSpace(writer) { writer.writeSpace(" "); } function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); return result; } function typeToString(type, enclosingDeclaration, flags) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; if (maxLength && result.length >= maxLength) { result = result.substr(0, maxLength - "...".length) + "..."; @@ -10486,10 +11117,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 140 /* ParenType */) { + while (node.kind === 140 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 190 /* TypeAliasDeclaration */) { + if (node.kind === 187 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -10652,7 +11283,7 @@ var ts; function shouldWriteTypeOfFunctionSymbol() { if (type.symbol) { var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 197 /* SourceFile */ || declaration.parent.kind === 193 /* ModuleBlock */; })); + var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 201 /* SourceFile */ || declaration.parent.kind === 190 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type)); } @@ -10664,6 +11295,14 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */); } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { @@ -10712,7 +11351,7 @@ var ts; } if (resolved.stringIndexType) { writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeKeyword(writer, 118 /* StringKeyword */); @@ -10725,7 +11364,7 @@ var ts; } if (resolved.numberIndexType) { writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeKeyword(writer, 116 /* NumberKeyword */); @@ -10784,11 +11423,11 @@ var ts; } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, typeStack) { - if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { + if (ts.hasDotDotDotToken(p.valueDeclaration)) { writePunctuation(writer, 20 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); - if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { + if (ts.hasQuestionToken(p.valueDeclaration) || p.valueDeclaration.initializer) { writePunctuation(writer, 49 /* QuestionToken */); } writePunctuation(writer, 50 /* ColonToken */); @@ -10871,12 +11510,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 192 /* ModuleDeclaration */) { + if (node.kind === 189 /* ModuleDeclaration */) { if (node.name.kind === 7 /* StringLiteral */) { return node; } } - else if (node.kind === 197 /* SourceFile */) { + else if (node.kind === 201 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10905,12 +11544,12 @@ var ts; if (resolvedExportSymbol === symbol) { return true; } - return ts.forEach(resolvedExportSymbol.declarations, function (declaration) { - while (declaration) { - if (declaration === node) { + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { return true; } - declaration = declaration.parent; + current = current.parent; } }); } @@ -10918,20 +11557,22 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 185 /* VariableDeclaration */: - case 192 /* ModuleDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 186 /* FunctionDeclaration */: - case 191 /* EnumDeclaration */: - case 194 /* ImportDeclaration */: - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (!(node.flags & 1 /* Export */) && !(node.kind !== 194 /* ImportDeclaration */ && parent.kind !== 197 /* SourceFile */ && ts.isInAmbientContext(parent))) { + case 183 /* VariableDeclaration */: + case 189 /* ModuleDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 184 /* FunctionDeclaration */: + case 188 /* EnumDeclaration */: + case 191 /* ImportDeclaration */: + var parent = node.kind === 183 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (!(node.flags & 1 /* Export */) && !(node.kind !== 191 /* ImportDeclaration */ && parent.kind !== 201 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); } return isDeclarationVisible(parent); case 124 /* Property */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: case 125 /* Method */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { return false; @@ -10941,10 +11582,18 @@ var ts; case 129 /* CallSignature */: case 131 /* IndexSignature */: case 123 /* Parameter */: - case 193 /* ModuleBlock */: + case 190 /* ModuleBlock */: case 122 /* TypeParameter */: + case 133 /* FunctionType */: + case 134 /* ConstructorType */: + case 136 /* TypeLiteral */: + case 132 /* TypeReference */: + case 137 /* ArrayType */: + case 138 /* TupleType */: + case 139 /* UnionType */: + case 140 /* ParenthesizedType */: return isDeclarationVisible(node.parent); - case 197 /* SourceFile */: + case 201 /* SourceFile */: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -10962,8 +11611,8 @@ var ts; var classType = getDeclaredTypeOfSymbol(prototype.parent); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } - function getTypeOfVariableOrPropertyDeclaration(declaration) { - if (declaration.parent.kind === 170 /* ForInStatement */) { + function getTypeOfVariableOrParameterOrPropertyDeclaration(declaration) { + if (declaration.parent.kind === 171 /* ForInStatement */) { return anyType; } if (declaration.type) { @@ -10971,8 +11620,8 @@ var ts; } if (declaration.kind === 123 /* Parameter */) { var func = declaration.parent; - if (func.kind === 128 /* SetAccessor */) { - var getter = getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); + if (func.kind === 128 /* SetAccessor */ && !ts.hasComputedNameButNotSymbol(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10984,7 +11633,7 @@ var ts; } if (declaration.initializer) { var type = checkAndMarkExpression(declaration.initializer); - if (declaration.kind !== 143 /* PropertyAssignment */) { + if (declaration.kind !== 198 /* PropertyAssignment */) { var unwidenedType = type; type = getWidenedType(type); if (type !== unwidenedType) { @@ -10993,11 +11642,11 @@ var ts; } return type; } - if (declaration.kind === 144 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 199 /* ShorthandPropertyAssignment */) { var type = checkIdentifier(declaration.name); return type; } - var type = declaration.flags & 8 /* Rest */ ? createArrayType(anyType) : anyType; + var type = ts.hasDotDotDotToken(declaration) ? createArrayType(anyType) : anyType; checkImplicitAny(type); return type; function checkImplicitAny(type) { @@ -11015,7 +11664,7 @@ var ts; var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; case 123 /* Parameter */: - var diagnostic = declaration.flags & 8 /* Rest */ ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + var diagnostic = ts.hasDotDotDotToken(declaration) ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; default: var diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; @@ -11030,11 +11679,11 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.kind === 182 /* CatchBlock */) { + if (declaration.kind === 197 /* CatchClause */) { return links.type = anyType; } links.type = resolvingType; - var type = getTypeOfVariableOrPropertyDeclaration(declaration); + var type = getTypeOfVariableOrParameterOrPropertyDeclaration(declaration); if (links.type === resolvingType) { links.type = type; } @@ -11072,8 +11721,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); - var setter = getDeclarationOfKind(symbol, 128 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 128 /* SetAccessor */); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11103,7 +11752,7 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 127 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -11170,7 +11819,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 188 /* ClassDeclaration */) { + if (node.kind === 186 /* InterfaceDeclaration */ || node.kind === 185 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -11201,9 +11850,10 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = getDeclarationOfKind(symbol, 188 /* ClassDeclaration */); - if (declaration.baseType) { - var baseType = getTypeFromTypeReferenceNode(declaration.baseType); + var declaration = ts.getDeclarationOfKind(symbol, 185 /* ClassDeclaration */); + var baseTypeNode = ts.getClassBaseTypeNode(declaration); + if (baseTypeNode) { + var baseType = getTypeFromTypeReferenceNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024 /* Class */) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -11214,7 +11864,7 @@ var ts; } } else { - error(declaration.baseType, ts.Diagnostics.A_class_may_only_extend_another_class); + error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); } } } @@ -11241,8 +11891,8 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 189 /* InterfaceDeclaration */ && declaration.baseTypes) { - ts.forEach(declaration.baseTypes, function (node) { + if (declaration.kind === 186 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { @@ -11272,7 +11922,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 187 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -11280,7 +11930,7 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 187 /* TypeAliasDeclaration */); error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; @@ -11299,7 +11949,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -11714,7 +12364,7 @@ var ts; hasStringLiterals = true; } if (minArgumentCount < 0) { - if (param.initializer || param.flags & (4 /* QuestionMark */ | 8 /* Rest */)) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { minArgumentCount = i; } } @@ -11730,8 +12380,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 127 /* GetAccessor */) { - var setter = getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); + if (declaration.kind === 127 /* GetAccessor */ && !ts.hasComputedNameButNotSymbol(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && !declaration.body) { @@ -11751,7 +12401,7 @@ var ts; switch (node.kind) { case 133 /* FunctionType */: case 134 /* ConstructorType */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: case 126 /* Constructor */: case 129 /* CallSignature */: @@ -11759,8 +12409,8 @@ var ts; case 131 /* IndexSignature */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11870,7 +12520,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11971,7 +12621,7 @@ var ts; function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpression(node.exprName)); + links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); } return links.resolvedType; } @@ -11981,9 +12631,9 @@ var ts; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; switch (declaration.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: return declaration; } } @@ -12131,8 +12781,9 @@ var ts; return links.resolvedType; } function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) + if (ts.hasProperty(stringLiteralTypes, node.text)) { return stringLiteralTypes[node.text]; + } var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); type.text = ts.getTextOfNode(node); return type; @@ -12168,14 +12819,14 @@ var ts; return getTypeFromTupleTypeNode(node); case 139 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 140 /* ParenType */: + case 140 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); case 133 /* FunctionType */: case 134 /* ConstructorType */: case 136 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 63 /* Identifier */: - case 121 /* QualifiedName */: + case 120 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -12318,22 +12969,30 @@ var ts; } return type; } - function isContextSensitiveExpression(node) { + function isContextSensitive(node) { + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); - case 142 /* ObjectLiteral */: - return ts.forEach(node.properties, function (p) { return p.kind === 143 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); - case 141 /* ArrayLiteral */: - return ts.forEach(node.elements, function (e) { return isContextSensitiveExpression(e); }); - case 157 /* ConditionalExpression */: - return isContextSensitiveExpression(node.whenTrue) || isContextSensitiveExpression(node.whenFalse); - case 156 /* BinaryExpression */: - return node.operator === 48 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 142 /* ObjectLiteralExpression */: + return ts.forEach(node.properties, isContextSensitive); + case 141 /* ArrayLiteralExpression */: + return ts.forEach(node.elements, isContextSensitive); + case 158 /* ConditionalExpression */: + return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); + case 157 /* BinaryExpression */: + return node.operator === 48 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 198 /* PropertyAssignment */: + return isContextSensitive(node.initializer); + case 125 /* Method */: + return isContextSensitiveFunctionLikeDeclaration(node); } return false; } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); + } function getTypeWithoutConstructors(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); @@ -13230,7 +13889,7 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; + links.resolvedSymbol = (ts.getFullWidth(node) > 0 && resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; } return links.resolvedSymbol; } @@ -13240,7 +13899,7 @@ var ts; case 135 /* TypeQuery */: return true; case 63 /* Identifier */: - case 121 /* QualifiedName */: + case 120 /* QualifiedName */: node = node.parent; continue; default: @@ -13273,7 +13932,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operator >= 51 /* FirstAssignment */ && node.operator <= 62 /* LastAssignment */) { var n = node.left; - while (n.kind === 151 /* ParenExpression */) { + while (n.kind === 149 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 63 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -13290,64 +13949,90 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return isAssignedInVariableDeclaration(node); - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 141 /* ArrayLiteralExpression */: + case 142 /* ObjectLiteralExpression */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + case 148 /* TypeAssertionExpression */: + case 149 /* ParenthesizedExpression */: + case 155 /* PrefixUnaryExpression */: + case 152 /* DeleteExpression */: + case 153 /* TypeOfExpression */: + case 154 /* VoidExpression */: + case 156 /* PostfixUnaryExpression */: + case 158 /* ConditionalExpression */: + case 163 /* Block */: + case 164 /* VariableStatement */: + case 166 /* ExpressionStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 174 /* ReturnStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: + case 177 /* LabeledStatement */: + case 178 /* ThrowStatement */: + case 179 /* TryStatement */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: return ts.forEachChild(node, isAssignedIn); } return false; } } + function resolveLocation(node) { + var containerNodes = []; + for (var parent = node.parent; parent; parent = parent.parent) { + if ((ts.isExpression(parent) || ts.isObjectLiteralMethod(node)) && isContextSensitive(parent)) { + containerNodes.unshift(parent); + } + } + ts.forEach(containerNodes, function (node) { + getTypeOfNode(node); + }); + } + function getSymbolAtLocation(node) { + resolveLocation(node); + return getSymbolInfo(node); + } + function getTypeAtLocation(node) { + resolveLocation(node); + return getTypeOfNode(node); + } + function getTypeOfSymbolAtLocation(symbol, node) { + resolveLocation(node); + return getNarrowedTypeOfSymbol(symbol, node); + } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (node && (symbol.flags & 3 /* Variable */ && type.flags & 65025 /* Structured */)) { - loop: while (true) { + if (node && symbol.flags & 3 /* Variable */ && type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 166 /* IfStatement */: + case 167 /* IfStatement */: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: if (child === node.right) { if (node.operator === 47 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); @@ -13357,9 +14042,9 @@ var ts; } } break; - case 197 /* SourceFile */: - case 192 /* ModuleDeclaration */: - case 186 /* FunctionDeclaration */: + case 201 /* SourceFile */: + case 189 /* ModuleDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: @@ -13376,9 +14061,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { + if (expr.left.kind !== 153 /* TypeOfExpression */ || expr.right.kind !== 7 /* StringLiteral */) { + return type; + } var left = expr.left; var right = expr.right; - if (left.kind !== 154 /* PrefixOperator */ || left.operator !== 95 /* TypeOfKeyword */ || left.operand.kind !== 63 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { + if (left.expression.kind !== 63 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var t = right.text; @@ -13432,9 +14120,9 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: var operator = expr.operator; if (operator === 29 /* EqualsEqualsEqualsToken */ || operator === 30 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -13449,7 +14137,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 154 /* PrefixOperator */: + case 155 /* PrefixUnaryExpression */: if (expr.operator === 45 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -13469,7 +14157,7 @@ var ts; return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 185 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; @@ -13481,15 +14169,15 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 153 /* ArrowFunction */) { + if (container.kind === 151 /* ArrowFunction */) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = true; } switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 126 /* Constructor */: @@ -13506,7 +14194,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 185 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -13519,9 +14207,9 @@ var ts; if (!node) return node; switch (node.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: case 124 /* Property */: case 125 /* Method */: case 126 /* Constructor */: @@ -13540,10 +14228,10 @@ var ts; return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 147 /* CallExpression */ && node.parent.func === node; - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 145 /* CallExpression */ && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 185 /* ClassDeclaration */); var baseClass; - if (enclosingClass && enclosingClass.baseType) { + if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); baseClass = classType.baseTypes.length && classType.baseTypes[0]; } @@ -13559,11 +14247,11 @@ var ts; } else { var needToCaptureLexicalThis = false; - while (container && container.kind === 153 /* ArrowFunction */) { + while (container && container.kind === 151 /* ArrowFunction */) { container = getSuperContainer(container); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 188 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 185 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */; } @@ -13601,9 +14289,9 @@ var ts; return unknownType; } function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (func.kind === 152 /* FunctionExpression */ || func.kind === 153 /* ArrowFunction */) { - if (isContextSensitiveExpression(func)) { + if (isFunctionExpressionOrArrowFunction(parameter.parent)) { + var func = parameter.parent; + if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var funcHasRestParameters = ts.hasRestParameters(func); @@ -13635,10 +14323,10 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { + if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } - var signature = getContextualSignature(func); + var signature = getContextualSignatureForFunctionLikeDeclaration(func); if (signature) { return getReturnTypeOfSignature(signature); } @@ -13709,11 +14397,17 @@ var ts; function contextualTypeHasIndexSignature(type, kind) { return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); } - function getContextualTypeForPropertyExpression(node) { - var declaration = node.parent; - var objectLiteral = declaration.parent; + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; var type = getContextualType(objectLiteral); - var name = declaration.name.text; + var name = element.name.text; if (type && name) { return getTypeOfPropertyOfContextualType(type, name) || isNumericName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || getIndexTypeOfContextualType(type, 0 /* String */); } @@ -13741,25 +14435,25 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 123 /* Parameter */: case 124 /* Property */: return getContextualTypeForInitializerExpression(node); - case 153 /* ArrowFunction */: - case 173 /* ReturnStatement */: + case 151 /* ArrowFunction */: + case 174 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return getContextualTypeForArgument(node); - case 150 /* TypeAssertion */: + case 148 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 143 /* PropertyAssignment */: - return getContextualTypeForPropertyExpression(node); - case 141 /* ArrayLiteral */: + case 198 /* PropertyAssignment */: + return getContextualTypeForObjectLiteralElement(parent); + case 141 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); } return undefined; @@ -13773,8 +14467,15 @@ var ts; } } } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 150 /* FunctionExpression */ || node.kind === 151 /* ArrowFunction */; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; + } function getContextualSignature(node) { - var type = getContextualType(node); + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); if (!type) { return undefined; } @@ -13833,31 +14534,35 @@ var ts; for (var id in members) { if (ts.hasProperty(members, id)) { var member = members[id]; - if (member.flags & 4 /* Property */) { + if (member.flags & 4 /* Property */ || ts.isObjectLiteralMethod(member.declarations[0])) { var memberDecl = member.declarations[0]; var type; - if (memberDecl.kind === 143 /* PropertyAssignment */) { + if (memberDecl.kind === 198 /* PropertyAssignment */) { type = checkExpression(memberDecl.initializer, contextualMapper); } + else if (memberDecl.kind === 125 /* Method */) { + type = checkObjectLiteralMethod(memberDecl, contextualMapper); + } else { - ts.Debug.assert(memberDecl.kind === 144 /* ShorthandPropertyAssignment */); - type = checkExpression(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 199 /* ShorthandPropertyAssignment */); + type = memberDecl.name.kind === 121 /* ComputedPropertyName */ ? unknownType : checkExpression(memberDecl.name, contextualMapper); } var prop = createSymbol(4 /* Property */ | 268435456 /* Transient */ | member.flags, member.name); prop.declarations = member.declarations; prop.parent = member.parent; - if (member.valueDeclaration) + if (member.valueDeclaration) { prop.valueDeclaration = member.valueDeclaration; + } prop.type = type; prop.target = member; member = prop; } else { - var getAccessor = getDeclarationOfKind(member, 127 /* GetAccessor */); + var getAccessor = ts.getDeclarationOfKind(member, 127 /* GetAccessor */); if (getAccessor) { checkAccessorDeclaration(getAccessor); } - var setAccessor = getDeclarationOfKind(member, 128 /* SetAccessor */); + var setAccessor = ts.getDeclarationOfKind(member, 128 /* SetAccessor */); if (setAccessor) { checkAccessorDeclaration(setAccessor); } @@ -13892,12 +14597,12 @@ var ts; function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 536870912 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } - function checkClassPropertyAccess(node, type, prop) { + function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); if (!(flags & (32 /* Private */ | 64 /* Protected */))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 185 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32 /* Private */) { @@ -13906,7 +14611,7 @@ var ts; } return; } - if (node.left.kind === 89 /* SuperKeyword */) { + if (left.kind === 89 /* SuperKeyword */) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13920,8 +14625,14 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); } } - function checkPropertyAccess(node) { - var type = checkExpression(node.left); + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpressionOrQualifiedName(left); if (type === unknownType) return type; if (type !== anyType) { @@ -13929,20 +14640,20 @@ var ts; if (apparentType === unknownType) { return unknownType; } - var prop = getPropertyOfType(apparentType, node.right.text); + var prop = getPropertyOfType(apparentType, right.text); if (!prop) { - if (node.right.text) { - error(node.right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(node.right), typeToString(type)); + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { - error(node.right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { + error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); } } return getTypeOfSymbol(prop); @@ -13950,16 +14661,17 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var type = checkExpression(node.left); + var left = node.kind === 143 /* PropertyAccessExpression */ ? node.expression : node.left; + var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { + if (left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { return false; } else { var diagnosticsCount = diagnostics.length; - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); return diagnostics.length === diagnosticsCount; } } @@ -13967,19 +14679,22 @@ var ts; return true; } function checkIndexedAccess(node) { - var objectType = getApparentType(checkExpression(node.object)); - var indexType = checkExpression(node.index); - if (objectType === unknownType) + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { return unknownType; - if (isConstEnumObjectType(objectType) && node.index.kind !== 7 /* StringLiteral */) { - error(node.index, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); } - if (node.index.kind === 7 /* StringLiteral */ || node.index.kind === 6 /* NumericLiteral */) { - var name = node.index.text; - var prop = getPropertyOfType(objectType, name); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); + if (isConstEnumObjectType(objectType) && node.argumentExpression && node.argumentExpression.kind !== 7 /* StringLiteral */) { + error(node.argumentExpression, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + } + if (node.argumentExpression) { + if (node.argumentExpression.kind === 7 /* StringLiteral */ || node.argumentExpression.kind === 6 /* NumericLiteral */) { + var name = node.argumentExpression.text; + var prop = getPropertyOfType(objectType, name); + if (prop) { + getNodeLinks(node).resolvedSymbol = prop; + return getTypeOfSymbol(prop); + } } } if (indexType.flags & (1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */)) { @@ -13993,7 +14708,7 @@ var ts; if (stringIndexType) { return stringIndexType; } - if (compilerOptions.noImplicitAny && objectType !== anyType) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) { error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); } return anyType; @@ -14002,7 +14717,7 @@ var ts; return unknownType; } function resolveUntypedCall(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -14020,26 +14735,26 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 158 /* TemplateExpression */) { + if (tagExpression.template.kind === 159 /* TemplateExpression */) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); - callIsIncomplete = lastSpan.literal.kind === 120 /* Missing */ || ts.isUnterminatedTemplateEnd(lastSpan.literal); + callIsIncomplete = ts.getFullWidth(lastSpan.literal) === 0 || !!lastSpan.literal.isUnterminated; } else { var templateLiteral = tagExpression.template; ts.Debug.assert(templateLiteral.kind === 9 /* NoSubstitutionTemplateLiteral */); - callIsIncomplete = ts.isUnterminatedTemplateEnd(templateLiteral); + callIsIncomplete = !!templateLiteral.isUnterminated; } } else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 148 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 146 /* NewExpression */); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -14087,7 +14802,7 @@ var ts; } if (!excludeArgument || excludeArgument[i] === undefined) { var parameterType = getTypeAtPosition(signature, i); - if (i === 0 && args[i].parent.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 147 /* TaggedTemplateExpression */) { inferTypes(context, globalTemplateStringsArrayType, parameterType); continue; } @@ -14138,7 +14853,7 @@ var ts; continue; } var paramType = getTypeAtPosition(signature, i); - if (i === 0 && node.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && node.kind === 147 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { @@ -14153,10 +14868,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 158 /* TemplateExpression */) { + if (template.kind === 159 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -14168,7 +14883,7 @@ var ts; return args; } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 149 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 147 /* TaggedTemplateExpression */; var typeArguments = isTaggedTemplate ? undefined : node.typeArguments; ts.forEach(typeArguments, checkSourceElement); var candidates = candidatesOutArray || []; @@ -14180,7 +14895,7 @@ var ts; var args = getEffectiveCallArguments(node); var excludeArgument; for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitiveExpression(args[i])) { + if (isContextSensitive(args[i])) { if (!excludeArgument) { excludeArgument = new Array(args.length); } @@ -14215,7 +14930,7 @@ var ts; var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - reportNoCommonSupertypeError(inferenceCandidates, node.func || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { @@ -14316,14 +15031,14 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.func.kind === 89 /* SuperKeyword */) { - var superType = checkSuperExpression(node.func); + if (node.expression.kind === 89 /* SuperKeyword */) { + var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); } return resolveUntypedCall(node); } - var funcType = checkExpression(node.func); + var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); if (apparentType === unknownType) { return resolveErrorCall(node); @@ -14348,7 +15063,7 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } function resolveNewExpression(node, candidatesOutArray) { - var expressionType = checkExpression(node.func); + var expressionType = checkExpression(node.expression); if (expressionType === anyType) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -14394,13 +15109,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 147 /* CallExpression */) { + if (node.kind === 145 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 148 /* NewExpression */) { + else if (node.kind === 146 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 147 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -14411,10 +15126,10 @@ var ts; } function checkCallExpression(node) { var signature = getResolvedSignature(node); - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 89 /* SuperKeyword */) { return voidType; } - if (node.kind === 148 /* NewExpression */) { + if (node.kind === 146 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 126 /* Constructor */ && declaration.kind !== 130 /* ConstructSignature */ && declaration.kind !== 134 /* ConstructorType */) { if (compilerOptions.noImplicitAny) { @@ -14429,7 +15144,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkTypeAssertion(node) { - var exprType = checkExpression(node.operand); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (fullTypeCheck && targetType !== unknownType) { var widenedType = getWidenedType(exprType, true); @@ -14456,8 +15171,8 @@ var ts; } } function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignature(func); - if (func.body.kind !== 187 /* FunctionBlock */) { + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (func.body.kind !== 163 /* Block */) { var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); var widenedType = getWidenedType(unwidenedType); if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { @@ -14505,7 +15220,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 179 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 178 /* ThrowStatement */); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!fullTypeCheck) { @@ -14514,7 +15229,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (!func.body || func.body.kind !== 187 /* FunctionBlock */) { + if (!func.body || func.body.kind !== 163 /* Block */) { return; } var bodyBlock = func.body; @@ -14526,7 +15241,8 @@ var ts; } error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } - function checkFunctionExpression(node, contextualMapper) { + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); if (contextualMapper === identityMapper) { return anyFunctionType; } @@ -14538,7 +15254,7 @@ var ts; links.flags |= 64 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitiveExpression(node)) { + if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } if (!node.type) { @@ -14552,21 +15268,28 @@ var ts; checkSignatureDeclaration(node); } } + if (fullTypeCheck && node.kind !== 125 /* Method */) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } return type; } - function checkFunctionExpressionBody(node) { + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (node.body.kind === 187 /* FunctionBlock */) { - checkSourceElement(node.body); - } - else { - var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (node.body) { + if (node.body.kind === 163 /* Block */) { + checkSourceElement(node.body); + } + else { + var exprType = checkExpression(node.body); + if (node.type) { + checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + } + checkFunctionExpressionBodies(node.body); } - checkFunctionExpressionBodies(node.body); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -14586,12 +15309,12 @@ var ts; case 63 /* Identifier */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; - case 145 /* PropertyAccess */: + case 143 /* PropertyAccessExpression */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - case 146 /* IndexedAccess */: + case 144 /* ElementAccessExpression */: return true; - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -14600,19 +15323,19 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 63 /* Identifier */: - case 145 /* PropertyAccess */: + case 143 /* PropertyAccessExpression */: var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; - case 146 /* IndexedAccess */: - var index = n.index; - var symbol = findSymbol(n.object); - if (symbol && index.kind === 7 /* StringLiteral */) { + case 144 /* ElementAccessExpression */: + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 7 /* StringLiteral */) { var name = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; } return false; - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -14628,7 +15351,19 @@ var ts; } return true; } - function checkPrefixExpression(node) { + function checkDeleteExpression(node) { + var operandType = checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + var operandType = checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + var operandType = checkExpression(node.expression); + return undefinedType; + } + function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { case 32 /* PlusToken */: @@ -14636,12 +15371,7 @@ var ts; case 46 /* TildeToken */: return numberType; case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: return booleanType; - case 95 /* TypeOfKeyword */: - return stringType; - case 97 /* VoidKeyword */: - return undefinedType; case 37 /* PlusPlusToken */: case 38 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); @@ -14652,7 +15382,7 @@ var ts; } return unknownType; } - function checkPostfixExpression(node) { + function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -14664,7 +15394,7 @@ var ts; if (type.flags & 16384 /* Union */) { return !ts.forEach(type.types, function (t) { return !isStructuredType(t); }); } - return (type.flags & 65025 /* Structured */) !== 0; + return (type.flags & (48128 /* ObjectType */ | 512 /* TypeParameter */)) !== 0; } function isConstEnumObjectType(type) { return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); @@ -14673,10 +15403,10 @@ var ts; return (symbol.flags & 128 /* ConstEnum */) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (leftType !== unknownType && !isStructuredType(leftType)) { + if (!(leftType.flags & 1 /* Any */ || isStructuredType(leftType))) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (rightType !== unknownType && rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { + if (!(rightType.flags & 1 /* Any */ || isTypeSubtypeOf(rightType, globalFunctionType))) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -14685,7 +15415,7 @@ var ts; if (leftType !== anyType && leftType !== stringType && leftType !== numberType) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number); } - if (!isStructuredType(rightType)) { + if (!(rightType.flags & 1 /* Any */ || isStructuredType(rightType))) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -14832,8 +15562,11 @@ var ts; getNodeLinks(node).flags |= 1 /* TypeChecked */; return result; } - function checkExpression(node, contextualMapper) { - var type = checkExpressionNode(node, contextualMapper); + function checkObjectLiteralMethod(node, contextualMapper) { + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { if (contextualMapper && contextualMapper !== identityMapper) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { @@ -14841,20 +15574,34 @@ var ts; if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); } } } } + return type; + } + function checkExpression(node, contextualMapper) { + return checkExpressionOrQualifiedName(node, contextualMapper); + } + function checkExpressionOrQualifiedName(node, contextualMapper) { + var type; + if (node.kind == 120 /* QualifiedName */) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 145 /* PropertyAccess */ && node.parent.left === node) || (node.parent.kind === 146 /* IndexedAccess */ && node.parent.object === node) || ((node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 143 /* PropertyAccessExpression */ && node.parent.expression === node) || (node.parent.kind === 144 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 63 /* Identifier */ || node.kind === 120 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } } return type; } - function checkExpressionNode(node, contextualMapper) { + function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { case 63 /* Identifier */: return checkIdentifier(node); @@ -14869,42 +15616,46 @@ var ts; return booleanType; case 6 /* NumericLiteral */: return numberType; - case 158 /* TemplateExpression */: + case 159 /* TemplateExpression */: return checkTemplateExpression(node); case 7 /* StringLiteral */: case 9 /* NoSubstitutionTemplateLiteral */: return stringType; case 8 /* RegularExpressionLiteral */: return globalRegExpType; - case 121 /* QualifiedName */: - return checkPropertyAccess(node); - case 141 /* ArrayLiteral */: + case 141 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 142 /* ObjectLiteral */: + case 142 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 145 /* PropertyAccess */: - return checkPropertyAccess(node); - case 146 /* IndexedAccess */: + case 143 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node); + case 144 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return checkCallExpression(node); - case 149 /* TaggedTemplateExpression */: + case 147 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: + case 148 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return checkExpression(node.expression); - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return checkFunctionExpression(node, contextualMapper); - case 154 /* PrefixOperator */: - return checkPrefixExpression(node); - case 155 /* PostfixOperator */: - return checkPostfixExpression(node); - case 156 /* BinaryExpression */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 153 /* TypeOfExpression */: + return checkTypeOfExpression(node); + case 152 /* DeleteExpression */: + return checkDeleteExpression(node); + case 154 /* VoidExpression */: + return checkVoidExpression(node); + case 155 /* PrefixUnaryExpression */: + return checkPrefixUnaryExpression(node); + case 156 /* PostfixUnaryExpression */: + return checkPostfixUnaryExpression(node); + case 157 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); case 161 /* OmittedExpression */: return undefinedType; @@ -14919,13 +15670,13 @@ var ts; } } function checkParameter(parameterDeclaration) { - checkVariableDeclaration(parameterDeclaration); + checkVariableOrParameterDeclaration(parameterDeclaration); if (fullTypeCheck) { checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 126 /* Constructor */ && parameterDeclaration.parent.body)) { error(parameterDeclaration, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (parameterDeclaration.flags & 8 /* Rest */) { + if (parameterDeclaration.dotDotDotToken) { if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) { error(parameterDeclaration, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } @@ -14968,9 +15719,6 @@ var ts; checkSourceElement(node.type); } if (fullTypeCheck) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { @@ -14986,7 +15734,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 186 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -15022,16 +15770,18 @@ var ts; } } function checkPropertyDeclaration(node) { - checkVariableDeclaration(node); + if (fullTypeCheck) { + checkVariableOrParameterOrPropertyInFullTypeCheck(node); + } } function checkMethodDeclaration(node) { - checkFunctionDeclaration(node); + checkFunctionLikeDeclaration(node); } function checkConstructorDeclaration(node) { checkSignatureDeclaration(node); checkSourceElement(node.body); var symbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(symbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(symbol); } @@ -15042,17 +15792,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 147 /* CallExpression */ && n.func.kind === 89 /* SuperKeyword */; + return n.kind === 145 /* CallExpression */ && n.expression.kind === 89 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - case 142 /* ObjectLiteral */: return false; + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: + case 142 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -15060,19 +15810,19 @@ var ts; if (n.kind === 91 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 186 /* FunctionDeclaration */) { + else if (n.kind !== 150 /* FunctionExpression */ && n.kind !== 184 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { return n.kind === 124 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; } - if (node.parent.baseType) { + if (ts.getClassBaseTypeNode(node.parent)) { if (containsSuperCall(node.body)) { var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 165 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 166 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -15092,23 +15842,25 @@ var ts; error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } - var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; - var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var thisType = getAnnotatedAccessorType(node); - var otherType = getAnnotatedAccessorType(otherAccessor); - if (thisType && otherType) { - if (!isTypeIdenticalTo(thisType, otherType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + if (!ts.hasComputedNameButNotSymbol(node)) { + var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } } } + checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); } } - checkFunctionDeclaration(node); - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + checkFunctionLikeDeclaration(node); } function checkTypeReference(node) { var type = getTypeFromTypeReferenceNode(node); @@ -15160,7 +15912,7 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 189 /* InterfaceDeclaration */) { + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 186 /* InterfaceDeclaration */) { ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */); var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); @@ -15180,7 +15932,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = n.flags; - if (n.parent.kind !== 189 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 186 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { flags |= 1 /* Export */; } @@ -15192,11 +15944,14 @@ var ts; if (!fullTypeCheck) { return; } + function getCanonicalOverload(overloads, implementation) { + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - var canonicalFlags = implementationSharesContainerWithFirstOverload ? getEffectiveDeclarationFlags(implementation, flagsToCheck) : getEffectiveDeclarationFlags(overloads[0], flagsToCheck); + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; if (deviation & 1 /* Export */) { @@ -15208,15 +15963,25 @@ var ts; else if (deviation & (32 /* Private */ | 64 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 4 /* QuestionMark */) { + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 4 /* QuestionMark */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; var hasOverloads = false; var bodyDeclaration; var lastSeenNonAmbientDeclaration; @@ -15224,7 +15989,7 @@ var ts; var declarations = symbol.declarations; var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { - if (node.name && node.name.kind === 120 /* Missing */) { + if (node.name && ts.getFullWidth(node.name) === 0) { return; } var seen = false; @@ -15266,14 +16031,16 @@ var ts; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 189 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 186 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { + if (node.kind === 184 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); if (node.body && bodyDeclaration) { if (isConstructor) { multipleConstructorImplementation = true; @@ -15314,6 +16081,7 @@ var ts; } if (hasOverloads) { checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -15340,7 +16108,7 @@ var ts; return; } } - if (getDeclarationOfKind(symbol, node.kind) !== node) { + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } var exportedDeclarationSpaces = 0; @@ -15364,14 +16132,14 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return 8388608 /* ExportType */; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */; - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: return 8388608 /* ExportType */ | 4194304 /* ExportValue */; - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: var result = 0; var target = resolveImport(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { @@ -15384,16 +16152,26 @@ var ts; } } function checkFunctionDeclaration(node) { - checkSignatureDeclaration(node); - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); + checkFunctionLikeDeclaration(node); + if (fullTypeCheck) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } - if (symbol.parent) { - if (getDeclarationOfKind(symbol, node.kind) === node) { - checkFunctionOrConstructorSymbol(symbol); + } + function checkFunctionLikeDeclaration(node) { + checkSignatureDeclaration(node); + if (!ts.hasComputedNameButNotSymbol(node)) { + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + checkFunctionOrConstructorSymbol(symbol); + } } } checkSourceElement(node.body); @@ -15414,6 +16192,9 @@ var ts; } function checkBlock(node) { ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 190 /* ModuleBlock */) { + checkFunctionExpressionBodies(node); + } } function checkCollisionWithArgumentsInGeneratedCode(node) { if (!ts.hasRestParameters(node) || ts.isInAmbientContext(node) || !node.body) { @@ -15446,10 +16227,10 @@ var ts; return; } switch (current.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: case 125 /* Method */: - case 153 /* ArrowFunction */: + case 151 /* ArrowFunction */: case 126 /* Constructor */: if (ts.hasRestParameters(current)) { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter); @@ -15461,7 +16242,7 @@ var ts; } } function needCollisionCheckForIdentifier(node, identifier, name) { - if (!(identifier && identifier.text === name)) { + if (!identifier || identifier.text !== name) { return false; } if (node.kind === 124 /* Property */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */) { @@ -15476,10 +16257,9 @@ var ts; return true; } function checkCollisionWithCapturedThisVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_this")) { - return; + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); } - potentialThisCollisions.push(node); } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -15501,11 +16281,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 185 /* ClassDeclaration */); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } - if (enclosingClass.baseType) { + if (ts.getClassBaseTypeNode(enclosingClass)) { var isDeclaration = node.kind !== 63 /* Identifier */; if (isDeclaration) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); @@ -15519,11 +16299,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 189 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (parent.kind === 197 /* SourceFile */ && ts.isExternalModule(parent)) { + var parent = node.kind === 183 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (parent.kind === 201 /* SourceFile */ && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -15540,30 +16320,38 @@ var ts; } } } - function checkVariableDeclaration(node) { + function checkVariableOrParameterOrPropertyInFullTypeCheck(node) { + ts.Debug.assert(fullTypeCheck); checkSourceElement(node.type); - checkExportsOnMergedDeclarations(node); + if (ts.hasComputedNameButNotSymbol(node)) { + return node.initializer ? checkAndMarkExpression(node.initializer) : anyType; + } + var symbol = getSymbolOfNode(node); + var type; + if (symbol.valueDeclaration !== node) { + type = getTypeOfVariableOrParameterOrPropertyDeclaration(node); + } + else { + type = getTypeOfVariableOrParameterOrProperty(symbol); + } + if (node.initializer && !(getNodeLinks(node.initializer).flags & 1 /* TypeChecked */)) { + checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, undefined); + } + return type; + } + function checkVariableOrParameterDeclaration(node) { if (fullTypeCheck) { - var symbol = getSymbolOfNode(node); - var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); - var type; - var useTypeFromValueDeclaration = node === symbol.valueDeclaration; - if (useTypeFromValueDeclaration) { - type = typeOfValueDeclaration; - } - else { - type = getTypeOfVariableOrPropertyDeclaration(node); - } + var type = checkVariableOrParameterOrPropertyInFullTypeCheck(node); + checkExportsOnMergedDeclarations(node); if (node.initializer) { - if (!(getNodeLinks(node.initializer).flags & 1 /* TypeChecked */)) { - checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, undefined); - } checkCollisionWithConstDeclarations(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - if (!useTypeFromValueDeclaration) { + var symbol = getSymbolOfNode(node); + if (node !== symbol.valueDeclaration) { + var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); 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.declarationNameToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); } @@ -15571,7 +16359,7 @@ var ts; } } function checkVariableStatement(node) { - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkVariableOrParameterDeclaration); } function checkExpressionStatement(node) { checkExpression(node.expression); @@ -15591,7 +16379,7 @@ var ts; } function checkForStatement(node) { if (node.declarations) - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkVariableOrParameterDeclaration); if (node.initializer) checkExpression(node.initializer); if (node.condition) @@ -15604,7 +16392,7 @@ var ts; if (node.declarations) { if (node.declarations.length >= 1) { var decl = node.declarations[0]; - checkVariableDeclaration(decl); + checkVariableOrParameterDeclaration(decl); if (decl.type) { error(decl, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation); } @@ -15620,7 +16408,7 @@ var ts; } } var exprType = checkExpression(node.expression); - if (!isStructuredType(exprType) && exprType !== unknownType) { + if (!(exprType.flags & 1 /* Any */ || isStructuredType(exprType))) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -15638,7 +16426,7 @@ var ts; } else { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); + var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); if (checkAssignability) { checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, undefined); } @@ -15658,25 +16446,28 @@ var ts; function checkSwitchStatement(node) { var expressionType = checkExpression(node.expression); ts.forEach(node.clauses, function (clause) { - if (fullTypeCheck && clause.expression) { - var caseType = checkExpression(clause.expression); + if (fullTypeCheck && clause.kind === 194 /* CaseClause */) { + var caseClause = clause; + var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { - checkTypeAssignableTo(caseType, expressionType, clause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); } } - checkBlock(clause); + ts.forEach(clause.statements, checkSourceElement); }); } function checkLabeledStatement(node) { checkSourceElement(node.statement); } function checkThrowStatement(node) { - checkExpression(node.expression); + if (node.expression) { + checkExpression(node.expression); + } } function checkTryStatement(node) { checkBlock(node.tryBlock); - if (node.catchBlock) - checkBlock(node.catchBlock); + if (node.catchClause) + checkBlock(node.catchClause.block); if (node.finallyBlock) checkBlock(node.finallyBlock); } @@ -15761,9 +16552,10 @@ var ts; var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); var staticType = getTypeOfSymbol(symbol); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkTypeReference(node.baseType); + checkTypeReference(baseTypeNode); } if (type.baseTypes.length) { if (fullTypeCheck) { @@ -15771,15 +16563,16 @@ var ts; checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); var staticBaseType = getTypeOfSymbol(baseType.symbol); checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, 107455 /* Value */)) { - error(node.baseType, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + if (baseType.symbol !== resolveEntityName(node, baseTypeNode.typeName, 107455 /* Value */)) { + error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); } checkKindsOfPropertyMemberOverrides(type, baseType); } - checkExpression(node.baseType.typeName); + checkExpressionOrQualifiedName(baseTypeNode.typeName); } - if (node.implementedTypes) { - ts.forEach(node.implementedTypes, function (typeRefNode) { + var implementedTypeNodes = ts.getClassImplementedTypeNodes(node); + if (implementedTypeNodes) { + ts.forEach(implementedTypeNodes, function (typeRefNode) { checkTypeReference(typeRefNode); if (fullTypeCheck) { var t = getTypeFromTypeReferenceNode(typeRefNode); @@ -15914,7 +16707,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = getDeclarationOfKind(symbol, 189 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 186 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15930,7 +16723,7 @@ var ts; } } } - ts.forEach(node.baseTypes, checkTypeReference); + ts.forEach(ts.getInterfaceBaseTypeNodes(node), checkTypeReference); ts.forEach(node.members, checkSourceElement); if (fullTypeCheck) { checkTypeForDuplicateIndexSignatures(node); @@ -15985,7 +16778,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 154 /* PrefixOperator */: + case 155 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -15996,7 +16789,7 @@ var ts; case 46 /* TildeToken */: return enumIsConst ? ~value : undefined; } return undefined; - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: if (!enumIsConst) { return undefined; } @@ -16024,11 +16817,11 @@ var ts; return undefined; case 6 /* NumericLiteral */: return +e.text; - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return enumIsConst ? evalConstant(e.expression) : undefined; case 63 /* Identifier */: - case 146 /* IndexedAccess */: - case 145 /* PropertyAccess */: + case 144 /* ElementAccessExpression */: + case 143 /* PropertyAccessExpression */: if (!enumIsConst) { return undefined; } @@ -16041,16 +16834,16 @@ var ts; propertyName = e.text; } else { - if (e.kind === 146 /* IndexedAccess */) { - if (e.index.kind !== 7 /* StringLiteral */) { + if (e.kind === 144 /* ElementAccessExpression */) { + if (e.argumentExpression === undefined || e.argumentExpression.kind !== 7 /* StringLiteral */) { return undefined; } - var enumType = getTypeOfNode(e.object); - propertyName = e.index.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.argumentExpression.text; } else { - var enumType = getTypeOfNode(e.left); - propertyName = e.right.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.name.text; } if (enumType !== currentType) { return undefined; @@ -16085,7 +16878,7 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { var enumIsConst = ts.isConst(node); @@ -16097,7 +16890,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 191 /* EnumDeclaration */) { + if (declaration.kind !== 188 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -16120,7 +16913,7 @@ var ts; var declarations = symbol.declarations; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; - if ((declaration.kind === 188 /* ClassDeclaration */ || (declaration.kind === 186 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 185 /* ClassDeclaration */ || (declaration.kind === 184 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -16155,7 +16948,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 121 /* QualifiedName */) { + while (node.kind === 120 /* QualifiedName */) { node = node.left; } return node; @@ -16165,13 +16958,13 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); var symbol = getSymbolOfNode(node); var target; - if (node.entityName) { + if (ts.isInternalModuleImportDeclaration(node)) { target = resolveImport(symbol); if (target !== unknownSymbol) { if (target.flags & 107455 /* Value */) { - var moduleName = getFirstIdentifier(node.entityName); + var moduleName = getFirstIdentifier(node.moduleReference); if (resolveEntityName(node, moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */) { - checkExpression(node.entityName); + checkExpressionOrQualifiedName(node.moduleReference); } else { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); @@ -16183,16 +16976,21 @@ var ts; } } else { - if (node.parent.kind === 197 /* SourceFile */) { + if (node.parent.kind === 201 /* SourceFile */) { target = resolveImport(symbol); } - else if (node.parent.kind === 193 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { - if (isExternalModuleNameRelative(node.externalModuleName.text)) { - error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); - target = unknownSymbol; + else if (node.parent.kind === 190 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { + if (ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { + if (isExternalModuleNameRelative(ts.getExternalModuleImportDeclarationExpression(node).text)) { + error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + target = unknownSymbol; + } + else { + target = resolveImport(symbol); + } } else { - target = resolveImport(symbol); + target = unknownSymbol; } } else { @@ -16208,7 +17006,7 @@ var ts; } function checkExportAssignment(node) { var container = node.parent; - if (container.kind !== 197 /* SourceFile */) { + if (container.kind !== 201 /* SourceFile */) { container = container.parent; } checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container)); @@ -16248,136 +17046,138 @@ var ts; return checkTupleType(node); case 139 /* UnionType */: return checkUnionType(node); - case 140 /* ParenType */: + case 140 /* ParenthesizedType */: return checkSourceElement(node.type); - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 162 /* Block */: + case 163 /* Block */: + case 190 /* ModuleBlock */: return checkBlock(node); - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - return checkBody(node); - case 163 /* VariableStatement */: + case 164 /* VariableStatement */: return checkVariableStatement(node); - case 165 /* ExpressionStatement */: + case 166 /* ExpressionStatement */: return checkExpressionStatement(node); - case 166 /* IfStatement */: + case 167 /* IfStatement */: return checkIfStatement(node); - case 167 /* DoStatement */: + case 168 /* DoStatement */: return checkDoStatement(node); - case 168 /* WhileStatement */: + case 169 /* WhileStatement */: return checkWhileStatement(node); - case 169 /* ForStatement */: + case 170 /* ForStatement */: return checkForStatement(node); - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return checkForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 174 /* ReturnStatement */: return checkReturnStatement(node); - case 174 /* WithStatement */: + case 175 /* WithStatement */: return checkWithStatement(node); - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: return checkSwitchStatement(node); - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return checkLabeledStatement(node); - case 179 /* ThrowStatement */: + case 178 /* ThrowStatement */: return checkThrowStatement(node); - case 180 /* TryStatement */: + case 179 /* TryStatement */: return checkTryStatement(node); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return ts.Debug.fail("Checker encountered variable declaration"); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return checkClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 187 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: return checkImportDeclaration(node); - case 195 /* ExportAssignment */: + case 192 /* ExportAssignment */: return checkExportAssignment(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); - checkFunctionExpressionBody(node); + checkFunctionExpressionOrObjectLiteralMethodBody(node); break; case 125 /* Method */: + ts.forEach(node.parameters, checkFunctionExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 174 /* WithStatement */: + case 175 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; case 123 /* Parameter */: case 124 /* Property */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 143 /* PropertyAssignment */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: - case 197 /* SourceFile */: + case 141 /* ArrayLiteralExpression */: + case 142 /* ObjectLiteralExpression */: + case 198 /* PropertyAssignment */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + case 147 /* TaggedTemplateExpression */: + case 148 /* TypeAssertionExpression */: + case 149 /* ParenthesizedExpression */: + case 153 /* TypeOfExpression */: + case 154 /* VoidExpression */: + case 152 /* DeleteExpression */: + case 155 /* PrefixUnaryExpression */: + case 156 /* PostfixUnaryExpression */: + case 157 /* BinaryExpression */: + case 158 /* ConditionalExpression */: + case 163 /* Block */: + case 190 /* ModuleBlock */: + case 164 /* VariableStatement */: + case 166 /* ExpressionStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: + case 174 /* ReturnStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: + case 177 /* LabeledStatement */: + case 178 /* ThrowStatement */: + case 179 /* TryStatement */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: + case 183 /* VariableDeclaration */: + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: + case 200 /* EnumMember */: + case 201 /* 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; - checkBody(node); + ts.forEach(node.statements, checkSourceElement); + checkFunctionExpressionBodies(node); if (ts.isExternalModule(node)) { var symbol = getExportAssignmentSymbol(node.symbol); if (symbol && symbol.flags & 33554432 /* Import */) { @@ -16388,14 +17188,12 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) + if (emitExtends) { links.flags |= 8 /* EmitExtends */; + } links.flags |= 1 /* TypeChecked */; } } - function checkProgram() { - ts.forEach(program.getSourceFiles(), checkSourceFile); - } function getSortedDiagnostics() { ts.Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode"); if (diagnosticsModified) { @@ -16410,7 +17208,7 @@ var ts; checkSourceFile(sourceFile); return ts.filter(getSortedDiagnostics(), function (d) { return d.file === sourceFile; }); } - checkProgram(); + ts.forEach(program.getSourceFiles(), checkSourceFile); return getSortedDiagnostics(); } function getDeclarationDiagnostics(targetSourceFile) { @@ -16421,25 +17219,10 @@ var ts; function getGlobalDiagnostics() { return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; }); } - function getNodeAtPosition(sourceFile, position) { - function findChildAtPosition(parent) { - var child = ts.forEachChild(parent, function (node) { - if (position >= node.pos && position <= node.end && position >= ts.getTokenPosOfNode(node)) { - return findChildAtPosition(node); - } - }); - return child || parent; - } - if (position < sourceFile.pos) - position = sourceFile.pos; - if (position > sourceFile.end) - position = sourceFile.end; - return findChildAtPosition(sourceFile); - } function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 174 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 175 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -16475,28 +17258,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */); } break; - case 152 /* FunctionExpression */: + case 150 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } break; - case 182 /* CatchBlock */: - if (location.variable.text) { + case 197 /* CatchClause */: + if (location.name.text) { copySymbol(location.symbol, meaning); } break; @@ -16513,16 +17296,16 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 122 /* TypeParameter */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 188 /* EnumDeclaration */: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 121 /* QualifiedName */) + while (node.parent && node.parent.kind === 120 /* QualifiedName */) node = node.parent; return node.parent && node.parent.kind === 132 /* TypeReference */; } @@ -16537,15 +17320,15 @@ var ts; case 110 /* BooleanKeyword */: return true; case 97 /* VoidKeyword */: - return node.parent.kind !== 154 /* PrefixOperator */; + return node.parent.kind !== 154 /* VoidExpression */; case 7 /* StringLiteral */: return node.parent.kind === 123 /* Parameter */; case 63 /* Identifier */: - if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - case 121 /* QualifiedName */: - ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + case 120 /* QualifiedName */: + ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 120 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; if (parent.kind === 135 /* TypeQuery */) { return false; @@ -16558,11 +17341,11 @@ var ts; return node === parent.constraint; case 124 /* Property */: case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return node === parent.type; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: case 126 /* Constructor */: case 125 /* Method */: case 127 /* GetAccessor */: @@ -16572,59 +17355,68 @@ var ts; case 130 /* ConstructSignature */: case 131 /* IndexSignature */: return node === parent.type; - case 150 /* TypeAssertion */: + case 148 /* TypeAssertionExpression */: return node === parent.type; - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; - case 149 /* TaggedTemplateExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 147 /* TaggedTemplateExpression */: return false; } } return false; } function isInRightSideOfImportOrExportAssignment(node) { - while (node.parent.kind === 121 /* QualifiedName */) { + while (node.parent.kind === 120 /* QualifiedName */) { node = node.parent; } - if (node.parent.kind === 194 /* ImportDeclaration */) { - return node.parent.entityName === node; + if (node.parent.kind === 191 /* ImportDeclaration */) { + return node.parent.moduleReference === node; } - if (node.parent.kind === 195 /* ExportAssignment */) { + if (node.parent.kind === 192 /* ExportAssignment */) { return node.parent.exportName === node; } return false; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 121 /* QualifiedName */ || node.parent.kind === 145 /* PropertyAccess */) && node.parent.right === node; + return (node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node) || (node.parent.kind === 143 /* PropertyAccessExpression */ && node.parent.name === node); } - function getSymbolOfEntityName(entityName) { + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 195 /* ExportAssignment */) { + if (entityName.parent.kind === 192 /* ExportAssignment */) { return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */); } - if (isInRightSideOfImportOrExportAssignment(entityName)) { - return getSymbolOfPartOfRightHandSideOfImport(entityName); + if (entityName.kind !== 143 /* PropertyAccessExpression */) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + return getSymbolOfPartOfRightHandSideOfImport(entityName); + } } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (ts.isExpression(entityName)) { + if (ts.getFullWidth(entityName) === 0) { + return undefined; + } if (entityName.kind === 63 /* Identifier */) { var meaning = 107455 /* Value */ | 33554432 /* Import */; return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.kind === 145 /* PropertyAccess */) { + else if (entityName.kind === 143 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { - checkPropertyAccess(entityName); + checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else { - return; + else if (entityName.kind === 120 /* QualifiedName */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; } } else if (isTypeReferenceIdentifier(entityName)) { @@ -16642,13 +17434,13 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 195 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); + return node.parent.kind === 192 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImport(node); } switch (node.kind) { case 63 /* Identifier */: - case 145 /* PropertyAccess */: - case 121 /* QualifiedName */: - return getSymbolOfEntityName(node); + case 143 /* PropertyAccessExpression */: + case 120 /* QualifiedName */: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 91 /* ThisKeyword */: case 89 /* SuperKeyword */: var type = checkExpression(node); @@ -16660,14 +17452,14 @@ var ts; } return undefined; case 7 /* StringLiteral */: - if (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node) { - var importSymbol = getSymbolOfNode(node.parent); + if (ts.isExternalModuleImportDeclaration(node.parent.parent) && ts.getExternalModuleImportDeclarationExpression(node.parent.parent) === node) { + var importSymbol = getSymbolOfNode(node.parent.parent); var moduleType = getTypeOfSymbol(importSymbol); return moduleType ? moduleType.symbol : undefined; } case 6 /* NumericLiteral */: - if (node.parent.kind == 146 /* IndexedAccess */ && node.parent.index === node) { - var objectType = checkExpression(node.parent.object); + if (node.parent.kind == 144 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; var apparentType = getApparentType(objectType); @@ -16680,7 +17472,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 144 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 199 /* ShorthandPropertyAssignment */) { return resolveEntityName(location, location.name, 107455 /* Value */); } return undefined; @@ -16754,7 +17546,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 197 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 201 /* SourceFile */; } function isNodeDescendentOf(node, ancestor) { while (node) { @@ -16787,7 +17579,7 @@ var ts; function getLocalNameForSymbol(symbol, location) { var node = location; while (node) { - if ((node.kind === 192 /* ModuleDeclaration */ || node.kind === 191 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { + if ((node.kind === 189 /* ModuleDeclaration */ || node.kind === 188 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { return getLocalNameOfContainer(node); } node = node.parent; @@ -16811,13 +17603,13 @@ var ts; return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined; } function isTopLevelValueImportWithEntityName(node) { - if (node.parent.kind !== 197 /* SourceFile */ || !node.entityName) { + if (node.parent.kind !== 201 /* SourceFile */ || !ts.isInternalModuleImportDeclaration(node)) { return false; } return isImportResolvedToValue(getSymbolOfNode(node)); } - function hasSemanticErrors() { - return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0; + function hasSemanticErrors(sourceFile) { + return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0; } function isEmitBlocked(sourceFile) { return program.getDiagnostics(sourceFile).length !== 0 || hasEarlyErrors(sourceFile) || (compilerOptions.noEmitOnError && getDiagnostics(sourceFile).length !== 0); @@ -16862,15 +17654,15 @@ var ts; if (symbol && (symbol.flags & 8 /* EnumMember */)) { var declaration = symbol.valueDeclaration; var constantValue; - if (declaration.kind === 196 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + if (declaration.kind === 200 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { return constantValue; } } return undefined; } - function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { - var symbol = getSymbolOfNode(location); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* CallSignature */ | 262144 /* ConstructSignature */)) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* CallSignature */ | 262144 /* ConstructSignature */)) ? getTypeOfSymbol(symbol) : unknownType; getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -16891,7 +17683,7 @@ var ts; isEmitBlocked: isEmitBlocked, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, - writeTypeAtLocation: writeTypeAtLocation, + writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, @@ -16900,7 +17692,6 @@ var ts; } function invokeEmitter(targetSourceFile) { var resolver = createResolver(); - checkProgram(); return ts.emitFiles(resolver, targetSourceFile); } function initializeTypeChecker() { @@ -17018,6 +17809,11 @@ var ts; description: ts.Diagnostics.Redirect_output_structure_to_the_directory, paramType: ts.Diagnostics.DIRECTORY }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, { name: "removeComments", type: "boolean", @@ -17034,6 +17830,11 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + }, { name: "target", shortName: "t", @@ -17053,11 +17854,6 @@ var ts; shortName: "w", type: "boolean", description: ts.Diagnostics.Watch_input_files - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code } ]; var shortOptionNames = {}; @@ -17129,7 +17925,7 @@ var ts; } } function parseResponseFile(filename) { - var text = sys.readFile(filename); + var text = ts.sys.readFile(filename); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, filename)); return; @@ -17167,7 +17963,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var version = "1.3.0.0"; + var version = "1.4.0.0"; function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { @@ -17183,18 +17979,18 @@ var ts; return true; } function trySetLanguageAndTerritory(language, territory, errors) { - var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath()); + var compilerFilePath = ts.normalizePath(ts.sys.getExecutingFilePath()); var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); var filePath = ts.combinePaths(containingDirectoryPath, language); if (territory) { filePath = filePath + "-" + territory; } - filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); - if (!sys.fileExists(filePath)) { + filePath = ts.sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); + if (!ts.sys.fileExists(filePath)) { return false; } try { - var fileContents = sys.readFile(filePath); + var fileContents = ts.sys.readFile(filePath); } catch (e) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); @@ -17231,8 +18027,8 @@ var ts; output += diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): "; } var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine; - sys.write(output); + output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + ts.sys.newLine; + ts.sys.write(output); } function reportDiagnostics(diagnostics) { for (var i = 0; i < diagnostics.length; i++) { @@ -17252,7 +18048,7 @@ var ts; return s; } function reportStatisticalValue(name, value) { - sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + sys.newLine); + ts.sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + ts.sys.newLine); } function reportCountStatistic(name, count) { reportStatisticalValue(name, "" + count); @@ -17260,101 +18056,45 @@ var ts; function reportTimeStatistic(name, time) { reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); } - function createCompilerHost(options) { - var currentDirectory; - var existingDirectories = {}; - function getCanonicalFileName(fileName) { - return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(filename, languageVersion, onError) { - try { - var text = sys.readFile(filename, options.charset); - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode ? getDiagnosticText(ts.Diagnostics.Unsupported_file_encoding) : e.message); - } - text = ""; - } - return text !== undefined ? ts.createSourceFile(filename, text, languageVersion, "0") : undefined; - } - function writeFile(fileName, data, writeByteOrderMark, onError) { - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - sys.createDirectory(directoryPath); - } - } - try { - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - sys.writeFile(fileName, data, writeByteOrderMark); - } - catch (e) { - if (onError) - onError(e.message); - } - } - return { - getSourceFile: getSourceFile, - getDefaultLibFilename: function () { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(sys.getExecutingFilePath())), "lib.d.ts"); }, - writeFile: writeFile, - getCurrentDirectory: function () { return currentDirectory || (currentDirectory = sys.getCurrentDirectory()); }, - useCaseSensitiveFileNames: function () { return sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return sys.newLine; } - }; - } function executeCommandLine(args) { var commandLine = ts.parseCommandLine(args); var compilerOptions = commandLine.options; if (compilerOptions.locale) { if (typeof JSON === "undefined") { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); - return sys.exit(1); + return ts.sys.exit(1); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); } if (commandLine.errors.length > 0) { reportDiagnostics(commandLine.errors); - return sys.exit(5 /* CompilerOptionsErrors */); + return ts.sys.exit(5 /* CompilerOptionsErrors */); } if (compilerOptions.version) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, version)); - return sys.exit(0 /* Succeeded */); + return ts.sys.exit(0 /* Succeeded */); } if (compilerOptions.help) { printVersion(); printHelp(); - return sys.exit(0 /* Succeeded */); + return ts.sys.exit(0 /* Succeeded */); } if (commandLine.filenames.length === 0) { printVersion(); printHelp(); - return sys.exit(5 /* CompilerOptionsErrors */); + return ts.sys.exit(5 /* CompilerOptionsErrors */); } - var defaultCompilerHost = createCompilerHost(compilerOptions); + var defaultCompilerHost = ts.createCompilerHost(compilerOptions); if (compilerOptions.watch) { - if (!sys.watchFile) { + if (!ts.sys.watchFile) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); - return sys.exit(5 /* CompilerOptionsErrors */); + return ts.sys.exit(5 /* CompilerOptionsErrors */); } watchProgram(commandLine, defaultCompilerHost); } else { var result = compile(commandLine, defaultCompilerHost).exitStatus; - return sys.exit(result); + return ts.sys.exit(result); } } ts.executeCommandLine = executeCommandLine; @@ -17368,7 +18108,7 @@ var ts; function addWatchers(program) { ts.forEach(program.getSourceFiles(), function (f) { var filename = getCanonicalName(f.filename); - watchers[filename] = sys.watchFile(filename, fileUpdated); + watchers[filename] = ts.sys.watchFile(filename, fileUpdated); }); } function removeWatchers(program) { @@ -17443,7 +18183,7 @@ var ts; } reportDiagnostics(errors); if (commandLine.options.diagnostics) { - var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; + var memoryUsed = ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : -1; reportCountStatistic("Files", program.getSourceFiles().length); reportCountStatistic("Lines", countLines(program)); reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0); @@ -17462,7 +18202,7 @@ var ts; return { program: program, exitStatus: exitStatus }; } function printVersion() { - sys.write(getDiagnosticText(ts.Diagnostics.Version_0, version) + sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, version) + ts.sys.newLine); } function printHelp() { var output = ""; @@ -17472,13 +18212,13 @@ var ts; var syntax = makePadding(marginLength - syntaxLength); syntax += "tsc [" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + " ...]"; output += getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax); - output += sys.newLine + sys.newLine; + output += ts.sys.newLine + ts.sys.newLine; var padding = makePadding(marginLength); - output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine; - output += padding + "tsc --out file.js file.ts" + sys.newLine; - output += padding + "tsc @args.txt" + sys.newLine; - output += sys.newLine; - output += getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine; + output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine; + output += padding + "tsc --out file.js file.ts" + ts.sys.newLine; + output += padding + "tsc @args.txt" + ts.sys.newLine; + output += ts.sys.newLine; + output += getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine; var optsList = ts.optionDeclarations.slice(); optsList.sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }); var marginLength = 0; @@ -17492,11 +18232,11 @@ var ts; var usageText = " "; if (option.shortName) { usageText += "-" + option.shortName; - usageText += getParamName(option); + usageText += getParamType(option); usageText += ", "; } usageText += "--" + option.name; - usageText += getParamName(option); + usageText += getParamType(option); usageColumn.push(usageText); descriptionColumn.push(getDiagnosticText(option.description)); marginLength = Math.max(usageText.length, marginLength); @@ -17508,13 +18248,13 @@ var ts; for (var i = 0; i < usageColumn.length; i++) { var usage = usageColumn[i]; var description = descriptionColumn[i]; - output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine; + output += usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine; } - sys.write(output); + ts.sys.write(output); return; - function getParamName(option) { - if (option.paramName !== undefined) { - return " " + getDiagnosticText(option.paramName); + function getParamType(option) { + if (option.paramType !== undefined) { + return " " + getDiagnosticText(option.paramType); } return ""; } @@ -17523,4 +18263,4 @@ var ts; } } })(ts || (ts = {})); -ts.executeCommandLine(sys.args); +ts.executeCommandLine(ts.sys.args); diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts new file mode 100644 index 00000000000..abaf4e1c8fe --- /dev/null +++ b/bin/typescript.d.ts @@ -0,0 +1,1849 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +declare module "typescript" { + interface Map { + [index: string]: T; + } + interface TextRange { + pos: number; + end: number; + } + const enum SyntaxKind { + Unknown = 0, + EndOfFileToken = 1, + SingleLineCommentTrivia = 2, + MultiLineCommentTrivia = 3, + NewLineTrivia = 4, + WhitespaceTrivia = 5, + NumericLiteral = 6, + StringLiteral = 7, + RegularExpressionLiteral = 8, + NoSubstitutionTemplateLiteral = 9, + TemplateHead = 10, + TemplateMiddle = 11, + TemplateTail = 12, + OpenBraceToken = 13, + CloseBraceToken = 14, + OpenParenToken = 15, + CloseParenToken = 16, + OpenBracketToken = 17, + CloseBracketToken = 18, + DotToken = 19, + DotDotDotToken = 20, + SemicolonToken = 21, + CommaToken = 22, + LessThanToken = 23, + GreaterThanToken = 24, + LessThanEqualsToken = 25, + GreaterThanEqualsToken = 26, + EqualsEqualsToken = 27, + ExclamationEqualsToken = 28, + EqualsEqualsEqualsToken = 29, + ExclamationEqualsEqualsToken = 30, + EqualsGreaterThanToken = 31, + PlusToken = 32, + MinusToken = 33, + AsteriskToken = 34, + SlashToken = 35, + PercentToken = 36, + PlusPlusToken = 37, + MinusMinusToken = 38, + LessThanLessThanToken = 39, + GreaterThanGreaterThanToken = 40, + GreaterThanGreaterThanGreaterThanToken = 41, + AmpersandToken = 42, + BarToken = 43, + CaretToken = 44, + ExclamationToken = 45, + TildeToken = 46, + AmpersandAmpersandToken = 47, + BarBarToken = 48, + QuestionToken = 49, + ColonToken = 50, + EqualsToken = 51, + PlusEqualsToken = 52, + MinusEqualsToken = 53, + AsteriskEqualsToken = 54, + SlashEqualsToken = 55, + PercentEqualsToken = 56, + LessThanLessThanEqualsToken = 57, + GreaterThanGreaterThanEqualsToken = 58, + GreaterThanGreaterThanGreaterThanEqualsToken = 59, + AmpersandEqualsToken = 60, + BarEqualsToken = 61, + CaretEqualsToken = 62, + Identifier = 63, + BreakKeyword = 64, + CaseKeyword = 65, + CatchKeyword = 66, + ClassKeyword = 67, + ConstKeyword = 68, + ContinueKeyword = 69, + DebuggerKeyword = 70, + DefaultKeyword = 71, + DeleteKeyword = 72, + DoKeyword = 73, + ElseKeyword = 74, + EnumKeyword = 75, + ExportKeyword = 76, + ExtendsKeyword = 77, + FalseKeyword = 78, + FinallyKeyword = 79, + ForKeyword = 80, + FunctionKeyword = 81, + IfKeyword = 82, + ImportKeyword = 83, + InKeyword = 84, + InstanceOfKeyword = 85, + NewKeyword = 86, + NullKeyword = 87, + ReturnKeyword = 88, + SuperKeyword = 89, + SwitchKeyword = 90, + ThisKeyword = 91, + ThrowKeyword = 92, + TrueKeyword = 93, + TryKeyword = 94, + TypeOfKeyword = 95, + VarKeyword = 96, + VoidKeyword = 97, + WhileKeyword = 98, + WithKeyword = 99, + ImplementsKeyword = 100, + InterfaceKeyword = 101, + LetKeyword = 102, + PackageKeyword = 103, + PrivateKeyword = 104, + ProtectedKeyword = 105, + PublicKeyword = 106, + StaticKeyword = 107, + YieldKeyword = 108, + AnyKeyword = 109, + BooleanKeyword = 110, + ConstructorKeyword = 111, + DeclareKeyword = 112, + GetKeyword = 113, + ModuleKeyword = 114, + RequireKeyword = 115, + NumberKeyword = 116, + SetKeyword = 117, + StringKeyword = 118, + TypeKeyword = 119, + QualifiedName = 120, + ComputedPropertyName = 121, + TypeParameter = 122, + Parameter = 123, + Property = 124, + Method = 125, + Constructor = 126, + GetAccessor = 127, + SetAccessor = 128, + CallSignature = 129, + ConstructSignature = 130, + IndexSignature = 131, + TypeReference = 132, + FunctionType = 133, + ConstructorType = 134, + TypeQuery = 135, + TypeLiteral = 136, + ArrayType = 137, + TupleType = 138, + UnionType = 139, + ParenthesizedType = 140, + ArrayLiteralExpression = 141, + ObjectLiteralExpression = 142, + PropertyAccessExpression = 143, + ElementAccessExpression = 144, + CallExpression = 145, + NewExpression = 146, + TaggedTemplateExpression = 147, + TypeAssertionExpression = 148, + ParenthesizedExpression = 149, + FunctionExpression = 150, + ArrowFunction = 151, + DeleteExpression = 152, + TypeOfExpression = 153, + VoidExpression = 154, + PrefixUnaryExpression = 155, + PostfixUnaryExpression = 156, + BinaryExpression = 157, + ConditionalExpression = 158, + TemplateExpression = 159, + YieldExpression = 160, + OmittedExpression = 161, + TemplateSpan = 162, + Block = 163, + VariableStatement = 164, + EmptyStatement = 165, + ExpressionStatement = 166, + IfStatement = 167, + DoStatement = 168, + WhileStatement = 169, + ForStatement = 170, + ForInStatement = 171, + ContinueStatement = 172, + BreakStatement = 173, + ReturnStatement = 174, + WithStatement = 175, + SwitchStatement = 176, + LabeledStatement = 177, + ThrowStatement = 178, + TryStatement = 179, + TryBlock = 180, + FinallyBlock = 181, + DebuggerStatement = 182, + VariableDeclaration = 183, + FunctionDeclaration = 184, + ClassDeclaration = 185, + InterfaceDeclaration = 186, + TypeAliasDeclaration = 187, + EnumDeclaration = 188, + ModuleDeclaration = 189, + ModuleBlock = 190, + ImportDeclaration = 191, + ExportAssignment = 192, + ExternalModuleReference = 193, + CaseClause = 194, + DefaultClause = 195, + HeritageClause = 196, + CatchClause = 197, + PropertyAssignment = 198, + ShorthandPropertyAssignment = 199, + EnumMember = 200, + SourceFile = 201, + Program = 202, + SyntaxList = 203, + Count = 204, + FirstAssignment = 51, + LastAssignment = 62, + FirstReservedWord = 64, + LastReservedWord = 99, + FirstKeyword = 64, + LastKeyword = 119, + FirstFutureReservedWord = 100, + LastFutureReservedWord = 108, + FirstTypeNode = 132, + LastTypeNode = 140, + FirstPunctuation = 13, + LastPunctuation = 62, + FirstToken = 0, + LastToken = 119, + FirstTriviaToken = 2, + LastTriviaToken = 5, + FirstLiteralToken = 6, + LastLiteralToken = 9, + FirstTemplateToken = 9, + LastTemplateToken = 12, + FirstOperator = 21, + LastOperator = 62, + FirstBinaryOperator = 23, + LastBinaryOperator = 62, + FirstNode = 120, + } + const enum NodeFlags { + Export = 1, + Ambient = 2, + Public = 16, + Private = 32, + Protected = 64, + Static = 128, + MultiLine = 256, + Synthetic = 512, + DeclarationFile = 1024, + Let = 2048, + Const = 4096, + OctalLiteral = 8192, + Modifier = 243, + AccessibilityModifier = 112, + BlockScoped = 6144, + } + const enum ParserContextFlags { + StrictMode = 1, + DisallowIn = 2, + Yield = 4, + GeneratorParameter = 8, + ContainsError = 16, + HasPropagatedChildContainsErrorFlag = 32, + } + interface Node extends TextRange { + kind: SyntaxKind; + flags: NodeFlags; + parserContextFlags?: ParserContextFlags; + id?: number; + parent?: Node; + symbol?: Symbol; + locals?: SymbolTable; + nextContainer?: Node; + localSymbol?: Symbol; + modifiers?: ModifiersArray; + } + interface NodeArray extends Array, TextRange { + hasTrailingComma?: boolean; + } + interface ModifiersArray extends NodeArray { + flags: number; + } + interface Identifier extends PrimaryExpression { + text: string; + } + interface QualifiedName extends Node { + left: EntityName; + right: Identifier; + } + type EntityName = Identifier | QualifiedName; + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName; + interface Declaration extends Node { + _declarationBrand: any; + name?: DeclarationName; + } + interface ComputedPropertyName extends Node { + expression: Expression; + } + interface TypeParameterDeclaration extends Declaration { + name: Identifier; + constraint?: TypeNode; + expression?: Expression; + } + interface SignatureDeclaration extends Declaration { + typeParameters?: NodeArray; + parameters: NodeArray; + type?: TypeNode; + } + interface VariableDeclaration extends Declaration { + name: Identifier; + type?: TypeNode; + initializer?: Expression; + } + interface ParameterDeclaration extends Declaration { + dotDotDotToken?: Node; + name: Identifier; + questionToken?: Node; + type?: TypeNode | StringLiteralExpression; + initializer?: Expression; + } + interface PropertyDeclaration extends Declaration, ClassElement { + _propertyDeclarationBrand: any; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + type VariableOrParameterDeclaration = VariableDeclaration | ParameterDeclaration; + type VariableOrParameterOrPropertyDeclaration = VariableOrParameterDeclaration | PropertyDeclaration; + interface ObjectLiteralElement extends Declaration { + _objectLiteralBrandBrand: any; + } + interface ShorthandPropertyAssignment extends ObjectLiteralElement { + name: Identifier; + questionToken?: Node; + } + interface PropertyAssignment extends ObjectLiteralElement { + _propertyAssignmentBrand: any; + name: DeclarationName; + questionToken?: Node; + initializer: Expression; + } + /** + * Several node kinds share function-like features such as a signature, + * a name, and a body. These nodes should extend FunctionLikeDeclaration. + * Examples: + * FunctionDeclaration + * MethodDeclaration + * AccessorDeclaration + */ + interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: Node; + questionToken?: Node; + body?: Block | Expression; + } + interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { + name: Identifier; + body?: Block; + } + interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + body?: Block; + } + interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + body?: Block; + } + interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + _accessorDeclarationBrand: any; + body: Block; + } + interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { + _indexSignatureDeclarationBrand: any; + } + interface TypeNode extends Node { + _typeNodeBrand: any; + } + interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { + _functionOrConstructorTypeNodeBrand: any; + } + interface TypeReferenceNode extends TypeNode { + typeName: EntityName; + typeArguments?: NodeArray; + } + interface TypeQueryNode extends TypeNode { + exprName: EntityName; + } + interface TypeLiteralNode extends TypeNode, Declaration { + members: NodeArray; + } + interface ArrayTypeNode extends TypeNode { + elementType: TypeNode; + } + interface TupleTypeNode extends TypeNode { + elementTypes: NodeArray; + } + interface UnionTypeNode extends TypeNode { + types: NodeArray; + } + interface ParenthesizedTypeNode extends TypeNode { + type: TypeNode; + } + interface Expression extends Node { + _expressionBrand: any; + contextualType?: Type; + } + interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; + } + interface PrefixUnaryExpression extends UnaryExpression { + operator: SyntaxKind; + operand: UnaryExpression; + } + interface PostfixUnaryExpression extends PostfixExpression { + operand: LeftHandSideExpression; + operator: SyntaxKind; + } + interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; + } + interface LeftHandSideExpression extends PostfixExpression { + _leftHandSideExpressionBrand: any; + } + interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; + } + interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; + } + interface DeleteExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface TypeOfExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface VoidExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface YieldExpression extends Expression { + asteriskToken?: Node; + expression: Expression; + } + interface BinaryExpression extends Expression { + left: Expression; + operator: SyntaxKind; + right: Expression; + } + interface ConditionalExpression extends Expression { + condition: Expression; + whenTrue: Expression; + whenFalse: Expression; + } + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + name?: Identifier; + body: Block | Expression; + } + interface LiteralExpression extends PrimaryExpression { + text: string; + isUnterminated?: boolean; + } + interface StringLiteralExpression extends LiteralExpression { + _stringLiteralExpressionBrand: any; + } + interface TemplateExpression extends PrimaryExpression { + head: LiteralExpression; + templateSpans: NodeArray; + } + interface TemplateSpan extends Node { + expression: Expression; + literal: LiteralExpression; + } + interface ParenthesizedExpression extends PrimaryExpression { + expression: Expression; + } + interface ArrayLiteralExpression extends PrimaryExpression { + elements: NodeArray; + } + interface ObjectLiteralExpression extends PrimaryExpression, Declaration { + properties: NodeArray; + } + interface PropertyAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + name: Identifier; + } + interface ElementAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + argumentExpression?: Expression; + } + interface CallExpression extends LeftHandSideExpression { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; + } + interface NewExpression extends CallExpression, PrimaryExpression { + } + interface TaggedTemplateExpression extends MemberExpression { + tag: LeftHandSideExpression; + template: LiteralExpression | TemplateExpression; + } + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + interface TypeAssertion extends UnaryExpression { + type: TypeNode; + expression: UnaryExpression; + } + interface Statement extends Node, ModuleElement { + _statementBrand: any; + } + interface Block extends Statement { + statements: NodeArray; + } + interface VariableStatement extends Statement { + declarations: NodeArray; + } + interface ExpressionStatement extends Statement { + expression: Expression; + } + interface IfStatement extends Statement { + expression: Expression; + thenStatement: Statement; + elseStatement?: Statement; + } + interface IterationStatement extends Statement { + statement: Statement; + } + interface DoStatement extends IterationStatement { + expression: Expression; + } + interface WhileStatement extends IterationStatement { + expression: Expression; + } + interface ForStatement extends IterationStatement { + declarations?: NodeArray; + initializer?: Expression; + condition?: Expression; + iterator?: Expression; + } + interface ForInStatement extends IterationStatement { + declarations?: NodeArray; + variable?: Expression; + expression: Expression; + } + interface BreakOrContinueStatement extends Statement { + label?: Identifier; + } + interface ReturnStatement extends Statement { + expression?: Expression; + } + interface WithStatement extends Statement { + expression: Expression; + statement: Statement; + } + interface SwitchStatement extends Statement { + expression: Expression; + clauses: NodeArray; + } + interface CaseClause extends Node { + expression?: Expression; + statements: NodeArray; + } + interface DefaultClause extends Node { + statements: NodeArray; + } + type CaseOrDefaultClause = CaseClause | DefaultClause; + interface LabeledStatement extends Statement { + label: Identifier; + statement: Statement; + } + interface ThrowStatement extends Statement { + expression: Expression; + } + interface TryStatement extends Statement { + tryBlock: Block; + catchClause?: CatchClause; + finallyBlock?: Block; + } + interface CatchClause extends Declaration { + name: Identifier; + type?: TypeNode; + block: Block; + } + interface ModuleElement extends Node { + _moduleElementBrand: any; + } + interface ClassDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface ClassElement extends Declaration { + _classElementBrand: any; + } + interface InterfaceDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface HeritageClause extends Node { + token: SyntaxKind; + types?: NodeArray; + } + interface TypeAliasDeclaration extends Declaration, ModuleElement { + name: Identifier; + type: TypeNode; + } + interface EnumMember extends Declaration { + name: DeclarationName; + initializer?: Expression; + } + interface EnumDeclaration extends Declaration, ModuleElement { + name: Identifier; + members: NodeArray; + } + interface ModuleDeclaration extends Declaration, ModuleElement { + name: Identifier | LiteralExpression; + body: ModuleBlock | ModuleDeclaration; + } + interface ModuleBlock extends Node, ModuleElement { + statements: NodeArray; + } + interface ImportDeclaration extends Declaration, ModuleElement { + name: Identifier; + moduleReference: EntityName | ExternalModuleReference; + } + interface ExternalModuleReference extends Node { + expression?: Expression; + } + interface ExportAssignment extends Statement, ModuleElement { + exportName: Identifier; + } + interface FileReference extends TextRange { + filename: string; + } + interface CommentRange extends TextRange { + hasTrailingNewLine?: boolean; + } + interface SourceFile extends Declaration { + statements: NodeArray; + endOfFileToken: Node; + filename: string; + text: string; + getLineAndCharacterFromPosition(position: number): LineAndCharacter; + getPositionFromLineAndCharacter(line: number, character: number): number; + getLineStarts(): number[]; + amdDependencies: string[]; + amdModuleName: string; + referencedFiles: FileReference[]; + referenceDiagnostics: Diagnostic[]; + parseDiagnostics: Diagnostic[]; + grammarDiagnostics: Diagnostic[]; + getSyntacticDiagnostics(): Diagnostic[]; + semanticDiagnostics: Diagnostic[]; + hasNoDefaultLib: boolean; + externalModuleIndicator: Node; + nodeCount: number; + identifierCount: number; + symbolCount: number; + isOpen: boolean; + version: string; + languageVersion: ScriptTarget; + identifiers: Map; + } + interface Program { + getSourceFile(filename: string): SourceFile; + getSourceFiles(): SourceFile[]; + getCompilerOptions(): CompilerOptions; + getCompilerHost(): CompilerHost; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getTypeChecker(fullTypeCheckMode: boolean): TypeChecker; + getCommonSourceDirectory(): string; + } + interface SourceMapSpan { + emittedLine: number; + emittedColumn: number; + sourceLine: number; + sourceColumn: number; + nameIndex?: number; + sourceIndex: number; + } + interface SourceMapData { + sourceMapFilePath: string; + jsSourceMappingURL: string; + sourceMapFile: string; + sourceMapSourceRoot: string; + sourceMapSources: string[]; + inputSourceFileNames: string[]; + sourceMapNames?: string[]; + sourceMapMappings: string; + sourceMapDecodedMappings: SourceMapSpan[]; + } + enum EmitReturnStatus { + Succeeded = 0, + AllOutputGenerationSkipped = 1, + JSGeneratedWithSemanticErrors = 2, + DeclarationGenerationSkipped = 3, + EmitErrorsEncountered = 4, + CompilerOptionsErrors = 5, + } + interface EmitResult { + emitResultStatus: EmitReturnStatus; + diagnostics: Diagnostic[]; + sourceMaps: SourceMapData[]; + } + interface TypeChecker { + getProgram(): Program; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + emitFiles(targetSourceFile?: SourceFile): EmitResult; + getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; + getDeclaredTypeOfSymbol(symbol: Symbol): Type; + getPropertiesOfType(type: Type): Symbol[]; + getPropertyOfType(type: Type, propertyName: string): Symbol; + getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getReturnTypeOfSignature(signature: Signature): Type; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; + getSymbolAtLocation(node: Node): Symbol; + getShorthandAssignmentValueSymbol(location: Node): Symbol; + getTypeAtLocation(node: Node): Type; + typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; + symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; + getFullyQualifiedName(symbol: Symbol): string; + getAugmentedPropertiesOfType(type: Type): Symbol[]; + getRootSymbols(symbol: Symbol): Symbol[]; + getContextualType(node: Expression): Type; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; + getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + isUndefinedSymbol(symbol: Symbol): boolean; + isArgumentsSymbol(symbol: Symbol): boolean; + isEmitBlocked(sourceFile?: SourceFile): boolean; + getEnumMemberValue(node: EnumMember): number; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + getAliasedSymbol(symbol: Symbol): Symbol; + } + interface SymbolDisplayBuilder { + buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; + buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + } + interface SymbolWriter { + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; + writeSymbol(text: string, symbol: Symbol): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + clear(): void; + trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + } + const enum TypeFormatFlags { + None = 0, + WriteArrayAsGenericType = 1, + UseTypeOfFunction = 2, + NoTruncation = 4, + WriteArrowStyleSignature = 8, + WriteOwnNameForAnyLike = 16, + WriteTypeArgumentsOfSignature = 32, + InElementType = 64, + } + const enum SymbolFormatFlags { + None = 0, + WriteTypeParametersOrArguments = 1, + UseOnlyExternalAliasing = 2, + } + const enum SymbolAccessibility { + Accessible = 0, + NotAccessible = 1, + CannotBeNamed = 2, + } + interface SymbolVisibilityResult { + accessibility: SymbolAccessibility; + aliasesToMakeVisible?: ImportDeclaration[]; + errorSymbolName?: string; + errorNode?: Node; + } + interface SymbolAccessiblityResult extends SymbolVisibilityResult { + errorModuleName?: string; + } + interface EmitResolver { + getProgram(): Program; + getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string; + getExpressionNamePrefix(node: Identifier): string; + getExportAssignmentName(node: SourceFile): string; + isReferencedImportDeclaration(node: ImportDeclaration): boolean; + isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean; + getNodeCheckFlags(node: Node): NodeCheckFlags; + getEnumMemberValue(node: EnumMember): number; + hasSemanticErrors(sourceFile?: SourceFile): boolean; + isDeclarationVisible(node: Declaration): boolean; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableOrParameterDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; + isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; + getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + isEmitBlocked(sourceFile?: SourceFile): boolean; + } + const enum SymbolFlags { + FunctionScopedVariable = 1, + BlockScopedVariable = 2, + Property = 4, + EnumMember = 8, + Function = 16, + Class = 32, + Interface = 64, + ConstEnum = 128, + RegularEnum = 256, + ValueModule = 512, + NamespaceModule = 1024, + TypeLiteral = 2048, + ObjectLiteral = 4096, + Method = 8192, + Constructor = 16384, + GetAccessor = 32768, + SetAccessor = 65536, + CallSignature = 131072, + ConstructSignature = 262144, + IndexSignature = 524288, + TypeParameter = 1048576, + TypeAlias = 2097152, + ExportValue = 4194304, + ExportType = 8388608, + ExportNamespace = 16777216, + Import = 33554432, + Instantiated = 67108864, + Merged = 134217728, + Transient = 268435456, + Prototype = 536870912, + UnionProperty = 1073741824, + Enum = 384, + Variable = 3, + Value = 107455, + Type = 3152352, + Namespace = 1536, + Module = 1536, + Accessor = 98304, + Signature = 917504, + FunctionScopedVariableExcludes = 107454, + BlockScopedVariableExcludes = 107455, + ParameterExcludes = 107455, + PropertyExcludes = 107455, + EnumMemberExcludes = 107455, + FunctionExcludes = 106927, + ClassExcludes = 3258879, + InterfaceExcludes = 3152288, + RegularEnumExcludes = 3258623, + ConstEnumExcludes = 3259263, + ValueModuleExcludes = 106639, + NamespaceModuleExcludes = 0, + MethodExcludes = 99263, + GetAccessorExcludes = 41919, + SetAccessorExcludes = 74687, + TypeParameterExcludes = 2103776, + TypeAliasExcludes = 3152352, + ImportExcludes = 33554432, + ModuleMember = 35653619, + ExportHasLocal = 944, + HasLocals = 1041936, + HasExports = 1952, + HasMembers = 6240, + IsContainer = 1048560, + PropertyOrAccessor = 98308, + Export = 29360128, + } + interface Symbol { + flags: SymbolFlags; + name: string; + id?: number; + mergeId?: number; + declarations?: Declaration[]; + parent?: Symbol; + members?: SymbolTable; + exports?: SymbolTable; + exportSymbol?: Symbol; + valueDeclaration?: Declaration; + constEnumOnlyModule?: boolean; + } + interface SymbolLinks { + target?: Symbol; + type?: Type; + declaredType?: Type; + mapper?: TypeMapper; + referenced?: boolean; + exportAssignSymbol?: Symbol; + unionType?: UnionType; + } + interface TransientSymbol extends Symbol, SymbolLinks { + } + interface SymbolTable { + [index: string]: Symbol; + } + const enum NodeCheckFlags { + TypeChecked = 1, + LexicalThis = 2, + CaptureThis = 4, + EmitExtends = 8, + SuperInstance = 16, + SuperStatic = 32, + ContextChecked = 64, + EnumValuesComputed = 128, + } + interface NodeLinks { + resolvedType?: Type; + resolvedSignature?: Signature; + resolvedSymbol?: Symbol; + flags?: NodeCheckFlags; + enumMemberValue?: number; + isIllegalTypeReferenceInConstraint?: boolean; + isVisible?: boolean; + localModuleName?: string; + assignmentChecks?: Map; + } + const enum TypeFlags { + Any = 1, + String = 2, + Number = 4, + Boolean = 8, + Void = 16, + Undefined = 32, + Null = 64, + Enum = 128, + StringLiteral = 256, + TypeParameter = 512, + Class = 1024, + Interface = 2048, + Reference = 4096, + Tuple = 8192, + Union = 16384, + Anonymous = 32768, + FromSignature = 65536, + Intrinsic = 127, + StringLike = 258, + NumberLike = 132, + ObjectType = 48128, + } + interface Type { + flags: TypeFlags; + id: number; + symbol?: Symbol; + } + interface IntrinsicType extends Type { + intrinsicName: string; + } + interface StringLiteralType extends Type { + text: string; + } + interface ObjectType extends Type { + } + interface InterfaceType extends ObjectType { + typeParameters: TypeParameter[]; + baseTypes: ObjectType[]; + declaredProperties: Symbol[]; + declaredCallSignatures: Signature[]; + declaredConstructSignatures: Signature[]; + declaredStringIndexType: Type; + declaredNumberIndexType: Type; + } + interface TypeReference extends ObjectType { + target: GenericType; + typeArguments: Type[]; + } + interface GenericType extends InterfaceType, TypeReference { + instantiations: Map; + openReferenceTargets: GenericType[]; + openReferenceChecks: Map; + } + interface TupleType extends ObjectType { + elementTypes: Type[]; + baseArrayType: TypeReference; + } + interface UnionType extends Type { + types: Type[]; + resolvedProperties: SymbolTable; + } + interface ResolvedType extends ObjectType, UnionType { + members: SymbolTable; + properties: Symbol[]; + callSignatures: Signature[]; + constructSignatures: Signature[]; + stringIndexType: Type; + numberIndexType: Type; + } + interface TypeParameter extends Type { + constraint: Type; + target?: TypeParameter; + mapper?: TypeMapper; + } + const enum SignatureKind { + Call = 0, + Construct = 1, + } + interface Signature { + declaration: SignatureDeclaration; + typeParameters: TypeParameter[]; + parameters: Symbol[]; + resolvedReturnType: Type; + minArgumentCount: number; + hasRestParameter: boolean; + hasStringLiterals: boolean; + target?: Signature; + mapper?: TypeMapper; + unionSignatures?: Signature[]; + erasedSignatureCache?: Signature; + isolatedSignatureType?: ObjectType; + } + const enum IndexKind { + String = 0, + Number = 1, + } + interface TypeMapper { + (t: Type): Type; + } + interface TypeInferences { + primary: Type[]; + secondary: Type[]; + } + interface InferenceContext { + typeParameters: TypeParameter[]; + inferUnionTypes: boolean; + inferences: TypeInferences[]; + inferredTypes: Type[]; + failedTypeParameterIndex?: number; + } + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + isEarly?: boolean; + } + interface DiagnosticMessageChain { + messageText: string; + category: DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain; + } + interface Diagnostic { + file: SourceFile; + start: number; + length: number; + messageText: string; + category: DiagnosticCategory; + code: number; + /** + * Early error - any error (can be produced at parsing\binding\typechecking step) that blocks emit + */ + isEarly?: boolean; + } + enum DiagnosticCategory { + Warning = 0, + Error = 1, + Message = 2, + } + interface CompilerOptions { + allowNonTsExtensions?: boolean; + charset?: string; + codepage?: number; + declaration?: boolean; + diagnostics?: boolean; + emitBOM?: boolean; + help?: boolean; + locale?: string; + mapRoot?: string; + module?: ModuleKind; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noImplicitAny?: boolean; + noLib?: boolean; + noLibCheck?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + preserveConstEnums?: boolean; + removeComments?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget; + version?: boolean; + watch?: boolean; + [option: string]: string | number | boolean; + } + const enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + } + interface LineAndCharacter { + line: number; + character: number; + } + const enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES6 = 2, + Latest = 2, + } + interface ParsedCommandLine { + options: CompilerOptions; + filenames: string[]; + errors: Diagnostic[]; + } + interface CommandLineOption { + name: string; + type: string | Map; + shortName?: string; + description?: DiagnosticMessage; + paramType?: DiagnosticMessage; + error?: DiagnosticMessage; + } + const enum CharacterCodes { + nullCharacter = 0, + maxAsciiCharacter = 127, + lineFeed = 10, + carriageReturn = 13, + lineSeparator = 8232, + paragraphSeparator = 8233, + nextLine = 133, + space = 32, + nonBreakingSpace = 160, + enQuad = 8192, + emQuad = 8193, + enSpace = 8194, + emSpace = 8195, + threePerEmSpace = 8196, + fourPerEmSpace = 8197, + sixPerEmSpace = 8198, + figureSpace = 8199, + punctuationSpace = 8200, + thinSpace = 8201, + hairSpace = 8202, + zeroWidthSpace = 8203, + narrowNoBreakSpace = 8239, + ideographicSpace = 12288, + mathematicalSpace = 8287, + ogham = 5760, + _ = 95, + $ = 36, + _0 = 48, + _1 = 49, + _2 = 50, + _3 = 51, + _4 = 52, + _5 = 53, + _6 = 54, + _7 = 55, + _8 = 56, + _9 = 57, + a = 97, + b = 98, + c = 99, + d = 100, + e = 101, + f = 102, + g = 103, + h = 104, + i = 105, + j = 106, + k = 107, + l = 108, + m = 109, + n = 110, + o = 111, + p = 112, + q = 113, + r = 114, + s = 115, + t = 116, + u = 117, + v = 118, + w = 119, + x = 120, + y = 121, + z = 122, + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + ampersand = 38, + asterisk = 42, + at = 64, + backslash = 92, + backtick = 96, + bar = 124, + caret = 94, + closeBrace = 125, + closeBracket = 93, + closeParen = 41, + colon = 58, + comma = 44, + dot = 46, + doubleQuote = 34, + equals = 61, + exclamation = 33, + greaterThan = 62, + lessThan = 60, + minus = 45, + openBrace = 123, + openBracket = 91, + openParen = 40, + percent = 37, + plus = 43, + question = 63, + semicolon = 59, + singleQuote = 39, + slash = 47, + tilde = 126, + backspace = 8, + formFeed = 12, + byteOrderMark = 65279, + tab = 9, + verticalTab = 11, + } + interface CancellationToken { + isCancellationRequested(): boolean; + } + interface CompilerHost { + getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getDefaultLibFilename(options: CompilerOptions): string; + getCancellationToken?(): CancellationToken; + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + useCaseSensitiveFileNames(): boolean; + getNewLine(): string; + } +} +declare module "typescript" { + interface ErrorCallback { + (message: DiagnosticMessage): void; + } + interface CommentCallback { + (pos: number, end: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } + function tokenToString(t: SyntaxKind): string; + function computeLineStarts(text: string): number[]; + function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number; + function getLineAndCharacterOfPosition(lineStarts: number[], position: number): { + line: number; + character: number; + }; + function positionToLineAndCharacter(text: string, pos: number): { + line: number; + character: number; + }; + function isWhiteSpace(ch: number): boolean; + function isLineBreak(ch: number): boolean; + function isOctalDigit(ch: number): boolean; + function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner; +} +declare module "typescript" { + function getNodeConstructor(kind: SyntaxKind): new () => Node; + function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; + function createCompilerHost(options: CompilerOptions): CompilerHost; + function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean): SourceFile; + function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program; +} +declare module "typescript" { + function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker; +} +declare module "typescript" { + var servicesVersion: string; + interface Node { + getSourceFile(): SourceFile; + getChildCount(sourceFile?: SourceFile): number; + getChildAt(index: number, sourceFile?: SourceFile): Node; + getChildren(sourceFile?: SourceFile): Node[]; + getStart(sourceFile?: SourceFile): number; + getFullStart(): number; + getEnd(): number; + getWidth(sourceFile?: SourceFile): number; + getFullWidth(): number; + getLeadingTriviaWidth(sourceFile?: SourceFile): number; + getFullText(sourceFile?: SourceFile): string; + getText(sourceFile?: SourceFile): string; + getFirstToken(sourceFile?: SourceFile): Node; + getLastToken(sourceFile?: SourceFile): Node; + } + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface Type { + getFlags(): TypeFlags; + getSymbol(): Symbol; + getProperties(): Symbol[]; + getProperty(propertyName: string): Symbol; + getApparentProperties(): Symbol[]; + getCallSignatures(): Signature[]; + getConstructSignatures(): Signature[]; + getStringIndexType(): Type; + getNumberIndexType(): Type; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + getScriptSnapshot(): IScriptSnapshot; + getNamedDeclarations(): Declaration[]; + update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + } + /** + * Represents an immutable snapshot of a script at a specified time.Once acquired, the + * snapshot is observably immutable. i.e. the same calls with the same parameters will return + * the same values. + */ + interface IScriptSnapshot { + /** Gets a portion of the script snapshot specified by [start, end). */ + getText(start: number, end: number): string; + /** Gets the length of this script snapshot. */ + getLength(): number; + /** + * This call returns the array containing the start position of every line. + * i.e."[0, 10, 55]". TODO: consider making this optional. The language service could + * always determine this (albeit in a more expensive manner). + */ + getLineStartPositions(): number[]; + /** + * Gets the TextChangeRange that describe how the text changed between this text and + * an older version. This information is used by the incremental parser to determine + * what sections of the script need to be re-parsed. 'undefined' can be returned if the + * change range cannot be determined. However, in that case, incremental parsing will + * not happen and the entire document will be re - parsed. + */ + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + } + module ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; + } + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + importedFiles: FileReference[]; + isLibFile: boolean; + } + interface Logger { + log(s: string): void; + } + interface LanguageServiceHost extends Logger { + getCompilationSettings(): CompilerOptions; + getScriptFileNames(): string[]; + getScriptVersion(fileName: string): string; + getScriptIsOpen(fileName: string): boolean; + getScriptSnapshot(fileName: string): IScriptSnapshot; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): CancellationToken; + getCurrentDirectory(): string; + getDefaultLibFilename(options: CompilerOptions): string; + } + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getRenameInfo(fileName: string, position: number): RenameInfo; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getNavigateToItems(searchValue: string): NavigateToItem[]; + getNavigationBarItems(fileName: string): NavigationBarItem[]; + getOutliningSpans(fileName: string): OutliningSpan[]; + getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getEmitOutput(fileName: string): EmitOutput; + getSourceFile(filename: string): SourceFile; + dispose(): void; + } + class TextSpan { + private _start; + private _length; + /** + * Creates a TextSpan instance beginning with the position Start and having the Length + * specified with length. + */ + constructor(start: number, length: number); + toJSON(key: any): any; + start(): number; + length(): number; + end(): number; + isEmpty(): boolean; + /** + * Determines whether the position lies within the span. Returns true if the position is greater than or equal to Start and strictly less + * than End, otherwise false. + * @param position The position to check. + */ + containsPosition(position: number): boolean; + /** + * Determines whether span falls completely within this span. Returns true if the specified span falls completely within this span, otherwise false. + * @param span The span to check. + */ + containsTextSpan(span: TextSpan): boolean; + /** + * Determines whether the given span overlaps this span. Two spans are considered to overlap + * if they have positions in common and neither is empty. Empty spans do not overlap with any + * other span. Returns true if the spans overlap, false otherwise. + * @param span The span to check. + */ + overlapsWith(span: TextSpan): boolean; + /** + * Returns the overlap with the given span, or undefined if there is no overlap. + * @param span The span to check. + */ + overlap(span: TextSpan): TextSpan; + /** + * Determines whether span intersects this span. Two spans are considered to + * intersect if they have positions in common or the end of one span + * coincides with the start of the other span. Returns true if the spans intersect, false otherwise. + * @param The span to check. + */ + intersectsWithTextSpan(span: TextSpan): boolean; + intersectsWith(start: number, length: number): boolean; + /** + * Determines whether the given position intersects this span. + * A position is considered to intersect if it is between the start and + * end positions (inclusive) of this span. Returns true if the position intersects, false otherwise. + * @param position The position to check. + */ + intersectsWithPosition(position: number): boolean; + /** + * Returns the intersection with the given span, or undefined if there is no intersection. + * @param span The span to check. + */ + intersection(span: TextSpan): TextSpan; + /** + * Creates a new TextSpan from the given start and end positions + * as opposed to a position and length. + */ + static fromBounds(start: number, end: number): TextSpan; + } + class TextChangeRange { + static unchanged: TextChangeRange; + private _span; + private _newLength; + /** + * Initializes a new instance of TextChangeRange. + */ + constructor(span: TextSpan, newLength: number); + /** + * The span of text before the edit which is being changed + */ + span(): TextSpan; + /** + * Width of the span after the edit. A 0 here would represent a delete + */ + newLength(): number; + newSpan(): TextSpan; + isUnchanged(): boolean; + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + static collapseChangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + } + interface FormatCodeOptions extends EditorOptions { + InsertSpaceAfterCommaDelimiter: boolean; + InsertSpaceAfterSemicolonInForStatements: boolean; + InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterKeywordsInControlFlowStatements: boolean; + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + PlaceOpenBraceOnNewLineForFunctions: boolean; + PlaceOpenBraceOnNewLineForControlBlocks: boolean; + } + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; + } + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + /** + * Represents a single signature to show in signature help. + * The id is used for subsequent calls into the language service to ask questions about the + * signature help item in the context of any documents that have been updated. i.e. after + * an edit has happened, while signature help is still active, the host can ask important + * questions like 'what parameter is the user currently contained within?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface CompletionInfo { + isMemberCompletion: boolean; + entries: CompletionEntry[]; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface OutliningSpan { + /** The span of the document to actually collapse. */ + textSpan: TextSpan; + /** The span of the document to display when the user hovers over the collapsed span. */ + hintSpan: TextSpan; + /** The text to display in the editor for the collapsed region. */ + bannerText: string; + /** + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ + autoCollapse: boolean; + } + interface EmitOutput { + outputFiles: OutputFile[]; + emitOutputStatus: EmitReturnStatus; + } + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, + } + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; + } + const enum EndOfLineState { + Start = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + } + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, + } + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; + } + interface ClassificationInfo { + length: number; + classification: TokenClass; + } + interface Classifier { + getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult; + } + interface DocumentRegistry { + acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean): SourceFile; + updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + releaseDocument(filename: string, compilationSettings: CompilerOptions): void; + } + class ScriptElementKind { + static unknown: string; + static keyword: string; + static scriptElement: string; + static moduleElement: string; + static classElement: string; + static interfaceElement: string; + static typeElement: string; + static enumElement: string; + static variableElement: string; + static localVariableElement: string; + static functionElement: string; + static localFunctionElement: string; + static memberFunctionElement: string; + static memberGetAccessorElement: string; + static memberSetAccessorElement: string; + static memberVariableElement: string; + static constructorImplementationElement: string; + static callSignatureElement: string; + static indexSignatureElement: string; + static constructSignatureElement: string; + static parameterElement: string; + static typeParameterElement: string; + static primitiveType: string; + static label: string; + static alias: string; + static constElement: string; + static letElement: string; + } + class ScriptElementKindModifier { + static none: string; + static publicMemberModifier: string; + static privateMemberModifier: string; + static protectedMemberModifier: string; + static exportedModifier: string; + static ambientModifier: string; + static staticModifier: string; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAlias: string; + } + interface DisplayPartsSymbolWriter extends SymbolWriter { + displayParts(): SymbolDisplayPart[]; + } + function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function getDefaultCompilerOptions(): CompilerOptions; + class OperationCanceledException { + } + class CancellationTokenObject { + private cancellationToken; + static None: CancellationTokenObject; + constructor(cancellationToken: CancellationToken); + isCancellationRequested(): boolean; + throwIfCancellationRequested(): void; + } + function createDocumentRegistry(): DocumentRegistry; + function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService; + function createClassifier(host: Logger): Classifier; +} diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts new file mode 100644 index 00000000000..04160566646 --- /dev/null +++ b/bin/typescriptServices.d.ts @@ -0,0 +1,1849 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +declare module ts { + interface Map { + [index: string]: T; + } + interface TextRange { + pos: number; + end: number; + } + const enum SyntaxKind { + Unknown = 0, + EndOfFileToken = 1, + SingleLineCommentTrivia = 2, + MultiLineCommentTrivia = 3, + NewLineTrivia = 4, + WhitespaceTrivia = 5, + NumericLiteral = 6, + StringLiteral = 7, + RegularExpressionLiteral = 8, + NoSubstitutionTemplateLiteral = 9, + TemplateHead = 10, + TemplateMiddle = 11, + TemplateTail = 12, + OpenBraceToken = 13, + CloseBraceToken = 14, + OpenParenToken = 15, + CloseParenToken = 16, + OpenBracketToken = 17, + CloseBracketToken = 18, + DotToken = 19, + DotDotDotToken = 20, + SemicolonToken = 21, + CommaToken = 22, + LessThanToken = 23, + GreaterThanToken = 24, + LessThanEqualsToken = 25, + GreaterThanEqualsToken = 26, + EqualsEqualsToken = 27, + ExclamationEqualsToken = 28, + EqualsEqualsEqualsToken = 29, + ExclamationEqualsEqualsToken = 30, + EqualsGreaterThanToken = 31, + PlusToken = 32, + MinusToken = 33, + AsteriskToken = 34, + SlashToken = 35, + PercentToken = 36, + PlusPlusToken = 37, + MinusMinusToken = 38, + LessThanLessThanToken = 39, + GreaterThanGreaterThanToken = 40, + GreaterThanGreaterThanGreaterThanToken = 41, + AmpersandToken = 42, + BarToken = 43, + CaretToken = 44, + ExclamationToken = 45, + TildeToken = 46, + AmpersandAmpersandToken = 47, + BarBarToken = 48, + QuestionToken = 49, + ColonToken = 50, + EqualsToken = 51, + PlusEqualsToken = 52, + MinusEqualsToken = 53, + AsteriskEqualsToken = 54, + SlashEqualsToken = 55, + PercentEqualsToken = 56, + LessThanLessThanEqualsToken = 57, + GreaterThanGreaterThanEqualsToken = 58, + GreaterThanGreaterThanGreaterThanEqualsToken = 59, + AmpersandEqualsToken = 60, + BarEqualsToken = 61, + CaretEqualsToken = 62, + Identifier = 63, + BreakKeyword = 64, + CaseKeyword = 65, + CatchKeyword = 66, + ClassKeyword = 67, + ConstKeyword = 68, + ContinueKeyword = 69, + DebuggerKeyword = 70, + DefaultKeyword = 71, + DeleteKeyword = 72, + DoKeyword = 73, + ElseKeyword = 74, + EnumKeyword = 75, + ExportKeyword = 76, + ExtendsKeyword = 77, + FalseKeyword = 78, + FinallyKeyword = 79, + ForKeyword = 80, + FunctionKeyword = 81, + IfKeyword = 82, + ImportKeyword = 83, + InKeyword = 84, + InstanceOfKeyword = 85, + NewKeyword = 86, + NullKeyword = 87, + ReturnKeyword = 88, + SuperKeyword = 89, + SwitchKeyword = 90, + ThisKeyword = 91, + ThrowKeyword = 92, + TrueKeyword = 93, + TryKeyword = 94, + TypeOfKeyword = 95, + VarKeyword = 96, + VoidKeyword = 97, + WhileKeyword = 98, + WithKeyword = 99, + ImplementsKeyword = 100, + InterfaceKeyword = 101, + LetKeyword = 102, + PackageKeyword = 103, + PrivateKeyword = 104, + ProtectedKeyword = 105, + PublicKeyword = 106, + StaticKeyword = 107, + YieldKeyword = 108, + AnyKeyword = 109, + BooleanKeyword = 110, + ConstructorKeyword = 111, + DeclareKeyword = 112, + GetKeyword = 113, + ModuleKeyword = 114, + RequireKeyword = 115, + NumberKeyword = 116, + SetKeyword = 117, + StringKeyword = 118, + TypeKeyword = 119, + QualifiedName = 120, + ComputedPropertyName = 121, + TypeParameter = 122, + Parameter = 123, + Property = 124, + Method = 125, + Constructor = 126, + GetAccessor = 127, + SetAccessor = 128, + CallSignature = 129, + ConstructSignature = 130, + IndexSignature = 131, + TypeReference = 132, + FunctionType = 133, + ConstructorType = 134, + TypeQuery = 135, + TypeLiteral = 136, + ArrayType = 137, + TupleType = 138, + UnionType = 139, + ParenthesizedType = 140, + ArrayLiteralExpression = 141, + ObjectLiteralExpression = 142, + PropertyAccessExpression = 143, + ElementAccessExpression = 144, + CallExpression = 145, + NewExpression = 146, + TaggedTemplateExpression = 147, + TypeAssertionExpression = 148, + ParenthesizedExpression = 149, + FunctionExpression = 150, + ArrowFunction = 151, + DeleteExpression = 152, + TypeOfExpression = 153, + VoidExpression = 154, + PrefixUnaryExpression = 155, + PostfixUnaryExpression = 156, + BinaryExpression = 157, + ConditionalExpression = 158, + TemplateExpression = 159, + YieldExpression = 160, + OmittedExpression = 161, + TemplateSpan = 162, + Block = 163, + VariableStatement = 164, + EmptyStatement = 165, + ExpressionStatement = 166, + IfStatement = 167, + DoStatement = 168, + WhileStatement = 169, + ForStatement = 170, + ForInStatement = 171, + ContinueStatement = 172, + BreakStatement = 173, + ReturnStatement = 174, + WithStatement = 175, + SwitchStatement = 176, + LabeledStatement = 177, + ThrowStatement = 178, + TryStatement = 179, + TryBlock = 180, + FinallyBlock = 181, + DebuggerStatement = 182, + VariableDeclaration = 183, + FunctionDeclaration = 184, + ClassDeclaration = 185, + InterfaceDeclaration = 186, + TypeAliasDeclaration = 187, + EnumDeclaration = 188, + ModuleDeclaration = 189, + ModuleBlock = 190, + ImportDeclaration = 191, + ExportAssignment = 192, + ExternalModuleReference = 193, + CaseClause = 194, + DefaultClause = 195, + HeritageClause = 196, + CatchClause = 197, + PropertyAssignment = 198, + ShorthandPropertyAssignment = 199, + EnumMember = 200, + SourceFile = 201, + Program = 202, + SyntaxList = 203, + Count = 204, + FirstAssignment = 51, + LastAssignment = 62, + FirstReservedWord = 64, + LastReservedWord = 99, + FirstKeyword = 64, + LastKeyword = 119, + FirstFutureReservedWord = 100, + LastFutureReservedWord = 108, + FirstTypeNode = 132, + LastTypeNode = 140, + FirstPunctuation = 13, + LastPunctuation = 62, + FirstToken = 0, + LastToken = 119, + FirstTriviaToken = 2, + LastTriviaToken = 5, + FirstLiteralToken = 6, + LastLiteralToken = 9, + FirstTemplateToken = 9, + LastTemplateToken = 12, + FirstOperator = 21, + LastOperator = 62, + FirstBinaryOperator = 23, + LastBinaryOperator = 62, + FirstNode = 120, + } + const enum NodeFlags { + Export = 1, + Ambient = 2, + Public = 16, + Private = 32, + Protected = 64, + Static = 128, + MultiLine = 256, + Synthetic = 512, + DeclarationFile = 1024, + Let = 2048, + Const = 4096, + OctalLiteral = 8192, + Modifier = 243, + AccessibilityModifier = 112, + BlockScoped = 6144, + } + const enum ParserContextFlags { + StrictMode = 1, + DisallowIn = 2, + Yield = 4, + GeneratorParameter = 8, + ContainsError = 16, + HasPropagatedChildContainsErrorFlag = 32, + } + interface Node extends TextRange { + kind: SyntaxKind; + flags: NodeFlags; + parserContextFlags?: ParserContextFlags; + id?: number; + parent?: Node; + symbol?: Symbol; + locals?: SymbolTable; + nextContainer?: Node; + localSymbol?: Symbol; + modifiers?: ModifiersArray; + } + interface NodeArray extends Array, TextRange { + hasTrailingComma?: boolean; + } + interface ModifiersArray extends NodeArray { + flags: number; + } + interface Identifier extends PrimaryExpression { + text: string; + } + interface QualifiedName extends Node { + left: EntityName; + right: Identifier; + } + type EntityName = Identifier | QualifiedName; + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName; + interface Declaration extends Node { + _declarationBrand: any; + name?: DeclarationName; + } + interface ComputedPropertyName extends Node { + expression: Expression; + } + interface TypeParameterDeclaration extends Declaration { + name: Identifier; + constraint?: TypeNode; + expression?: Expression; + } + interface SignatureDeclaration extends Declaration { + typeParameters?: NodeArray; + parameters: NodeArray; + type?: TypeNode; + } + interface VariableDeclaration extends Declaration { + name: Identifier; + type?: TypeNode; + initializer?: Expression; + } + interface ParameterDeclaration extends Declaration { + dotDotDotToken?: Node; + name: Identifier; + questionToken?: Node; + type?: TypeNode | StringLiteralExpression; + initializer?: Expression; + } + interface PropertyDeclaration extends Declaration, ClassElement { + _propertyDeclarationBrand: any; + questionToken?: Node; + type?: TypeNode; + initializer?: Expression; + } + type VariableOrParameterDeclaration = VariableDeclaration | ParameterDeclaration; + type VariableOrParameterOrPropertyDeclaration = VariableOrParameterDeclaration | PropertyDeclaration; + interface ObjectLiteralElement extends Declaration { + _objectLiteralBrandBrand: any; + } + interface ShorthandPropertyAssignment extends ObjectLiteralElement { + name: Identifier; + questionToken?: Node; + } + interface PropertyAssignment extends ObjectLiteralElement { + _propertyAssignmentBrand: any; + name: DeclarationName; + questionToken?: Node; + initializer: Expression; + } + /** + * Several node kinds share function-like features such as a signature, + * a name, and a body. These nodes should extend FunctionLikeDeclaration. + * Examples: + * FunctionDeclaration + * MethodDeclaration + * AccessorDeclaration + */ + interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: Node; + questionToken?: Node; + body?: Block | Expression; + } + interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { + name: Identifier; + body?: Block; + } + interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + body?: Block; + } + interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + body?: Block; + } + interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + _accessorDeclarationBrand: any; + body: Block; + } + interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { + _indexSignatureDeclarationBrand: any; + } + interface TypeNode extends Node { + _typeNodeBrand: any; + } + interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { + _functionOrConstructorTypeNodeBrand: any; + } + interface TypeReferenceNode extends TypeNode { + typeName: EntityName; + typeArguments?: NodeArray; + } + interface TypeQueryNode extends TypeNode { + exprName: EntityName; + } + interface TypeLiteralNode extends TypeNode, Declaration { + members: NodeArray; + } + interface ArrayTypeNode extends TypeNode { + elementType: TypeNode; + } + interface TupleTypeNode extends TypeNode { + elementTypes: NodeArray; + } + interface UnionTypeNode extends TypeNode { + types: NodeArray; + } + interface ParenthesizedTypeNode extends TypeNode { + type: TypeNode; + } + interface Expression extends Node { + _expressionBrand: any; + contextualType?: Type; + } + interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; + } + interface PrefixUnaryExpression extends UnaryExpression { + operator: SyntaxKind; + operand: UnaryExpression; + } + interface PostfixUnaryExpression extends PostfixExpression { + operand: LeftHandSideExpression; + operator: SyntaxKind; + } + interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; + } + interface LeftHandSideExpression extends PostfixExpression { + _leftHandSideExpressionBrand: any; + } + interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; + } + interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; + } + interface DeleteExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface TypeOfExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface VoidExpression extends UnaryExpression { + expression: UnaryExpression; + } + interface YieldExpression extends Expression { + asteriskToken?: Node; + expression: Expression; + } + interface BinaryExpression extends Expression { + left: Expression; + operator: SyntaxKind; + right: Expression; + } + interface ConditionalExpression extends Expression { + condition: Expression; + whenTrue: Expression; + whenFalse: Expression; + } + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + name?: Identifier; + body: Block | Expression; + } + interface LiteralExpression extends PrimaryExpression { + text: string; + isUnterminated?: boolean; + } + interface StringLiteralExpression extends LiteralExpression { + _stringLiteralExpressionBrand: any; + } + interface TemplateExpression extends PrimaryExpression { + head: LiteralExpression; + templateSpans: NodeArray; + } + interface TemplateSpan extends Node { + expression: Expression; + literal: LiteralExpression; + } + interface ParenthesizedExpression extends PrimaryExpression { + expression: Expression; + } + interface ArrayLiteralExpression extends PrimaryExpression { + elements: NodeArray; + } + interface ObjectLiteralExpression extends PrimaryExpression, Declaration { + properties: NodeArray; + } + interface PropertyAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + name: Identifier; + } + interface ElementAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + argumentExpression?: Expression; + } + interface CallExpression extends LeftHandSideExpression { + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; + } + interface NewExpression extends CallExpression, PrimaryExpression { + } + interface TaggedTemplateExpression extends MemberExpression { + tag: LeftHandSideExpression; + template: LiteralExpression | TemplateExpression; + } + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; + interface TypeAssertion extends UnaryExpression { + type: TypeNode; + expression: UnaryExpression; + } + interface Statement extends Node, ModuleElement { + _statementBrand: any; + } + interface Block extends Statement { + statements: NodeArray; + } + interface VariableStatement extends Statement { + declarations: NodeArray; + } + interface ExpressionStatement extends Statement { + expression: Expression; + } + interface IfStatement extends Statement { + expression: Expression; + thenStatement: Statement; + elseStatement?: Statement; + } + interface IterationStatement extends Statement { + statement: Statement; + } + interface DoStatement extends IterationStatement { + expression: Expression; + } + interface WhileStatement extends IterationStatement { + expression: Expression; + } + interface ForStatement extends IterationStatement { + declarations?: NodeArray; + initializer?: Expression; + condition?: Expression; + iterator?: Expression; + } + interface ForInStatement extends IterationStatement { + declarations?: NodeArray; + variable?: Expression; + expression: Expression; + } + interface BreakOrContinueStatement extends Statement { + label?: Identifier; + } + interface ReturnStatement extends Statement { + expression?: Expression; + } + interface WithStatement extends Statement { + expression: Expression; + statement: Statement; + } + interface SwitchStatement extends Statement { + expression: Expression; + clauses: NodeArray; + } + interface CaseClause extends Node { + expression?: Expression; + statements: NodeArray; + } + interface DefaultClause extends Node { + statements: NodeArray; + } + type CaseOrDefaultClause = CaseClause | DefaultClause; + interface LabeledStatement extends Statement { + label: Identifier; + statement: Statement; + } + interface ThrowStatement extends Statement { + expression: Expression; + } + interface TryStatement extends Statement { + tryBlock: Block; + catchClause?: CatchClause; + finallyBlock?: Block; + } + interface CatchClause extends Declaration { + name: Identifier; + type?: TypeNode; + block: Block; + } + interface ModuleElement extends Node { + _moduleElementBrand: any; + } + interface ClassDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface ClassElement extends Declaration { + _classElementBrand: any; + } + interface InterfaceDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + interface HeritageClause extends Node { + token: SyntaxKind; + types?: NodeArray; + } + interface TypeAliasDeclaration extends Declaration, ModuleElement { + name: Identifier; + type: TypeNode; + } + interface EnumMember extends Declaration { + name: DeclarationName; + initializer?: Expression; + } + interface EnumDeclaration extends Declaration, ModuleElement { + name: Identifier; + members: NodeArray; + } + interface ModuleDeclaration extends Declaration, ModuleElement { + name: Identifier | LiteralExpression; + body: ModuleBlock | ModuleDeclaration; + } + interface ModuleBlock extends Node, ModuleElement { + statements: NodeArray; + } + interface ImportDeclaration extends Declaration, ModuleElement { + name: Identifier; + moduleReference: EntityName | ExternalModuleReference; + } + interface ExternalModuleReference extends Node { + expression?: Expression; + } + interface ExportAssignment extends Statement, ModuleElement { + exportName: Identifier; + } + interface FileReference extends TextRange { + filename: string; + } + interface CommentRange extends TextRange { + hasTrailingNewLine?: boolean; + } + interface SourceFile extends Declaration { + statements: NodeArray; + endOfFileToken: Node; + filename: string; + text: string; + getLineAndCharacterFromPosition(position: number): LineAndCharacter; + getPositionFromLineAndCharacter(line: number, character: number): number; + getLineStarts(): number[]; + amdDependencies: string[]; + amdModuleName: string; + referencedFiles: FileReference[]; + referenceDiagnostics: Diagnostic[]; + parseDiagnostics: Diagnostic[]; + grammarDiagnostics: Diagnostic[]; + getSyntacticDiagnostics(): Diagnostic[]; + semanticDiagnostics: Diagnostic[]; + hasNoDefaultLib: boolean; + externalModuleIndicator: Node; + nodeCount: number; + identifierCount: number; + symbolCount: number; + isOpen: boolean; + version: string; + languageVersion: ScriptTarget; + identifiers: Map; + } + interface Program { + getSourceFile(filename: string): SourceFile; + getSourceFiles(): SourceFile[]; + getCompilerOptions(): CompilerOptions; + getCompilerHost(): CompilerHost; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getTypeChecker(fullTypeCheckMode: boolean): TypeChecker; + getCommonSourceDirectory(): string; + } + interface SourceMapSpan { + emittedLine: number; + emittedColumn: number; + sourceLine: number; + sourceColumn: number; + nameIndex?: number; + sourceIndex: number; + } + interface SourceMapData { + sourceMapFilePath: string; + jsSourceMappingURL: string; + sourceMapFile: string; + sourceMapSourceRoot: string; + sourceMapSources: string[]; + inputSourceFileNames: string[]; + sourceMapNames?: string[]; + sourceMapMappings: string; + sourceMapDecodedMappings: SourceMapSpan[]; + } + enum EmitReturnStatus { + Succeeded = 0, + AllOutputGenerationSkipped = 1, + JSGeneratedWithSemanticErrors = 2, + DeclarationGenerationSkipped = 3, + EmitErrorsEncountered = 4, + CompilerOptionsErrors = 5, + } + interface EmitResult { + emitResultStatus: EmitReturnStatus; + diagnostics: Diagnostic[]; + sourceMaps: SourceMapData[]; + } + interface TypeChecker { + getProgram(): Program; + getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[]; + getGlobalDiagnostics(): Diagnostic[]; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + emitFiles(targetSourceFile?: SourceFile): EmitResult; + getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; + getDeclaredTypeOfSymbol(symbol: Symbol): Type; + getPropertiesOfType(type: Type): Symbol[]; + getPropertyOfType(type: Type, propertyName: string): Symbol; + getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getReturnTypeOfSignature(signature: Signature): Type; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; + getSymbolAtLocation(node: Node): Symbol; + getShorthandAssignmentValueSymbol(location: Node): Symbol; + getTypeAtLocation(node: Node): Type; + typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; + symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; + getFullyQualifiedName(symbol: Symbol): string; + getAugmentedPropertiesOfType(type: Type): Symbol[]; + getRootSymbols(symbol: Symbol): Symbol[]; + getContextualType(node: Expression): Type; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; + getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + isUndefinedSymbol(symbol: Symbol): boolean; + isArgumentsSymbol(symbol: Symbol): boolean; + isEmitBlocked(sourceFile?: SourceFile): boolean; + getEnumMemberValue(node: EnumMember): number; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + getAliasedSymbol(symbol: Symbol): Symbol; + } + interface SymbolDisplayBuilder { + buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; + buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + } + interface SymbolWriter { + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; + writeSymbol(text: string, symbol: Symbol): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + clear(): void; + trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + } + const enum TypeFormatFlags { + None = 0, + WriteArrayAsGenericType = 1, + UseTypeOfFunction = 2, + NoTruncation = 4, + WriteArrowStyleSignature = 8, + WriteOwnNameForAnyLike = 16, + WriteTypeArgumentsOfSignature = 32, + InElementType = 64, + } + const enum SymbolFormatFlags { + None = 0, + WriteTypeParametersOrArguments = 1, + UseOnlyExternalAliasing = 2, + } + const enum SymbolAccessibility { + Accessible = 0, + NotAccessible = 1, + CannotBeNamed = 2, + } + interface SymbolVisibilityResult { + accessibility: SymbolAccessibility; + aliasesToMakeVisible?: ImportDeclaration[]; + errorSymbolName?: string; + errorNode?: Node; + } + interface SymbolAccessiblityResult extends SymbolVisibilityResult { + errorModuleName?: string; + } + interface EmitResolver { + getProgram(): Program; + getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string; + getExpressionNamePrefix(node: Identifier): string; + getExportAssignmentName(node: SourceFile): string; + isReferencedImportDeclaration(node: ImportDeclaration): boolean; + isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean; + getNodeCheckFlags(node: Node): NodeCheckFlags; + getEnumMemberValue(node: EnumMember): number; + hasSemanticErrors(sourceFile?: SourceFile): boolean; + isDeclarationVisible(node: Declaration): boolean; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableOrParameterDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; + isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; + getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + isEmitBlocked(sourceFile?: SourceFile): boolean; + } + const enum SymbolFlags { + FunctionScopedVariable = 1, + BlockScopedVariable = 2, + Property = 4, + EnumMember = 8, + Function = 16, + Class = 32, + Interface = 64, + ConstEnum = 128, + RegularEnum = 256, + ValueModule = 512, + NamespaceModule = 1024, + TypeLiteral = 2048, + ObjectLiteral = 4096, + Method = 8192, + Constructor = 16384, + GetAccessor = 32768, + SetAccessor = 65536, + CallSignature = 131072, + ConstructSignature = 262144, + IndexSignature = 524288, + TypeParameter = 1048576, + TypeAlias = 2097152, + ExportValue = 4194304, + ExportType = 8388608, + ExportNamespace = 16777216, + Import = 33554432, + Instantiated = 67108864, + Merged = 134217728, + Transient = 268435456, + Prototype = 536870912, + UnionProperty = 1073741824, + Enum = 384, + Variable = 3, + Value = 107455, + Type = 3152352, + Namespace = 1536, + Module = 1536, + Accessor = 98304, + Signature = 917504, + FunctionScopedVariableExcludes = 107454, + BlockScopedVariableExcludes = 107455, + ParameterExcludes = 107455, + PropertyExcludes = 107455, + EnumMemberExcludes = 107455, + FunctionExcludes = 106927, + ClassExcludes = 3258879, + InterfaceExcludes = 3152288, + RegularEnumExcludes = 3258623, + ConstEnumExcludes = 3259263, + ValueModuleExcludes = 106639, + NamespaceModuleExcludes = 0, + MethodExcludes = 99263, + GetAccessorExcludes = 41919, + SetAccessorExcludes = 74687, + TypeParameterExcludes = 2103776, + TypeAliasExcludes = 3152352, + ImportExcludes = 33554432, + ModuleMember = 35653619, + ExportHasLocal = 944, + HasLocals = 1041936, + HasExports = 1952, + HasMembers = 6240, + IsContainer = 1048560, + PropertyOrAccessor = 98308, + Export = 29360128, + } + interface Symbol { + flags: SymbolFlags; + name: string; + id?: number; + mergeId?: number; + declarations?: Declaration[]; + parent?: Symbol; + members?: SymbolTable; + exports?: SymbolTable; + exportSymbol?: Symbol; + valueDeclaration?: Declaration; + constEnumOnlyModule?: boolean; + } + interface SymbolLinks { + target?: Symbol; + type?: Type; + declaredType?: Type; + mapper?: TypeMapper; + referenced?: boolean; + exportAssignSymbol?: Symbol; + unionType?: UnionType; + } + interface TransientSymbol extends Symbol, SymbolLinks { + } + interface SymbolTable { + [index: string]: Symbol; + } + const enum NodeCheckFlags { + TypeChecked = 1, + LexicalThis = 2, + CaptureThis = 4, + EmitExtends = 8, + SuperInstance = 16, + SuperStatic = 32, + ContextChecked = 64, + EnumValuesComputed = 128, + } + interface NodeLinks { + resolvedType?: Type; + resolvedSignature?: Signature; + resolvedSymbol?: Symbol; + flags?: NodeCheckFlags; + enumMemberValue?: number; + isIllegalTypeReferenceInConstraint?: boolean; + isVisible?: boolean; + localModuleName?: string; + assignmentChecks?: Map; + } + const enum TypeFlags { + Any = 1, + String = 2, + Number = 4, + Boolean = 8, + Void = 16, + Undefined = 32, + Null = 64, + Enum = 128, + StringLiteral = 256, + TypeParameter = 512, + Class = 1024, + Interface = 2048, + Reference = 4096, + Tuple = 8192, + Union = 16384, + Anonymous = 32768, + FromSignature = 65536, + Intrinsic = 127, + StringLike = 258, + NumberLike = 132, + ObjectType = 48128, + } + interface Type { + flags: TypeFlags; + id: number; + symbol?: Symbol; + } + interface IntrinsicType extends Type { + intrinsicName: string; + } + interface StringLiteralType extends Type { + text: string; + } + interface ObjectType extends Type { + } + interface InterfaceType extends ObjectType { + typeParameters: TypeParameter[]; + baseTypes: ObjectType[]; + declaredProperties: Symbol[]; + declaredCallSignatures: Signature[]; + declaredConstructSignatures: Signature[]; + declaredStringIndexType: Type; + declaredNumberIndexType: Type; + } + interface TypeReference extends ObjectType { + target: GenericType; + typeArguments: Type[]; + } + interface GenericType extends InterfaceType, TypeReference { + instantiations: Map; + openReferenceTargets: GenericType[]; + openReferenceChecks: Map; + } + interface TupleType extends ObjectType { + elementTypes: Type[]; + baseArrayType: TypeReference; + } + interface UnionType extends Type { + types: Type[]; + resolvedProperties: SymbolTable; + } + interface ResolvedType extends ObjectType, UnionType { + members: SymbolTable; + properties: Symbol[]; + callSignatures: Signature[]; + constructSignatures: Signature[]; + stringIndexType: Type; + numberIndexType: Type; + } + interface TypeParameter extends Type { + constraint: Type; + target?: TypeParameter; + mapper?: TypeMapper; + } + const enum SignatureKind { + Call = 0, + Construct = 1, + } + interface Signature { + declaration: SignatureDeclaration; + typeParameters: TypeParameter[]; + parameters: Symbol[]; + resolvedReturnType: Type; + minArgumentCount: number; + hasRestParameter: boolean; + hasStringLiterals: boolean; + target?: Signature; + mapper?: TypeMapper; + unionSignatures?: Signature[]; + erasedSignatureCache?: Signature; + isolatedSignatureType?: ObjectType; + } + const enum IndexKind { + String = 0, + Number = 1, + } + interface TypeMapper { + (t: Type): Type; + } + interface TypeInferences { + primary: Type[]; + secondary: Type[]; + } + interface InferenceContext { + typeParameters: TypeParameter[]; + inferUnionTypes: boolean; + inferences: TypeInferences[]; + inferredTypes: Type[]; + failedTypeParameterIndex?: number; + } + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + isEarly?: boolean; + } + interface DiagnosticMessageChain { + messageText: string; + category: DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain; + } + interface Diagnostic { + file: SourceFile; + start: number; + length: number; + messageText: string; + category: DiagnosticCategory; + code: number; + /** + * Early error - any error (can be produced at parsing\binding\typechecking step) that blocks emit + */ + isEarly?: boolean; + } + enum DiagnosticCategory { + Warning = 0, + Error = 1, + Message = 2, + } + interface CompilerOptions { + allowNonTsExtensions?: boolean; + charset?: string; + codepage?: number; + declaration?: boolean; + diagnostics?: boolean; + emitBOM?: boolean; + help?: boolean; + locale?: string; + mapRoot?: string; + module?: ModuleKind; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noImplicitAny?: boolean; + noLib?: boolean; + noLibCheck?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + preserveConstEnums?: boolean; + removeComments?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget; + version?: boolean; + watch?: boolean; + [option: string]: string | number | boolean; + } + const enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + } + interface LineAndCharacter { + line: number; + character: number; + } + const enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES6 = 2, + Latest = 2, + } + interface ParsedCommandLine { + options: CompilerOptions; + filenames: string[]; + errors: Diagnostic[]; + } + interface CommandLineOption { + name: string; + type: string | Map; + shortName?: string; + description?: DiagnosticMessage; + paramType?: DiagnosticMessage; + error?: DiagnosticMessage; + } + const enum CharacterCodes { + nullCharacter = 0, + maxAsciiCharacter = 127, + lineFeed = 10, + carriageReturn = 13, + lineSeparator = 8232, + paragraphSeparator = 8233, + nextLine = 133, + space = 32, + nonBreakingSpace = 160, + enQuad = 8192, + emQuad = 8193, + enSpace = 8194, + emSpace = 8195, + threePerEmSpace = 8196, + fourPerEmSpace = 8197, + sixPerEmSpace = 8198, + figureSpace = 8199, + punctuationSpace = 8200, + thinSpace = 8201, + hairSpace = 8202, + zeroWidthSpace = 8203, + narrowNoBreakSpace = 8239, + ideographicSpace = 12288, + mathematicalSpace = 8287, + ogham = 5760, + _ = 95, + $ = 36, + _0 = 48, + _1 = 49, + _2 = 50, + _3 = 51, + _4 = 52, + _5 = 53, + _6 = 54, + _7 = 55, + _8 = 56, + _9 = 57, + a = 97, + b = 98, + c = 99, + d = 100, + e = 101, + f = 102, + g = 103, + h = 104, + i = 105, + j = 106, + k = 107, + l = 108, + m = 109, + n = 110, + o = 111, + p = 112, + q = 113, + r = 114, + s = 115, + t = 116, + u = 117, + v = 118, + w = 119, + x = 120, + y = 121, + z = 122, + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + ampersand = 38, + asterisk = 42, + at = 64, + backslash = 92, + backtick = 96, + bar = 124, + caret = 94, + closeBrace = 125, + closeBracket = 93, + closeParen = 41, + colon = 58, + comma = 44, + dot = 46, + doubleQuote = 34, + equals = 61, + exclamation = 33, + greaterThan = 62, + lessThan = 60, + minus = 45, + openBrace = 123, + openBracket = 91, + openParen = 40, + percent = 37, + plus = 43, + question = 63, + semicolon = 59, + singleQuote = 39, + slash = 47, + tilde = 126, + backspace = 8, + formFeed = 12, + byteOrderMark = 65279, + tab = 9, + verticalTab = 11, + } + interface CancellationToken { + isCancellationRequested(): boolean; + } + interface CompilerHost { + getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getDefaultLibFilename(options: CompilerOptions): string; + getCancellationToken?(): CancellationToken; + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + useCaseSensitiveFileNames(): boolean; + getNewLine(): string; + } +} +declare module ts { + interface ErrorCallback { + (message: DiagnosticMessage): void; + } + interface CommentCallback { + (pos: number, end: number): void; + } + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scan(): SyntaxKind; + setText(text: string): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + tryScan(callback: () => T): T; + } + function tokenToString(t: SyntaxKind): string; + function computeLineStarts(text: string): number[]; + function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number; + function getLineAndCharacterOfPosition(lineStarts: number[], position: number): { + line: number; + character: number; + }; + function positionToLineAndCharacter(text: string, pos: number): { + line: number; + character: number; + }; + function isWhiteSpace(ch: number): boolean; + function isLineBreak(ch: number): boolean; + function isOctalDigit(ch: number): boolean; + function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner; +} +declare module ts { + function getNodeConstructor(kind: SyntaxKind): new () => Node; + function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; + function createCompilerHost(options: CompilerOptions): CompilerHost; + function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen?: boolean): SourceFile; + function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program; +} +declare module ts { + function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker; +} +declare module ts { + var servicesVersion: string; + interface Node { + getSourceFile(): SourceFile; + getChildCount(sourceFile?: SourceFile): number; + getChildAt(index: number, sourceFile?: SourceFile): Node; + getChildren(sourceFile?: SourceFile): Node[]; + getStart(sourceFile?: SourceFile): number; + getFullStart(): number; + getEnd(): number; + getWidth(sourceFile?: SourceFile): number; + getFullWidth(): number; + getLeadingTriviaWidth(sourceFile?: SourceFile): number; + getFullText(sourceFile?: SourceFile): string; + getText(sourceFile?: SourceFile): string; + getFirstToken(sourceFile?: SourceFile): Node; + getLastToken(sourceFile?: SourceFile): Node; + } + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface Type { + getFlags(): TypeFlags; + getSymbol(): Symbol; + getProperties(): Symbol[]; + getProperty(propertyName: string): Symbol; + getApparentProperties(): Symbol[]; + getCallSignatures(): Signature[]; + getConstructSignatures(): Signature[]; + getStringIndexType(): Type; + getNumberIndexType(): Type; + } + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; + } + interface SourceFile { + getScriptSnapshot(): IScriptSnapshot; + getNamedDeclarations(): Declaration[]; + update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + } + /** + * Represents an immutable snapshot of a script at a specified time.Once acquired, the + * snapshot is observably immutable. i.e. the same calls with the same parameters will return + * the same values. + */ + interface IScriptSnapshot { + /** Gets a portion of the script snapshot specified by [start, end). */ + getText(start: number, end: number): string; + /** Gets the length of this script snapshot. */ + getLength(): number; + /** + * This call returns the array containing the start position of every line. + * i.e."[0, 10, 55]". TODO: consider making this optional. The language service could + * always determine this (albeit in a more expensive manner). + */ + getLineStartPositions(): number[]; + /** + * Gets the TextChangeRange that describe how the text changed between this text and + * an older version. This information is used by the incremental parser to determine + * what sections of the script need to be re-parsed. 'undefined' can be returned if the + * change range cannot be determined. However, in that case, incremental parsing will + * not happen and the entire document will be re - parsed. + */ + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange; + } + module ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; + } + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + importedFiles: FileReference[]; + isLibFile: boolean; + } + interface Logger { + log(s: string): void; + } + interface LanguageServiceHost extends Logger { + getCompilationSettings(): CompilerOptions; + getScriptFileNames(): string[]; + getScriptVersion(fileName: string): string; + getScriptIsOpen(fileName: string): boolean; + getScriptSnapshot(fileName: string): IScriptSnapshot; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): CancellationToken; + getCurrentDirectory(): string; + getDefaultLibFilename(options: CompilerOptions): string; + } + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getRenameInfo(fileName: string, position: number): RenameInfo; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getNavigateToItems(searchValue: string): NavigateToItem[]; + getNavigationBarItems(fileName: string): NavigationBarItem[]; + getOutliningSpans(fileName: string): OutliningSpan[]; + getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getEmitOutput(fileName: string): EmitOutput; + getSourceFile(filename: string): SourceFile; + dispose(): void; + } + class TextSpan { + private _start; + private _length; + /** + * Creates a TextSpan instance beginning with the position Start and having the Length + * specified with length. + */ + constructor(start: number, length: number); + toJSON(key: any): any; + start(): number; + length(): number; + end(): number; + isEmpty(): boolean; + /** + * Determines whether the position lies within the span. Returns true if the position is greater than or equal to Start and strictly less + * than End, otherwise false. + * @param position The position to check. + */ + containsPosition(position: number): boolean; + /** + * Determines whether span falls completely within this span. Returns true if the specified span falls completely within this span, otherwise false. + * @param span The span to check. + */ + containsTextSpan(span: TextSpan): boolean; + /** + * Determines whether the given span overlaps this span. Two spans are considered to overlap + * if they have positions in common and neither is empty. Empty spans do not overlap with any + * other span. Returns true if the spans overlap, false otherwise. + * @param span The span to check. + */ + overlapsWith(span: TextSpan): boolean; + /** + * Returns the overlap with the given span, or undefined if there is no overlap. + * @param span The span to check. + */ + overlap(span: TextSpan): TextSpan; + /** + * Determines whether span intersects this span. Two spans are considered to + * intersect if they have positions in common or the end of one span + * coincides with the start of the other span. Returns true if the spans intersect, false otherwise. + * @param The span to check. + */ + intersectsWithTextSpan(span: TextSpan): boolean; + intersectsWith(start: number, length: number): boolean; + /** + * Determines whether the given position intersects this span. + * A position is considered to intersect if it is between the start and + * end positions (inclusive) of this span. Returns true if the position intersects, false otherwise. + * @param position The position to check. + */ + intersectsWithPosition(position: number): boolean; + /** + * Returns the intersection with the given span, or undefined if there is no intersection. + * @param span The span to check. + */ + intersection(span: TextSpan): TextSpan; + /** + * Creates a new TextSpan from the given start and end positions + * as opposed to a position and length. + */ + static fromBounds(start: number, end: number): TextSpan; + } + class TextChangeRange { + static unchanged: TextChangeRange; + private _span; + private _newLength; + /** + * Initializes a new instance of TextChangeRange. + */ + constructor(span: TextSpan, newLength: number); + /** + * The span of text before the edit which is being changed + */ + span(): TextSpan; + /** + * Width of the span after the edit. A 0 here would represent a delete + */ + newLength(): number; + newSpan(): TextSpan; + isUnchanged(): boolean; + /** + * Called to merge all the changes that occurred across several versions of a script snapshot + * into a single change. i.e. if a user keeps making successive edits to a script we will + * have a text change from V1 to V2, V2 to V3, ..., Vn. + * + * This function will then merge those changes into a single change range valid between V1 and + * Vn. + */ + static collapseChangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + } + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; + } + interface TodoCommentDescriptor { + text: string; + priority: number; + } + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + class TextChange { + span: TextSpan; + newText: string; + } + interface RenameLocation { + textSpan: TextSpan; + fileName: string; + } + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + } + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; + } + interface EditorOptions { + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + } + interface FormatCodeOptions extends EditorOptions { + InsertSpaceAfterCommaDelimiter: boolean; + InsertSpaceAfterSemicolonInForStatements: boolean; + InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterKeywordsInControlFlowStatements: boolean; + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + PlaceOpenBraceOnNewLineForFunctions: boolean; + PlaceOpenBraceOnNewLineForControlBlocks: boolean; + } + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; + } + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + /** + * Represents a single signature to show in signature help. + * The id is used for subsequent calls into the language service to ask questions about the + * signature help item in the context of any documents that have been updated. i.e. after + * an edit has happened, while signature help is still active, the host can ask important + * questions like 'what parameter is the user currently contained within?'. + */ + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + /** + * Represents a set of signature help items, and the preferred item that should be selected. + */ + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface CompletionInfo { + isMemberCompletion: boolean; + entries: CompletionEntry[]; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface OutliningSpan { + /** The span of the document to actually collapse. */ + textSpan: TextSpan; + /** The span of the document to display when the user hovers over the collapsed span. */ + hintSpan: TextSpan; + /** The text to display in the editor for the collapsed region. */ + bannerText: string; + /** + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ + autoCollapse: boolean; + } + interface EmitOutput { + outputFiles: OutputFile[]; + emitOutputStatus: EmitReturnStatus; + } + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, + } + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; + } + const enum EndOfLineState { + Start = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + } + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, + } + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; + } + interface ClassificationInfo { + length: number; + classification: TokenClass; + } + interface Classifier { + getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult; + } + interface DocumentRegistry { + acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean): SourceFile; + updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile; + releaseDocument(filename: string, compilationSettings: CompilerOptions): void; + } + class ScriptElementKind { + static unknown: string; + static keyword: string; + static scriptElement: string; + static moduleElement: string; + static classElement: string; + static interfaceElement: string; + static typeElement: string; + static enumElement: string; + static variableElement: string; + static localVariableElement: string; + static functionElement: string; + static localFunctionElement: string; + static memberFunctionElement: string; + static memberGetAccessorElement: string; + static memberSetAccessorElement: string; + static memberVariableElement: string; + static constructorImplementationElement: string; + static callSignatureElement: string; + static indexSignatureElement: string; + static constructSignatureElement: string; + static parameterElement: string; + static typeParameterElement: string; + static primitiveType: string; + static label: string; + static alias: string; + static constElement: string; + static letElement: string; + } + class ScriptElementKindModifier { + static none: string; + static publicMemberModifier: string; + static privateMemberModifier: string; + static protectedMemberModifier: string; + static exportedModifier: string; + static ambientModifier: string; + static staticModifier: string; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAlias: string; + } + interface DisplayPartsSymbolWriter extends SymbolWriter { + displayParts(): SymbolDisplayPart[]; + } + function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function getDefaultCompilerOptions(): CompilerOptions; + class OperationCanceledException { + } + class CancellationTokenObject { + private cancellationToken; + static None: CancellationTokenObject; + constructor(cancellationToken: CancellationToken); + isCancellationRequested(): boolean; + throwIfCancellationRequested(): void; + } + function createDocumentRegistry(): DocumentRegistry; + function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; + function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService; + function createClassifier(host: Logger): Classifier; +} diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 8c36e0b88f6..a07dba93a1c 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -15,6 +15,266 @@ and limitations under the License. var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 6] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 7] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 8] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 9] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 10] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 11] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 12] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 13] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 14] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 15] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 16] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 17] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 18] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 19] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 20] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 21] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 22] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 23] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 24] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 25] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 26] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 27] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 28] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 29] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 30] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 31] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 32] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 33] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 34] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 35] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 36] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 37] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 38] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 39] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 40] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 41] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 42] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 43] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 44] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 45] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 46] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 47] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 48] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 49] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 50] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 51] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 52] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 53] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 54] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 55] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 56] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 57] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 58] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 59] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 60] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 61] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 62] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 63] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 64] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 65] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 66] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 67] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 68] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 69] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 70] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 71] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 72] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 73] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 74] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 75] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 76] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 77] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 78] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 79] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 80] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 81] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 82] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 83] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 84] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 85] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 86] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 87] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 88] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 89] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 90] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 91] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 92] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 93] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 94] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 95] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 96] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 97] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 98] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 99] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 100] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 101] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 102] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 103] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 104] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 105] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 106] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 107] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 108] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 109] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 110] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 111] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 112] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 113] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 114] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 115] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 116] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 117] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 118] = "StringKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 119] = "TypeKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 120] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 121] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 122] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 123] = "Parameter"; + SyntaxKind[SyntaxKind["Property"] = 124] = "Property"; + SyntaxKind[SyntaxKind["Method"] = 125] = "Method"; + SyntaxKind[SyntaxKind["Constructor"] = 126] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 127] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 128] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 129] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 130] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 131] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypeReference"] = 132] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 133] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 134] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 135] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 136] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 137] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 138] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 139] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 140] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 141] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 142] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 143] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 144] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 145] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 146] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 147] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 148] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 149] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 150] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 151] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 152] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 153] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 154] = "VoidExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 155] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 156] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 157] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 158] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 159] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 160] = "YieldExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 161] = "OmittedExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 162] = "TemplateSpan"; + SyntaxKind[SyntaxKind["Block"] = 163] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 164] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 165] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 166] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 167] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 168] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 169] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 170] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 171] = "ForInStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 172] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 173] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 174] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 175] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 176] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 177] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 178] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 179] = "TryStatement"; + SyntaxKind[SyntaxKind["TryBlock"] = 180] = "TryBlock"; + SyntaxKind[SyntaxKind["FinallyBlock"] = 181] = "FinallyBlock"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 182] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 183] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 184] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 185] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 186] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 187] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 188] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 189] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 190] = "ModuleBlock"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 191] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 192] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 193] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["CaseClause"] = 194] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 195] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 196] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 197] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 198] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 199] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 200] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 201] = "SourceFile"; + SyntaxKind[SyntaxKind["Program"] = 202] = "Program"; + SyntaxKind[SyntaxKind["SyntaxList"] = 203] = "SyntaxList"; + SyntaxKind[SyntaxKind["Count"] = 204] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 51] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 62] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 64] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 99] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 64] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 119] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 100] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 108] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 132] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 140] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 13] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 62] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 119] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 5] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 6] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 9] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 9] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 12] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstOperator"] = 21] = "FirstOperator"; + SyntaxKind[SyntaxKind["LastOperator"] = 62] = "LastOperator"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 23] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 62] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 120] = "FirstNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["Export"] = 1] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 16] = "Public"; + NodeFlags[NodeFlags["Private"] = 32] = "Private"; + NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; + NodeFlags[NodeFlags["Static"] = 128] = "Static"; + NodeFlags[NodeFlags["MultiLine"] = 256] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 512] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 1024] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 2048] = "Let"; + NodeFlags[NodeFlags["Const"] = 4096] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 8192] = "OctalLiteral"; + NodeFlags[NodeFlags["Modifier"] = 243] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 6144] = "BlockScoped"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ParserContextFlags) { + ParserContextFlags[ParserContextFlags["StrictMode"] = 1] = "StrictMode"; + ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; + ParserContextFlags[ParserContextFlags["Yield"] = 4] = "Yield"; + ParserContextFlags[ParserContextFlags["GeneratorParameter"] = 8] = "GeneratorParameter"; + ParserContextFlags[ParserContextFlags["ContainsError"] = 16] = "ContainsError"; + ParserContextFlags[ParserContextFlags["HasPropagatedChildContainsErrorFlag"] = 32] = "HasPropagatedChildContainsErrorFlag"; + })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); + var ParserContextFlags = ts.ParserContextFlags; (function (EmitReturnStatus) { EmitReturnStatus[EmitReturnStatus["Succeeded"] = 0] = "Succeeded"; EmitReturnStatus[EmitReturnStatus["AllOutputGenerationSkipped"] = 1] = "AllOutputGenerationSkipped"; @@ -24,25 +284,312 @@ var ts; EmitReturnStatus[EmitReturnStatus["CompilerOptionsErrors"] = 5] = "CompilerOptionsErrors"; })(ts.EmitReturnStatus || (ts.EmitReturnStatus = {})); var EmitReturnStatus = ts.EmitReturnStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["CallSignature"] = 131072] = "CallSignature"; + SymbolFlags[SymbolFlags["ConstructSignature"] = 262144] = "ConstructSignature"; + SymbolFlags[SymbolFlags["IndexSignature"] = 524288] = "IndexSignature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 1048576] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 2097152] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 4194304] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 8388608] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 16777216] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Import"] = 33554432] = "Import"; + SymbolFlags[SymbolFlags["Instantiated"] = 67108864] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 134217728] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 268435456] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 536870912] = "Prototype"; + SymbolFlags[SymbolFlags["UnionProperty"] = 1073741824] = "UnionProperty"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 3152352] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1536] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["Signature"] = 917504] = "Signature"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 3258879] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 3152288] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 3258623] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 3259263] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 2103776] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 3152352] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["ImportExcludes"] = 33554432] = "ImportExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 35653619] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasLocals"] = 1041936] = "HasLocals"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["IsContainer"] = 1048560] = "IsContainer"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 29360128] = "Export"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 16] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 32] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 64] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 128] = "EnumValuesComputed"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Void"] = 16] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 64] = "Null"; + TypeFlags[TypeFlags["Enum"] = 128] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 256] = "StringLiteral"; + TypeFlags[TypeFlags["TypeParameter"] = 512] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 1024] = "Class"; + TypeFlags[TypeFlags["Interface"] = 2048] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 16384] = "Union"; + TypeFlags[TypeFlags["Anonymous"] = 32768] = "Anonymous"; + TypeFlags[TypeFlags["FromSignature"] = 65536] = "FromSignature"; + TypeFlags[TypeFlags["Intrinsic"] = 127] = "Intrinsic"; + TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; + TypeFlags[TypeFlags["ObjectType"] = 48128] = "ObjectType"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleKind) { + ModuleKind[ModuleKind["None"] = 0] = "None"; + ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; + ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; + })(ts.ModuleKind || (ts.ModuleKind = {})); + var ModuleKind = ts.ModuleKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; + ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { - var result; if (array) { for (var i = 0, len = array.length; i < len; i++) { - if (result = callback(array[i])) { - break; + var result = callback(array[i]); + if (result) { + return result; } } } - return result; + return undefined; } ts.forEach = forEach; function contains(array, value) { @@ -568,6 +1115,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { var currentAssertionLevel = 0 /* None */; @@ -592,6 +1146,204 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); var ts; +(function (ts) { + ts.sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1; + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); + try { + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + fileStream.Position = 0; + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + return fileStream.ReadText(); + } + catch (e) { + throw e; + } + finally { + fileStream.Close(); + } + } + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + if (writeByteOrderMark) { + fileStream.Position = 0; + } + else { + fileStream.Position = 3; + } + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } + return { + args: args, + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: function (s) { + WScript.StdOut.Write(s); + }, + readFile: readFile, + writeFile: writeFile, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require('os'); + var platform = _os.platform(); + var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + return buffer.toString("utf8", 3); + } + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + if (writeByteOrderMark) { + data = '\uFEFF' + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + _fs.writeSync(1, s); + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + return { + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + function fileChanged(curr, prev) { + if (+curr.mtime <= +prev.mtime) { + return; + } + callback(fileName); + } + ; + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return __filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWScriptSystem(); + } + else if (typeof module !== "undefined" && module.exports) { + return getNodeSystem(); + } + else { + return undefined; + } + })(); +})(ts || (ts = {})); +var ts; (function (ts) { ts.Diagnostics = { Unterminated_string_literal: { code: 1002, category: 1 /* Error */, key: "Unterminated string literal." }, @@ -698,8 +1450,7 @@ var ts; Type_argument_expected: { code: 1140, category: 1 /* Error */, key: "Type argument expected." }, String_literal_expected: { code: 1141, category: 1 /* Error */, key: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: 1 /* Error */, key: "Line break not permitted here." }, - catch_or_finally_expected: { code: 1143, category: 1 /* Error */, key: "'catch' or 'finally' expected." }, - Block_or_expected: { code: 1144, category: 1 /* Error */, key: "Block or ';' expected." }, + or_expected: { code: 1144, category: 1 /* Error */, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1 /* Error */, key: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: 1 /* Error */, key: "Declaration expected." }, Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1 /* Error */, key: "Import declarations in an internal module cannot reference an external module." }, @@ -712,12 +1463,27 @@ var ts; const_declarations_must_be_initialized: { code: 1155, category: 1 /* Error */, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1 /* Error */, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1 /* Error */, key: "'let' declarations can only be declared inside a block." }, - Invalid_template_literal_expected: { code: 1158, category: 1 /* Error */, key: "Invalid template literal; expected '}'" }, Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: 1 /* Error */, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: 1 /* Error */, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: 1 /* Error */, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: 1 /* Error */, key: "An object member cannot be declared optional." }, yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1 /* Error */, key: "'yield' expression must be contained_within a generator declaration." }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1 /* Error */, key: "Computed property names are not allowed in enums." }, + Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: 1 /* Error */, key: "Computed property names are not allowed in an ambient context." }, + Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: 1 /* Error */, key: "Computed property names are not allowed in class property declarations." }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1 /* Error */, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, + Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: 1 /* Error */, key: "Computed property names are not allowed in method overloads." }, + Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: 1 /* Error */, key: "Computed property names are not allowed in interfaces." }, + Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: 1 /* Error */, key: "Computed property names are not allowed in type literals." }, + A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1 /* Error */, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: 1 /* Error */, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: 1 /* Error */, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: 1 /* Error */, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: 1 /* Error */, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1 /* Error */, key: "Interface declaration cannot have 'implements' clause." }, + Binary_digit_expected: { code: 1177, category: 1 /* Error */, key: "Binary digit expected." }, + Octal_digit_expected: { code: 1178, category: 1 /* Error */, key: "Octal digit expected." }, + Unexpected_token_expected: { code: 1179, category: 1 /* Error */, key: "Unexpected token. '{' expected." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -989,6 +1755,7 @@ var ts; Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: 1 /* Error */, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1 /* Error */, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2 /* Message */, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1 /* Error */, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1 /* Error */, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: 1 /* Error */, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1007,7 +1774,8 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: 1 /* Error */, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." }, yield_expressions_are_not_currently_supported: { code: 9000, category: 1 /* Error */, key: "'yield' expressions are not currently supported." }, - generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "'generators' are not currently supported." } + Generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "Generators are not currently supported." }, + Computed_property_names_are_not_currently_supported: { code: 9002, category: 1 /* Error */, key: "Computed property names are not currently supported." } }; })(ts || (ts = {})); var ts; @@ -1368,7 +2136,7 @@ var ts; 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, skipTrivia, text, onError, onComment) { + function createScanner(languageVersion, skipTrivia, text, onError) { var pos; var len; var startPos; @@ -1376,6 +2144,7 @@ var ts; var token; var tokenValue; var precedingLineBreak; + var tokenIsUnterminated; function error(message) { if (onError) { onError(message); @@ -1452,6 +2221,7 @@ var ts; while (true) { if (pos >= len) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1469,6 +2239,7 @@ var ts; } if (isLineBreak(ch)) { result += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -1485,6 +2256,7 @@ var ts; while (true) { if (pos >= len) { contents += text.substring(start, pos); + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; break; @@ -1617,9 +2389,29 @@ var ts; } return token = 63 /* Identifier */; } + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48 /* _0 */; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + if (numberOfDigits === 0) { + return -1; + } + return value; + } function scan() { startPos = pos; precedingLineBreak = false; + tokenIsUnterminated = false; while (true) { tokenPos = pos; if (pos >= len) { @@ -1729,9 +2521,6 @@ var ts; } pos++; } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } @@ -1757,13 +2546,11 @@ var ts; if (!commentClosed) { error(ts.Diagnostics.Asterisk_Slash_expected); } - if (onComment) { - onComment(tokenPos, pos); - } if (skipTrivia) { continue; } else { + tokenIsUnterminated = !commentClosed; return token = 3 /* MultiLineCommentTrivia */; } } @@ -1782,6 +2569,26 @@ var ts; tokenValue = "" + value; return token = 6 /* NumericLiteral */; } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 6 /* NumericLiteral */; + } + else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return 6 /* NumericLiteral */; + } if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); return token = 6 /* NumericLiteral */; @@ -1911,11 +2718,13 @@ var ts; var inCharacterClass = false; while (true) { if (p >= len) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { + tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -1951,7 +2760,7 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } - function tryScan(callback) { + function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; var saveTokenPos = tokenPos; @@ -1959,7 +2768,7 @@ var ts; var saveTokenValue = tokenValue; var savePrecedingLineBreak = precedingLineBreak; var result = callback(); - if (!result) { + if (!result || isLookahead) { pos = savePos; startPos = saveStartPos; tokenPos = saveTokenPos; @@ -1969,6 +2778,12 @@ var ts; } return result; } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } function setText(newText) { text = newText || ""; len = text.length; @@ -1992,34 +2807,87 @@ var ts; hasPrecedingLineBreak: function () { return precedingLineBreak; }, isIdentifier: function () { return token === 63 /* Identifier */ || token > 99 /* LastReservedWord */; }, isReservedWord: function () { return token >= 64 /* FirstReservedWord */ && token <= 99 /* LastReservedWord */; }, + isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, scan: scan, setText: setText, setTextPos: setTextPos, - tryScan: tryScan + tryScan: tryScan, + lookAhead: lookAhead }; } ts.createScanner = createScanner; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(200 /* Count */); - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + 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.getNodeConstructor = getNodeConstructor; - function createRootNode(kind, pos, end, flags) { - var node = new (getNodeConstructor(kind))(); - node.pos = pos; - node.end = end; - node.flags = flags; - return node; + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length == 0) { + var str = ""; + var writeText = function (text) { return str += text; }; + return { + string: function () { return str; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str += " "; }, + increaseIndent: function () { + }, + decreaseIndent: function () { + }, + clear: function () { return str = ""; }, + trackSymbol: function () { + } + }; + } + return stringWriters.pop(); } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + ts.hasFlag = hasFlag; + function containsParseError(node) { + if (!hasFlag(node.parserContextFlags, 32 /* HasPropagatedChildContainsErrorFlag */)) { + var val = hasFlag(node.parserContextFlags, 16 /* ContainsError */) || ts.forEachChild(node, containsParseError); + if (val) { + node.parserContextFlags |= 16 /* ContainsError */; + } + node.parserContextFlags |= 32 /* HasPropagatedChildContainsErrorFlag */; + } + return hasFlag(node.parserContextFlags, 16 /* ContainsError */); + } + ts.containsParseError = containsParseError; function getSourceFileOfNode(node) { - while (node && node.kind !== 197 /* SourceFile */) + while (node && node.kind !== 201 /* SourceFile */) { node = node.parent; + } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; @@ -2033,19 +2901,29 @@ var ts; return node.pos; } ts.getStartPosOfNode = getStartPosOfNode; + function isMissingNode(node) { + return node.pos === node.end && node.kind !== 1 /* EndOfFileToken */; + } + ts.isMissingNode = isMissingNode; function getTokenPosOfNode(node, sourceFile) { - if (node.pos === node.end) { + if (isMissingNode(node)) { return node.pos; } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + if (isMissingNode(node)) { + return ""; + } var text = sourceFile.text; return text.substring(ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { + if (isMissingNode(node)) { + return ""; + } return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; @@ -2062,13 +2940,13 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function declarationNameToString(name) { - return name.kind === 120 /* Missing */ ? "(Missing)" : getTextOfNode(name); + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); - var start = node.kind === 120 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); + var start = getTokenPosOfNode(node, file); var length = node.end - start; return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); } @@ -2084,12 +2962,12 @@ var ts; function getErrorSpanForNode(node) { var errorSpan; switch (node.kind) { - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: + case 183 /* VariableDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 189 /* ModuleDeclaration */: + case 188 /* EnumDeclaration */: + case 200 /* EnumMember */: errorSpan = node.name; break; } @@ -2105,7 +2983,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 191 /* EnumDeclaration */ && isConst(node); + return node.kind === 188 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -2117,16 +2995,9 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 165 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; + return node.kind === 166 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 63 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); - } - function isUseStrictPrologueDirective(node) { - ts.Debug.assert(isPrologueDirective(node)); - return node.expression.text === "use strict"; - } function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); if (node.kind === 123 /* Parameter */ || node.kind === 122 /* TypeParameter */) { @@ -2138,184 +3009,35 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); + return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; } } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - function forEachChild(node, cbNode, cbNodes) { - function child(node) { - if (node) - return cbNode(node); - } - function children(nodes) { - if (nodes) { - if (cbNodes) - return cbNodes(nodes); - var result; - for (var i = 0, len = nodes.length; i < len; i++) { - if (result = cbNode(nodes[i])) - break; - } - return result; - } - } - if (!node) - return; - switch (node.kind) { - case 121 /* QualifiedName */: - return child(node.left) || child(node.right); - case 122 /* TypeParameter */: - return child(node.name) || child(node.constraint); - case 123 /* Parameter */: - return child(node.name) || child(node.type) || child(node.initializer); - case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - return child(node.name) || child(node.type) || child(node.initializer); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - return children(node.typeParameters) || children(node.parameters) || child(node.type); - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); - case 132 /* TypeReference */: - return child(node.typeName) || children(node.typeArguments); - case 135 /* TypeQuery */: - return child(node.exprName); - case 136 /* TypeLiteral */: - return children(node.members); - case 137 /* ArrayType */: - return child(node.elementType); - case 138 /* TupleType */: - return children(node.elementTypes); - case 139 /* UnionType */: - return children(node.types); - case 140 /* ParenType */: - return child(node.type); - case 141 /* ArrayLiteral */: - return children(node.elements); - case 142 /* ObjectLiteral */: - return children(node.properties); - case 145 /* PropertyAccess */: - return child(node.left) || child(node.right); - case 146 /* IndexedAccess */: - return child(node.object) || child(node.index); - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return child(node.func) || children(node.typeArguments) || children(node.arguments); - case 149 /* TaggedTemplateExpression */: - return child(node.tag) || child(node.template); - case 150 /* TypeAssertion */: - return child(node.type) || child(node.operand); - case 151 /* ParenExpression */: - return child(node.expression); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return child(node.operand); - case 156 /* BinaryExpression */: - return child(node.left) || child(node.right); - case 157 /* ConditionalExpression */: - return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 197 /* SourceFile */: - return children(node.statements); - case 163 /* VariableStatement */: - return children(node.declarations); - case 165 /* ExpressionStatement */: - return child(node.expression); - case 166 /* IfStatement */: - return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); - case 167 /* DoStatement */: - return child(node.statement) || child(node.expression); - case 168 /* WhileStatement */: - return child(node.expression) || child(node.statement); - case 169 /* ForStatement */: - return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); - case 170 /* ForInStatement */: - return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - return child(node.label); - case 173 /* ReturnStatement */: - return child(node.expression); - case 174 /* WithStatement */: - return child(node.expression) || child(node.statement); - case 175 /* SwitchStatement */: - return child(node.expression) || children(node.clauses); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - return child(node.expression) || children(node.statements); - case 178 /* LabeledStatement */: - return child(node.label) || child(node.statement); - case 179 /* ThrowStatement */: - return child(node.expression); - case 180 /* TryStatement */: - return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock); - case 182 /* CatchBlock */: - return child(node.variable) || children(node.statements); - case 185 /* VariableDeclaration */: - return child(node.name) || child(node.type) || child(node.initializer); - case 188 /* ClassDeclaration */: - return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members); - case 189 /* InterfaceDeclaration */: - return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members); - case 190 /* TypeAliasDeclaration */: - return child(node.name) || child(node.type); - case 191 /* EnumDeclaration */: - return child(node.name) || children(node.members); - case 196 /* EnumMember */: - return child(node.name) || child(node.initializer); - case 192 /* ModuleDeclaration */: - return child(node.name) || child(node.body); - case 194 /* ImportDeclaration */: - return child(node.name) || child(node.entityName) || child(node.externalModuleName); - case 195 /* ExportAssignment */: - return child(node.exportName); - case 158 /* TemplateExpression */: - return child(node.head) || children(node.templateSpans); - case 159 /* TemplateSpan */: - return child(node.expression) || child(node.literal); - } - } - ts.forEachChild = forEachChild; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 173 /* ReturnStatement */: + case 174 /* ReturnStatement */: return visitor(node); - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - return forEachChild(node, traverse); + case 163 /* Block */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: + case 177 /* LabeledStatement */: + case 179 /* TryStatement */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: + return ts.forEachChild(node, traverse); } } } @@ -2323,9 +3045,9 @@ var ts; function isAnyFunction(node) { if (node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: @@ -2336,6 +3058,14 @@ var ts; return false; } ts.isAnyFunction = isAnyFunction; + function isFunctionBlock(node) { + return node !== undefined && node.kind === 163 /* Block */ && isAnyFunction(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node !== undefined && node.kind === 125 /* Method */ && node.parent.kind === 142 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { while (true) { node = node.parent; @@ -2352,20 +3082,20 @@ var ts; return undefined; } switch (node.kind) { - case 153 /* ArrowFunction */: + case 151 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 192 /* ModuleDeclaration */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 189 /* ModuleDeclaration */: case 124 /* Property */: case 125 /* Method */: case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 191 /* EnumDeclaration */: - case 197 /* SourceFile */: + case 188 /* EnumDeclaration */: + case 201 /* SourceFile */: return node; } } @@ -2389,10 +3119,10 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getInvokedExpression(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { return node.tag; } - return node.func; + return node.expression; } ts.getInvokedExpression = getInvokedExpression; function isExpression(node) { @@ -2403,28 +3133,32 @@ var ts; case 93 /* TrueKeyword */: case 78 /* FalseKeyword */: case 8 /* RegularExpressionLiteral */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 158 /* TemplateExpression */: + case 141 /* ArrayLiteralExpression */: + case 142 /* ObjectLiteralExpression */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + case 147 /* TaggedTemplateExpression */: + case 148 /* TypeAssertionExpression */: + case 149 /* ParenthesizedExpression */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + case 154 /* VoidExpression */: + case 152 /* DeleteExpression */: + case 153 /* TypeOfExpression */: + case 155 /* PrefixUnaryExpression */: + case 156 /* PostfixUnaryExpression */: + case 157 /* BinaryExpression */: + case 158 /* ConditionalExpression */: + case 159 /* TemplateExpression */: case 9 /* NoSubstitutionTemplateLiteral */: case 161 /* OmittedExpression */: return true; - case 121 /* QualifiedName */: - while (node.parent.kind === 121 /* QualifiedName */) + case 120 /* QualifiedName */: + while (node.parent.kind === 120 /* QualifiedName */) { node = node.parent; + } return node.parent.kind === 135 /* TypeQuery */; case 63 /* Identifier */: if (node.parent.kind === 135 /* TypeQuery */) { @@ -2434,30 +3168,30 @@ var ts; case 7 /* StringLiteral */: var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 123 /* Parameter */: case 124 /* Property */: - case 196 /* EnumMember */: - case 143 /* PropertyAssignment */: + case 200 /* EnumMember */: + case 198 /* PropertyAssignment */: return parent.initializer === node; - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 179 /* ThrowStatement */: - case 175 /* SwitchStatement */: + case 166 /* ExpressionStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 174 /* ReturnStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 178 /* ThrowStatement */: + case 176 /* SwitchStatement */: return parent.expression === node; - case 169 /* ForStatement */: + case 170 /* ForStatement */: return parent.initializer === node || parent.condition === node || parent.iterator === node; - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return parent.variable === node || parent.expression === node; - case 150 /* TypeAssertion */: - return node === parent.operand; - case 159 /* TemplateSpan */: + case 148 /* TypeAssertionExpression */: + return node === parent.expression; + case 162 /* TemplateSpan */: return node === parent.expression; default: if (isExpression(parent)) { @@ -2468,8 +3202,41 @@ var ts; return false; } ts.isExpression = isExpression; + function isExternalModuleImportDeclaration(node) { + return node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind === 193 /* ExternalModuleReference */; + } + ts.isExternalModuleImportDeclaration = isExternalModuleImportDeclaration; + function getExternalModuleImportDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportDeclarationExpression = getExternalModuleImportDeclarationExpression; + function isInternalModuleImportDeclaration(node) { + return node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind !== 193 /* ExternalModuleReference */; + } + ts.isInternalModuleImportDeclaration = isInternalModuleImportDeclaration; + function hasDotDotDotToken(node) { + return node && node.kind === 123 /* Parameter */ && node.dotDotDotToken !== undefined; + } + ts.hasDotDotDotToken = hasDotDotDotToken; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 123 /* Parameter */: + return node.questionToken !== undefined; + case 125 /* Method */: + return node.questionToken !== undefined; + case 199 /* ShorthandPropertyAssignment */: + case 198 /* PropertyAssignment */: + case 124 /* Property */: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; function hasRestParameters(s) { - return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & 8 /* Rest */) !== 0; + return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; } ts.hasRestParameters = hasRestParameters; function isLiteralKind(kind) { @@ -2497,22 +3264,22 @@ var ts; switch (node.kind) { case 122 /* TypeParameter */: case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: + case 200 /* EnumMember */: case 125 /* Method */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: case 126 /* Constructor */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 188 /* EnumDeclaration */: + case 189 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: return true; } return false; @@ -2520,24 +3287,24 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 184 /* DebuggerStatement */: - case 167 /* DoStatement */: - case 165 /* ExpressionStatement */: - case 164 /* EmptyStatement */: - case 170 /* ForInStatement */: - case 169 /* ForStatement */: - case 166 /* IfStatement */: - case 178 /* LabeledStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: + case 173 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 182 /* DebuggerStatement */: + case 168 /* DoStatement */: + case 166 /* ExpressionStatement */: + case 165 /* EmptyStatement */: + case 171 /* ForInStatement */: + case 170 /* ForStatement */: + case 167 /* IfStatement */: + case 177 /* LabeledStatement */: + case 174 /* ReturnStatement */: + case 176 /* SwitchStatement */: case 92 /* ThrowKeyword */: - case 180 /* TryStatement */: - case 163 /* VariableStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 195 /* ExportAssignment */: + case 179 /* TryStatement */: + case 164 /* VariableStatement */: + case 169 /* WhileStatement */: + case 175 /* WithStatement */: + case 192 /* ExportAssignment */: return true; default: return false; @@ -2549,15 +3316,41 @@ var ts; return false; } var parent = name.parent; - if (isDeclaration(parent) || parent.kind === 152 /* FunctionExpression */) { + if (isDeclaration(parent) || parent.kind === 150 /* FunctionExpression */) { return parent.name === name; } - if (parent.kind === 182 /* CatchBlock */) { - return parent.variable === name; + if (parent.kind === 197 /* CatchClause */) { + return parent.name === name; } return false; } ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName; + function getClassBaseTypeNode(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 77 /* ExtendsKeyword */); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassBaseTypeNode = getClassBaseTypeNode; + function getClassImplementedTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 100 /* ImplementsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 77 /* ExtendsKeyword */); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var i = 0, n = clauses.length; i < n; i++) { + if (clauses[i].token === kind) { + return clauses[i]; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; function tryResolveScriptReference(program, sourceFile, reference) { if (!program.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.filename) ? reference.filename : ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename); @@ -2568,16 +3361,16 @@ var ts; ts.tryResolveScriptReference = tryResolveScriptReference; function getAncestor(node, kind) { switch (kind) { - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: while (node) { switch (node.kind) { - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return node; - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 188 /* EnumDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 189 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: return undefined; default: node = node.parent; @@ -2597,28 +3390,6 @@ var ts; return undefined; } ts.getAncestor = getAncestor; - function parsingContextErrors(context) { - switch (context) { - case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* BaseTypeReferences */: return ts.Diagnostics.Type_reference_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - } - } - ; function getFileReferenceFromReferencePath(comment, commentRange) { var simpleReferenceRegEx = /^\/\/\/\s*/gim; @@ -2644,7 +3415,7 @@ var ts; } else { return { - diagnostic: ts.Diagnostics.Invalid_reference_directive_syntax, + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, isNoDefaultLib: false }; } @@ -2661,18 +3432,6 @@ var ts; return 2 /* FirstTriviaToken */ <= token && token <= 5 /* LastTriviaToken */; } ts.isTrivia = isTrivia; - function isUnterminatedTemplateEnd(node) { - ts.Debug.assert(isTemplateLiteralKind(node.kind)); - var sourceText = getSourceFileOfNode(node).text; - if (node.end !== sourceText.length) { - return false; - } - if (node.kind !== 12 /* TemplateTail */ && node.kind !== 9 /* NoSubstitutionTemplateLiteral */) { - return false; - } - return sourceText.charCodeAt(node.end - 1) !== 96 /* backtick */ || node.text.length === 0; - } - ts.isUnterminatedTemplateEnd = isUnterminatedTemplateEnd; function isModifier(token) { switch (token) { case 106 /* PublicKeyword */: @@ -2681,11 +3440,302 @@ var ts; case 107 /* StaticKeyword */: case 76 /* ExportKeyword */: case 112 /* DeclareKeyword */: + case 68 /* ConstKeyword */: return true; } return false; } ts.isModifier = isModifier; +})(ts || (ts = {})); +var ts; +(function (ts) { + var nodeConstructors = new Array(204 /* Count */); + function getNodeConstructor(kind) { + return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); + } + ts.getNodeConstructor = getNodeConstructor; + function createRootNode(kind, pos, end, flags) { + var node = new (getNodeConstructor(kind))(); + node.pos = pos; + node.end = end; + node.flags = flags; + return node; + } + function forEachChild(node, cbNode, cbNodes) { + function child(node) { + if (node) { + return cbNode(node); + } + } + function children(nodes) { + if (nodes) { + if (cbNodes) { + return cbNodes(nodes); + } + for (var i = 0, len = nodes.length; i < len; i++) { + var result = cbNode(nodes[i]); + if (result) { + return result; + } + } + return undefined; + } + } + if (!node) { + return; + } + switch (node.kind) { + case 120 /* QualifiedName */: + return child(node.left) || child(node.right); + case 122 /* TypeParameter */: + return child(node.name) || child(node.constraint); + case 123 /* Parameter */: + return children(node.modifiers) || child(node.dotDotDotToken) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + case 124 /* Property */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: + return children(node.modifiers) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + case 133 /* FunctionType */: + case 134 /* ConstructorType */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: + return children(node.modifiers) || children(node.typeParameters) || children(node.parameters) || child(node.type); + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: + return children(node.modifiers) || child(node.name) || child(node.questionToken) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); + case 132 /* TypeReference */: + return child(node.typeName) || children(node.typeArguments); + case 135 /* TypeQuery */: + return child(node.exprName); + case 136 /* TypeLiteral */: + return children(node.members); + case 137 /* ArrayType */: + return child(node.elementType); + case 138 /* TupleType */: + return children(node.elementTypes); + case 139 /* UnionType */: + return children(node.types); + case 140 /* ParenthesizedType */: + return child(node.type); + case 141 /* ArrayLiteralExpression */: + return children(node.elements); + case 142 /* ObjectLiteralExpression */: + return children(node.properties); + case 143 /* PropertyAccessExpression */: + return child(node.expression) || child(node.name); + case 144 /* ElementAccessExpression */: + return child(node.expression) || child(node.argumentExpression); + case 145 /* CallExpression */: + case 146 /* NewExpression */: + return child(node.expression) || children(node.typeArguments) || children(node.arguments); + case 147 /* TaggedTemplateExpression */: + return child(node.tag) || child(node.template); + case 148 /* TypeAssertionExpression */: + return child(node.type) || child(node.expression); + case 149 /* ParenthesizedExpression */: + return child(node.expression); + case 152 /* DeleteExpression */: + return child(node.expression); + case 153 /* TypeOfExpression */: + return child(node.expression); + case 154 /* VoidExpression */: + return child(node.expression); + case 155 /* PrefixUnaryExpression */: + return child(node.operand); + case 156 /* PostfixUnaryExpression */: + return child(node.operand); + case 157 /* BinaryExpression */: + return child(node.left) || child(node.right); + case 158 /* ConditionalExpression */: + return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); + case 163 /* Block */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: + return children(node.statements); + case 201 /* SourceFile */: + return children(node.statements) || child(node.endOfFileToken); + case 164 /* VariableStatement */: + return children(node.modifiers) || children(node.declarations); + case 166 /* ExpressionStatement */: + return child(node.expression); + case 167 /* IfStatement */: + return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); + case 168 /* DoStatement */: + return child(node.statement) || child(node.expression); + case 169 /* WhileStatement */: + return child(node.expression) || child(node.statement); + case 170 /* ForStatement */: + return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); + case 171 /* ForInStatement */: + return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: + return child(node.label); + case 174 /* ReturnStatement */: + return child(node.expression); + case 175 /* WithStatement */: + return child(node.expression) || child(node.statement); + case 176 /* SwitchStatement */: + return child(node.expression) || children(node.clauses); + case 194 /* CaseClause */: + return child(node.expression) || children(node.statements); + case 195 /* DefaultClause */: + return children(node.statements); + case 177 /* LabeledStatement */: + return child(node.label) || child(node.statement); + case 178 /* ThrowStatement */: + return child(node.expression); + case 179 /* TryStatement */: + return child(node.tryBlock) || child(node.catchClause) || child(node.finallyBlock); + case 197 /* CatchClause */: + return child(node.name) || child(node.type) || child(node.block); + case 183 /* VariableDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.type) || child(node.initializer); + case 185 /* ClassDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 186 /* InterfaceDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + case 187 /* TypeAliasDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.type); + case 188 /* EnumDeclaration */: + return children(node.modifiers) || child(node.name) || children(node.members); + case 200 /* EnumMember */: + return child(node.name) || child(node.initializer); + case 189 /* ModuleDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.body); + case 191 /* ImportDeclaration */: + return children(node.modifiers) || child(node.name) || child(node.moduleReference); + case 192 /* ExportAssignment */: + return children(node.modifiers) || child(node.exportName); + case 159 /* TemplateExpression */: + return child(node.head) || children(node.templateSpans); + case 162 /* TemplateSpan */: + return child(node.expression) || child(node.literal); + case 121 /* ComputedPropertyName */: + return child(node.expression); + case 196 /* HeritageClause */: + return children(node.types); + case 193 /* ExternalModuleReference */: + return child(node.expression); + } + } + ts.forEachChild = forEachChild; + function createCompilerHost(options) { + var currentDirectory; + var existingDirectories = {}; + function getCanonicalFileName(fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(filename, languageVersion, onError) { + try { + var text = ts.sys.readFile(filename, options.charset); + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText : e.message); + } + text = ""; + } + return text !== undefined ? createSourceFile(filename, text, languageVersion, "0") : undefined; + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + function directoryExists(directoryPath) { + if (ts.hasProperty(existingDirectories, directoryPath)) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + try { + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + ts.sys.writeFile(fileName, data, writeByteOrderMark); + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + return { + getSourceFile: getSourceFile, + getDefaultLibFilename: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"); }, + writeFile: writeFile, + getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return ts.sys.newLine; } + }; + } + ts.createCompilerHost = createCompilerHost; + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["ModuleElements"] = 1] = "ModuleElements"; + ParsingContext[ParsingContext["BlockStatements"] = 2] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 3] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 4] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 5] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 6] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 7] = "EnumMembers"; + ParsingContext[ParsingContext["TypeReferences"] = 8] = "TypeReferences"; + ParsingContext[ParsingContext["VariableDeclarations"] = 9] = "VariableDeclarations"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 10] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 11] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 12] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 13] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 14] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 15] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 16] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 17] = "HeritageClauses"; + ParsingContext[ParsingContext["Count"] = 18] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); + function parsingContextErrors(context) { + switch (context) { + case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; + case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 8 /* TypeReferences */: return ts.Diagnostics.Type_reference_expected; + case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 17 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + } + } + ; function modifierToFlag(token) { switch (token) { case 107 /* StaticKeyword */: return 128 /* Static */; @@ -2694,22 +3744,28 @@ var ts; case 104 /* PrivateKeyword */: return 32 /* Private */; case 76 /* ExportKeyword */: return 1 /* Export */; case 112 /* DeclareKeyword */: return 2 /* Ambient */; + case 68 /* ConstKeyword */: return 4096 /* Const */; } return 0; } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 63 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); + } + function isUseStrictPrologueDirective(sourceFile, node) { + ts.Debug.assert(ts.isPrologueDirective(node)); + var nodeText = ts.getSourceTextOfNodeFromSourceFile(sourceFile, node.expression); + return nodeText === '"use strict"' || nodeText === "'use strict'"; + } function createSourceFile(filename, sourceText, languageVersion, version, isOpen) { if (isOpen === void 0) { isOpen = false; } - var file; - var scanner; var token; var parsingContext; - var commentRanges; var identifiers = {}; var identifierCount = 0; var nodeCount = 0; var lineStarts; - var lookAheadMode = 0 /* NotLookingAhead */; var contextFlags = 0; + var parseErrorBeforeNextFinishedNode = false; function setContextFlag(val, flag) { if (val) { contextFlags |= flag; @@ -2787,29 +3843,21 @@ var ts; function getPositionFromSourceLineAndCharacter(line, character) { return ts.getPositionFromLineAndCharacter(getLineStarts(), line, character); } - function error(message, arg0, arg1, arg2) { + function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var length = scanner.getTextPos() - start; - errorAtPos(start, length, message, arg0, arg1, arg2); + parseErrorAtPosition(start, length, message, arg0); } - function errorAtPos(start, length, message, arg0, arg1, arg2) { - var lastErrorPos = file.parseDiagnostics.length ? file.parseDiagnostics[file.parseDiagnostics.length - 1].start : -1; - if (start !== lastErrorPos) { - var diagnostic = ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); - diagnostic.isParseError = true; - file.parseDiagnostics.push(diagnostic); - } - if (lookAheadMode === 1 /* NoErrorYet */) { - lookAheadMode = 2 /* Error */; + function parseErrorAtPosition(start, length, message, arg0) { + var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); + if (!lastError || start !== lastError.start) { + sourceFile.parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); } + parseErrorBeforeNextFinishedNode = true; } function scanError(message) { var pos = scanner.getTextPos(); - errorAtPos(pos, 0, message); - } - function onComment(pos, end) { - if (commentRanges) - commentRanges.push({ pos: pos, end: end }); + parseErrorAtPosition(pos, 0, message); } function getNodePos() { return scanner.getStartPos(); @@ -2832,33 +3880,25 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } - function lookAheadHelper(callback, alwaysResetState) { + function speculationHelper(callback, isLookAhead) { var saveToken = token; - var saveSyntacticErrorsLength = file.parseDiagnostics.length; - var saveLookAheadMode = lookAheadMode; - lookAheadMode = 1 /* NoErrorYet */; - var result = callback(); - ts.Debug.assert(lookAheadMode === 2 /* Error */ || lookAheadMode === 1 /* NoErrorYet */); - if (lookAheadMode === 2 /* Error */) { - result = undefined; - } - lookAheadMode = saveLookAheadMode; - if (!result || alwaysResetState) { + var saveParseDiagnosticsLength = sourceFile.parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + var saveContextFlags = contextFlags; + var result = isLookAhead ? scanner.lookAhead(callback) : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + if (!result || isLookAhead) { token = saveToken; - file.parseDiagnostics.length = saveSyntacticErrorsLength; + sourceFile.parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; } return result; } function lookAhead(callback) { - var result; - scanner.tryScan(function () { - result = lookAheadHelper(callback, true); - return false; - }); - return result; + return speculationHelper(callback, true); } function tryParse(callback) { - return scanner.tryScan(function () { return lookAheadHelper(callback, false); }); + return speculationHelper(callback, false); } function isIdentifier() { if (token === 63 /* Identifier */) { @@ -2869,12 +3909,17 @@ var ts; } return inStrictModeContext() ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */; } - function parseExpected(t) { - if (token === t) { + function parseExpected(kind, diagnosticMessage, arg0) { + if (token === kind) { nextToken(); return true; } - error(ts.Diagnostics._0_expected, ts.tokenToString(t)); + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } return false; } function parseOptional(t) { @@ -2898,14 +3943,15 @@ var ts; } return token === 14 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } - function parseSemicolon() { + function parseSemicolon(diagnosticMessage) { if (canParseSemicolon()) { if (token === 21 /* SemicolonToken */) { nextToken(); } + return true; } else { - error(ts.Diagnostics._0_expected, ";"); + return parseExpected(21 /* SemicolonToken */, diagnosticMessage); } } function createNode(kind, pos) { @@ -2923,16 +3969,28 @@ var ts; if (contextFlags) { node.parserContextFlags = contextFlags; } + if (parseErrorBeforeNextFinishedNode) { + parseErrorBeforeNextFinishedNode = false; + node.parserContextFlags |= 16 /* ContainsError */; + } return node; } - function createMissingNode(pos) { - return createNode(120 /* Missing */, pos); + function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { + if (reportAtCurrentPosition) { + parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); + } + else { + parseErrorAtCurrentToken(diagnosticMessage, arg0); + } + var result = createNode(kind, scanner.getStartPos()); + result.text = ""; + return finishNode(result); } function internIdentifier(text) { - text = escapeIdentifier(text); + text = ts.escapeIdentifier(text); return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); } - function createIdentifier(isIdentifier) { + function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { var node = createNode(63 /* Identifier */); @@ -2940,37 +3998,59 @@ var ts; nextToken(); return finishNode(node); } - error(ts.Diagnostics.Identifier_expected); - var node = createMissingNode(); - node.text = ""; - return node; + return createMissingNode(63 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } - function parseIdentifier() { - return createIdentifier(isIdentifier()); + function parseIdentifier(diagnosticMessage) { + return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(token >= 63 /* Identifier */); + return createIdentifier(isIdentifierOrKeyword()); } - function isPropertyName() { - return token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; + function isLiteralPropertyName() { + return isIdentifierOrKeyword() || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; } function parsePropertyName() { if (token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { return parseLiteralNode(true); } + if (token === 17 /* OpenBracketToken */) { + return parseComputedPropertyName(); + } return parseIdentifierName(); } + function parseComputedPropertyName() { + var node = createNode(121 /* ComputedPropertyName */); + parseExpected(17 /* OpenBracketToken */); + var yieldContext = inYieldContext(); + if (inGeneratorParameterContext()) { + setYieldContext(false); + } + node.expression = allowInAnd(parseExpression); + if (inGeneratorParameterContext()) { + setYieldContext(yieldContext); + } + parseExpected(18 /* CloseBracketToken */); + return finishNode(node); + } function parseContextualModifier(t) { - return token === t && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || isPropertyName(); - }); + return token === t && tryParse(nextTokenCanFollowModifier); + } + function nextTokenCanFollowModifier() { + nextToken(); + return canFollowModifier(); } function parseAnyContextualModifier() { - return isModifier(token) && tryParse(function () { - nextToken(); - return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isPropertyName(); - }); + return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); + } + function nextTokenCanFollowContextualModifier() { + if (token === 68 /* ConstKeyword */) { + return nextToken() === 75 /* EnumKeyword */; + } + nextToken(); + return canFollowModifier(); + } + function canFollowModifier() { + return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isLiteralPropertyName(); } function isListElement(kind, inErrorRecovery) { switch (kind) { @@ -2987,11 +4067,11 @@ var ts; case 6 /* ClassMembers */: return lookAhead(isClassMemberStart); case 7 /* EnumMembers */: - return isPropertyName(); + return token === 17 /* OpenBracketToken */ || isLiteralPropertyName(); case 11 /* ObjectLiteralMembers */: - return token === 34 /* AsteriskToken */ || isPropertyName(); - case 8 /* BaseTypeReferences */: - return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); + return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isLiteralPropertyName(); + case 8 /* TypeReferences */: + return isIdentifier() && !isNotHeritageClauseTypeName(); case 9 /* VariableDeclarations */: case 14 /* TypeParameters */: return isIdentifier(); @@ -3004,9 +4084,21 @@ var ts; case 15 /* TypeArguments */: case 16 /* TupleElementTypes */: return token === 22 /* CommaToken */ || isStartOfType(); + case 17 /* HeritageClauses */: + return isHeritageClause(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } + function nextTokenIsIdentifier() { + nextToken(); + return isIdentifier(); + } + function isNotHeritageClauseTypeName() { + if (token === 100 /* ImplementsKeyword */ || token === 77 /* ExtendsKeyword */) { + return lookAhead(nextTokenIsIdentifier); + } + return false; + } function isListTerminator(kind) { if (token === 1 /* EndOfFileToken */) { return true; @@ -3022,7 +4114,7 @@ var ts; return token === 14 /* CloseBraceToken */; case 4 /* SwitchClauseStatements */: return token === 14 /* CloseBraceToken */ || token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; - case 8 /* BaseTypeReferences */: + case 8 /* TypeReferences */: return token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; case 9 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); @@ -3037,6 +4129,8 @@ var ts; return token === 16 /* CloseParenToken */ || token === 18 /* CloseBracketToken */ || token === 13 /* OpenBraceToken */; case 15 /* TypeArguments */: return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */; + case 17 /* HeritageClauses */: + return token === 13 /* OpenBraceToken */ || token === 14 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -3052,7 +4146,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 17 /* Count */; kind++) { + for (var kind = 0; kind < 18 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -3071,9 +4165,9 @@ var ts; if (isListElement(kind, false)) { var element = parseElement(); result.push(element); - if (!inStrictModeContext() && checkForStrictMode) { - if (isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { + if (checkForStrictMode && !inStrictModeContext()) { + if (ts.isPrologueDirective(element)) { + if (isUseStrictPrologueDirective(sourceFile, element)) { setStrictModeContext(true); checkForStrictMode = false; } @@ -3082,13 +4176,10 @@ var ts; checkForStrictMode = false; } } + continue; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } setStrictModeContext(savedStrictModeContext); @@ -3096,6 +4187,14 @@ var ts; parsingContext = saveParsingContext; return result; } + function abortParsingListOrMoveToNextToken(kind) { + parseErrorAtCurrentToken(parsingContextErrors(kind)); + if (isInSomeParsingContext()) { + return true; + } + nextToken(); + return false; + } function parseDelimitedList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; @@ -3113,17 +4212,14 @@ var ts; if (isListTerminator(kind)) { break; } - error(ts.Diagnostics._0_expected, ","); + parseExpected(22 /* CommaToken */); + continue; } - else if (isListTerminator(kind)) { + if (isListTerminator(kind)) { break; } - else { - error(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - break; - } - nextToken(); + if (abortParsingListOrMoveToNextToken(kind)) { + break; } } if (commaStart >= 0) { @@ -3148,23 +4244,32 @@ var ts; } return createMissingList(); } - function parseEntityName(allowReservedWords) { - var entity = parseIdentifier(); + function parseEntityName(allowReservedWords, diagnosticMessage) { + var entity = parseIdentifier(diagnosticMessage); while (parseOptional(19 /* DotToken */)) { - var node = createNode(121 /* QualifiedName */, entity.pos); + var node = createNode(120 /* QualifiedName */, entity.pos); node.left = entity; - node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); + node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); } return entity; } + function parseRightSideOfDot(allowIdentifierNames) { + if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); + if (matchesPattern) { + return createMissingNode(63 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + } + } + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } function parseTokenNode() { var node = createNode(token); nextToken(); return finishNode(node); } function parseTemplateExpression() { - var template = createNode(158 /* TemplateExpression */); + var template = createNode(159 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 10 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -3177,7 +4282,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(159 /* TemplateSpan */); + var span = createNode(162 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 14 /* CloseBraceToken */) { @@ -3185,9 +4290,7 @@ var ts; literal = parseLiteralNode(); } else { - error(ts.Diagnostics.Invalid_template_literal_expected); - literal = createMissingNode(); - literal.text = ""; + literal = createMissingNode(12 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(14 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -3196,6 +4299,9 @@ var ts; var node = createNode(token); var text = scanner.getTokenValue(); node.text = internName ? internIdentifier(text) : text; + if (scanner.isUnterminated()) { + node.isUnterminated = true; + } var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); @@ -3204,18 +4310,11 @@ var ts; } return node; } - function parseStringLiteral() { - if (token === 7 /* StringLiteral */) { - return parseLiteralNode(true); - } - error(ts.Diagnostics.String_literal_expected); - return createMissingNode(); - } function parseTypeReference() { var node = createNode(132 /* TypeReference */); - node.typeName = parseEntityName(false); + node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token === 23 /* LessThanToken */) { - node.typeArguments = parseTypeArguments(); + node.typeArguments = parseBracketedList(15 /* TypeArguments */, parseType, 23 /* LessThanToken */, 24 /* GreaterThanToken */); } return finishNode(node); } @@ -3233,7 +4332,7 @@ var ts; node.constraint = parseType(); } else { - node.expression = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); } } return finishNode(node); @@ -3244,10 +4343,13 @@ var ts; } } function parseParameterType() { - return parseOptional(50 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; + if (parseOptional(50 /* ColonToken */)) { + return token === 7 /* StringLiteral */ ? parseLiteralNode(true) : parseType(); + } + return undefined; } function isStartOfParameter() { - return token === 20 /* DotDotDotToken */ || isIdentifier() || isModifier(token); + return token === 20 /* DotDotDotToken */ || isIdentifier() || ts.isModifier(token); } function setModifiers(node, modifiers) { if (modifiers) { @@ -3257,18 +4359,13 @@ var ts; } function parseParameter() { var node = createNode(123 /* Parameter */); - var modifiers = parseModifiers(); - setModifiers(node, modifiers); - if (parseOptional(20 /* DotDotDotToken */)) { - node.flags |= 8 /* Rest */; - } + setModifiers(node, parseModifiers()); + node.dotDotDotToken = parseOptionalToken(20 /* DotDotDotToken */); node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifier) : parseIdentifier(); - if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) { + if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - if (parseOptional(49 /* QuestionToken */)) { - node.flags |= 4 /* QuestionMark */; - } + node.questionToken = parseOptionalToken(49 /* QuestionToken */); node.type = parseParameterType(); node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); return finishNode(node); @@ -3276,17 +4373,10 @@ var ts; function parseParameterInitializer() { return parseInitializer(true); } - function parseSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext) { - var signature = {}; - fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature); - return signature; - } - function fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature) { - if (kind === 130 /* ConstructSignature */) { - parseExpected(86 /* NewKeyword */); - } + function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 31 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext); + signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -3295,55 +4385,95 @@ var ts; signature.type = parseType(); } } - function parseParameterList(yieldAndGeneratorParameterContext) { + function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { if (parseExpected(15 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(yieldAndGeneratorParameterContext); setGeneratorParameterContext(yieldAndGeneratorParameterContext); var result = parseDelimitedList(13 /* Parameters */, parseParameter); - parseExpected(16 /* CloseParenToken */); setYieldContext(savedYieldContext); setGeneratorParameterContext(savedGeneratorParameterContext); + if (!parseExpected(16 /* CloseParenToken */) && requireCompleteParameterList) { + return undefined; + } return result; } - return createMissingList(); + return requireCompleteParameterList ? undefined : createMissingList(); } - function parseSignatureMember(kind, returnToken) { + function parseTypeMemberSemicolon() { + if (parseSemicolon()) { + return; + } + parseOptional(22 /* CommaToken */); + } + function parseSignatureMember(kind) { var node = createNode(kind); - fillSignature(kind, returnToken, false, false, node); - parseSemicolon(); + if (kind === 130 /* ConstructSignature */) { + parseExpected(86 /* NewKeyword */); + } + fillSignature(50 /* ColonToken */, false, false, node); + parseTypeMemberSemicolon(); return finishNode(node); } - function parseIndexSignatureMember(fullStart, modifiers) { + function isIndexSignature() { + if (token !== 17 /* OpenBracketToken */) { + return false; + } + return lookAhead(isUnambiguouslyIndexSignature); + } + function isUnambiguouslyIndexSignature() { + nextToken(); + if (token === 20 /* DotDotDotToken */ || token === 18 /* CloseBracketToken */) { + return true; + } + if (ts.isModifier(token)) { + nextToken(); + if (isIdentifier()) { + return true; + } + } + else if (!isIdentifier()) { + return false; + } + else { + nextToken(); + } + if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */) { + return true; + } + if (token !== 49 /* QuestionToken */) { + return false; + } + nextToken(); + return token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 18 /* CloseBracketToken */; + } + function parseIndexSignatureDeclaration(fullStart, modifiers) { var node = createNode(131 /* IndexSignature */, fullStart); setModifiers(node, modifiers); node.parameters = parseBracketedList(13 /* Parameters */, parseParameter, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); node.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethod() { + function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var flags = 0; - if (parseOptional(49 /* QuestionToken */)) { - flags = 4 /* QuestionMark */; - } + var questionToken = parseOptionalToken(49 /* QuestionToken */); if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { var method = createNode(125 /* Method */, fullStart); method.name = name; - method.flags = flags; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, method); - parseSemicolon(); + method.questionToken = questionToken; + fillSignature(50 /* ColonToken */, false, false, method); + parseTypeMemberSemicolon(); return finishNode(method); } else { var property = createNode(124 /* Property */, fullStart); property.name = name; - property.flags = flags; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - parseSemicolon(); + parseTypeMemberSemicolon(); return finishNode(property); } } @@ -3354,35 +4484,43 @@ var ts; case 17 /* OpenBracketToken */: return true; default: - return isPropertyName() && lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); }); + return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); } } + function isTypeMemberWithLiteralPropertyName() { + nextToken(); + return token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); + } function parseTypeMember() { switch (token) { case 15 /* OpenParenToken */: case 23 /* LessThanToken */: - return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */); + return parseSignatureMember(129 /* CallSignature */); case 17 /* OpenBracketToken */: - return parseIndexSignatureMember(scanner.getStartPos(), undefined); + return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined) : parsePropertyOrMethodSignature(); case 86 /* NewKeyword */: - if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) { - return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */); + if (lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(130 /* ConstructSignature */); } case 7 /* StringLiteral */: case 6 /* NumericLiteral */: - return parsePropertyOrMethod(); + return parsePropertyOrMethodSignature(); default: - if (token >= 63 /* Identifier */) { - return parsePropertyOrMethod(); + if (isIdentifierOrKeyword()) { + return parsePropertyOrMethodSignature(); } } } + function isStartOfConstructSignature() { + nextToken(); + return token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; + } function parseTypeLiteral() { var node = createNode(136 /* TypeLiteral */); - node.members = parseObjectType(); + node.members = parseObjectTypeMembers(); return finishNode(node); } - function parseObjectType() { + function parseObjectTypeMembers() { var members; if (parseExpected(13 /* OpenBraceToken */)) { members = parseList(5 /* TypeMembers */, false, parseTypeMember); @@ -3398,16 +4536,19 @@ var ts; node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); return finishNode(node); } - function parseParenType() { - var node = createNode(140 /* ParenType */); + function parseParenthesizedType() { + var node = createNode(140 /* ParenthesizedType */); parseExpected(15 /* OpenParenToken */); node.type = parseType(); parseExpected(16 /* CloseParenToken */); return finishNode(node); } - function parseFunctionType(typeKind) { - var node = createNode(typeKind); - fillSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true, false, node); + function parseFunctionOrConstructorType(kind) { + var node = createNode(kind); + if (kind === 134 /* ConstructorType */) { + parseExpected(86 /* NewKeyword */); + } + fillSignature(31 /* EqualsGreaterThanToken */, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -3420,9 +4561,10 @@ var ts; case 118 /* StringKeyword */: case 116 /* NumberKeyword */: case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); + case 97 /* VoidKeyword */: + return parseTokenNode(); case 95 /* TypeOfKeyword */: return parseTypeQuery(); case 13 /* OpenBraceToken */: @@ -3430,14 +4572,10 @@ var ts; case 17 /* OpenBracketToken */: return parseTupleType(); case 15 /* OpenParenToken */: - return parseParenType(); + return parseParenthesizedType(); default: - if (isIdentifier()) { - return parseTypeReference(); - } + return parseTypeReference(); } - error(ts.Diagnostics.Type_expected); - return createMissingNode(); } function isStartOfType() { switch (token) { @@ -3453,15 +4591,16 @@ var ts; case 86 /* NewKeyword */: return true; case 15 /* OpenParenToken */: - return lookAhead(function () { - nextToken(); - return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); - }); + return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } } - function parsePrimaryType() { + function isStartOfParenthesizedOrFunctionType() { + nextToken(); + return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + } + function parseArrayTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(17 /* OpenBracketToken */)) { parseExpected(18 /* CloseBracketToken */); @@ -3471,13 +4610,13 @@ var ts; } return type; } - function parseUnionType() { - var type = parsePrimaryType(); + function parseUnionTypeOrHigher() { + var type = parseArrayTypeOrHigher(); if (token === 43 /* BarToken */) { var types = [type]; types.pos = type.pos; while (parseOptional(43 /* BarToken */)) { - types.push(parsePrimaryType()); + types.push(parseArrayTypeOrHigher()); } types.end = getNodeEnd(); var node = createNode(139 /* UnionType */, type.pos); @@ -3487,25 +4626,29 @@ var ts; return type; } function isStartOfFunctionType() { - return token === 23 /* LessThanToken */ || token === 15 /* OpenParenToken */ && lookAhead(function () { + if (token === 23 /* LessThanToken */) { + return true; + } + return token === 15 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + } + function isUnambiguouslyStartOfFunctionType() { + nextToken(); + if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { + return true; + } + if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { + if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { return true; } - if (isIdentifier() || isModifier(token)) { + if (token === 16 /* CloseParenToken */) { nextToken(); - if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || isModifier(token)) { + if (token === 31 /* EqualsGreaterThanToken */) { return true; } - if (token === 16 /* CloseParenToken */) { - nextToken(); - if (token === 31 /* EqualsGreaterThanToken */) { - return true; - } - } } - return false; - }); + } + return false; } function parseType() { var savedYieldContext = inYieldContext(); @@ -3519,12 +4662,12 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionType(133 /* FunctionType */); + return parseFunctionOrConstructorType(133 /* FunctionType */); } if (token === 86 /* NewKeyword */) { - return parseFunctionType(134 /* ConstructorType */); + return parseFunctionOrConstructorType(134 /* ConstructorType */); } - return parseUnionType(); + return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { return parseOptional(50 /* ColonToken */) ? parseType() : undefined; @@ -3561,6 +4704,9 @@ var ts; case 108 /* YieldKeyword */: return true; default: + if (isBinaryOperator()) { + return true; + } return isIdentifier(); } } @@ -3568,9 +4714,9 @@ var ts; return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression(); } function parseExpression() { - var expr = parseAssignmentExpression(); + var expr = parseAssignmentExpressionOrHigher(); while (parseOptional(22 /* CommaToken */)) { - expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression()); + expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpressionOrHigher()); } return expr; } @@ -3581,9 +4727,9 @@ var ts; } } parseExpected(51 /* EqualsToken */); - return parseAssignmentExpression(); + return parseAssignmentExpressionOrHigher(); } - function parseAssignmentExpression() { + function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { return parseYieldExpression(); } @@ -3591,16 +4737,16 @@ var ts; if (arrowExpression) { return arrowExpression; } - var expr = parseConditionalExpression(); + var expr = parseBinaryExpressionOrHigher(0); if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } - if (isLeftHandSideExpression(expr) && isAssignmentOperator(token)) { + if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { var operator = token; nextToken(); - return makeBinaryExpression(expr, operator, parseAssignmentExpression()); + return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher()); } - return expr; + return parseConditionalExpressionRest(expr); } function isYieldExpression() { if (token === 108 /* YieldKeyword */) { @@ -3610,19 +4756,20 @@ var ts; if (inStrictModeContext()) { return true; } - return lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - }); + return lookAhead(nextTokenIsIdentifierOnSameLine); } return false; } + function nextTokenIsIdentifierOnSameLine() { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + } function parseYieldExpression() { var node = createNode(160 /* YieldExpression */); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 34 /* AsteriskToken */ || isStartOfExpression())) { node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - node.expression = parseAssignmentExpression(); + node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } else { @@ -3631,131 +4778,138 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - parseExpected(31 /* EqualsGreaterThanToken */); + var node = createNode(151 /* ArrowFunction */, identifier.pos); var parameter = createNode(123 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); - var parameters = []; - parameters.push(parameter); - parameters.pos = parameter.pos; - parameters.end = parameter.end; - var signature = { parameters: parameters }; - return parseArrowExpressionTail(identifier.pos, signature); + node.parameters = [parameter]; + node.parameters.pos = parameter.pos; + node.parameters.end = parameter.end; + parseExpected(31 /* EqualsGreaterThanToken */); + node.body = parseArrowFunctionExpressionBody(); + return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { var triState = isParenthesizedArrowFunctionExpression(); if (triState === 0 /* False */) { return undefined; } - var pos = getNodePos(); - if (triState === 1 /* True */) { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { - return parseArrowExpressionTail(pos, sig); - } - else { - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, createMissingNode()); - } - } - var sig = tryParseSignatureIfArrowOrBraceFollows(); - if (sig) { - parseExpected(31 /* EqualsGreaterThanToken */); - return parseArrowExpressionTail(pos, sig); - } - else { + var arrowFunction = triState === 1 /* True */ ? parseParenthesizedArrowFunctionExpressionHead(true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); + if (!arrowFunction) { return undefined; } + if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { + arrowFunction.body = parseArrowFunctionExpressionBody(); + } + else { + arrowFunction.body = parseIdentifier(); + } + return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - return lookAhead(function () { - var first = token; - var second = nextToken(); - if (first === 15 /* OpenParenToken */) { - if (second === 16 /* CloseParenToken */) { - var third = nextToken(); - switch (third) { - case 31 /* EqualsGreaterThanToken */: - case 50 /* ColonToken */: - case 13 /* OpenBraceToken */: - return 1 /* True */; - default: - return 0 /* False */; - } - } - if (second === 20 /* DotDotDotToken */) { - return 1 /* True */; - } - if (!isIdentifier()) { - return 0 /* False */; - } - if (nextToken() === 50 /* ColonToken */) { - return 1 /* True */; - } - return 2 /* Unknown */; - } - else { - ts.Debug.assert(first === 23 /* LessThanToken */); - if (!isIdentifier()) { - return 0 /* False */; - } - return 2 /* Unknown */; - } - }); + return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token === 31 /* EqualsGreaterThanToken */) { return 1 /* True */; } return 0 /* False */; } - function tryParseSignatureIfArrowOrBraceFollows() { - return tryParse(function () { - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false); - if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) { - return sig; + function isParenthesizedArrowFunctionExpressionWorker() { + var first = token; + var second = nextToken(); + if (first === 15 /* OpenParenToken */) { + if (second === 16 /* CloseParenToken */) { + var third = nextToken(); + switch (third) { + case 31 /* EqualsGreaterThanToken */: + case 50 /* ColonToken */: + case 13 /* OpenBraceToken */: + return 1 /* True */; + default: + return 0 /* False */; + } } - return undefined; - }); - } - function parseArrowExpressionTail(pos, sig) { - var body; - if (token === 13 /* OpenBraceToken */) { - body = parseFunctionBlock(false, false); - } - else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { - body = parseFunctionBlock(false, true); + if (second === 20 /* DotDotDotToken */) { + return 1 /* True */; + } + if (!isIdentifier()) { + return 0 /* False */; + } + if (nextToken() === 50 /* ColonToken */) { + return 1 /* True */; + } + return 2 /* Unknown */; } else { - body = parseAssignmentExpression(); + ts.Debug.assert(first === 23 /* LessThanToken */); + if (!isIdentifier()) { + return 0 /* False */; + } + return 2 /* Unknown */; } - return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, body); } - function parseConditionalExpression() { - var expr = parseBinaryOperators(parseUnaryExpression(), 0); - while (parseOptional(49 /* QuestionToken */)) { - var node = createNode(157 /* ConditionalExpression */, expr.pos); - node.condition = expr; - node.whenTrue = allowInAnd(parseAssignmentExpression); - parseExpected(50 /* ColonToken */); - node.whenFalse = parseAssignmentExpression(); - expr = finishNode(node); + function parsePossibleParenthesizedArrowFunctionExpressionHead() { + return parseParenthesizedArrowFunctionExpressionHead(false); + } + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { + var node = createNode(151 /* ArrowFunction */); + fillSignature(50 /* ColonToken */, false, !allowAmbiguity, node); + if (!node.parameters) { + return undefined; } - return expr; + if (!allowAmbiguity && token !== 31 /* EqualsGreaterThanToken */ && token !== 13 /* OpenBraceToken */) { + return undefined; + } + return node; } - function parseBinaryOperators(expr, minPrecedence) { + function parseArrowFunctionExpressionBody() { + if (token === 13 /* OpenBraceToken */) { + return parseFunctionBlock(false, false); + } + if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { + return parseFunctionBlock(false, true); + } + return parseAssignmentExpressionOrHigher(); + } + function parseConditionalExpressionRest(leftOperand) { + if (!parseOptional(49 /* QuestionToken */)) { + return leftOperand; + } + var node = createNode(158 /* ConditionalExpression */, leftOperand.pos); + node.condition = leftOperand; + node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(50 /* ColonToken */); + node.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); + } + function parseBinaryExpressionOrHigher(precedence) { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); - var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== 84 /* InKeyword */)) { - var operator = token; - nextToken(); - expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence)); - continue; + var newPrecedence = getBinaryOperatorPrecedence(); + if (newPrecedence <= precedence) { + break; } - return expr; + if (token === 84 /* InKeyword */ && inDisallowInContext()) { + break; + } + var operator = token; + nextToken(); + leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence)); } + return leftOperand; } - function getOperatorPrecedence() { + function isBinaryOperator() { + if (inDisallowInContext() && token === 84 /* InKeyword */) { + return false; + } + return getBinaryOperatorPrecedence() > 0; + } + function getBinaryOperatorPrecedence() { switch (token) { case 48 /* BarBarToken */: return 1; @@ -3791,137 +4945,200 @@ var ts; case 36 /* PercentToken */: return 10; } - return undefined; + return -1; } function makeBinaryExpression(left, operator, right) { - var node = createNode(156 /* BinaryExpression */, left.pos); + var node = createNode(157 /* BinaryExpression */, left.pos); node.left = left; node.operator = operator; node.right = right; return finishNode(node); } - function parseUnaryExpression() { - var pos = getNodePos(); + function parsePrefixUnaryExpression() { + var node = createNode(155 /* PrefixUnaryExpression */); + node.operator = token; + nextToken(); + node.operand = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseDeleteExpression() { + var node = createNode(152 /* DeleteExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseTypeOfExpression() { + var node = createNode(153 /* TypeOfExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(154 /* VoidExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function parseUnaryExpressionOrHigher() { switch (token) { case 32 /* PlusToken */: case 33 /* MinusToken */: case 46 /* TildeToken */: case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: - case 95 /* TypeOfKeyword */: - case 97 /* VoidKeyword */: case 37 /* PlusPlusToken */: case 38 /* MinusMinusToken */: - var operator = token; - nextToken(); - return makeUnaryExpression(154 /* PrefixOperator */, pos, operator, parseUnaryExpression()); + return parsePrefixUnaryExpression(); + case 72 /* DeleteKeyword */: + return parseDeleteExpression(); + case 95 /* TypeOfKeyword */: + return parseTypeOfExpression(); + case 97 /* VoidKeyword */: + return parseVoidExpression(); case 23 /* LessThanToken */: return parseTypeAssertion(); + default: + return parsePostfixExpressionOrHigher(); } - var primaryExpression = parsePrimaryExpression(); - var illegalUsageOfSuperKeyword = primaryExpression.kind === 89 /* SuperKeyword */ && token !== 15 /* OpenParenToken */ && token !== 19 /* DotToken */; - if (illegalUsageOfSuperKeyword) { - error(ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - } - var expr = parseCallAndAccess(primaryExpression, false); - ts.Debug.assert(isLeftHandSideExpression(expr)); + } + function parsePostfixExpressionOrHigher() { + var expression = parseLeftHandSideExpressionOrHigher(); + ts.Debug.assert(isLeftHandSideExpression(expression)); if ((token === 37 /* PlusPlusToken */ || token === 38 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var operator = token; + var node = createNode(156 /* PostfixUnaryExpression */, expression.pos); + node.operand = expression; + node.operator = token; nextToken(); - expr = makeUnaryExpression(155 /* PostfixOperator */, expr.pos, operator, expr); + return finishNode(node); } - return expr; + return expression; + } + function parseLeftHandSideExpressionOrHigher() { + var expression = token === 89 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + return parseCallExpressionRest(expression); + } + function parseMemberExpressionOrHigher() { + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + function parseSuperExpression() { + var expression = parseTokenNode(); + if (token === 15 /* OpenParenToken */ || token === 19 /* DotToken */) { + return expression; + } + var node = createNode(143 /* PropertyAccessExpression */, expression.pos); + node.expression = expression; + parseExpected(19 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(true); + return finishNode(node); } function parseTypeAssertion() { - var node = createNode(150 /* TypeAssertion */); + var node = createNode(148 /* TypeAssertionExpression */); parseExpected(23 /* LessThanToken */); node.type = parseType(); parseExpected(24 /* GreaterThanToken */); - node.operand = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function makeUnaryExpression(kind, pos, operator, operand) { - var node = createNode(kind, pos); - node.operator = operator; - node.operand = operand; - return finishNode(node); - } - function parseCallAndAccess(expr, inNewExpression) { + function parseMemberExpressionRest(expression) { while (true) { var dotOrBracketStart = scanner.getTokenPos(); if (parseOptional(19 /* DotToken */)) { - var propertyAccess = createNode(145 /* PropertyAccess */, expr.pos); - var id; - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { - var matchesPattern = lookAhead(function () { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (scanner.isIdentifier() || scanner.isReservedWord); - }); - if (matchesPattern) { - errorAtPos(dotOrBracketStart + 1, 0, ts.Diagnostics.Identifier_expected); - id = createMissingNode(); - } - } - propertyAccess.left = expr; - propertyAccess.right = id || parseIdentifierName(); - expr = finishNode(propertyAccess); + var propertyAccess = createNode(143 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); continue; } if (parseOptional(17 /* OpenBracketToken */)) { - var indexedAccess = createNode(146 /* IndexedAccess */, expr.pos); - indexedAccess.object = expr; - if (inNewExpression && parseOptional(18 /* CloseBracketToken */)) { - indexedAccess.index = createMissingNode(); - } - else { - indexedAccess.index = allowInAnd(parseExpression); - if (indexedAccess.index.kind === 7 /* StringLiteral */ || indexedAccess.index.kind === 6 /* NumericLiteral */) { - var literal = indexedAccess.index; + var indexedAccess = createNode(144 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + if (token !== 18 /* CloseBracketToken */) { + indexedAccess.argumentExpression = allowInAnd(parseExpression); + if (indexedAccess.argumentExpression.kind === 7 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 6 /* NumericLiteral */) { + var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } - parseExpected(18 /* CloseBracketToken */); } - expr = finishNode(indexedAccess); - continue; - } - if ((token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) && !inNewExpression) { - var callExpr = createNode(147 /* CallExpression */, expr.pos); - callExpr.func = expr; - if (token === 23 /* LessThanToken */) { - if (!(callExpr.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) - return expr; - } - else { - parseExpected(15 /* OpenParenToken */); - } - callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); - expr = finishNode(callExpr); + parseExpected(18 /* CloseBracketToken */); + expression = finishNode(indexedAccess); continue; } if (token === 9 /* NoSubstitutionTemplateLiteral */ || token === 10 /* TemplateHead */) { - var tagExpression = createNode(149 /* TaggedTemplateExpression */, expr.pos); - tagExpression.tag = expr; + var tagExpression = createNode(147 /* TaggedTemplateExpression */, expression.pos); + tagExpression.tag = expression; tagExpression.template = token === 9 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); - expr = finishNode(tagExpression); + expression = finishNode(tagExpression); continue; } - return expr; + return expression; } } - function parseTypeArgumentsAndOpenParen() { - var result = parseTypeArguments(); + function parseCallExpressionRest(expression) { + while (true) { + expression = parseMemberExpressionRest(expression); + if (token === 23 /* LessThanToken */) { + var typeArguments = tryParse(parseTypeArgumentsInExpression); + if (!typeArguments) { + return expression; + } + var callExpr = createNode(145 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + else if (token === 15 /* OpenParenToken */) { + var callExpr = createNode(145 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.arguments = parseArgumentList(); + expression = finishNode(callExpr); + continue; + } + return expression; + } + } + function parseArgumentList() { parseExpected(15 /* OpenParenToken */); + var result = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); + parseExpected(16 /* CloseParenToken */); return result; } - function parseTypeArguments() { - return parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 23 /* LessThanToken */, 24 /* GreaterThanToken */); + function parseTypeArgumentsInExpression() { + if (!parseOptional(23 /* LessThanToken */)) { + return undefined; + } + var typeArguments = parseDelimitedList(15 /* TypeArguments */, parseType); + if (!parseExpected(24 /* GreaterThanToken */)) { + return undefined; + } + return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined; } - function parseSingleTypeArgument() { - if (token === 22 /* CommaToken */) { - return createNode(120 /* Missing */); + function canFollowTypeArgumentsInExpression() { + switch (token) { + case 15 /* OpenParenToken */: + case 19 /* DotToken */: + case 16 /* CloseParenToken */: + case 18 /* CloseBracketToken */: + case 50 /* ColonToken */: + case 21 /* SemicolonToken */: + case 22 /* CommaToken */: + case 49 /* QuestionToken */: + case 27 /* EqualsEqualsToken */: + case 29 /* EqualsEqualsEqualsToken */: + case 28 /* ExclamationEqualsToken */: + case 30 /* ExclamationEqualsEqualsToken */: + case 47 /* AmpersandAmpersandToken */: + case 48 /* BarBarToken */: + case 44 /* CaretToken */: + case 42 /* AmpersandToken */: + case 43 /* BarToken */: + case 14 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + return true; + default: + return false; } - return parseType(); } function parsePrimaryExpression() { switch (token) { @@ -3936,11 +5153,11 @@ var ts; case 9 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); case 15 /* OpenParenToken */: - return parseParenExpression(); + return parseParenthesizedExpression(); case 17 /* OpenBracketToken */: - return parseArrayLiteral(); + return parseArrayLiteralExpression(); case 13 /* OpenBraceToken */: - return parseObjectLiteral(); + return parseObjectLiteralExpression(); case 81 /* FunctionKeyword */: return parseFunctionExpression(); case 86 /* NewKeyword */: @@ -3953,23 +5170,18 @@ var ts; break; case 10 /* TemplateHead */: return parseTemplateExpression(); - default: - if (isIdentifier()) { - return parseIdentifier(); - } } - error(ts.Diagnostics.Expression_expected); - return createMissingNode(); + return parseIdentifier(ts.Diagnostics.Expression_expected); } - function parseParenExpression() { - var node = createNode(151 /* ParenExpression */); + function parseParenthesizedExpression() { + var node = createNode(149 /* ParenthesizedExpression */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(16 /* CloseParenToken */); return finishNode(node); } function parseAssignmentExpressionOrOmittedExpression() { - return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpression(); + return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArrayLiteralElement() { return parseAssignmentExpressionOrOmittedExpression(); @@ -3977,8 +5189,8 @@ var ts; function parseArgumentExpression() { return allowInAnd(parseAssignmentExpressionOrOmittedExpression); } - function parseArrayLiteral() { - var node = createNode(141 /* ArrayLiteral */); + function parseArrayLiteralExpression() { + var node = createNode(141 /* ArrayLiteralExpression */); parseExpected(17 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; @@ -3986,92 +5198,70 @@ var ts; parseExpected(18 /* CloseBracketToken */); return finishNode(node); } - function parsePropertyAssignment() { - var nodePos = scanner.getStartPos(); + function parseObjectLiteralElement() { + var fullStart = scanner.getStartPos(); + var initialToken = token; + if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { + var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; + return parseAccessorDeclaration(kind, fullStart, undefined); + } var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var node; if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, asteriskToken, undefined, sig, body); - return finishNode(node); - } - var flags = 0; - if (token === 49 /* QuestionToken */) { - flags |= 4 /* QuestionMark */; - nextToken(); + return parseMethodDeclaration(fullStart, undefined, asteriskToken, propertyName, undefined, true); } + var questionToken = parseOptionalToken(49 /* QuestionToken */); if ((token === 22 /* CommaToken */ || token === 14 /* CloseBraceToken */) && tokenIsIdentifier) { - node = createNode(144 /* ShorthandPropertyAssignment */, nodePos); - node.name = propertyName; + var shorthandDeclaration = createNode(199 /* ShorthandPropertyAssignment */, fullStart); + shorthandDeclaration.name = propertyName; + shorthandDeclaration.questionToken = questionToken; + return finishNode(shorthandDeclaration); } else { - node = createNode(143 /* PropertyAssignment */, nodePos); - node.name = propertyName; + var propertyAssignment = createNode(198 /* PropertyAssignment */, fullStart); + propertyAssignment.name = propertyName; + propertyAssignment.questionToken = questionToken; parseExpected(50 /* ColonToken */); - node.initializer = allowInAnd(parseAssignmentExpression); + propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); + return finishNode(propertyAssignment); } - node.flags = flags; - return finishNode(node); } - function parseObjectLiteralMember() { - var initialPos = getNodePos(); - var initialToken = token; - if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { - var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; - return parseMemberAccessorDeclaration(kind, initialPos, undefined); - } - return parsePropertyAssignment(); - } - function parseObjectLiteral() { - var node = createNode(142 /* ObjectLiteral */); + function parseObjectLiteralExpression() { + var node = createNode(142 /* ObjectLiteralExpression */); parseExpected(13 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } - node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember); + node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralElement); parseExpected(14 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { - var pos = getNodePos(); + var node = createNode(150 /* FunctionExpression */); parseExpected(81 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - var name = asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken); - var body = parseFunctionBlock(!!asteriskToken, false); - return makeFunctionExpression(152 /* FunctionExpression */, pos, asteriskToken, name, sig, body); + node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); + node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); + fillSignature(50 /* ColonToken */, !!node.asteriskToken, false, node); + node.body = parseFunctionBlock(!!node.asteriskToken, false); + return finishNode(node); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } - function makeFunctionExpression(kind, pos, asteriskToken, name, sig, body) { - var node = createNode(kind, pos); - node.asteriskToken = asteriskToken; - node.name = name; - node.typeParameters = sig.typeParameters; - node.parameters = sig.parameters; - node.type = sig.type; - node.body = body; - return finishNode(node); - } function parseNewExpression() { - var node = createNode(148 /* NewExpression */); + var node = createNode(146 /* NewExpression */); parseExpected(86 /* NewKeyword */); - node.func = parseCallAndAccess(parsePrimaryExpression(), true); - if (parseOptional(15 /* OpenParenToken */) || token === 23 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { - node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); + node.expression = parseMemberExpressionOrHigher(); + node.typeArguments = tryParse(parseTypeArgumentsInExpression); + if (node.typeArguments || token === 15 /* OpenParenToken */) { + node.arguments = parseArgumentList(); } return finishNode(node); } - function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) { - var node = createNode(162 /* Block */); + function parseBlock(kind, ignoreMissingOpenBrace, checkForStrictMode) { + var node = createNode(kind); if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); parseExpected(14 /* CloseBraceToken */); @@ -4084,18 +5274,17 @@ var ts; function parseFunctionBlock(allowYield, ignoreMissingOpenBrace) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); - var block = parseBlock(ignoreMissingOpenBrace, true); - block.kind = 187 /* FunctionBlock */; + var block = parseBlock(163 /* Block */, ignoreMissingOpenBrace, true); setYieldContext(savedYieldContext); return block; } function parseEmptyStatement() { - var node = createNode(164 /* EmptyStatement */); + var node = createNode(165 /* EmptyStatement */); parseExpected(21 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(166 /* IfStatement */); + var node = createNode(167 /* IfStatement */); parseExpected(82 /* IfKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4105,7 +5294,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(167 /* DoStatement */); + var node = createNode(168 /* DoStatement */); parseExpected(73 /* DoKeyword */); node.statement = parseStatement(); parseExpected(98 /* WhileKeyword */); @@ -4116,7 +5305,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(168 /* WhileStatement */); + var node = createNode(169 /* WhileStatement */); parseExpected(98 /* WhileKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4144,7 +5333,7 @@ var ts; } var forOrForInStatement; if (parseOptional(84 /* InKeyword */)) { - var forInStatement = createNode(170 /* ForInStatement */, pos); + var forInStatement = createNode(171 /* ForInStatement */, pos); if (declarations) { forInStatement.declarations = declarations; } @@ -4156,7 +5345,7 @@ var ts; forOrForInStatement = forInStatement; } else { - var forStatement = createNode(169 /* ForStatement */, pos); + var forStatement = createNode(170 /* ForStatement */, pos); if (declarations) { forStatement.declarations = declarations; } @@ -4179,7 +5368,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); + parseExpected(kind === 173 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -4187,7 +5376,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(173 /* ReturnStatement */); + var node = createNode(174 /* ReturnStatement */); parseExpected(88 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -4196,7 +5385,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(174 /* WithStatement */); + var node = createNode(175 /* WithStatement */); parseExpected(99 /* WithKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4205,7 +5394,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(176 /* CaseClause */); + var node = createNode(194 /* CaseClause */); parseExpected(65 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(50 /* ColonToken */); @@ -4213,7 +5402,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(177 /* DefaultClause */); + var node = createNode(195 /* DefaultClause */); parseExpected(71 /* DefaultKeyword */); parseExpected(50 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); @@ -4223,7 +5412,7 @@ var ts; return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(175 /* SwitchStatement */); + var node = createNode(176 /* SwitchStatement */); parseExpected(90 /* SwitchKeyword */); parseExpected(15 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -4234,69 +5423,57 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(179 /* ThrowStatement */); + var node = createNode(178 /* ThrowStatement */); parseExpected(92 /* ThrowKeyword */); - if (scanner.hasPrecedingLineBreak()) { - error(ts.Diagnostics.Line_break_not_permitted_here); - } - node.expression = allowInAnd(parseExpression); + node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(180 /* TryStatement */); - node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 181 /* TryBlock */); - if (token === 66 /* CatchKeyword */) { - node.catchBlock = parseCatchBlock(); - } - if (token === 79 /* FinallyKeyword */) { - node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 183 /* FinallyBlock */); - } - if (!(node.catchBlock || node.finallyBlock)) { - error(ts.Diagnostics.catch_or_finally_expected); - } + var node = createNode(179 /* TryStatement */); + node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */); + node.catchClause = token === 66 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.finallyBlock = !node.catchClause || token === 79 /* FinallyKeyword */ ? parseTokenAndBlock(79 /* FinallyKeyword */) : undefined; return finishNode(node); } - function parseTokenAndBlock(token, kind) { + function parseTokenAndBlock(token) { var pos = getNodePos(); parseExpected(token); - var result = parseBlock(false, false); - result.kind = kind; + var result = parseBlock(token === 94 /* TryKeyword */ ? 180 /* TryBlock */ : 181 /* FinallyBlock */, false, false); result.pos = pos; return result; } - function parseCatchBlock() { - var pos = getNodePos(); + function parseCatchClause() { + var result = createNode(197 /* CatchClause */); parseExpected(66 /* CatchKeyword */); parseExpected(15 /* OpenParenToken */); - var variable = parseIdentifier(); - var typeAnnotation = parseTypeAnnotation(); + result.name = parseIdentifier(); + result.type = parseTypeAnnotation(); parseExpected(16 /* CloseParenToken */); - var result = parseBlock(false, false); - result.kind = 182 /* CatchBlock */; - result.pos = pos; - result.variable = variable; - result.type = typeAnnotation; - return result; + result.block = parseBlock(163 /* Block */, false, false); + return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(184 /* DebuggerStatement */); + var node = createNode(182 /* DebuggerStatement */); parseExpected(70 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } function isLabel() { - return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; }); + return isIdentifier() && lookAhead(nextTokenIsColonToken); + } + function nextTokenIsColonToken() { + return nextToken() === 50 /* ColonToken */; } function parseLabeledStatement() { - var node = createNode(178 /* LabeledStatement */); + var node = createNode(177 /* LabeledStatement */); node.label = parseIdentifier(); parseExpected(50 /* ColonToken */); node.statement = parseStatement(); return finishNode(node); } function parseExpressionStatement() { - var node = createNode(165 /* ExpressionStatement */); + var node = createNode(166 /* ExpressionStatement */); node.expression = allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); @@ -4325,7 +5502,7 @@ var ts; case 79 /* FinallyKeyword */: return true; case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + var isConstEnum = lookAhead(nextTokenIsEnumKeyword); return !isConstEnum; case 101 /* InterfaceKeyword */: case 67 /* ClassKeyword */: @@ -4339,19 +5516,26 @@ var ts; case 104 /* PrivateKeyword */: case 105 /* ProtectedKeyword */: case 107 /* StaticKeyword */: - if (lookAhead(function () { return nextToken() >= 63 /* Identifier */; })) { + if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { return false; } default: return isStartOfExpression(); } } + function nextTokenIsEnumKeyword() { + nextToken(); + return token === 75 /* EnumKeyword */; + } + function nextTokenIsIdentifierOrKeywordOnSameLine() { + nextToken(); + return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + } function parseStatement() { switch (token) { case 13 /* OpenBraceToken */: - return parseBlock(false, false); + return parseBlock(163 /* Block */, false, false); case 96 /* VarKeyword */: - case 102 /* LetKeyword */: case 68 /* ConstKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined); case 81 /* FunctionKeyword */: @@ -4367,9 +5551,9 @@ var ts; case 80 /* ForKeyword */: return parseForOrForInStatement(); case 69 /* ContinueKeyword */: - return parseBreakOrContinueStatement(171 /* ContinueStatement */); + return parseBreakOrContinueStatement(172 /* ContinueStatement */); case 64 /* BreakKeyword */: - return parseBreakOrContinueStatement(172 /* BreakStatement */); + return parseBreakOrContinueStatement(173 /* BreakStatement */); case 88 /* ReturnKeyword */: return parseReturnStatement(); case 99 /* WithKeyword */: @@ -4384,6 +5568,10 @@ var ts; return parseTryStatement(); case 70 /* DebuggerKeyword */: return parseDebuggerStatement(); + case 102 /* LetKeyword */: + if (isLetDeclaration()) { + return parseVariableStatement(scanner.getStartPos(), undefined); + } default: return isLabel() ? parseLabeledStatement() : parseExpressionStatement(); } @@ -4392,14 +5580,11 @@ var ts; if (token === 13 /* OpenBraceToken */) { return parseFunctionBlock(isGenerator, false); } - if (canParseSemicolon()) { - parseSemicolon(); - return undefined; - } - error(ts.Diagnostics.Block_or_expected); + parseSemicolon(ts.Diagnostics.or_expected); + return undefined; } function parseVariableDeclaration() { - var node = createNode(185 /* VariableDeclaration */); + var node = createNode(183 /* VariableDeclaration */); node.name = parseIdentifier(); node.type = parseTypeAnnotation(); node.initializer = parseInitializer(false); @@ -4415,7 +5600,7 @@ var ts; return parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); } function parseVariableStatement(fullStart, modifiers) { - var node = createNode(163 /* VariableStatement */, fullStart); + var node = createNode(164 /* VariableStatement */, fullStart); setModifiers(node, modifiers); if (token === 102 /* LetKeyword */) { node.flags |= 2048 /* Let */; @@ -4433,12 +5618,12 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(186 /* FunctionDeclaration */, fullStart); + var node = createNode(184 /* FunctionDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(81 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); node.name = parseIdentifier(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!node.asteriskToken, node); + fillSignature(50 /* ColonToken */, !!node.asteriskToken, false, node); node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken); return finishNode(node); } @@ -4446,60 +5631,59 @@ var ts; var node = createNode(126 /* Constructor */, pos); setModifiers(node, modifiers); parseExpected(111 /* ConstructorKeyword */); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + fillSignature(50 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } - function parsePropertyMemberDeclaration(fullStart, modifiers) { - var flags = modifiers ? modifiers.flags : 0; + function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, requireBlock) { + var method = createNode(125 /* Method */, fullStart); + setModifiers(method, modifiers); + method.asteriskToken = asteriskToken; + method.name = name; + method.questionToken = questionToken; + fillSignature(50 /* ColonToken */, !!asteriskToken, false, method); + method.body = requireBlock ? parseFunctionBlock(!!asteriskToken, false) : parseFunctionBlockOrSemicolon(!!asteriskToken); + return finishNode(method); + } + function parsePropertyOrMethodDeclaration(fullStart, modifiers) { var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); var name = parsePropertyName(); - if (parseOptional(49 /* QuestionToken */)) { - flags |= 4 /* QuestionMark */; - } + var questionToken = parseOptionalToken(49 /* QuestionToken */); if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - var method = createNode(125 /* Method */, fullStart); - setModifiers(method, modifiers); - if (flags) { - method.flags = flags; - } - method.asteriskToken = asteriskToken; - method.name = name; - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken); - return finishNode(method); + return parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, false); } else { var property = createNode(124 /* Property */, fullStart); setModifiers(property, modifiers); - if (flags) { - property.flags = flags; - } property.name = name; + property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(function () { return parseInitializer(false); }); + property.initializer = allowInAnd(parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } } - function parseMemberAccessorDeclaration(kind, fullStart, modifiers) { + function parseNonParameterInitializer() { + return parseInitializer(false); + } + function parseAccessorDeclaration(kind, fullStart, modifiers) { var node = createNode(kind, fullStart); setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node); + fillSignature(50 /* ColonToken */, false, false, node); node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } function isClassMemberStart() { var idToken; - while (isModifier(token)) { + while (ts.isModifier(token)) { idToken = token; nextToken(); } if (token === 34 /* AsteriskToken */) { return true; } - if (isPropertyName()) { + if (isLiteralPropertyName()) { idToken = token; nextToken(); } @@ -4507,7 +5691,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { return true; } switch (token) { @@ -4527,52 +5711,51 @@ var ts; var flags = 0; var modifiers; while (true) { - var modifierStart = scanner.getTokenPos(); + var modifierStart = scanner.getStartPos(); var modifierKind = token; if (!parseAnyContextualModifier()) { break; } if (!modifiers) { modifiers = []; + modifiers.pos = modifierStart; } flags |= modifierToFlag(modifierKind); modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } if (modifiers) { modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); } return modifiers; } - function parseClassMemberDeclaration() { + function parseClassElement() { var fullStart = getNodePos(); var modifiers = parseModifiers(); if (parseContextualModifier(113 /* GetKeyword */)) { - return parseMemberAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers); + return parseAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers); } if (parseContextualModifier(117 /* SetKeyword */)) { - return parseMemberAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers); + return parseAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers); } if (token === 111 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, modifiers); } - if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */) { - return parsePropertyMemberDeclaration(fullStart, modifiers); + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, modifiers); } - if (token === 17 /* OpenBracketToken */) { - return parseIndexSignatureMember(fullStart, modifiers); + if (isIdentifierOrKeyword() || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */ || token === 17 /* OpenBracketToken */) { + return parsePropertyOrMethodDeclaration(fullStart, modifiers); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(188 /* ClassDeclaration */, fullStart); + var node = createNode(185 /* ClassDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(67 /* ClassKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.baseType = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassBaseType) : parseClassBaseType(); - if (parseOptional(100 /* ImplementsKeyword */)) { - node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } + node.heritageClauses = parseHeritageClauses(true); if (parseExpected(13 /* OpenBraceToken */)) { node.members = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassMembers) : parseClassMembers(); parseExpected(14 /* CloseBraceToken */); @@ -4582,26 +5765,43 @@ var ts; } return finishNode(node); } - function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration); + function parseHeritageClauses(isClassHeritageClause) { + if (isHeritageClause()) { + return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) : parseHeritageClausesWorker(); + } + return undefined; } - function parseClassBaseType() { - return parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined; + function parseHeritageClausesWorker() { + return parseList(17 /* HeritageClauses */, false, parseHeritageClause); + } + function parseHeritageClause() { + if (token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */) { + var node = createNode(196 /* HeritageClause */); + node.token = token; + nextToken(); + node.types = parseDelimitedList(8 /* TypeReferences */, parseTypeReference); + return finishNode(node); + } + return undefined; + } + function isHeritageClause() { + return token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; + } + function parseClassMembers() { + return parseList(6 /* ClassMembers */, false, parseClassElement); } function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(189 /* InterfaceDeclaration */, fullStart); + var node = createNode(186 /* InterfaceDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(101 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - if (parseOptional(77 /* ExtendsKeyword */)) { - node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference); - } - node.members = parseObjectType(); + node.heritageClauses = parseHeritageClauses(false); + node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(190 /* TypeAliasDeclaration */, fullStart); + var node = createNode(187 /* TypeAliasDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(119 /* TypeKeyword */); node.name = parseIdentifier(); @@ -4611,17 +5811,14 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(196 /* EnumMember */, scanner.getStartPos()); + var node = createNode(200 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); - node.initializer = allowInAnd(function () { return parseInitializer(false); }); + node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } - function parseAndCheckEnumDeclaration(fullStart, flags) { - var node = createNode(191 /* EnumDeclaration */, fullStart); - node.flags = flags; - if (flags & 4096 /* Const */) { - parseExpected(68 /* ConstKeyword */); - } + function parseEnumDeclaration(fullStart, modifiers) { + var node = createNode(188 /* EnumDeclaration */, fullStart); + setModifiers(node, modifiers); parseExpected(75 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(13 /* OpenBraceToken */)) { @@ -4633,8 +5830,8 @@ var ts; } return finishNode(node); } - function parseModuleBody() { - var node = createNode(193 /* ModuleBlock */, scanner.getStartPos()); + function parseModuleBlock() { + var node = createNode(190 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(13 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); parseExpected(14 /* CloseBraceToken */); @@ -4644,76 +5841,110 @@ var ts; } return finishNode(node); } - function parseInternalModuleTail(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; + function parseInternalModuleTail(fullStart, modifiers, flags) { + var node = createNode(189 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), 1 /* Export */) : parseModuleBody(); + node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), undefined, 1 /* Export */) : parseModuleBlock(); return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart, flags) { - var node = createNode(192 /* ModuleDeclaration */, fullStart); - node.flags = flags; - node.name = parseStringLiteral(); - node.body = parseModuleBody(); + function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { + var node = createNode(189 /* ModuleDeclaration */, fullStart); + setModifiers(node, modifiers); + node.name = parseLiteralNode(true); + node.body = parseModuleBlock(); return finishNode(node); } - function parseModuleDeclaration(fullStart, flags) { + function parseModuleDeclaration(fullStart, modifiers) { parseExpected(114 /* ModuleKeyword */); - return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, flags) : parseInternalModuleTail(fullStart, flags); + return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); + } + function isExternalModuleReference() { + return token === 115 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); + } + function nextTokenIsOpenParen() { + return nextToken() === 15 /* OpenParenToken */; } function parseImportDeclaration(fullStart, modifiers) { - var node = createNode(194 /* ImportDeclaration */, fullStart); + var node = createNode(191 /* ImportDeclaration */, fullStart); setModifiers(node, modifiers); parseExpected(83 /* ImportKeyword */); node.name = parseIdentifier(); parseExpected(51 /* EqualsToken */); - var entityName = parseEntityName(false); - if (entityName.kind === 63 /* Identifier */ && entityName.text === "require" && parseOptional(15 /* OpenParenToken */)) { - node.externalModuleName = parseStringLiteral(); - parseExpected(16 /* CloseParenToken */); - } - else { - node.entityName = entityName; - } + node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); } + function parseModuleReference() { + return isExternalModuleReference() ? parseExternalModuleReference() : parseEntityName(false); + } + function parseExternalModuleReference() { + var node = createNode(193 /* ExternalModuleReference */); + parseExpected(115 /* RequireKeyword */); + parseExpected(15 /* OpenParenToken */); + node.expression = parseExpression(); + if (node.expression.kind === 7 /* StringLiteral */) { + internIdentifier(node.expression.text); + } + parseExpected(16 /* CloseParenToken */); + return finishNode(node); + } function parseExportAssignmentTail(fullStart, modifiers) { - var node = createNode(195 /* ExportAssignment */, fullStart); + var node = createNode(192 /* ExportAssignment */, fullStart); setModifiers(node, modifiers); node.exportName = parseIdentifier(); parseSemicolon(); return finishNode(node); } + function isLetDeclaration() { + return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOnSameLine); + } function isDeclarationStart() { switch (token) { case 96 /* VarKeyword */: - case 102 /* LetKeyword */: case 68 /* ConstKeyword */: case 81 /* FunctionKeyword */: return true; + case 102 /* LetKeyword */: + return isLetDeclaration(); case 67 /* ClassKeyword */: case 101 /* InterfaceKeyword */: case 75 /* EnumKeyword */: case 83 /* ImportKeyword */: case 119 /* TypeKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */; }); + return lookAhead(nextTokenIsIdentifierOrKeyword); case 114 /* ModuleKeyword */: - return lookAhead(function () { return nextToken() >= 63 /* Identifier */ || token === 7 /* StringLiteral */; }); + return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); case 76 /* ExportKeyword */: - return lookAhead(function () { return nextToken() === 51 /* EqualsToken */ || isDeclarationStart(); }); + return lookAhead(nextTokenIsEqualsTokenOrDeclarationStart); case 112 /* DeclareKeyword */: case 106 /* PublicKeyword */: case 104 /* PrivateKeyword */: case 105 /* ProtectedKeyword */: case 107 /* StaticKeyword */: - return lookAhead(function () { - nextToken(); - return isDeclarationStart(); - }); + return lookAhead(nextTokenIsDeclarationStart); } } + function isIdentifierOrKeyword() { + return token >= 63 /* Identifier */; + } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } + function nextTokenIsIdentifierOrKeywordOrStringLiteral() { + nextToken(); + return isIdentifierOrKeyword() || token === 7 /* StringLiteral */; + } + function nextTokenIsEqualsTokenOrDeclarationStart() { + nextToken(); + return token === 51 /* EqualsToken */ || isDeclarationStart(); + } + function nextTokenIsDeclarationStart() { + nextToken(); + return isDeclarationStart(); + } function parseDeclaration() { var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -4723,50 +5954,28 @@ var ts; return parseExportAssignmentTail(fullStart, modifiers); } } - var flags = modifiers ? modifiers.flags : 0; - var result; switch (token) { case 96 /* VarKeyword */: case 102 /* LetKeyword */: - result = parseVariableStatement(fullStart, modifiers); - break; case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); - if (isConstEnum) { - result = parseAndCheckEnumDeclaration(fullStart, flags | 4096 /* Const */); - } - else { - result = parseVariableStatement(fullStart, modifiers); - } - break; + return parseVariableStatement(fullStart, modifiers); case 81 /* FunctionKeyword */: - result = parseFunctionDeclaration(fullStart, modifiers); - break; + return parseFunctionDeclaration(fullStart, modifiers); case 67 /* ClassKeyword */: - result = parseClassDeclaration(fullStart, modifiers); - break; + return parseClassDeclaration(fullStart, modifiers); case 101 /* InterfaceKeyword */: - result = parseInterfaceDeclaration(fullStart, modifiers); - break; + return parseInterfaceDeclaration(fullStart, modifiers); case 119 /* TypeKeyword */: - result = parseTypeAliasDeclaration(fullStart, modifiers); - break; + return parseTypeAliasDeclaration(fullStart, modifiers); case 75 /* EnumKeyword */: - result = parseAndCheckEnumDeclaration(fullStart, flags); - break; + return parseEnumDeclaration(fullStart, modifiers); case 114 /* ModuleKeyword */: - result = parseModuleDeclaration(fullStart, flags); - break; + return parseModuleDeclaration(fullStart, modifiers); case 83 /* ImportKeyword */: - result = parseImportDeclaration(fullStart, modifiers); - break; + return parseImportDeclaration(fullStart, modifiers); default: - error(ts.Diagnostics.Declaration_expected); + ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); } - if (modifiers) { - result.modifiers = modifiers; - } - return result; } function isSourceElement(inErrorRecovery) { return isDeclarationStart() || isStatement(inErrorRecovery); @@ -4781,24 +5990,30 @@ var ts; return isDeclarationStart() ? parseDeclaration() : parseStatement(); } function processReferenceComments() { + var triviaScanner = ts.createScanner(languageVersion, false, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; - commentRanges = []; - token = scanner.scan(); - for (var i = 0; i < commentRanges.length; i++) { - var range = commentRanges[i]; + while (true) { + var kind = triviaScanner.scan(); + if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { + continue; + } + if (kind !== 2 /* SingleLineCommentTrivia */) { + break; + } + var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos() }; var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = getFileReferenceFromReferencePath(comment, range); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { var fileReference = referencePathMatchResult.fileReference; - file.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnostic = referencePathMatchResult.diagnostic; + sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var diagnosticMessage = referencePathMatchResult.diagnosticMessage; if (fileReference) { referencedFiles.push(fileReference); } - if (diagnostic) { - errorAtPos(range.pos, range.end - range.pos, diagnostic); + if (diagnosticMessage) { + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); } } else { @@ -4806,7 +6021,7 @@ var ts; var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment); if (amdModuleNameMatchResult) { if (amdModuleName) { - errorAtPos(range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments); + sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments)); } amdModuleName = amdModuleNameMatchResult[2]; } @@ -4817,7 +6032,6 @@ var ts; } } } - commentRanges = undefined; return { referencedFiles: referencedFiles, amdDependencies: amdDependencies, @@ -4825,71 +6039,74 @@ var ts; }; } function getExternalModuleIndicator() { - return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 194 /* ImportDeclaration */ && node.externalModuleName || node.kind === 195 /* ExportAssignment */ ? node : undefined; }); + return ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind === 193 /* ExternalModuleReference */ || node.kind === 192 /* ExportAssignment */ ? node : undefined; }); } var syntacticDiagnostics; function getSyntacticDiagnostics() { if (syntacticDiagnostics === undefined) { - if (file.parseDiagnostics.length > 0) { - syntacticDiagnostics = file.parseDiagnostics; + if (sourceFile.parseDiagnostics.length > 0) { + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics); } else { - syntacticDiagnostics = file.grammarDiagnostics; - checkGrammar(sourceText, languageVersion, file); + checkGrammar(sourceText, languageVersion, sourceFile); + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.grammarDiagnostics); } } ts.Debug.assert(syntacticDiagnostics !== undefined); return syntacticDiagnostics; } - scanner = ts.createScanner(languageVersion, true, sourceText, scanError, onComment); var rootNodeFlags = 0; if (ts.fileExtensionIs(filename, ".d.ts")) { rootNodeFlags = 1024 /* DeclarationFile */; } - file = createRootNode(197 /* SourceFile */, 0, sourceText.length, rootNodeFlags); - file.filename = ts.normalizePath(filename); - file.text = sourceText; - file.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; - file.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; - file.getLineStarts = getLineStarts; - file.getSyntacticDiagnostics = getSyntacticDiagnostics; - file.parseDiagnostics = []; - file.grammarDiagnostics = []; - file.semanticDiagnostics = []; + var sourceFile = createRootNode(201 /* SourceFile */, 0, sourceText.length, rootNodeFlags); + sourceFile.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; + sourceFile.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; + sourceFile.getLineStarts = getLineStarts; + sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics; + sourceFile.filename = ts.normalizePath(filename); + sourceFile.text = sourceText; + sourceFile.referenceDiagnostics = []; + sourceFile.parseDiagnostics = []; + sourceFile.grammarDiagnostics = []; + sourceFile.semanticDiagnostics = []; var referenceComments = processReferenceComments(); - file.referencedFiles = referenceComments.referencedFiles; - file.amdDependencies = referenceComments.amdDependencies; - file.amdModuleName = referenceComments.amdModuleName; - file.statements = parseList(0 /* SourceElements */, true, parseSourceElement); - file.externalModuleIndicator = getExternalModuleIndicator(); - file.nodeCount = nodeCount; - file.identifierCount = identifierCount; - file.version = version; - file.isOpen = isOpen; - file.languageVersion = languageVersion; - file.identifiers = identifiers; - return file; + sourceFile.referencedFiles = referenceComments.referencedFiles; + sourceFile.amdDependencies = referenceComments.amdDependencies; + sourceFile.amdModuleName = referenceComments.amdModuleName; + var scanner = ts.createScanner(languageVersion, true, sourceText, scanError); + nextToken(); + sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); + ts.Debug.assert(token === 1 /* EndOfFileToken */); + sourceFile.endOfFileToken = parseTokenNode(); + sourceFile.externalModuleIndicator = getExternalModuleIndicator(); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.version = version; + sourceFile.isOpen = isOpen; + sourceFile.languageVersion = languageVersion; + sourceFile.identifiers = identifiers; + return sourceFile; } ts.createSourceFile = createSourceFile; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 148 /* NewExpression */: - case 147 /* CallExpression */: - case 149 /* TaggedTemplateExpression */: - case 141 /* ArrayLiteral */: - case 151 /* ParenExpression */: - case 142 /* ObjectLiteral */: - case 152 /* FunctionExpression */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 146 /* NewExpression */: + case 145 /* CallExpression */: + case 147 /* TaggedTemplateExpression */: + case 141 /* ArrayLiteralExpression */: + case 149 /* ParenthesizedExpression */: + case 142 /* ObjectLiteralExpression */: + case 150 /* FunctionExpression */: case 63 /* Identifier */: - case 120 /* Missing */: case 8 /* RegularExpressionLiteral */: case 6 /* NumericLiteral */: case 7 /* StringLiteral */: case 9 /* NoSubstitutionTemplateLiteral */: - case 158 /* TemplateExpression */: + case 159 /* TemplateExpression */: case 78 /* FalseKeyword */: case 87 /* NullKeyword */: case 91 /* ThisKeyword */: @@ -4916,7 +6133,7 @@ var ts; parent = node; if (!checkModifiers(node)) { var savedInFunctionBlock = inFunctionBlock; - if (node.kind === 187 /* FunctionBlock */) { + if (ts.isFunctionBlock(node)) { inFunctionBlock = true; } var savedInAmbientContext = inAmbientContext; @@ -4941,67 +6158,80 @@ var ts; } function checkNode(node, nodeKind) { switch (nodeKind) { - case 153 /* ArrowFunction */: + case 151 /* ArrowFunction */: case 129 /* CallSignature */: case 134 /* ConstructorType */: case 130 /* ConstructSignature */: case 133 /* FunctionType */: - return checkAnyParsedSignature(node); - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: + return checkAnySignatureDeclaration(node); + case 173 /* BreakStatement */: + case 172 /* ContinueStatement */: return checkBreakOrContinueStatement(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return checkCallOrNewExpression(node); - case 191 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 156 /* BinaryExpression */: return checkBinaryExpression(node); - case 182 /* CatchBlock */: return checkCatchBlock(node); - case 188 /* ClassDeclaration */: return checkClassDeclaration(node); + case 188 /* EnumDeclaration */: return checkEnumDeclaration(node); + case 157 /* BinaryExpression */: return checkBinaryExpression(node); + case 197 /* CatchClause */: return checkCatchClause(node); + case 185 /* ClassDeclaration */: return checkClassDeclaration(node); + case 121 /* ComputedPropertyName */: return checkComputedPropertyName(node); case 126 /* Constructor */: return checkConstructor(node); - case 195 /* ExportAssignment */: return checkExportAssignment(node); - case 170 /* ForInStatement */: return checkForInStatement(node); - case 169 /* ForStatement */: return checkForStatement(node); - case 186 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 152 /* FunctionExpression */: return checkFunctionExpression(node); + case 152 /* DeleteExpression */: return checkDeleteExpression(node); + case 144 /* ElementAccessExpression */: return checkElementAccessExpression(node); + case 192 /* ExportAssignment */: return checkExportAssignment(node); + case 193 /* ExternalModuleReference */: return checkExternalModuleReference(node); + case 171 /* ForInStatement */: return checkForInStatement(node); + case 170 /* ForStatement */: return checkForStatement(node); + case 184 /* FunctionDeclaration */: return checkFunctionDeclaration(node); + case 150 /* FunctionExpression */: return checkFunctionExpression(node); case 127 /* GetAccessor */: return checkGetAccessor(node); - case 146 /* IndexedAccess */: return checkIndexedAccess(node); + case 196 /* HeritageClause */: return checkHeritageClause(node); case 131 /* IndexSignature */: return checkIndexSignature(node); - case 189 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 178 /* LabeledStatement */: return checkLabeledStatement(node); + case 186 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); + case 177 /* LabeledStatement */: return checkLabeledStatement(node); + case 198 /* PropertyAssignment */: return checkPropertyAssignment(node); case 125 /* Method */: return checkMethod(node); - case 192 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 142 /* ObjectLiteral */: return checkObjectLiteral(node); + case 189 /* ModuleDeclaration */: return checkModuleDeclaration(node); + case 142 /* ObjectLiteralExpression */: return checkObjectLiteralExpression(node); case 6 /* NumericLiteral */: return checkNumericLiteral(node); case 123 /* Parameter */: return checkParameter(node); - case 155 /* PostfixOperator */: return checkPostfixOperator(node); - case 154 /* PrefixOperator */: return checkPrefixOperator(node); + case 156 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); + case 155 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); case 124 /* Property */: return checkProperty(node); - case 143 /* PropertyAssignment */: return checkPropertyAssignment(node); - case 173 /* ReturnStatement */: return checkReturnStatement(node); + case 174 /* ReturnStatement */: return checkReturnStatement(node); case 128 /* SetAccessor */: return checkSetAccessor(node); - case 197 /* SourceFile */: return checkSourceFile(node); - case 144 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); - case 175 /* SwitchStatement */: return checkSwitchStatement(node); - case 149 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); + case 201 /* SourceFile */: return checkSourceFile(node); + case 199 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); + case 176 /* SwitchStatement */: return checkSwitchStatement(node); + case 147 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); + case 178 /* ThrowStatement */: return checkThrowStatement(node); case 138 /* TupleType */: return checkTupleType(node); case 122 /* TypeParameter */: return checkTypeParameter(node); case 132 /* TypeReference */: return checkTypeReference(node); - case 185 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 163 /* VariableStatement */: return checkVariableStatement(node); - case 174 /* WithStatement */: return checkWithStatement(node); + case 183 /* VariableDeclaration */: return checkVariableDeclaration(node); + case 164 /* VariableStatement */: return checkVariableStatement(node); + case 175 /* WithStatement */: return checkWithStatement(node); case 160 /* YieldExpression */: return checkYieldExpression(node); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var start = ts.skipTrivia(sourceText, node.pos); + function scanToken(pos) { + var start = ts.skipTrivia(sourceText, pos); scanner.setTextPos(start); scanner.scan(); - var end = scanner.getTextPos(); - grammarDiagnostics.push(ts.createFileDiagnostic(file, start, end - start, message, arg0, arg1, arg2)); + return start; + } + function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + var start = scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); + return true; + } + function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { + scanToken(node.pos); + grammarDiagnostics.push(ts.createFileDiagnostic(file, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); return true; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var span = getErrorSpanForNode(node); + var span = ts.getErrorSpanForNode(node); var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos; var length = span.end - start; grammarDiagnostics.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); @@ -5017,27 +6247,27 @@ var ts; } function checkForStatementInAmbientContext(node, kind) { switch (kind) { - case 162 /* Block */: - case 164 /* EmptyStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 184 /* DebuggerStatement */: - case 178 /* LabeledStatement */: - case 165 /* ExpressionStatement */: + case 163 /* Block */: + case 165 /* EmptyStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: + case 174 /* ReturnStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 178 /* ThrowStatement */: + case 179 /* TryStatement */: + case 182 /* DebuggerStatement */: + case 177 /* LabeledStatement */: + case 166 /* ExpressionStatement */: return grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } - function checkAnyParsedSignature(node) { + function checkAnySignatureDeclaration(node) { return checkTypeParameterList(node.typeParameters) || checkParameterList(node.parameters); } function checkBinaryExpression(node) { @@ -5051,12 +6281,12 @@ var ts; } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: return true; - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -5064,11 +6294,11 @@ var ts; function checkLabeledStatement(node) { var current = node.parent; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { break; } - if (current.kind === 178 /* LabeledStatement */ && current.label.text === node.label.text) { - return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); + if (current.kind === 177 /* LabeledStatement */ && current.label.text === node.label.text) { + return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceText, node.label)); } current = current.parent; } @@ -5076,21 +6306,21 @@ var ts; function checkBreakOrContinueStatement(node) { var current = node; while (current) { - if (isAnyFunction(current)) { + if (ts.isAnyFunction(current)) { return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 171 /* ContinueStatement */ && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 172 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 175 /* SwitchStatement */: - if (node.kind === 172 /* BreakStatement */ && !node.label) { + case 176 /* SwitchStatement */: + if (node.kind === 173 /* BreakStatement */ && !node.label) { return false; } break; @@ -5103,11 +6333,11 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; + var message = node.kind === 173 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; + var message = node.kind === 173 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } } @@ -5118,7 +6348,7 @@ var ts; return checkForDisallowedTrailingComma(arguments) || checkForOmittedArgument(arguments); } function checkTypeArguments(typeArguments) { - return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments) || checkForMissingTypeArgument(typeArguments); + return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments); } function checkForOmittedArgument(arguments) { if (arguments) { @@ -5130,16 +6360,6 @@ var ts; } } } - function checkForMissingTypeArgument(typeArguments) { - if (typeArguments) { - for (var i = 0, n = typeArguments.length; i < n; i++) { - var arg = typeArguments[i]; - if (arg.kind === 120 /* Missing */) { - return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Type_expected); - } - } - } - } function checkForAtLeastOneTypeArgument(typeArguments) { if (typeArguments && typeArguments.length === 0) { var start = typeArguments.pos - "<".length; @@ -5154,17 +6374,47 @@ var ts; return grammarErrorAtPos(start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkCatchBlock(node) { + function checkCatchClause(node) { if (node.type) { - var colonStart = ts.skipTrivia(sourceText, node.variable.end); + var colonStart = ts.skipTrivia(sourceText, node.name.end); return grammarErrorAtPos(colonStart, ":".length, ts.Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); } - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) { - return reportInvalidUseInStrictMode(node.variable); + if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { + return reportInvalidUseInStrictMode(node.name); } } function checkClassDeclaration(node) { - return checkForDisallowedTrailingComma(node.implementedTypes) || checkForAtLeastOneHeritageClause(node.implementedTypes, "implements"); + return checkClassDeclarationHeritageClauses(node); + } + function checkClassDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + var seenImplementsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 77 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); + } + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 100 /* ImplementsKeyword */); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); + } + seenImplementsClause = true; + } + } + } + return false; } function checkForAtLeastOneHeritageClause(types, listType) { if (types && types.length === 0) { @@ -5172,7 +6422,7 @@ var ts; } } function checkConstructor(node) { - return checkAnyParsedSignature(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); + return checkAnySignatureDeclaration(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); } function checkConstructorTypeParameters(node) { if (node.typeParameters) { @@ -5184,6 +6434,11 @@ var ts; return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); } } + function checkDeleteExpression(node) { + if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 63 /* Identifier */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); + } + } function checkEnumDeclaration(enumDecl) { var enumIsConst = (enumDecl.flags & 4096 /* Const */) !== 0; var hasError = false; @@ -5191,7 +6446,10 @@ var ts; var inConstantEnumMemberSection = true; for (var i = 0, n = enumDecl.members.length; i < n; i++) { var node = enumDecl.members[i]; - if (inAmbientContext) { + if (node.name.kind === 121 /* ComputedPropertyName */) { + hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (inAmbientContext) { if (node.initializer && !isIntegerLiteral(node.initializer)) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; } @@ -5210,7 +6468,7 @@ var ts; function isInteger(literalExpression) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); } - if (expression.kind === 154 /* PrefixOperator */) { + if (expression.kind === 155 /* PrefixUnaryExpression */) { var unaryExpression = expression; if (unaryExpression.operator === 32 /* PlusToken */ || unaryExpression.operator === 33 /* MinusToken */) { expression = unaryExpression.operand; @@ -5226,6 +6484,11 @@ var ts; return grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } } + function checkExternalModuleReference(node) { + if (node.expression.kind !== 7 /* StringLiteral */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.String_literal_expected); + } + } function checkForInStatement(node) { return checkVariableDeclarations(node.declarations) || checkForMoreThanOneDeclaration(node.declarations); } @@ -5238,15 +6501,15 @@ var ts; } } function checkFunctionDeclaration(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); } function checkForGenerator(node) { if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.generators_are_not_currently_supported); + return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_currently_supported); } } function checkFunctionExpression(node) { - return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForGenerator(node); + return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForGenerator(node); } function checkFunctionName(name) { if (name && name.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(name)) { @@ -5254,15 +6517,25 @@ var ts; } } function checkGetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } - function checkIndexedAccess(node) { - if (node.index.kind === 120 /* Missing */ && node.parent.kind === 148 /* NewExpression */ && node.parent.func === node) { - var start = ts.skipTrivia(sourceText, node.parent.pos); - var end = node.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + function checkElementAccessExpression(node) { + if (!node.argumentExpression) { + if (node.parent.kind === 146 /* NewExpression */ && node.parent.expression === node) { + var start = ts.skipTrivia(sourceText, node.expression.end); + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + return grammarErrorAtPos(start, end - start, ts.Diagnostics.Expression_expected); + } } } + function checkHeritageClause(node) { + return checkForDisallowedTrailingComma(node.types) || checkForAtLeastOneHeritageClause(node.types, ts.tokenToString(node.token)); + } function checkIndexSignature(node) { return checkIndexSignatureParameters(node) || checkForIndexSignatureModifiers(node); } @@ -5281,14 +6554,14 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); } } - else if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + else if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); } else if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); @@ -5304,13 +6577,52 @@ var ts; } } function checkInterfaceDeclaration(node) { - return checkForDisallowedTrailingComma(node.baseTypes) || checkForAtLeastOneHeritageClause(node.baseTypes, "extends"); + return checkInterfaceDeclarationHeritageClauses(node); + } + function checkInterfaceDeclarationHeritageClauses(node) { + var seenExtendsClause = false; + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + ts.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses[i]; + if (heritageClause.token === 77 /* ExtendsKeyword */) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); + } + seenExtendsClause = true; + } + else { + ts.Debug.assert(heritageClause.token === 100 /* ImplementsKeyword */); + return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + } + } + return false; } function checkMethod(node) { - return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForGenerator(node); + if (checkAnySignatureDeclaration(node) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node)) { + return true; + } + if (node.parent.kind === 185 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + if (inAmbientContext) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + } + else if (!node.body) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); + } + } + else if (node.parent.kind === 186 /* InterfaceDeclaration */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); + } + else if (node.parent.kind === 136 /* TypeLiteral */) { + return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); + } } function checkForBodyInAmbientContext(body, isConstructor) { - if (inAmbientContext && body && body.kind === 187 /* FunctionBlock */) { + if (inAmbientContext && body && body.kind === 163 /* Block */) { var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; return grammarErrorOnFirstToken(body, diagnostic); } @@ -5324,20 +6636,20 @@ var ts; } } function checkModuleDeclarationStatements(node) { - if (node.name.kind === 63 /* Identifier */ && node.body.kind === 193 /* ModuleBlock */) { + if (node.name.kind === 63 /* Identifier */ && node.body.kind === 190 /* ModuleBlock */) { var statements = node.body.statements; for (var i = 0, n = statements.length; i < n; i++) { var statement = statements[i]; - if (statement.kind === 195 /* ExportAssignment */) { + if (statement.kind === 192 /* ExportAssignment */) { return grammarErrorOnNode(statement, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); } - else if (statement.kind === 194 /* ImportDeclaration */ && statement.externalModuleName) { - return grammarErrorOnNode(statement.externalModuleName, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + else if (ts.isExternalModuleImportDeclaration(statement)) { + return grammarErrorOnNode(ts.getExternalModuleImportDeclarationExpression(statement), ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } } } } - function checkObjectLiteral(node) { + function checkObjectLiteralExpression(node) { var seen = {}; var Property = 1; var GetAccessor = 2; @@ -5346,26 +6658,22 @@ var ts; var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var i = 0, n = node.properties.length; i < n; i++) { var prop = node.properties[i]; - if (prop.kind === 161 /* OmittedExpression */) { + var name = prop.name; + if (prop.kind === 161 /* OmittedExpression */ || name.kind === 121 /* ComputedPropertyName */) { continue; } - var p = prop; - var name = p.name; var currentKind; - if (p.kind === 143 /* PropertyAssignment */) { + if (prop.kind === 198 /* PropertyAssignment */ || prop.kind === 199 /* ShorthandPropertyAssignment */ || prop.kind === 125 /* Method */) { currentKind = Property; } - else if (p.kind === 144 /* ShorthandPropertyAssignment */) { - currentKind = Property; - } - else if (p.kind === 127 /* GetAccessor */) { + else if (prop.kind === 127 /* GetAccessor */) { currentKind = GetAccessor; } - else if (p.kind === 128 /* SetAccessor */) { + else if (prop.kind === 128 /* SetAccessor */) { currentKind = SetAccesor; } else { - ts.Debug.fail("Unexpected syntax kind:" + p.kind); + ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } if (!ts.hasProperty(seen, name.text)) { seen[name.text] = currentKind; @@ -5409,15 +6717,15 @@ var ts; case 124 /* Property */: case 125 /* Method */: case 131 /* IndexSignature */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 195 /* ExportAssignment */: - case 163 /* VariableStatement */: - case 186 /* FunctionDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 194 /* ImportDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 189 /* ModuleDeclaration */: + case 188 /* EnumDeclaration */: + case 192 /* ExportAssignment */: + case 164 /* VariableStatement */: + case 184 /* FunctionDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 191 /* ImportDeclaration */: case 123 /* Parameter */: break; default: @@ -5452,7 +6760,7 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 190 /* ModuleBlock */ || node.parent.kind === 201 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } flags |= modifierToFlag(modifier.kind); @@ -5461,7 +6769,7 @@ var ts; if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) { + else if (node.parent.kind === 190 /* ModuleBlock */ || node.parent.kind === 201 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } else if (node.kind === 123 /* Parameter */) { @@ -5477,7 +6785,7 @@ var ts; else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 123 /* Parameter */) { @@ -5489,13 +6797,13 @@ var ts; if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 123 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (inAmbientContext && node.parent.kind === 193 /* ModuleBlock */) { + else if (inAmbientContext && node.parent.kind === 190 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -5514,10 +6822,10 @@ var ts; return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } } - else if (node.kind === 194 /* ImportDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 191 /* ImportDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 189 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { + else if (node.kind === 186 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } } @@ -5544,20 +6852,20 @@ var ts; var parameterCount = parameters.length; for (var i = 0; i < parameterCount; i++) { var parameter = parameters[i]; - if (parameter.flags & 8 /* Rest */) { + if (parameter.dotDotDotToken) { if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_be_optional); + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); } if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.flags & 4 /* QuestionMark */ || parameter.initializer) { + else if (parameter.questionToken || parameter.initializer) { seenOptionalParameter = true; - if (parameter.flags & 4 /* QuestionMark */ && parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -5568,23 +6876,49 @@ var ts; } } } - function checkPostfixOperator(node) { + function checkPostfixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } } - function checkPrefixOperator(node) { + function checkPrefixUnaryExpression(node) { if (node.parserContextFlags & 1 /* StrictMode */) { if ((node.operator === 37 /* PlusPlusToken */ || node.operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } - else if (node.operator === 72 /* DeleteKeyword */ && node.operand.kind === 63 /* Identifier */) { - return grammarErrorOnNode(node.operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } } } function checkProperty(node) { - return (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node); + if (node.parent.kind === 185 /* ClassDeclaration */) { + if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { + return true; + } + } + else if (node.parent.kind === 186 /* InterfaceDeclaration */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { + return true; + } + } + else if (node.parent.kind === 136 /* TypeLiteral */) { + if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { + return true; + } + } + return checkForInitializerInAmbientContext(node); + } + function checkComputedPropertyName(node) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_not_currently_supported); + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + else if (node.expression.kind === 157 /* BinaryExpression */ && node.expression.operator === 22 /* CommaToken */) { + return grammarErrorOnNode(node.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function checkForDisallowedComputedProperty(node, message) { + if (node.kind === 121 /* ComputedPropertyName */) { + return grammarErrorOnNode(node, message); + } } function checkForInitializerInAmbientContext(node) { if (inAmbientContext && node.initializer) { @@ -5592,12 +6926,11 @@ var ts; } } function checkPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } - function checkForInvalidQuestionMark(node, message) { - if (node.flags & 4 /* QuestionMark */) { - var pos = ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(pos, "?".length, message); + function checkForInvalidQuestionMark(node, questionToken, message) { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); } } function checkReturnStatement(node) { @@ -5606,7 +6939,7 @@ var ts; } } function checkSetAccessor(node) { - return checkAnyParsedSignature(node) || checkAccessor(node); + return checkAnySignatureDeclaration(node) || checkAccessor(node); } function checkAccessor(accessor) { var kind = accessor.kind; @@ -5634,14 +6967,14 @@ var ts; } else { var parameter = accessor.parameters[0]; - if (parameter.flags & 8 /* Rest */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } else if (parameter.flags & 243 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - else if (parameter.flags & 4 /* QuestionMark */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); } else if (parameter.initializer) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); @@ -5655,7 +6988,7 @@ var ts; function checkTopLevelElementsForRequiredDeclareModifier(file) { for (var i = 0, n = file.statements.length; i < n; i++) { var decl = file.statements[i]; - if (isDeclaration(decl) || decl.kind === 163 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 164 /* VariableStatement */) { if (checkTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -5663,19 +6996,19 @@ var ts; } } function checkTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 194 /* ImportDeclaration */ || node.kind === 195 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { + if (node.kind === 186 /* InterfaceDeclaration */ || node.kind === 191 /* ImportDeclaration */ || node.kind === 192 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); } function checkShorthandPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); } function checkSwitchStatement(node) { var firstDefaultClause; for (var i = 0, n = node.clauses.length; i < n; i++) { var clause = node.clauses[i]; - if (clause.kind === 177 /* DefaultClause */) { + if (clause.kind === 195 /* DefaultClause */) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -5692,6 +7025,11 @@ var ts; return grammarErrorOnFirstToken(node.template, ts.Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); } } + function checkThrowStatement(node) { + if (node.expression === undefined) { + return grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); + } + } function checkTupleType(node) { return checkForDisallowedTrailingComma(node.elementTypes) || checkForAtLeastOneType(node); } @@ -5713,7 +7051,7 @@ var ts; var equalsPos = node.type ? ts.skipTrivia(sourceText, node.type.end) : ts.skipTrivia(sourceText, node.name.end); return grammarErrorAtPos(equalsPos, "=".length, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!inAmbientContext && !node.initializer && isConst(node)) { + if (!inAmbientContext && !node.initializer && ts.isConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { @@ -5730,10 +7068,10 @@ var ts; } var decl = declarations[0]; if (languageVersion < 2 /* ES6 */) { - if (isLet(decl)) { + if (ts.isLet(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } - else if (isConst(decl)) { + else if (ts.isConst(decl)) { return grammarErrorOnFirstToken(decl, ts.Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } } @@ -5744,24 +7082,24 @@ var ts; } function checkForDisallowedLetOrConstStatement(node) { if (!allowLetAndConstDeclarations(node.parent)) { - if (isLet(node)) { + if (ts.isLet(node)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (isConst(node)) { + else if (ts.isConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 174 /* WithStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 175 /* WithStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: return false; - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -5787,7 +7125,7 @@ var ts; var commonSourceDirectory; ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); if (!seenNoDefaultLib) { - processRootFile(host.getDefaultLibFilename(), true); + processRootFile(host.getDefaultLibFilename(options), true); } verifyCompilerOptions(); errors.sort(ts.compareDiagnostics); @@ -5825,7 +7163,7 @@ var ts; } var diagnostic; if (hasExtension(filename)) { - if (!ts.fileExtensionIs(filename, ".ts")) { + if (!options.allowNonTsExtensions && !ts.fileExtensionIs(filename, ".ts")) { diagnostic = ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts; } else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { @@ -5903,8 +7241,8 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchPath = basePath; @@ -5921,10 +7259,10 @@ var ts; } } } - else if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { + else if (node.kind === 189 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { forEachChild(node.body, function (node) { - if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) { - var nameLiteral = node.externalModuleName; + if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { + var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); var moduleName = nameLiteral.text; if (moduleName) { var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); @@ -5951,9 +7289,9 @@ var ts; } return; } - var firstExternalModule = ts.forEach(files, function (f) { return isExternalModule(f) ? f : undefined; }); + var firstExternalModule = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (firstExternalModule && options.module === 0 /* None */) { - var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator); + var externalModuleErrorSpan = ts.getErrorSpanForNode(firstExternalModule.externalModuleIndicator); var errorStart = ts.skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos); var errorLength = externalModuleErrorSpan.end - errorStart; errors.push(ts.createFileDiagnostic(firstExternalModule, errorStart, errorLength, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); @@ -5995,17 +7333,23 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 186 /* InterfaceDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if (node.kind === 194 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { + else if (node.kind === 191 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 193 /* ModuleBlock */) { + else if (node.kind === 190 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -6021,7 +7365,7 @@ var ts; }); return state; } - else if (node.kind === 192 /* ModuleDeclaration */) { + else if (node.kind === 189 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -6029,6 +7373,10 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + function hasComputedNameButNotSymbol(declaration) { + return declaration.name && declaration.name.kind === 121 /* ComputedPropertyName */; + } + ts.hasComputedNameButNotSymbol = hasComputedNameButNotSymbol; function bindSourceFile(file) { var parent; var container; @@ -6061,9 +7409,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 189 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { return '"' + node.name.text + '"'; } + ts.Debug.assert(!hasComputedNameButNotSymbol(node)); return node.name.text; } switch (node.kind) { @@ -6083,6 +7432,9 @@ var ts; return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); } function declareSymbol(symbols, parent, node, includes, excludes) { + if (hasComputedNameButNotSymbol(node)) { + return undefined; + } var name = getDeclarationName(node); if (name !== undefined) { var symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); @@ -6103,7 +7455,7 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if (node.kind === 188 /* ClassDeclaration */ && symbol.exports) { + if (node.kind === 185 /* ClassDeclaration */ && symbol.exports) { var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { @@ -6135,7 +7487,7 @@ var ts; if (symbolKind & 1536 /* Namespace */) { exportKind |= 16777216 /* ExportNamespace */; } - if (node.flags & 1 /* Export */ || (node.kind !== 194 /* ImportDeclaration */ && isAmbientContext(container))) { + if (node.flags & 1 /* Export */ || (node.kind !== 191 /* ImportDeclaration */ && isAmbientContext(container))) { if (exportKind) { var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); @@ -6176,10 +7528,10 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; @@ -6193,22 +7545,22 @@ var ts; case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } case 136 /* TypeLiteral */: - case 142 /* ObjectLiteral */: - case 189 /* InterfaceDeclaration */: + case 142 /* ObjectLiteralExpression */: + case 186 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } @@ -6258,7 +7610,7 @@ var ts; bindChildren(node, symbolKind, isBlockScopeContainer); } function bindCatchVariableDeclaration(node) { - var symbol = createSymbol(1 /* FunctionScopedVariable */, node.variable.text || "__missing"); + var symbol = createSymbol(1 /* FunctionScopedVariable */, node.name.text || "__missing"); addDeclarationToSymbol(symbol, node, 1 /* FunctionScopedVariable */); var saveParent = parent; var savedBlockScopeContainer = blockScopeContainer; @@ -6269,10 +7621,10 @@ var ts; } function bindBlockScopedVariableDeclaration(node) { switch (blockScopeContainer.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; @@ -6294,7 +7646,7 @@ var ts; case 123 /* Parameter */: bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); break; - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: if (node.flags & 6144 /* BlockScoped */) { bindBlockScopedVariableDeclaration(node); } @@ -6303,11 +7655,11 @@ var ts; } break; case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 196 /* EnumMember */: + case 200 /* EnumMember */: bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; case 129 /* CallSignature */: @@ -6317,12 +7669,12 @@ var ts; bindDeclaration(node, 262144 /* ConstructSignature */, 0, true); break; case 125 /* Method */: - bindDeclaration(node, 8192 /* Method */, 99263 /* MethodExcludes */, true); + bindDeclaration(node, 8192 /* Method */, ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */, true); break; case 131 /* IndexSignature */: bindDeclaration(node, 524288 /* IndexSignature */, 0, false); break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; case 126 /* Constructor */: @@ -6341,26 +7693,26 @@ var ts; case 136 /* TypeLiteral */: bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 142 /* ObjectLiteral */: + case 142 /* ObjectLiteralExpression */: bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 182 /* CatchBlock */: + case 197 /* CatchClause */: bindCatchVariableDeclaration(node); break; - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false); break; - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false); break; - case 190 /* TypeAliasDeclaration */: + case 187 /* TypeAliasDeclaration */: bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: if (ts.isConst(node)) { bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false); } @@ -6368,24 +7720,24 @@ var ts; bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false); } break; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false); break; - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (ts.isExternalModule(node)) { bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); break; } - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 175 /* SwitchStatement */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 176 /* SwitchStatement */: bindChildren(node, 0, true); break; default: @@ -6580,19 +7932,33 @@ var ts; var firstAccessor; var getAccessor; var setAccessor; - ts.forEach(node.members, function (member) { - if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 127 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 128 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } + if (accessor.name.kind === 121 /* ComputedPropertyName */) { + firstAccessor = accessor; + if (accessor.kind === 127 /* GetAccessor */) { + getAccessor = accessor; } - }); + else if (accessor.kind === 128 /* SetAccessor */) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(node.members, function (member) { + if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if (!firstAccessor) { + firstAccessor = member; + } + if (member.kind === 127 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 128 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + }); + } return { firstAccessor: firstAccessor, getAccessor: getAccessor, @@ -6694,14 +8060,14 @@ var ts; function trackSymbol(symbol, enclosingDeclaration, meaning) { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } - function writeTypeAtLocation(location, type, getSymbolAccessibilityDiagnostic) { + function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); if (type) { emitType(type); } else { - resolver.writeTypeAtLocation(location, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); } } function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { @@ -6739,7 +8105,7 @@ var ts; emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); } } - function emitTypeWithNewGetSymbolAccessibilityDiangostic(type, getSymbolAccessibilityDiagnostic) { + function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; emitType(type); } @@ -6762,7 +8128,7 @@ var ts; return emitTupleType(type); case 139 /* UnionType */: return emitUnionType(type); - case 140 /* ParenType */: + case 140 /* ParenthesizedType */: return emitParenType(type); case 133 /* FunctionType */: case 134 /* ConstructorType */: @@ -6771,13 +8137,13 @@ var ts; return emitTypeLiteral(type); case 63 /* Identifier */: return emitEntityName(type); - case 121 /* QualifiedName */: + case 120 /* QualifiedName */: return emitEntityName(type); default: ts.Debug.fail("Unknown type annotation: " + type.kind); } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 194 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 191 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); function writeEntityName(entityName) { @@ -6848,7 +8214,7 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.kind !== 189 /* InterfaceDeclaration */) { + if (node.kind !== 186 /* InterfaceDeclaration */) { write("declare "); } } @@ -6884,13 +8250,13 @@ var ts; write("import "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - if (node.entityName) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.entityName, getImportEntityNameVisibilityError); + if (ts.isInternalModuleImportDeclaration(node)) { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); write(";"); } else { write("require("); - writeTextOfNode(currentSourceFile, node.externalModuleName); + writeTextOfNode(currentSourceFile, ts.getExternalModuleImportDeclarationExpression(node)); write(");"); } writer.writeLine(); @@ -6908,7 +8274,7 @@ var ts; emitModuleElementDeclarationFlags(node); write("module "); writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 193 /* ModuleBlock */) { + while (node.body.kind !== 190 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -6932,7 +8298,7 @@ var ts; write("type "); writeTextOfNode(currentSourceFile, node.name); write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.type, getTypeAliasDeclarationVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); } @@ -6986,16 +8352,16 @@ var ts; emitType(node.constraint); } else { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node.constraint, getTypeParameterConstraintVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 130 /* ConstructSignature */: @@ -7008,14 +8374,14 @@ var ts; if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7040,10 +8406,10 @@ var ts; emitCommaList(typeReferences, emitTypeOfTypeReference); } function emitTypeOfTypeReference(node) { - emitTypeWithNewGetSymbolAccessibilityDiangostic(node, getHeritageClauseVisibilityError); + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.kind === 188 /* ClassDeclaration */) { + if (node.parent.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } else { @@ -7052,7 +8418,7 @@ var ts; return { diagnosticMessage: diagnosticMessage, errorNode: node, - typeName: node.parent.name + typeName: node.parent.parent.name }; } } @@ -7075,10 +8441,11 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - if (node.baseType) { - emitHeritageClause([node.baseType], false); + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], false); } - emitHeritageClause(node.implementedTypes, true); + emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); write(" {"); writeLine(); increaseIndent(); @@ -7099,7 +8466,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(node.baseTypes, false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); write(" {"); writeLine(); increaseIndent(); @@ -7118,28 +8485,28 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 185 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 183 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { writeTextOfNode(currentSourceFile, node.name); - if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + if (node.kind === 124 /* Property */ && ts.hasQuestionToken(node)) { write("?"); } if (node.kind === 124 /* Property */ && node.parent.kind === 136 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getVariableDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 185 /* VariableDeclaration */) { + if (node.kind === 183 /* VariableDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } else if (node.kind === 124 /* Property */) { if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { @@ -7195,7 +8562,7 @@ var ts; accessorWithTypeAnnotation = anotherAccessor; } } - writeTypeAtLocation(node, type, getAccessorDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); } write(";"); writeLine(); @@ -7236,15 +8603,15 @@ var ts; } } function emitFunctionDeclaration(node) { - if ((node.kind !== 186 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + if ((node.kind !== 184 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 184 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 125 /* Method */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 184 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } @@ -7253,7 +8620,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, node.name); - if (node.flags & 4 /* QuestionMark */) { + if (ts.hasQuestionToken(node)) { write("?"); } } @@ -7315,14 +8682,14 @@ var ts; if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: @@ -7337,11 +8704,11 @@ var ts; function emitParameterDeclaration(node) { increaseIndent(); emitJsDocComments(node); - if (node.flags & 8 /* Rest */) { + if (node.dotDotDotToken) { write("..."); } writeTextOfNode(currentSourceFile, node.name); - if (node.initializer || (node.flags & 4 /* QuestionMark */)) { + if (node.initializer || ts.hasQuestionToken(node)) { write("?"); } decreaseIndent(); @@ -7349,7 +8716,7 @@ var ts; emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { - writeTypeAtLocation(node, node.type, getParameterDeclarationTypeVisibilityError); + writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; @@ -7367,14 +8734,14 @@ var ts; if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 188 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 185 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -7390,7 +8757,7 @@ var ts; function emitNode(node) { switch (node.kind) { case 126 /* Constructor */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: return emitFunctionDeclaration(node); case 130 /* ConstructSignature */: @@ -7400,27 +8767,27 @@ var ts; case 127 /* GetAccessor */: case 128 /* SetAccessor */: return emitAccessorDeclaration(node); - case 163 /* VariableStatement */: + case 164 /* VariableStatement */: return emitVariableStatement(node); case 124 /* Property */: return emitPropertyDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return emitClassDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 187 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 196 /* EnumMember */: + case 200 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: return emitImportDeclaration(node); - case 195 /* ExportAssignment */: + case 192 /* ExportAssignment */: return emitExportAssignment(node); - case 197 /* SourceFile */: + case 201 /* SourceFile */: return emitSourceFile(node); } } @@ -7647,7 +9014,7 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */) { + else if (node.kind === 184 /* FunctionDeclaration */ || node.kind === 150 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 189 /* ModuleDeclaration */ || node.kind === 185 /* ClassDeclaration */ || node.kind === 188 /* EnumDeclaration */) { if (node.name) { scopeName = node.name.text; } @@ -7729,7 +9096,7 @@ var ts; } function emitNodeWithMap(node) { if (node) { - if (node.kind != 197 /* SourceFile */) { + if (node.kind != 201 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNode(node); recordEmitNodeEndSpan(node); @@ -7815,11 +9182,23 @@ var ts; emit(nodes[i]); } } + function isBinaryOrOctalIntegerLiteral(text) { + if (text.length <= 0) { + return false; + } + if (text.charCodeAt(1) === 66 /* B */ || text.charCodeAt(1) === 98 /* b */ || text.charCodeAt(1) === 79 /* O */ || text.charCodeAt(1) === 111 /* o */) { + return true; + } + return false; + } function emitLiteral(node) { var text = getLiteralText(); if (compilerOptions.sourceMap && (node.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } + else if (compilerOptions.target < 2 /* ES6 */ && node.kind === 6 /* NumericLiteral */ && isBinaryOrOctalIntegerLiteral(text)) { + write(node.text); + } else { write(text); } @@ -7838,14 +9217,14 @@ var ts; ts.forEachChild(node, emit); return; } - ts.Debug.assert(node.parent.kind !== 149 /* TaggedTemplateExpression */); + ts.Debug.assert(node.parent.kind !== 147 /* TaggedTemplateExpression */); var emitOuterParens = ts.isExpression(node.parent) && templateNeedsParens(node, node.parent); if (emitOuterParens) { write("("); } emitLiteral(node.head); ts.forEach(node.templateSpans, function (templateSpan) { - var needsParens = templateSpan.expression.kind !== 151 /* ParenExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + var needsParens = templateSpan.expression.kind !== 149 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; write(" + "); if (needsParens) { write("("); @@ -7864,12 +9243,12 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.func === template; - case 151 /* ParenExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + return parent.expression === template; + case 149 /* ParenthesizedExpression */: return false; - case 149 /* TaggedTemplateExpression */: + case 147 /* TaggedTemplateExpression */: ts.Debug.fail("Path should be unreachable; tagged templates not supported pre-ES6."); default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -7878,7 +9257,7 @@ var ts; function comparePrecedenceToBinaryPlus(expression) { ts.Debug.assert(compilerOptions.target <= 1 /* ES5 */); switch (expression.kind) { - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: switch (expression.operator) { case 34 /* AsteriskToken */: case 35 /* SlashToken */: @@ -7889,7 +9268,7 @@ var ts; default: return -1 /* LessThan */; } - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -7904,6 +9283,9 @@ var ts; if (node.kind === 7 /* StringLiteral */) { emitLiteral(node); } + else if (node.kind === 121 /* ComputedPropertyName */) { + emit(node.expression); + } else { write("\""); if (node.kind === 6 /* NumericLiteral */) { @@ -7919,30 +9301,30 @@ var ts; var parent = node.parent; switch (parent.kind) { case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: + case 200 /* EnumMember */: case 125 /* Method */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 150 /* FunctionExpression */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: + case 189 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: return parent.name === node; - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: - case 195 /* ExportAssignment */: + case 173 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 192 /* ExportAssignment */: return false; - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return node.parent.label === node; - case 182 /* CatchBlock */: - return node.parent.variable === node; + case 197 /* CatchClause */: + return node.parent.name === node; } } function emitExpressionIdentifier(node) { @@ -8014,6 +9396,31 @@ var ts; write(" }"); } } + function emitComputedPropertyName(node) { + write("["); + emit(node.expression); + write("]"); + } + function emitDownlevelMethod(node) { + if (!ts.isObjectLiteralMethod(node)) { + return; + } + emitLeadingComments(node); + emit(node.name); + write(": "); + write("function "); + emitSignatureAndBody(node); + emitTrailingComments(node); + } + function emitMethod(node) { + if (!ts.isObjectLiteralMethod(node)) { + return; + } + emitLeadingComments(node); + emit(node.name); + emitSignatureAndBody(node); + emitTrailingComments(node); + } function emitPropertyAssignment(node) { emitLeadingComments(node); emit(node.name); @@ -8021,33 +9428,28 @@ var ts; emit(node.initializer); emitTrailingComments(node); } - function emitShortHandPropertyAssignment(node) { - function emitAsNormalPropertyAssignment() { + function emitDownlevelShorthandPropertyAssignment(node) { + emitLeadingComments(node); + emit(node.name); + write(": "); + emitExpressionIdentifier(node.name); + emitTrailingComments(node); + } + function emitShorthandPropertyAssignment(node) { + var prefix = resolver.getExpressionNamePrefix(node.name); + if (prefix) { + emitDownlevelShorthandPropertyAssignment(node); + } + else { emitLeadingComments(node); emit(node.name); - write(": "); - emitExpressionIdentifier(node.name); emitTrailingComments(node); } - if (compilerOptions.target < 2 /* ES6 */) { - emitAsNormalPropertyAssignment(); - } - else if (compilerOptions.target >= 2 /* ES6 */) { - var prefix = resolver.getExpressionNamePrefix(node.name); - if (prefix) { - emitAsNormalPropertyAssignment(); - } - else { - emitLeadingComments(node); - emit(node.name); - emitTrailingComments(node); - } - } } function tryEmitConstantValue(node) { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - var propertyName = node.kind === 145 /* PropertyAccess */ ? ts.declarationNameToString(node.right) : ts.getTextOfNode(node.index); + var propertyName = node.kind === 143 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(constantValue.toString() + " /* " + propertyName + " */"); return true; } @@ -8057,6 +9459,11 @@ var ts; if (tryEmitConstantValue(node)) { return; } + emit(node.expression); + write("."); + emit(node.name); + } + function emitQualifiedName(node) { emit(node.left); write("."); emit(node.right); @@ -8065,24 +9472,24 @@ var ts; if (tryEmitConstantValue(node)) { return; } - emit(node.object); + emit(node.expression); write("["); - emit(node.index); + emit(node.argumentExpression); write("]"); } function emitCallExpression(node) { var superCall = false; - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 89 /* SuperKeyword */) { write("_super"); superCall = true; } else { - emit(node.func); - superCall = node.func.kind === 145 /* PropertyAccess */ && node.func.left.kind === 89 /* SuperKeyword */; + emit(node.expression); + superCall = node.expression.kind === 143 /* PropertyAccessExpression */ && node.expression.expression.kind === 89 /* SuperKeyword */; } if (superCall) { write(".call("); - emitThis(node.func); + emitThis(node.expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments, false); @@ -8097,7 +9504,7 @@ var ts; } function emitNewExpression(node) { write("new "); - emit(node.func); + emit(node.expression); if (node.arguments) { write("("); emitCommaList(node.arguments, false); @@ -8111,12 +9518,12 @@ var ts; emit(node.template); } function emitParenExpression(node) { - if (node.expression.kind === 150 /* TypeAssertion */) { - var operand = node.expression.operand; - while (operand.kind == 150 /* TypeAssertion */) { - operand = operand.operand; + if (node.expression.kind === 148 /* TypeAssertionExpression */) { + var operand = node.expression.expression; + while (operand.kind == 148 /* TypeAssertionExpression */) { + operand = operand.expression; } - if (operand.kind !== 154 /* PrefixOperator */ && operand.kind !== 155 /* PostfixOperator */ && operand.kind !== 148 /* NewExpression */ && !(operand.kind === 147 /* CallExpression */ && node.parent.kind === 148 /* NewExpression */) && !(operand.kind === 152 /* FunctionExpression */ && node.parent.kind === 147 /* CallExpression */)) { + if (operand.kind !== 155 /* PrefixUnaryExpression */ && operand.kind !== 154 /* VoidExpression */ && operand.kind !== 153 /* TypeOfExpression */ && operand.kind !== 152 /* DeleteExpression */ && operand.kind !== 156 /* PostfixUnaryExpression */ && operand.kind !== 146 /* NewExpression */ && !(operand.kind === 145 /* CallExpression */ && node.parent.kind === 146 /* NewExpression */) && !(operand.kind === 150 /* FunctionExpression */ && node.parent.kind === 145 /* CallExpression */)) { emit(operand); return; } @@ -8125,14 +9532,24 @@ var ts; emit(node.expression); write(")"); } - function emitUnaryExpression(node) { - if (node.kind === 154 /* PrefixOperator */) { - write(ts.tokenToString(node.operator)); - } - if (node.operator >= 63 /* Identifier */) { - write(" "); - } - else if (node.kind === 154 /* PrefixOperator */ && node.operand.kind === 154 /* PrefixOperator */) { + function emitDeleteExpression(node) { + write(ts.tokenToString(72 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(97 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(95 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function emitPrefixUnaryExpression(node) { + write(ts.tokenToString(node.operator)); + if (node.operand.kind === 155 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 32 /* PlusToken */ && (operand.operator === 32 /* PlusToken */ || operand.operator === 37 /* PlusPlusToken */)) { write(" "); @@ -8142,9 +9559,10 @@ var ts; } } emit(node.operand); - if (node.kind === 155 /* PostfixOperator */) { - write(ts.tokenToString(node.operator)); - } + } + function emitPostfixUnaryExpression(node) { + emit(node.operand); + write(ts.tokenToString(node.operator)); } function emitBinaryExpression(node) { emit(node.left); @@ -8165,8 +9583,8 @@ var ts; emitToken(13 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 193 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 192 /* ModuleDeclaration */); + if (node.kind === 190 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 189 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); @@ -8176,7 +9594,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 162 /* Block */) { + if (node.kind === 163 /* Block */) { write(" "); emit(node); } @@ -8188,7 +9606,7 @@ var ts; } } function emitExpressionStatement(node) { - var isArrowExpression = node.expression.kind === 153 /* ArrowFunction */; + var isArrowExpression = node.expression.kind === 151 /* ArrowFunction */; emitLeadingComments(node); if (isArrowExpression) write("("); @@ -8209,7 +9627,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(74 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 166 /* IfStatement */) { + if (node.elseStatement.kind === 167 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -8222,7 +9640,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 162 /* Block */) { + if (node.statement.kind === 163 /* Block */) { write(" "); } else { @@ -8291,7 +9709,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 173 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -8326,7 +9744,7 @@ var ts; return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 176 /* CaseClause */) { + if (node.kind === 194 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -8352,22 +9770,22 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchBlock); + emit(node.catchClause); if (node.finallyBlock) { writeLine(); write("finally "); emit(node.finallyBlock); } } - function emitCatchBlock(node) { + function emitCatchClause(node) { writeLine(); var endPos = emitToken(66 /* CatchKeyword */, node.pos); write(" "); emitToken(15 /* OpenParenToken */, endPos); - emit(node.variable); - emitToken(16 /* CloseParenToken */, node.variable.end); + emit(node.name); + emitToken(16 /* CloseParenToken */, node.name.end); write(" "); - emitBlock(node); + emitBlock(node.block); } function emitDebuggerStatement(node) { emitToken(70 /* DebuggerKeyword */, node.pos); @@ -8381,7 +9799,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 192 /* ModuleDeclaration */); + } while (node && node.kind !== 189 /* ModuleDeclaration */); return node; } function emitModuleMemberName(node) { @@ -8493,7 +9911,7 @@ var ts; emitLeadingComments(node); } write("function "); - if (node.kind === 186 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) { + if (node.kind === 184 /* FunctionDeclaration */ || (node.kind === 150 /* FunctionExpression */ && node.name)) { emit(node.name); } emitSignatureAndBody(node); @@ -8523,16 +9941,16 @@ var ts; write(" {"); scopeEmitStart(node); increaseIndent(); - emitDetachedComments(node.body.kind === 187 /* FunctionBlock */ ? node.body.statements : node.body); + emitDetachedComments(node.body.kind === 163 /* Block */ ? node.body.statements : node.body); var startIndex = 0; - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 163 /* Block */) { startIndex = emitDirectivePrologues(node.body.statements, true); } var outPos = writer.getTextPos(); emitCaptureThisForNodeIfNecessary(node); emitDefaultValueAssignments(node); emitRestParameter(node); - if (node.body.kind !== 187 /* FunctionBlock */ && outPos === writer.getTextPos()) { + if (node.body.kind !== 163 /* Block */ && outPos === writer.getTextPos()) { decreaseIndent(); write(" "); emitStart(node.body); @@ -8545,7 +9963,7 @@ var ts; emitEnd(node.body); } else { - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 163 /* Block */) { emitLinesStartingAt(node.body.statements, startIndex); } else { @@ -8557,7 +9975,7 @@ var ts; emitTrailingComments(node.body); } writeLine(); - if (node.body.kind === 187 /* FunctionBlock */) { + if (node.body.kind === 163 /* Block */) { emitLeadingCommentsOfPosition(node.body.statements.end); decreaseIndent(); emitToken(14 /* CloseBraceToken */, node.body.statements.end); @@ -8583,10 +10001,10 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 165 /* ExpressionStatement */) { + if (statement && statement.kind === 166 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 147 /* CallExpression */) { - var func = expr.func; + if (expr && expr.kind === 145 /* CallExpression */) { + var func = expr.expression; if (func && func.kind === 89 /* SuperKeyword */) { return statement; } @@ -8610,12 +10028,15 @@ var ts; } }); } - function emitMemberAccess(memberName) { + function emitMemberAccessForPropertyName(memberName) { if (memberName.kind === 7 /* StringLiteral */ || memberName.kind === 6 /* NumericLiteral */) { write("["); emitNode(memberName); write("]"); } + else if (memberName.kind === 121 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } else { write("."); emitNode(memberName); @@ -8634,7 +10055,7 @@ var ts; else { write("this"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emit(member.initializer); @@ -8658,7 +10079,7 @@ var ts; if (!(member.flags & 128 /* Static */)) { write(".prototype"); } - emitMemberAccess(member.name); + emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); emitStart(member); @@ -8723,19 +10144,20 @@ var ts; write("var "); emit(node.name); write(" = (function ("); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { write("_super"); } write(") {"); increaseIndent(); scopeEmitStart(node); - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("__extends("); emit(node.name); write(", _super);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } writeLine(); emitConstructorOfClass(); @@ -8754,8 +10176,8 @@ var ts; scopeEmitEnd(); emitStart(node); write(")("); - if (node.baseType) { - emit(node.baseType.typeName); + if (baseTypeNode) { + emit(baseTypeNode.typeName); } write(");"); emitEnd(node); @@ -8793,7 +10215,7 @@ var ts; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); - if (node.baseType) { + if (baseTypeNode) { var superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); @@ -8803,11 +10225,11 @@ var ts; emitParameterPropertyAssignments(ctor); } else { - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("_super.apply(this, arguments);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } } emitMemberAssignments(node, 0); @@ -8903,7 +10325,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 189 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -8926,7 +10348,7 @@ var ts; write(resolver.getLocalNameOfContainer(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 193 /* ModuleBlock */) { + if (node.body.kind === 190 /* ModuleBlock */) { emit(node.body); } else { @@ -8960,7 +10382,7 @@ var ts; emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); } if (emitImportDeclaration) { - if (node.externalModuleName && node.parent.kind === 197 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { + if (ts.isExternalModuleImportDeclaration(node) && node.parent.kind === 201 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { if (node.flags & 1 /* Export */) { writeLine(); emitLeadingComments(node); @@ -8981,15 +10403,16 @@ var ts; write("var "); emitModuleMemberName(node); write(" = "); - if (node.entityName) { - emit(node.entityName); + if (ts.isInternalModuleImportDeclaration(node)) { + emit(node.moduleReference); } else { + var literal = ts.getExternalModuleImportDeclarationExpression(node); write("require("); - emitStart(node.externalModuleName); - emitLiteral(node.externalModuleName); - emitEnd(node.externalModuleName); - emitToken(16 /* CloseParenToken */, node.externalModuleName.end); + emitStart(literal); + emitLiteral(literal); + emitEnd(literal); + emitToken(16 /* CloseParenToken */, literal.end); } write(";"); emitEnd(node); @@ -8999,16 +10422,16 @@ var ts; } function getExternalImportDeclarations(node) { var result = []; - ts.forEach(node.statements, function (stat) { - if (stat.kind === 194 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { - result.push(stat); + ts.forEach(node.statements, function (statement) { + if (ts.isExternalModuleImportDeclaration(statement) && resolver.isReferencedImportDeclaration(statement)) { + result.push(statement); } }); return result; } function getFirstExportAssignment(sourceFile) { return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 192 /* ExportAssignment */) { return node; } }); @@ -9023,7 +10446,7 @@ var ts; write("[\"require\", \"exports\""); ts.forEach(imports, function (imp) { write(", "); - emitLiteral(imp.externalModuleName); + emitLiteral(ts.getExternalModuleImportDeclarationExpression(imp)); }); ts.forEach(node.amdDependencies, function (amdDependency) { var text = "\"" + amdDependency + "\""; @@ -9119,6 +10542,7 @@ var ts; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); } + emitLeadingComments(node.endOfFileToken); } function emitNode(node) { if (!node) { @@ -9153,106 +10577,129 @@ var ts; case 11 /* TemplateMiddle */: case 12 /* TemplateTail */: return emitLiteral(node); - case 158 /* TemplateExpression */: + case 159 /* TemplateExpression */: return emitTemplateExpression(node); - case 159 /* TemplateSpan */: + case 162 /* TemplateSpan */: return emitTemplateSpan(node); - case 121 /* QualifiedName */: - return emitPropertyAccess(node); - case 141 /* ArrayLiteral */: + case 120 /* QualifiedName */: + return emitQualifiedName(node); + case 141 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 142 /* ObjectLiteral */: + case 142 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 143 /* PropertyAssignment */: + case 198 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 144 /* ShorthandPropertyAssignment */: - return emitShortHandPropertyAssignment(node); - case 145 /* PropertyAccess */: + case 121 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 143 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 146 /* IndexedAccess */: + case 144 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 147 /* CallExpression */: + case 145 /* CallExpression */: return emitCallExpression(node); - case 148 /* NewExpression */: + case 146 /* NewExpression */: return emitNewExpression(node); - case 149 /* TaggedTemplateExpression */: + case 147 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: - return emit(node.operand); - case 151 /* ParenExpression */: + case 148 /* TypeAssertionExpression */: + return emit(node.expression); + case 149 /* ParenthesizedExpression */: return emitParenExpression(node); - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - return emitUnaryExpression(node); - case 156 /* BinaryExpression */: + case 152 /* DeleteExpression */: + return emitDeleteExpression(node); + case 153 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 154 /* VoidExpression */: + return emitVoidExpression(node); + case 155 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 156 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 157 /* BinaryExpression */: return emitBinaryExpression(node); - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return emitConditionalExpression(node); case 161 /* OmittedExpression */: return; - case 162 /* Block */: - case 181 /* TryBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: return emitBlock(node); - case 163 /* VariableStatement */: + case 164 /* VariableStatement */: return emitVariableStatement(node); - case 164 /* EmptyStatement */: + case 165 /* EmptyStatement */: return write(";"); - case 165 /* ExpressionStatement */: + case 166 /* ExpressionStatement */: return emitExpressionStatement(node); - case 166 /* IfStatement */: + case 167 /* IfStatement */: return emitIfStatement(node); - case 167 /* DoStatement */: + case 168 /* DoStatement */: return emitDoStatement(node); - case 168 /* WhileStatement */: + case 169 /* WhileStatement */: return emitWhileStatement(node); - case 169 /* ForStatement */: + case 170 /* ForStatement */: return emitForStatement(node); - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return emitForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 174 /* ReturnStatement */: return emitReturnStatement(node); - case 174 /* WithStatement */: + case 175 /* WithStatement */: return emitWithStatement(node); - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: return emitSwitchStatement(node); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return emitLabelledStatement(node); - case 179 /* ThrowStatement */: + case 178 /* ThrowStatement */: return emitThrowStatement(node); - case 180 /* TryStatement */: + case 179 /* TryStatement */: return emitTryStatement(node); - case 182 /* CatchBlock */: - return emitCatchBlock(node); - case 184 /* DebuggerStatement */: + case 197 /* CatchClause */: + return emitCatchClause(node); + case 182 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return emitClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: return emitImportDeclaration(node); - case 197 /* SourceFile */: + case 201 /* SourceFile */: return emitSourceFile(node); } + if (compilerOptions.target < 2 /* ES6 */) { + switch (node.kind) { + case 199 /* ShorthandPropertyAssignment */: + return emitDownlevelShorthandPropertyAssignment(node); + case 125 /* Method */: + return emitDownlevelMethod(node); + } + } + else { + ts.Debug.assert(compilerOptions.target >= 2 /* ES6 */, "Invalid ScriptTarget. We should emit as ES6 or above"); + switch (node.kind) { + case 199 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 125 /* Method */: + return emitMethod(node); + } + } } function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; @@ -9268,7 +10715,7 @@ var ts; return leadingComments; } function getLeadingCommentsToEmit(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 201 /* SourceFile */ || node.pos !== node.parent.pos) { var leadingComments; if (hasDetachedComments(node.pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -9285,7 +10732,7 @@ var ts; emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingDeclarationComments(node) { - if (node.parent.kind === 197 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 201 /* SourceFile */ || node.end !== node.parent.end) { var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } @@ -9379,17 +10826,11 @@ var ts; writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); } } - var hasSemanticErrors = resolver.hasSemanticErrors(); - var isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); - function emitFile(jsFilePath, sourceFile) { - if (!isEmitBlocked) { - emitJavaScript(jsFilePath, sourceFile); - if (!hasSemanticErrors && compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); - } - } - } + var hasSemanticErrors = false; + var isEmitBlocked = false; if (targetSourceFile === undefined) { + hasSemanticErrors = resolver.hasSemanticErrors(); + isEmitBlocked = resolver.isEmitBlocked(); ts.forEach(program.getSourceFiles(), function (sourceFile) { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js"); @@ -9402,13 +10843,29 @@ var ts; } else { if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + hasSemanticErrors = resolver.hasSemanticErrors(targetSourceFile); + isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (!shouldEmitToOwnFile(sourceFile, compilerOptions)) { + hasSemanticErrors = hasSemanticErrors || resolver.hasSemanticErrors(sourceFile); + isEmitBlocked = isEmitBlocked || resolver.isEmitBlocked(sourceFile); + } + }); emitFile(compilerOptions.out); } } + function emitFile(jsFilePath, sourceFile) { + if (!isEmitBlocked) { + emitJavaScript(jsFilePath, sourceFile); + if (!hasSemanticErrors && compilerOptions.declaration) { + writeDeclarationFile(jsFilePath, sourceFile); + } + } + } diagnostics.sort(ts.compareDiagnostics); diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); var hasEmitterError = ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1 /* Error */; }); @@ -9441,44 +10898,6 @@ 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; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length == 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str += " "; }, - increaseIndent: function () { - }, - decreaseIndent: function () { - }, - clear: function () { return str = ""; }, - trackSymbol: function () { - } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; function createTypeChecker(program, fullTypeCheck) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -9499,9 +10918,7 @@ var ts; getDiagnostics: getDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - checkProgram: checkProgram, - getParentOfSymbol: getParentOfSymbol, - getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol, + getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -9509,9 +10926,9 @@ var ts; getIndexTypeOfType: getIndexTypeOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, - getSymbolInfo: getSymbolInfo, + getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeOfNode: getTypeOfNode, + getTypeAtLocation: getTypeAtLocation, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -9705,10 +11122,10 @@ var ts; return nodeLinks[node.id] || (nodeLinks[node.id] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 197 /* SourceFile */); + return ts.getAncestor(node, 201 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 197 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 201 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -9749,21 +11166,21 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) { break loop; } break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; case 124 /* Property */: - if (location.parent.kind === 188 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + if (location.parent.kind === 185 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -9772,8 +11189,8 @@ var ts; } } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -9786,14 +11203,14 @@ var ts; case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 152 /* FunctionExpression */: + case 150 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -9804,8 +11221,8 @@ var ts; break loop; } break; - case 182 /* CatchBlock */: - var id = location.variable; + case 197 /* CatchClause */: + var id = location.name; if (name === id.text) { result = location.symbol; break loop; @@ -9845,8 +11262,8 @@ var ts; var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; - var node = getDeclarationOfKind(symbol, 194 /* ImportDeclaration */); - var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node); + var node = ts.getDeclarationOfKind(symbol, 191 /* ImportDeclaration */); + var target = node.moduleReference.kind === 193 /* ExternalModuleReference */ ? resolveExternalModuleName(node, ts.getExternalModuleImportDeclarationExpression(node)) : getSymbolOfPartOfRightHandSideOfImport(node.moduleReference, node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; } @@ -9861,17 +11278,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 194 /* ImportDeclaration */); + importDeclaration = ts.getAncestor(entityName, 191 /* ImportDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { + if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 120 /* QualifiedName */) { return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */); } else { - ts.Debug.assert(entityName.parent.kind === 194 /* ImportDeclaration */); + ts.Debug.assert(entityName.parent.kind === 191 /* ImportDeclaration */); return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */); } } @@ -9879,15 +11296,18 @@ var ts; return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } function resolveEntityName(location, name, meaning) { + if (ts.getFullWidth(name) === 0) { + return undefined; + } if (name.kind === 63 /* Identifier */) { var symbol = resolveName(location, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return; } } - else if (name.kind === 121 /* QualifiedName */) { + else if (name.kind === 120 /* QualifiedName */) { var namespace = resolveEntityName(location, name.left, 1536 /* Namespace */); - if (!namespace || namespace === unknownSymbol || name.right.kind === 120 /* Missing */) + if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) return; var symbol = getSymbol(namespace.exports, name.right.text, meaning); if (!symbol) { @@ -9895,18 +11315,19 @@ var ts; return; } } - else { - return; - } ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveImport(symbol); } function isExternalModuleNameRelative(moduleName) { return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } - function resolveExternalModuleName(location, moduleLiteral) { + function resolveExternalModuleName(location, moduleReferenceExpression) { + if (moduleReferenceExpression.kind !== 7 /* StringLiteral */) { + return; + } + var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).filename); - var moduleName = moduleLiteral.text; + var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); if (!moduleName) return; var isRelative = isExternalModuleNameRelative(moduleName); @@ -9930,10 +11351,10 @@ var ts; if (sourceFile.symbol) { return getResolvedExportSymbol(sourceFile.symbol); } - error(moduleLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); + error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); return; } - error(moduleLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); + error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); } function getResolvedExportSymbol(moduleSymbol) { var symbol = getExportAssignmentSymbol(moduleSymbol); @@ -9976,9 +11397,9 @@ var ts; var seenExportedMember = false; var result = []; ts.forEach(symbol.declarations, function (declaration) { - var block = (declaration.kind === 197 /* SourceFile */ ? declaration : declaration.body); + var block = (declaration.kind === 201 /* SourceFile */ ? declaration : declaration.body); ts.forEach(block.statements, function (node) { - if (node.kind === 195 /* ExportAssignment */) { + if (node.kind === 192 /* ExportAssignment */) { result.push(node); } else { @@ -10074,7 +11495,7 @@ var ts; return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function isOptionalProperty(propertySymbol) { - return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; + return propertySymbol.valueDeclaration && ts.hasQuestionToken(propertySymbol.valueDeclaration) && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -10085,17 +11506,17 @@ var ts; } } switch (location.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location).members)) { return result; } @@ -10126,7 +11547,7 @@ var ts; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 33554432 /* Import */) { - if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 194 /* ImportDeclaration */ && declaration.externalModuleName; })) { + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportDeclaration)) { var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { return [symbolFromSymbolTable]; @@ -10208,7 +11629,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 192 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 197 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 189 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 201 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10218,7 +11639,7 @@ var ts; return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 194 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + if (declaration.kind === 191 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { if (!ts.contains(aliasesToMakeVisible, declaration)) { @@ -10240,7 +11661,7 @@ var ts; if (entityName.parent.kind === 135 /* TypeQuery */) { meaning = 107455 /* Value */ | 4194304 /* ExportValue */; } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 194 /* ImportDeclaration */) { + else if (entityName.kind === 120 /* QualifiedName */ || entityName.parent.kind === 191 /* ImportDeclaration */) { meaning = 1536 /* Namespace */; } else { @@ -10248,40 +11669,33 @@ var ts; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); - return hasVisibleDeclarations(symbol) || { + return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } function writeKeyword(writer, kind) { writer.writeKeyword(ts.tokenToString(kind)); } function writePunctuation(writer, kind) { writer.writePunctuation(ts.tokenToString(kind)); } - function writeOperator(writer, kind) { - writer.writeOperator(ts.tokenToString(kind)); - } function writeSpace(writer) { writer.writeSpace(" "); } function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); return result; } function typeToString(type, enclosingDeclaration, flags) { - var writer = getSingleLineStringWriter(); + var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); var result = writer.string(); - releaseStringWriter(writer); + ts.releaseStringWriter(writer); var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; if (maxLength && result.length >= maxLength) { result = result.substr(0, maxLength - "...".length) + "..."; @@ -10291,10 +11705,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 140 /* ParenType */) { + while (node.kind === 140 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 190 /* TypeAliasDeclaration */) { + if (node.kind === 187 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -10457,7 +11871,7 @@ var ts; function shouldWriteTypeOfFunctionSymbol() { if (type.symbol) { var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 197 /* SourceFile */ || declaration.parent.kind === 193 /* ModuleBlock */; })); + var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 201 /* SourceFile */ || declaration.parent.kind === 190 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type)); } @@ -10469,6 +11883,14 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */); } + function getIndexerParameterName(type, indexKind, fallbackName) { + var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + if (!declaration) { + return fallbackName; + } + ts.Debug.assert(declaration.parameters.length !== 0); + return ts.declarationNameToString(declaration.parameters[0].name); + } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { @@ -10517,7 +11939,7 @@ var ts; } if (resolved.stringIndexType) { writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeKeyword(writer, 118 /* StringKeyword */); @@ -10530,7 +11952,7 @@ var ts; } if (resolved.numberIndexType) { writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter("x"); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeKeyword(writer, 116 /* NumberKeyword */); @@ -10589,11 +12011,11 @@ var ts; } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, typeStack) { - if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { + if (ts.hasDotDotDotToken(p.valueDeclaration)) { writePunctuation(writer, 20 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); - if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { + if (ts.hasQuestionToken(p.valueDeclaration) || p.valueDeclaration.initializer) { writePunctuation(writer, 49 /* QuestionToken */); } writePunctuation(writer, 50 /* ColonToken */); @@ -10676,12 +12098,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 192 /* ModuleDeclaration */) { + if (node.kind === 189 /* ModuleDeclaration */) { if (node.name.kind === 7 /* StringLiteral */) { return node; } } - else if (node.kind === 197 /* SourceFile */) { + else if (node.kind === 201 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10710,12 +12132,12 @@ var ts; if (resolvedExportSymbol === symbol) { return true; } - return ts.forEach(resolvedExportSymbol.declarations, function (declaration) { - while (declaration) { - if (declaration === node) { + return ts.forEach(resolvedExportSymbol.declarations, function (current) { + while (current) { + if (current === node) { return true; } - declaration = declaration.parent; + current = current.parent; } }); } @@ -10723,20 +12145,22 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 185 /* VariableDeclaration */: - case 192 /* ModuleDeclaration */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 186 /* FunctionDeclaration */: - case 191 /* EnumDeclaration */: - case 194 /* ImportDeclaration */: - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (!(node.flags & 1 /* Export */) && !(node.kind !== 194 /* ImportDeclaration */ && parent.kind !== 197 /* SourceFile */ && ts.isInAmbientContext(parent))) { + case 183 /* VariableDeclaration */: + case 189 /* ModuleDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 184 /* FunctionDeclaration */: + case 188 /* EnumDeclaration */: + case 191 /* ImportDeclaration */: + var parent = node.kind === 183 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (!(node.flags & 1 /* Export */) && !(node.kind !== 191 /* ImportDeclaration */ && parent.kind !== 201 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); } return isDeclarationVisible(parent); case 124 /* Property */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: case 125 /* Method */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { return false; @@ -10746,10 +12170,18 @@ var ts; case 129 /* CallSignature */: case 131 /* IndexSignature */: case 123 /* Parameter */: - case 193 /* ModuleBlock */: + case 190 /* ModuleBlock */: case 122 /* TypeParameter */: + case 133 /* FunctionType */: + case 134 /* ConstructorType */: + case 136 /* TypeLiteral */: + case 132 /* TypeReference */: + case 137 /* ArrayType */: + case 138 /* TupleType */: + case 139 /* UnionType */: + case 140 /* ParenthesizedType */: return isDeclarationVisible(node.parent); - case 197 /* SourceFile */: + case 201 /* SourceFile */: return true; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -10767,8 +12199,8 @@ var ts; var classType = getDeclaredTypeOfSymbol(prototype.parent); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } - function getTypeOfVariableOrPropertyDeclaration(declaration) { - if (declaration.parent.kind === 170 /* ForInStatement */) { + function getTypeOfVariableOrParameterOrPropertyDeclaration(declaration) { + if (declaration.parent.kind === 171 /* ForInStatement */) { return anyType; } if (declaration.type) { @@ -10776,8 +12208,8 @@ var ts; } if (declaration.kind === 123 /* Parameter */) { var func = declaration.parent; - if (func.kind === 128 /* SetAccessor */) { - var getter = getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); + if (func.kind === 128 /* SetAccessor */ && !ts.hasComputedNameButNotSymbol(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10789,7 +12221,7 @@ var ts; } if (declaration.initializer) { var type = checkAndMarkExpression(declaration.initializer); - if (declaration.kind !== 143 /* PropertyAssignment */) { + if (declaration.kind !== 198 /* PropertyAssignment */) { var unwidenedType = type; type = getWidenedType(type); if (type !== unwidenedType) { @@ -10798,11 +12230,11 @@ var ts; } return type; } - if (declaration.kind === 144 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 199 /* ShorthandPropertyAssignment */) { var type = checkIdentifier(declaration.name); return type; } - var type = declaration.flags & 8 /* Rest */ ? createArrayType(anyType) : anyType; + var type = ts.hasDotDotDotToken(declaration) ? createArrayType(anyType) : anyType; checkImplicitAny(type); return type; function checkImplicitAny(type) { @@ -10820,7 +12252,7 @@ var ts; var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; case 123 /* Parameter */: - var diagnostic = declaration.flags & 8 /* Rest */ ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + var diagnostic = ts.hasDotDotDotToken(declaration) ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; default: var diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; @@ -10835,11 +12267,11 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.kind === 182 /* CatchBlock */) { + if (declaration.kind === 197 /* CatchClause */) { return links.type = anyType; } links.type = resolvingType; - var type = getTypeOfVariableOrPropertyDeclaration(declaration); + var type = getTypeOfVariableOrParameterOrPropertyDeclaration(declaration); if (links.type === resolvingType) { links.type = type; } @@ -10877,8 +12309,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); - var setter = getDeclarationOfKind(symbol, 128 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 128 /* SetAccessor */); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -10908,7 +12340,7 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 127 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -10975,7 +12407,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 188 /* ClassDeclaration */) { + if (node.kind === 186 /* InterfaceDeclaration */ || node.kind === 185 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -11006,9 +12438,10 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = getDeclarationOfKind(symbol, 188 /* ClassDeclaration */); - if (declaration.baseType) { - var baseType = getTypeFromTypeReferenceNode(declaration.baseType); + var declaration = ts.getDeclarationOfKind(symbol, 185 /* ClassDeclaration */); + var baseTypeNode = ts.getClassBaseTypeNode(declaration); + if (baseTypeNode) { + var baseType = getTypeFromTypeReferenceNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & 1024 /* Class */) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -11019,7 +12452,7 @@ var ts; } } else { - error(declaration.baseType, ts.Diagnostics.A_class_may_only_extend_another_class); + error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); } } } @@ -11046,8 +12479,8 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 189 /* InterfaceDeclaration */ && declaration.baseTypes) { - ts.forEach(declaration.baseTypes, function (node) { + if (declaration.kind === 186 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { @@ -11077,7 +12510,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 187 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -11085,7 +12518,7 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 187 /* TypeAliasDeclaration */); error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; @@ -11104,7 +12537,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -11519,7 +12952,7 @@ var ts; hasStringLiterals = true; } if (minArgumentCount < 0) { - if (param.initializer || param.flags & (4 /* QuestionMark */ | 8 /* Rest */)) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { minArgumentCount = i; } } @@ -11535,8 +12968,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 127 /* GetAccessor */) { - var setter = getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); + if (declaration.kind === 127 /* GetAccessor */ && !ts.hasComputedNameButNotSymbol(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && !declaration.body) { @@ -11556,7 +12989,7 @@ var ts; switch (node.kind) { case 133 /* FunctionType */: case 134 /* ConstructorType */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: case 126 /* Constructor */: case 129 /* CallSignature */: @@ -11564,8 +12997,8 @@ var ts; case 131 /* IndexSignature */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11675,7 +13108,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11776,7 +13209,7 @@ var ts; function getTypeFromTypeQueryNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpression(node.exprName)); + links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); } return links.resolvedType; } @@ -11786,9 +13219,9 @@ var ts; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; switch (declaration.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: return declaration; } } @@ -11936,8 +13369,9 @@ var ts; return links.resolvedType; } function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) + if (ts.hasProperty(stringLiteralTypes, node.text)) { return stringLiteralTypes[node.text]; + } var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); type.text = ts.getTextOfNode(node); return type; @@ -11973,14 +13407,14 @@ var ts; return getTypeFromTupleTypeNode(node); case 139 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 140 /* ParenType */: + case 140 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); case 133 /* FunctionType */: case 134 /* ConstructorType */: case 136 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 63 /* Identifier */: - case 121 /* QualifiedName */: + case 120 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -12123,22 +13557,30 @@ var ts; } return type; } - function isContextSensitiveExpression(node) { + function isContextSensitive(node) { + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); - case 142 /* ObjectLiteral */: - return ts.forEach(node.properties, function (p) { return p.kind === 143 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); - case 141 /* ArrayLiteral */: - return ts.forEach(node.elements, function (e) { return isContextSensitiveExpression(e); }); - case 157 /* ConditionalExpression */: - return isContextSensitiveExpression(node.whenTrue) || isContextSensitiveExpression(node.whenFalse); - case 156 /* BinaryExpression */: - return node.operator === 48 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + return isContextSensitiveFunctionLikeDeclaration(node); + case 142 /* ObjectLiteralExpression */: + return ts.forEach(node.properties, isContextSensitive); + case 141 /* ArrayLiteralExpression */: + return ts.forEach(node.elements, isContextSensitive); + case 158 /* ConditionalExpression */: + return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); + case 157 /* BinaryExpression */: + return node.operator === 48 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); + case 198 /* PropertyAssignment */: + return isContextSensitive(node.initializer); + case 125 /* Method */: + return isContextSensitiveFunctionLikeDeclaration(node); } return false; } + function isContextSensitiveFunctionLikeDeclaration(node) { + return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); + } function getTypeWithoutConstructors(type) { if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); @@ -13035,7 +14477,7 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; + links.resolvedSymbol = (ts.getFullWidth(node) > 0 && resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; } return links.resolvedSymbol; } @@ -13045,7 +14487,7 @@ var ts; case 135 /* TypeQuery */: return true; case 63 /* Identifier */: - case 121 /* QualifiedName */: + case 120 /* QualifiedName */: node = node.parent; continue; default: @@ -13078,7 +14520,7 @@ var ts; function isAssignedInBinaryExpression(node) { if (node.operator >= 51 /* FirstAssignment */ && node.operator <= 62 /* LastAssignment */) { var n = node.left; - while (n.kind === 151 /* ParenExpression */) { + while (n.kind === 149 /* ParenthesizedExpression */) { n = n.expression; } if (n.kind === 63 /* Identifier */ && getResolvedSymbol(n) === symbol) { @@ -13095,64 +14537,90 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return isAssignedInVariableDeclaration(node); - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 173 /* ReturnStatement */: - case 174 /* WithStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 141 /* ArrayLiteralExpression */: + case 142 /* ObjectLiteralExpression */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + case 148 /* TypeAssertionExpression */: + case 149 /* ParenthesizedExpression */: + case 155 /* PrefixUnaryExpression */: + case 152 /* DeleteExpression */: + case 153 /* TypeOfExpression */: + case 154 /* VoidExpression */: + case 156 /* PostfixUnaryExpression */: + case 158 /* ConditionalExpression */: + case 163 /* Block */: + case 164 /* VariableStatement */: + case 166 /* ExpressionStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 174 /* ReturnStatement */: + case 175 /* WithStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: + case 177 /* LabeledStatement */: + case 178 /* ThrowStatement */: + case 179 /* TryStatement */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: return ts.forEachChild(node, isAssignedIn); } return false; } } + function resolveLocation(node) { + var containerNodes = []; + for (var parent = node.parent; parent; parent = parent.parent) { + if ((ts.isExpression(parent) || ts.isObjectLiteralMethod(node)) && isContextSensitive(parent)) { + containerNodes.unshift(parent); + } + } + ts.forEach(containerNodes, function (node) { + getTypeOfNode(node); + }); + } + function getSymbolAtLocation(node) { + resolveLocation(node); + return getSymbolInfo(node); + } + function getTypeAtLocation(node) { + resolveLocation(node); + return getTypeOfNode(node); + } + function getTypeOfSymbolAtLocation(symbol, node) { + resolveLocation(node); + return getNarrowedTypeOfSymbol(symbol, node); + } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (node && (symbol.flags & 3 /* Variable */ && type.flags & 65025 /* Structured */)) { - loop: while (true) { + if (node && symbol.flags & 3 /* Variable */ && type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 166 /* IfStatement */: + case 167 /* IfStatement */: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: if (child === node.right) { if (node.operator === 47 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); @@ -13162,9 +14630,9 @@ var ts; } } break; - case 197 /* SourceFile */: - case 192 /* ModuleDeclaration */: - case 186 /* FunctionDeclaration */: + case 201 /* SourceFile */: + case 189 /* ModuleDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: @@ -13181,9 +14649,12 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { + if (expr.left.kind !== 153 /* TypeOfExpression */ || expr.right.kind !== 7 /* StringLiteral */) { + return type; + } var left = expr.left; var right = expr.right; - if (left.kind !== 154 /* PrefixOperator */ || left.operator !== 95 /* TypeOfKeyword */ || left.operand.kind !== 63 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { + if (left.expression.kind !== 63 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var t = right.text; @@ -13237,9 +14708,9 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: var operator = expr.operator; if (operator === 29 /* EqualsEqualsEqualsToken */ || operator === 30 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -13254,7 +14725,7 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 154 /* PrefixOperator */: + case 155 /* PrefixUnaryExpression */: if (expr.operator === 45 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -13274,7 +14745,7 @@ var ts; return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 185 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; @@ -13286,15 +14757,15 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 153 /* ArrowFunction */) { + if (container.kind === 151 /* ArrowFunction */) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = true; } switch (container.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 126 /* Constructor */: @@ -13311,7 +14782,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 185 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -13324,9 +14795,9 @@ var ts; if (!node) return node; switch (node.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: case 124 /* Property */: case 125 /* Method */: case 126 /* Constructor */: @@ -13345,10 +14816,10 @@ var ts; return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 147 /* CallExpression */ && node.parent.func === node; - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 145 /* CallExpression */ && node.parent.expression === node; + var enclosingClass = ts.getAncestor(node, 185 /* ClassDeclaration */); var baseClass; - if (enclosingClass && enclosingClass.baseType) { + if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); baseClass = classType.baseTypes.length && classType.baseTypes[0]; } @@ -13364,11 +14835,11 @@ var ts; } else { var needToCaptureLexicalThis = false; - while (container && container.kind === 153 /* ArrowFunction */) { + while (container && container.kind === 151 /* ArrowFunction */) { container = getSuperContainer(container); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 188 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 185 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */; } @@ -13406,9 +14877,9 @@ var ts; return unknownType; } function getContextuallyTypedParameterType(parameter) { - var func = parameter.parent; - if (func.kind === 152 /* FunctionExpression */ || func.kind === 153 /* ArrowFunction */) { - if (isContextSensitiveExpression(func)) { + if (isFunctionExpressionOrArrowFunction(parameter.parent)) { + var func = parameter.parent; + if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var funcHasRestParameters = ts.hasRestParameters(func); @@ -13440,10 +14911,10 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { + if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } - var signature = getContextualSignature(func); + var signature = getContextualSignatureForFunctionLikeDeclaration(func); if (signature) { return getReturnTypeOfSignature(signature); } @@ -13514,11 +14985,17 @@ var ts; function contextualTypeHasIndexSignature(type, kind) { return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); } - function getContextualTypeForPropertyExpression(node) { - var declaration = node.parent; - var objectLiteral = declaration.parent; + function getContextualTypeForObjectLiteralMethod(node) { + ts.Debug.assert(ts.isObjectLiteralMethod(node)); + if (isInsideWithStatementBody(node)) { + return undefined; + } + return getContextualTypeForObjectLiteralElement(node); + } + function getContextualTypeForObjectLiteralElement(element) { + var objectLiteral = element.parent; var type = getContextualType(objectLiteral); - var name = declaration.name.text; + var name = element.name.text; if (type && name) { return getTypeOfPropertyOfContextualType(type, name) || isNumericName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || getIndexTypeOfContextualType(type, 0 /* String */); } @@ -13546,25 +15023,25 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 123 /* Parameter */: case 124 /* Property */: return getContextualTypeForInitializerExpression(node); - case 153 /* ArrowFunction */: - case 173 /* ReturnStatement */: + case 151 /* ArrowFunction */: + case 174 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return getContextualTypeForArgument(node); - case 150 /* TypeAssertion */: + case 148 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 143 /* PropertyAssignment */: - return getContextualTypeForPropertyExpression(node); - case 141 /* ArrayLiteral */: + case 198 /* PropertyAssignment */: + return getContextualTypeForObjectLiteralElement(parent); + case 141 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); } return undefined; @@ -13578,8 +15055,15 @@ var ts; } } } + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 150 /* FunctionExpression */ || node.kind === 151 /* ArrowFunction */; + } + function getContextualSignatureForFunctionLikeDeclaration(node) { + return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; + } function getContextualSignature(node) { - var type = getContextualType(node); + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); + var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); if (!type) { return undefined; } @@ -13638,31 +15122,35 @@ var ts; for (var id in members) { if (ts.hasProperty(members, id)) { var member = members[id]; - if (member.flags & 4 /* Property */) { + if (member.flags & 4 /* Property */ || ts.isObjectLiteralMethod(member.declarations[0])) { var memberDecl = member.declarations[0]; var type; - if (memberDecl.kind === 143 /* PropertyAssignment */) { + if (memberDecl.kind === 198 /* PropertyAssignment */) { type = checkExpression(memberDecl.initializer, contextualMapper); } + else if (memberDecl.kind === 125 /* Method */) { + type = checkObjectLiteralMethod(memberDecl, contextualMapper); + } else { - ts.Debug.assert(memberDecl.kind === 144 /* ShorthandPropertyAssignment */); - type = checkExpression(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 199 /* ShorthandPropertyAssignment */); + type = memberDecl.name.kind === 121 /* ComputedPropertyName */ ? unknownType : checkExpression(memberDecl.name, contextualMapper); } var prop = createSymbol(4 /* Property */ | 268435456 /* Transient */ | member.flags, member.name); prop.declarations = member.declarations; prop.parent = member.parent; - if (member.valueDeclaration) + if (member.valueDeclaration) { prop.valueDeclaration = member.valueDeclaration; + } prop.type = type; prop.target = member; member = prop; } else { - var getAccessor = getDeclarationOfKind(member, 127 /* GetAccessor */); + var getAccessor = ts.getDeclarationOfKind(member, 127 /* GetAccessor */); if (getAccessor) { checkAccessorDeclaration(getAccessor); } - var setAccessor = getDeclarationOfKind(member, 128 /* SetAccessor */); + var setAccessor = ts.getDeclarationOfKind(member, 128 /* SetAccessor */); if (setAccessor) { checkAccessorDeclaration(setAccessor); } @@ -13697,12 +15185,12 @@ var ts; function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 536870912 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } - function checkClassPropertyAccess(node, type, prop) { + function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); if (!(flags & (32 /* Private */ | 64 /* Protected */))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 185 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32 /* Private */) { @@ -13711,7 +15199,7 @@ var ts; } return; } - if (node.left.kind === 89 /* SuperKeyword */) { + if (left.kind === 89 /* SuperKeyword */) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13725,8 +15213,14 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); } } - function checkPropertyAccess(node) { - var type = checkExpression(node.left); + function checkPropertyAccessExpression(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + function checkQualifiedName(node) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { + var type = checkExpressionOrQualifiedName(left); if (type === unknownType) return type; if (type !== anyType) { @@ -13734,20 +15228,20 @@ var ts; if (apparentType === unknownType) { return unknownType; } - var prop = getPropertyOfType(apparentType, node.right.text); + var prop = getPropertyOfType(apparentType, right.text); if (!prop) { - if (node.right.text) { - error(node.right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(node.right), typeToString(type)); + if (right.text) { + error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); } return unknownType; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { - error(node.right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { + error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); } } return getTypeOfSymbol(prop); @@ -13755,16 +15249,17 @@ var ts; return anyType; } function isValidPropertyAccess(node, propertyName) { - var type = checkExpression(node.left); + var left = node.kind === 143 /* PropertyAccessExpression */ ? node.expression : node.left; + var type = checkExpressionOrQualifiedName(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { + if (left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { return false; } else { var diagnosticsCount = diagnostics.length; - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); return diagnostics.length === diagnosticsCount; } } @@ -13772,19 +15267,22 @@ var ts; return true; } function checkIndexedAccess(node) { - var objectType = getApparentType(checkExpression(node.object)); - var indexType = checkExpression(node.index); - if (objectType === unknownType) + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + if (objectType === unknownType) { return unknownType; - if (isConstEnumObjectType(objectType) && node.index.kind !== 7 /* StringLiteral */) { - error(node.index, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); } - if (node.index.kind === 7 /* StringLiteral */ || node.index.kind === 6 /* NumericLiteral */) { - var name = node.index.text; - var prop = getPropertyOfType(objectType, name); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); + if (isConstEnumObjectType(objectType) && node.argumentExpression && node.argumentExpression.kind !== 7 /* StringLiteral */) { + error(node.argumentExpression, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + } + if (node.argumentExpression) { + if (node.argumentExpression.kind === 7 /* StringLiteral */ || node.argumentExpression.kind === 6 /* NumericLiteral */) { + var name = node.argumentExpression.text; + var prop = getPropertyOfType(objectType, name); + if (prop) { + getNodeLinks(node).resolvedSymbol = prop; + return getTypeOfSymbol(prop); + } } } if (indexType.flags & (1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */)) { @@ -13798,7 +15296,7 @@ var ts; if (stringIndexType) { return stringIndexType; } - if (compilerOptions.noImplicitAny && objectType !== anyType) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) { error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); } return anyType; @@ -13807,7 +15305,7 @@ var ts; return unknownType; } function resolveUntypedCall(node) { - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { checkExpression(node.template); } else { @@ -13825,26 +15323,26 @@ var ts; var adjustedArgCount; var typeArguments; var callIsIncomplete; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 158 /* TemplateExpression */) { + if (tagExpression.template.kind === 159 /* TemplateExpression */) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); - callIsIncomplete = lastSpan.literal.kind === 120 /* Missing */ || ts.isUnterminatedTemplateEnd(lastSpan.literal); + callIsIncomplete = ts.getFullWidth(lastSpan.literal) === 0 || !!lastSpan.literal.isUnterminated; } else { var templateLiteral = tagExpression.template; ts.Debug.assert(templateLiteral.kind === 9 /* NoSubstitutionTemplateLiteral */); - callIsIncomplete = ts.isUnterminatedTemplateEnd(templateLiteral); + callIsIncomplete = !!templateLiteral.isUnterminated; } } else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 148 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 146 /* NewExpression */); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -13892,7 +15390,7 @@ var ts; } if (!excludeArgument || excludeArgument[i] === undefined) { var parameterType = getTypeAtPosition(signature, i); - if (i === 0 && args[i].parent.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && args[i].parent.kind === 147 /* TaggedTemplateExpression */) { inferTypes(context, globalTemplateStringsArrayType, parameterType); continue; } @@ -13943,7 +15441,7 @@ var ts; continue; } var paramType = getTypeAtPosition(signature, i); - if (i === 0 && node.kind === 149 /* TaggedTemplateExpression */) { + if (i === 0 && node.kind === 147 /* TaggedTemplateExpression */) { argType = globalTemplateStringsArrayType; } else { @@ -13958,10 +15456,10 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 149 /* TaggedTemplateExpression */) { + if (node.kind === 147 /* TaggedTemplateExpression */) { var template = node.template; args = [template]; - if (template.kind === 158 /* TemplateExpression */) { + if (template.kind === 159 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); @@ -13973,7 +15471,7 @@ var ts; return args; } function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 149 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 147 /* TaggedTemplateExpression */; var typeArguments = isTaggedTemplate ? undefined : node.typeArguments; ts.forEach(typeArguments, checkSourceElement); var candidates = candidatesOutArray || []; @@ -13985,7 +15483,7 @@ var ts; var args = getEffectiveCallArguments(node); var excludeArgument; for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitiveExpression(args[i])) { + if (isContextSensitive(args[i])) { if (!excludeArgument) { excludeArgument = new Array(args.length); } @@ -14020,7 +15518,7 @@ var ts; var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - reportNoCommonSupertypeError(inferenceCandidates, node.func || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); } } else { @@ -14121,14 +15619,14 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.func.kind === 89 /* SuperKeyword */) { - var superType = checkSuperExpression(node.func); + if (node.expression.kind === 89 /* SuperKeyword */) { + var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); } return resolveUntypedCall(node); } - var funcType = checkExpression(node.func); + var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); if (apparentType === unknownType) { return resolveErrorCall(node); @@ -14153,7 +15651,7 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } function resolveNewExpression(node, candidatesOutArray) { - var expressionType = checkExpression(node.func); + var expressionType = checkExpression(node.expression); if (expressionType === anyType) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -14199,13 +15697,13 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 147 /* CallExpression */) { + if (node.kind === 145 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 148 /* NewExpression */) { + else if (node.kind === 146 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 147 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } else { @@ -14216,10 +15714,10 @@ var ts; } function checkCallExpression(node) { var signature = getResolvedSignature(node); - if (node.func.kind === 89 /* SuperKeyword */) { + if (node.expression.kind === 89 /* SuperKeyword */) { return voidType; } - if (node.kind === 148 /* NewExpression */) { + if (node.kind === 146 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 126 /* Constructor */ && declaration.kind !== 130 /* ConstructSignature */ && declaration.kind !== 134 /* ConstructorType */) { if (compilerOptions.noImplicitAny) { @@ -14234,7 +15732,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkTypeAssertion(node) { - var exprType = checkExpression(node.operand); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (fullTypeCheck && targetType !== unknownType) { var widenedType = getWidenedType(exprType, true); @@ -14261,8 +15759,8 @@ var ts; } } function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignature(func); - if (func.body.kind !== 187 /* FunctionBlock */) { + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (func.body.kind !== 163 /* Block */) { var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); var widenedType = getWidenedType(unwidenedType); if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { @@ -14310,7 +15808,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 179 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 178 /* ThrowStatement */); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!fullTypeCheck) { @@ -14319,7 +15817,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (!func.body || func.body.kind !== 187 /* FunctionBlock */) { + if (!func.body || func.body.kind !== 163 /* Block */) { return; } var bodyBlock = func.body; @@ -14331,7 +15829,8 @@ var ts; } error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } - function checkFunctionExpression(node, contextualMapper) { + function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); if (contextualMapper === identityMapper) { return anyFunctionType; } @@ -14343,7 +15842,7 @@ var ts; links.flags |= 64 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitiveExpression(node)) { + if (isContextSensitive(node)) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } if (!node.type) { @@ -14357,21 +15856,28 @@ var ts; checkSignatureDeclaration(node); } } + if (fullTypeCheck && node.kind !== 125 /* Method */) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + } return type; } - function checkFunctionExpressionBody(node) { + function checkFunctionExpressionOrObjectLiteralMethodBody(node) { + ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (node.body.kind === 187 /* FunctionBlock */) { - checkSourceElement(node.body); - } - else { - var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (node.body) { + if (node.body.kind === 163 /* Block */) { + checkSourceElement(node.body); + } + else { + var exprType = checkExpression(node.body); + if (node.type) { + checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + } + checkFunctionExpressionBodies(node.body); } - checkFunctionExpressionBodies(node.body); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -14391,12 +15897,12 @@ var ts; case 63 /* Identifier */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; - case 145 /* PropertyAccess */: + case 143 /* PropertyAccessExpression */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - case 146 /* IndexedAccess */: + case 144 /* ElementAccessExpression */: return true; - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -14405,19 +15911,19 @@ var ts; function isConstVariableReference(n) { switch (n.kind) { case 63 /* Identifier */: - case 145 /* PropertyAccess */: + case 143 /* PropertyAccessExpression */: var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; - case 146 /* IndexedAccess */: - var index = n.index; - var symbol = findSymbol(n.object); - if (symbol && index.kind === 7 /* StringLiteral */) { + case 144 /* ElementAccessExpression */: + var index = n.argumentExpression; + var symbol = findSymbol(n.expression); + if (symbol && index && index.kind === 7 /* StringLiteral */) { var name = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; } return false; - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -14433,7 +15939,19 @@ var ts; } return true; } - function checkPrefixExpression(node) { + function checkDeleteExpression(node) { + var operandType = checkExpression(node.expression); + return booleanType; + } + function checkTypeOfExpression(node) { + var operandType = checkExpression(node.expression); + return stringType; + } + function checkVoidExpression(node) { + var operandType = checkExpression(node.expression); + return undefinedType; + } + function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { case 32 /* PlusToken */: @@ -14441,12 +15959,7 @@ var ts; case 46 /* TildeToken */: return numberType; case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: return booleanType; - case 95 /* TypeOfKeyword */: - return stringType; - case 97 /* VoidKeyword */: - return undefinedType; case 37 /* PlusPlusToken */: case 38 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); @@ -14457,7 +15970,7 @@ var ts; } return unknownType; } - function checkPostfixExpression(node) { + function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -14469,7 +15982,7 @@ var ts; if (type.flags & 16384 /* Union */) { return !ts.forEach(type.types, function (t) { return !isStructuredType(t); }); } - return (type.flags & 65025 /* Structured */) !== 0; + return (type.flags & (48128 /* ObjectType */ | 512 /* TypeParameter */)) !== 0; } function isConstEnumObjectType(type) { return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); @@ -14478,10 +15991,10 @@ var ts; return (symbol.flags & 128 /* ConstEnum */) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (leftType !== unknownType && !isStructuredType(leftType)) { + if (!(leftType.flags & 1 /* Any */ || isStructuredType(leftType))) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (rightType !== unknownType && rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { + if (!(rightType.flags & 1 /* Any */ || isTypeSubtypeOf(rightType, globalFunctionType))) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -14490,7 +16003,7 @@ var ts; if (leftType !== anyType && leftType !== stringType && leftType !== numberType) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number); } - if (!isStructuredType(rightType)) { + if (!(rightType.flags & 1 /* Any */ || isStructuredType(rightType))) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -14637,8 +16150,11 @@ var ts; getNodeLinks(node).flags |= 1 /* TypeChecked */; return result; } - function checkExpression(node, contextualMapper) { - var type = checkExpressionNode(node, contextualMapper); + function checkObjectLiteralMethod(node, contextualMapper) { + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } + function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { if (contextualMapper && contextualMapper !== identityMapper) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { @@ -14646,20 +16162,34 @@ var ts; if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); } } } } + return type; + } + function checkExpression(node, contextualMapper) { + return checkExpressionOrQualifiedName(node, contextualMapper); + } + function checkExpressionOrQualifiedName(node, contextualMapper) { + var type; + if (node.kind == 120 /* QualifiedName */) { + type = checkQualifiedName(node); + } + else { + var uninstantiatedType = checkExpressionWorker(node, contextualMapper); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 145 /* PropertyAccess */ && node.parent.left === node) || (node.parent.kind === 146 /* IndexedAccess */ && node.parent.object === node) || ((node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 143 /* PropertyAccessExpression */ && node.parent.expression === node) || (node.parent.kind === 144 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 63 /* Identifier */ || node.kind === 120 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } } return type; } - function checkExpressionNode(node, contextualMapper) { + function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { case 63 /* Identifier */: return checkIdentifier(node); @@ -14674,42 +16204,46 @@ var ts; return booleanType; case 6 /* NumericLiteral */: return numberType; - case 158 /* TemplateExpression */: + case 159 /* TemplateExpression */: return checkTemplateExpression(node); case 7 /* StringLiteral */: case 9 /* NoSubstitutionTemplateLiteral */: return stringType; case 8 /* RegularExpressionLiteral */: return globalRegExpType; - case 121 /* QualifiedName */: - return checkPropertyAccess(node); - case 141 /* ArrayLiteral */: + case 141 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 142 /* ObjectLiteral */: + case 142 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 145 /* PropertyAccess */: - return checkPropertyAccess(node); - case 146 /* IndexedAccess */: + case 143 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node); + case 144 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return checkCallExpression(node); - case 149 /* TaggedTemplateExpression */: + case 147 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 150 /* TypeAssertion */: + case 148 /* TypeAssertionExpression */: return checkTypeAssertion(node); - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return checkExpression(node.expression); - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - return checkFunctionExpression(node, contextualMapper); - case 154 /* PrefixOperator */: - return checkPrefixExpression(node); - case 155 /* PostfixOperator */: - return checkPostfixExpression(node); - case 156 /* BinaryExpression */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 153 /* TypeOfExpression */: + return checkTypeOfExpression(node); + case 152 /* DeleteExpression */: + return checkDeleteExpression(node); + case 154 /* VoidExpression */: + return checkVoidExpression(node); + case 155 /* PrefixUnaryExpression */: + return checkPrefixUnaryExpression(node); + case 156 /* PostfixUnaryExpression */: + return checkPostfixUnaryExpression(node); + case 157 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 157 /* ConditionalExpression */: + case 158 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); case 161 /* OmittedExpression */: return undefinedType; @@ -14724,13 +16258,13 @@ var ts; } } function checkParameter(parameterDeclaration) { - checkVariableDeclaration(parameterDeclaration); + checkVariableOrParameterDeclaration(parameterDeclaration); if (fullTypeCheck) { checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 126 /* Constructor */ && parameterDeclaration.parent.body)) { error(parameterDeclaration, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (parameterDeclaration.flags & 8 /* Rest */) { + if (parameterDeclaration.dotDotDotToken) { if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) { error(parameterDeclaration, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } @@ -14773,9 +16307,6 @@ var ts; checkSourceElement(node.type); } if (fullTypeCheck) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { @@ -14791,7 +16322,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 189 /* InterfaceDeclaration */) { + if (node.kind === 186 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14827,16 +16358,18 @@ var ts; } } function checkPropertyDeclaration(node) { - checkVariableDeclaration(node); + if (fullTypeCheck) { + checkVariableOrParameterOrPropertyInFullTypeCheck(node); + } } function checkMethodDeclaration(node) { - checkFunctionDeclaration(node); + checkFunctionLikeDeclaration(node); } function checkConstructorDeclaration(node) { checkSignatureDeclaration(node); checkSourceElement(node.body); var symbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(symbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(symbol); } @@ -14847,17 +16380,17 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 147 /* CallExpression */ && n.func.kind === 89 /* SuperKeyword */; + return n.kind === 145 /* CallExpression */ && n.expression.kind === 89 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: - case 142 /* ObjectLiteral */: return false; + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: + case 142 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } @@ -14865,19 +16398,19 @@ var ts; if (n.kind === 91 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 186 /* FunctionDeclaration */) { + else if (n.kind !== 150 /* FunctionExpression */ && n.kind !== 184 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { return n.kind === 124 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; } - if (node.parent.baseType) { + if (ts.getClassBaseTypeNode(node.parent)) { if (containsSuperCall(node.body)) { var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 165 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 166 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14897,23 +16430,25 @@ var ts; error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } - var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; - var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var thisType = getAnnotatedAccessorType(node); - var otherType = getAnnotatedAccessorType(otherAccessor); - if (thisType && otherType) { - if (!isTypeIdenticalTo(thisType, otherType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + if (!ts.hasComputedNameButNotSymbol(node)) { + var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; + var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); + if (otherAccessor) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + } + var currentAccessorType = getAnnotatedAccessorType(node); + var otherAccessorType = getAnnotatedAccessorType(otherAccessor); + if (currentAccessorType && otherAccessorType) { + if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { + error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); + } } } + checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); } } - checkFunctionDeclaration(node); - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); + checkFunctionLikeDeclaration(node); } function checkTypeReference(node) { var type = getTypeFromTypeReferenceNode(node); @@ -14965,7 +16500,7 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 189 /* InterfaceDeclaration */) { + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 186 /* InterfaceDeclaration */) { ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */); var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); @@ -14985,7 +16520,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = n.flags; - if (n.parent.kind !== 189 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 186 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { flags |= 1 /* Export */; } @@ -14997,11 +16532,14 @@ var ts; if (!fullTypeCheck) { return; } + function getCanonicalOverload(overloads, implementation) { + var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; + return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; + } function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - var canonicalFlags = implementationSharesContainerWithFirstOverload ? getEffectiveDeclarationFlags(implementation, flagsToCheck) : getEffectiveDeclarationFlags(overloads[0], flagsToCheck); + var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; if (deviation & 1 /* Export */) { @@ -15013,15 +16551,25 @@ var ts; else if (deviation & (32 /* Private */ | 64 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 4 /* QuestionMark */) { + }); + } + } + function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { + if (someHaveQuestionToken !== allHaveQuestionToken) { + var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + ts.forEach(overloads, function (o) { + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + if (deviation) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 4 /* QuestionMark */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; + var someHaveQuestionToken = false; + var allHaveQuestionToken = true; var hasOverloads = false; var bodyDeclaration; var lastSeenNonAmbientDeclaration; @@ -15029,7 +16577,7 @@ var ts; var declarations = symbol.declarations; var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { - if (node.name && node.name.kind === 120 /* Missing */) { + if (node.name && ts.getFullWidth(node.name) === 0) { return; } var seen = false; @@ -15071,14 +16619,16 @@ var ts; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 189 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 186 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { + if (node.kind === 184 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); if (node.body && bodyDeclaration) { if (isConstructor) { multipleConstructorImplementation = true; @@ -15119,6 +16669,7 @@ var ts; } if (hasOverloads) { checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -15145,7 +16696,7 @@ var ts; return; } } - if (getDeclarationOfKind(symbol, node.kind) !== node) { + if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } var exportedDeclarationSpaces = 0; @@ -15169,14 +16720,14 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return 8388608 /* ExportType */; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */; - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: return 8388608 /* ExportType */ | 4194304 /* ExportValue */; - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: var result = 0; var target = resolveImport(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { @@ -15189,16 +16740,26 @@ var ts; } } function checkFunctionDeclaration(node) { - checkSignatureDeclaration(node); - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = getDeclarationOfKind(localSymbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); + checkFunctionLikeDeclaration(node); + if (fullTypeCheck) { + checkCollisionWithCapturedSuperVariable(node, node.name); + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); } - if (symbol.parent) { - if (getDeclarationOfKind(symbol, node.kind) === node) { - checkFunctionOrConstructorSymbol(symbol); + } + function checkFunctionLikeDeclaration(node) { + checkSignatureDeclaration(node); + if (!ts.hasComputedNameButNotSymbol(node)) { + var symbol = getSymbolOfNode(node); + var localSymbol = node.localSymbol || symbol; + var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); + if (node === firstDeclaration) { + checkFunctionOrConstructorSymbol(localSymbol); + } + if (symbol.parent) { + if (ts.getDeclarationOfKind(symbol, node.kind) === node) { + checkFunctionOrConstructorSymbol(symbol); + } } } checkSourceElement(node.body); @@ -15219,6 +16780,9 @@ var ts; } function checkBlock(node) { ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionBlock(node) || node.kind === 190 /* ModuleBlock */) { + checkFunctionExpressionBodies(node); + } } function checkCollisionWithArgumentsInGeneratedCode(node) { if (!ts.hasRestParameters(node) || ts.isInAmbientContext(node) || !node.body) { @@ -15251,10 +16815,10 @@ var ts; return; } switch (current.kind) { - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: case 125 /* Method */: - case 153 /* ArrowFunction */: + case 151 /* ArrowFunction */: case 126 /* Constructor */: if (ts.hasRestParameters(current)) { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter); @@ -15266,7 +16830,7 @@ var ts; } } function needCollisionCheckForIdentifier(node, identifier, name) { - if (!(identifier && identifier.text === name)) { + if (!identifier || identifier.text !== name) { return false; } if (node.kind === 124 /* Property */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */) { @@ -15281,10 +16845,9 @@ var ts; return true; } function checkCollisionWithCapturedThisVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_this")) { - return; + if (needCollisionCheckForIdentifier(node, name, "_this")) { + potentialThisCollisions.push(node); } - potentialThisCollisions.push(node); } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -15306,11 +16869,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 185 /* ClassDeclaration */); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } - if (enclosingClass.baseType) { + if (ts.getClassBaseTypeNode(enclosingClass)) { var isDeclaration = node.kind !== 63 /* Identifier */; if (isDeclaration) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); @@ -15324,11 +16887,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 189 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } - var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (parent.kind === 197 /* SourceFile */ && ts.isExternalModule(parent)) { + var parent = node.kind === 183 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (parent.kind === 201 /* SourceFile */ && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -15345,30 +16908,38 @@ var ts; } } } - function checkVariableDeclaration(node) { + function checkVariableOrParameterOrPropertyInFullTypeCheck(node) { + ts.Debug.assert(fullTypeCheck); checkSourceElement(node.type); - checkExportsOnMergedDeclarations(node); + if (ts.hasComputedNameButNotSymbol(node)) { + return node.initializer ? checkAndMarkExpression(node.initializer) : anyType; + } + var symbol = getSymbolOfNode(node); + var type; + if (symbol.valueDeclaration !== node) { + type = getTypeOfVariableOrParameterOrPropertyDeclaration(node); + } + else { + type = getTypeOfVariableOrParameterOrProperty(symbol); + } + if (node.initializer && !(getNodeLinks(node.initializer).flags & 1 /* TypeChecked */)) { + checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, undefined); + } + return type; + } + function checkVariableOrParameterDeclaration(node) { if (fullTypeCheck) { - var symbol = getSymbolOfNode(node); - var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); - var type; - var useTypeFromValueDeclaration = node === symbol.valueDeclaration; - if (useTypeFromValueDeclaration) { - type = typeOfValueDeclaration; - } - else { - type = getTypeOfVariableOrPropertyDeclaration(node); - } + var type = checkVariableOrParameterOrPropertyInFullTypeCheck(node); + checkExportsOnMergedDeclarations(node); if (node.initializer) { - if (!(getNodeLinks(node.initializer).flags & 1 /* TypeChecked */)) { - checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, undefined); - } checkCollisionWithConstDeclarations(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - if (!useTypeFromValueDeclaration) { + var symbol = getSymbolOfNode(node); + if (node !== symbol.valueDeclaration) { + var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); 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.declarationNameToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); } @@ -15376,7 +16947,7 @@ var ts; } } function checkVariableStatement(node) { - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkVariableOrParameterDeclaration); } function checkExpressionStatement(node) { checkExpression(node.expression); @@ -15396,7 +16967,7 @@ var ts; } function checkForStatement(node) { if (node.declarations) - ts.forEach(node.declarations, checkVariableDeclaration); + ts.forEach(node.declarations, checkVariableOrParameterDeclaration); if (node.initializer) checkExpression(node.initializer); if (node.condition) @@ -15409,7 +16980,7 @@ var ts; if (node.declarations) { if (node.declarations.length >= 1) { var decl = node.declarations[0]; - checkVariableDeclaration(decl); + checkVariableOrParameterDeclaration(decl); if (decl.type) { error(decl, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation); } @@ -15425,7 +16996,7 @@ var ts; } } var exprType = checkExpression(node.expression); - if (!isStructuredType(exprType) && exprType !== unknownType) { + if (!(exprType.flags & 1 /* Any */ || isStructuredType(exprType))) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -15443,7 +17014,7 @@ var ts; } else { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); + var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); if (checkAssignability) { checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, undefined); } @@ -15463,25 +17034,28 @@ var ts; function checkSwitchStatement(node) { var expressionType = checkExpression(node.expression); ts.forEach(node.clauses, function (clause) { - if (fullTypeCheck && clause.expression) { - var caseType = checkExpression(clause.expression); + if (fullTypeCheck && clause.kind === 194 /* CaseClause */) { + var caseClause = clause; + var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { - checkTypeAssignableTo(caseType, expressionType, clause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); } } - checkBlock(clause); + ts.forEach(clause.statements, checkSourceElement); }); } function checkLabeledStatement(node) { checkSourceElement(node.statement); } function checkThrowStatement(node) { - checkExpression(node.expression); + if (node.expression) { + checkExpression(node.expression); + } } function checkTryStatement(node) { checkBlock(node.tryBlock); - if (node.catchBlock) - checkBlock(node.catchBlock); + if (node.catchClause) + checkBlock(node.catchClause.block); if (node.finallyBlock) checkBlock(node.finallyBlock); } @@ -15566,9 +17140,10 @@ var ts; var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); var staticType = getTypeOfSymbol(symbol); - if (node.baseType) { + var baseTypeNode = ts.getClassBaseTypeNode(node); + if (baseTypeNode) { emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkTypeReference(node.baseType); + checkTypeReference(baseTypeNode); } if (type.baseTypes.length) { if (fullTypeCheck) { @@ -15576,15 +17151,16 @@ var ts; checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); var staticBaseType = getTypeOfSymbol(baseType.symbol); checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, 107455 /* Value */)) { - error(node.baseType, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + if (baseType.symbol !== resolveEntityName(node, baseTypeNode.typeName, 107455 /* Value */)) { + error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); } checkKindsOfPropertyMemberOverrides(type, baseType); } - checkExpression(node.baseType.typeName); + checkExpressionOrQualifiedName(baseTypeNode.typeName); } - if (node.implementedTypes) { - ts.forEach(node.implementedTypes, function (typeRefNode) { + var implementedTypeNodes = ts.getClassImplementedTypeNodes(node); + if (implementedTypeNodes) { + ts.forEach(implementedTypeNodes, function (typeRefNode) { checkTypeReference(typeRefNode); if (fullTypeCheck) { var t = getTypeFromTypeReferenceNode(typeRefNode); @@ -15719,7 +17295,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = getDeclarationOfKind(symbol, 189 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 186 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15735,7 +17311,7 @@ var ts; } } } - ts.forEach(node.baseTypes, checkTypeReference); + ts.forEach(ts.getInterfaceBaseTypeNodes(node), checkTypeReference); ts.forEach(node.members, checkSourceElement); if (fullTypeCheck) { checkTypeForDuplicateIndexSignatures(node); @@ -15790,7 +17366,7 @@ var ts; return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 154 /* PrefixOperator */: + case 155 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; @@ -15801,7 +17377,7 @@ var ts; case 46 /* TildeToken */: return enumIsConst ? ~value : undefined; } return undefined; - case 156 /* BinaryExpression */: + case 157 /* BinaryExpression */: if (!enumIsConst) { return undefined; } @@ -15829,11 +17405,11 @@ var ts; return undefined; case 6 /* NumericLiteral */: return +e.text; - case 151 /* ParenExpression */: + case 149 /* ParenthesizedExpression */: return enumIsConst ? evalConstant(e.expression) : undefined; case 63 /* Identifier */: - case 146 /* IndexedAccess */: - case 145 /* PropertyAccess */: + case 144 /* ElementAccessExpression */: + case 143 /* PropertyAccessExpression */: if (!enumIsConst) { return undefined; } @@ -15846,16 +17422,16 @@ var ts; propertyName = e.text; } else { - if (e.kind === 146 /* IndexedAccess */) { - if (e.index.kind !== 7 /* StringLiteral */) { + if (e.kind === 144 /* ElementAccessExpression */) { + if (e.argumentExpression === undefined || e.argumentExpression.kind !== 7 /* StringLiteral */) { return undefined; } - var enumType = getTypeOfNode(e.object); - propertyName = e.index.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.argumentExpression.text; } else { - var enumType = getTypeOfNode(e.left); - propertyName = e.right.text; + var enumType = getTypeOfNode(e.expression); + propertyName = e.name.text; } if (enumType !== currentType) { return undefined; @@ -15890,7 +17466,7 @@ var ts; checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); + var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { var enumIsConst = ts.isConst(node); @@ -15902,7 +17478,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 191 /* EnumDeclaration */) { + if (declaration.kind !== 188 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -15925,7 +17501,7 @@ var ts; var declarations = symbol.declarations; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; - if ((declaration.kind === 188 /* ClassDeclaration */ || (declaration.kind === 186 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 185 /* ClassDeclaration */ || (declaration.kind === 184 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -15960,7 +17536,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 121 /* QualifiedName */) { + while (node.kind === 120 /* QualifiedName */) { node = node.left; } return node; @@ -15970,13 +17546,13 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); var symbol = getSymbolOfNode(node); var target; - if (node.entityName) { + if (ts.isInternalModuleImportDeclaration(node)) { target = resolveImport(symbol); if (target !== unknownSymbol) { if (target.flags & 107455 /* Value */) { - var moduleName = getFirstIdentifier(node.entityName); + var moduleName = getFirstIdentifier(node.moduleReference); if (resolveEntityName(node, moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */) { - checkExpression(node.entityName); + checkExpressionOrQualifiedName(node.moduleReference); } else { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); @@ -15988,16 +17564,21 @@ var ts; } } else { - if (node.parent.kind === 197 /* SourceFile */) { + if (node.parent.kind === 201 /* SourceFile */) { target = resolveImport(symbol); } - else if (node.parent.kind === 193 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { - if (isExternalModuleNameRelative(node.externalModuleName.text)) { - error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); - target = unknownSymbol; + else if (node.parent.kind === 190 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { + if (ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { + if (isExternalModuleNameRelative(ts.getExternalModuleImportDeclarationExpression(node).text)) { + error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); + target = unknownSymbol; + } + else { + target = resolveImport(symbol); + } } else { - target = resolveImport(symbol); + target = unknownSymbol; } } else { @@ -16013,7 +17594,7 @@ var ts; } function checkExportAssignment(node) { var container = node.parent; - if (container.kind !== 197 /* SourceFile */) { + if (container.kind !== 201 /* SourceFile */) { container = container.parent; } checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container)); @@ -16053,136 +17634,138 @@ var ts; return checkTupleType(node); case 139 /* UnionType */: return checkUnionType(node); - case 140 /* ParenType */: + case 140 /* ParenthesizedType */: return checkSourceElement(node.type); - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 162 /* Block */: + case 163 /* Block */: + case 190 /* ModuleBlock */: return checkBlock(node); - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - return checkBody(node); - case 163 /* VariableStatement */: + case 164 /* VariableStatement */: return checkVariableStatement(node); - case 165 /* ExpressionStatement */: + case 166 /* ExpressionStatement */: return checkExpressionStatement(node); - case 166 /* IfStatement */: + case 167 /* IfStatement */: return checkIfStatement(node); - case 167 /* DoStatement */: + case 168 /* DoStatement */: return checkDoStatement(node); - case 168 /* WhileStatement */: + case 169 /* WhileStatement */: return checkWhileStatement(node); - case 169 /* ForStatement */: + case 170 /* ForStatement */: return checkForStatement(node); - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return checkForInStatement(node); - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 173 /* ReturnStatement */: + case 174 /* ReturnStatement */: return checkReturnStatement(node); - case 174 /* WithStatement */: + case 175 /* WithStatement */: return checkWithStatement(node); - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: return checkSwitchStatement(node); - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return checkLabeledStatement(node); - case 179 /* ThrowStatement */: + case 178 /* ThrowStatement */: return checkThrowStatement(node); - case 180 /* TryStatement */: + case 179 /* TryStatement */: return checkTryStatement(node); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return ts.Debug.fail("Checker encountered variable declaration"); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return checkClassDeclaration(node); - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 190 /* TypeAliasDeclaration */: + case 187 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: return checkImportDeclaration(node); - case 195 /* ExportAssignment */: + case 192 /* ExportAssignment */: return checkExportAssignment(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); - checkFunctionExpressionBody(node); + checkFunctionExpressionOrObjectLiteralMethodBody(node); break; case 125 /* Method */: + ts.forEach(node.parameters, checkFunctionExpressionBodies); + if (ts.isObjectLiteralMethod(node)) { + checkFunctionExpressionOrObjectLiteralMethodBody(node); + } + break; case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 174 /* WithStatement */: + case 175 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; case 123 /* Parameter */: case 124 /* Property */: - case 141 /* ArrayLiteral */: - case 142 /* ObjectLiteral */: - case 143 /* PropertyAssignment */: - case 145 /* PropertyAccess */: - case 146 /* IndexedAccess */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 149 /* TaggedTemplateExpression */: - case 150 /* TypeAssertion */: - case 151 /* ParenExpression */: - case 154 /* PrefixOperator */: - case 155 /* PostfixOperator */: - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 163 /* VariableStatement */: - case 165 /* ExpressionStatement */: - case 166 /* IfStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 171 /* ContinueStatement */: - case 172 /* BreakStatement */: - case 173 /* ReturnStatement */: - case 175 /* SwitchStatement */: - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - case 178 /* LabeledStatement */: - case 179 /* ThrowStatement */: - case 180 /* TryStatement */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 185 /* VariableDeclaration */: - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: - case 197 /* SourceFile */: + case 141 /* ArrayLiteralExpression */: + case 142 /* ObjectLiteralExpression */: + case 198 /* PropertyAssignment */: + case 143 /* PropertyAccessExpression */: + case 144 /* ElementAccessExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + case 147 /* TaggedTemplateExpression */: + case 148 /* TypeAssertionExpression */: + case 149 /* ParenthesizedExpression */: + case 153 /* TypeOfExpression */: + case 154 /* VoidExpression */: + case 152 /* DeleteExpression */: + case 155 /* PrefixUnaryExpression */: + case 156 /* PostfixUnaryExpression */: + case 157 /* BinaryExpression */: + case 158 /* ConditionalExpression */: + case 163 /* Block */: + case 190 /* ModuleBlock */: + case 164 /* VariableStatement */: + case 166 /* ExpressionStatement */: + case 167 /* IfStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 172 /* ContinueStatement */: + case 173 /* BreakStatement */: + case 174 /* ReturnStatement */: + case 176 /* SwitchStatement */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: + case 177 /* LabeledStatement */: + case 178 /* ThrowStatement */: + case 179 /* TryStatement */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: + case 183 /* VariableDeclaration */: + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: + case 200 /* EnumMember */: + case 201 /* 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; - checkBody(node); + ts.forEach(node.statements, checkSourceElement); + checkFunctionExpressionBodies(node); if (ts.isExternalModule(node)) { var symbol = getExportAssignmentSymbol(node.symbol); if (symbol && symbol.flags & 33554432 /* Import */) { @@ -16193,14 +17776,12 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) + if (emitExtends) { links.flags |= 8 /* EmitExtends */; + } links.flags |= 1 /* TypeChecked */; } } - function checkProgram() { - ts.forEach(program.getSourceFiles(), checkSourceFile); - } function getSortedDiagnostics() { ts.Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode"); if (diagnosticsModified) { @@ -16215,7 +17796,7 @@ var ts; checkSourceFile(sourceFile); return ts.filter(getSortedDiagnostics(), function (d) { return d.file === sourceFile; }); } - checkProgram(); + ts.forEach(program.getSourceFiles(), checkSourceFile); return getSortedDiagnostics(); } function getDeclarationDiagnostics(targetSourceFile) { @@ -16226,25 +17807,10 @@ var ts; function getGlobalDiagnostics() { return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; }); } - function getNodeAtPosition(sourceFile, position) { - function findChildAtPosition(parent) { - var child = ts.forEachChild(parent, function (node) { - if (position >= node.pos && position <= node.end && position >= ts.getTokenPosOfNode(node)) { - return findChildAtPosition(node); - } - }); - return child || parent; - } - if (position < sourceFile.pos) - position = sourceFile.pos; - if (position > sourceFile.end) - position = sourceFile.end; - return findChildAtPosition(sourceFile); - } function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 174 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 175 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -16280,28 +17846,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */); break; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */); } break; - case 152 /* FunctionExpression */: + case 150 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } break; - case 182 /* CatchBlock */: - if (location.variable.text) { + case 197 /* CatchClause */: + if (location.name.text) { copySymbol(location.symbol, meaning); } break; @@ -16318,16 +17884,16 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 122 /* TypeParameter */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 188 /* EnumDeclaration */: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 121 /* QualifiedName */) + while (node.parent && node.parent.kind === 120 /* QualifiedName */) node = node.parent; return node.parent && node.parent.kind === 132 /* TypeReference */; } @@ -16342,15 +17908,15 @@ var ts; case 110 /* BooleanKeyword */: return true; case 97 /* VoidKeyword */: - return node.parent.kind !== 154 /* PrefixOperator */; + return node.parent.kind !== 154 /* VoidExpression */; case 7 /* StringLiteral */: return node.parent.kind === 123 /* Parameter */; case 63 /* Identifier */: - if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - case 121 /* QualifiedName */: - ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + case 120 /* QualifiedName */: + ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 120 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; if (parent.kind === 135 /* TypeQuery */) { return false; @@ -16363,11 +17929,11 @@ var ts; return node === parent.constraint; case 124 /* Property */: case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: return node === parent.type; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: case 126 /* Constructor */: case 125 /* Method */: case 127 /* GetAccessor */: @@ -16377,59 +17943,68 @@ var ts; case 130 /* ConstructSignature */: case 131 /* IndexSignature */: return node === parent.type; - case 150 /* TypeAssertion */: + case 148 /* TypeAssertionExpression */: return node === parent.type; - case 147 /* CallExpression */: - case 148 /* NewExpression */: - return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; - case 149 /* TaggedTemplateExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 147 /* TaggedTemplateExpression */: return false; } } return false; } function isInRightSideOfImportOrExportAssignment(node) { - while (node.parent.kind === 121 /* QualifiedName */) { + while (node.parent.kind === 120 /* QualifiedName */) { node = node.parent; } - if (node.parent.kind === 194 /* ImportDeclaration */) { - return node.parent.entityName === node; + if (node.parent.kind === 191 /* ImportDeclaration */) { + return node.parent.moduleReference === node; } - if (node.parent.kind === 195 /* ExportAssignment */) { + if (node.parent.kind === 192 /* ExportAssignment */) { return node.parent.exportName === node; } return false; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 121 /* QualifiedName */ || node.parent.kind === 145 /* PropertyAccess */) && node.parent.right === node; + return (node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node) || (node.parent.kind === 143 /* PropertyAccessExpression */ && node.parent.name === node); } - function getSymbolOfEntityName(entityName) { + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 195 /* ExportAssignment */) { + if (entityName.parent.kind === 192 /* ExportAssignment */) { return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */); } - if (isInRightSideOfImportOrExportAssignment(entityName)) { - return getSymbolOfPartOfRightHandSideOfImport(entityName); + if (entityName.kind !== 143 /* PropertyAccessExpression */) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + return getSymbolOfPartOfRightHandSideOfImport(entityName); + } } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (ts.isExpression(entityName)) { + if (ts.getFullWidth(entityName) === 0) { + return undefined; + } if (entityName.kind === 63 /* Identifier */) { var meaning = 107455 /* Value */ | 33554432 /* Import */; return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === 121 /* QualifiedName */ || entityName.kind === 145 /* PropertyAccess */) { + else if (entityName.kind === 143 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { - checkPropertyAccess(entityName); + checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else { - return; + else if (entityName.kind === 120 /* QualifiedName */) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; } } else if (isTypeReferenceIdentifier(entityName)) { @@ -16447,13 +18022,13 @@ var ts; return getSymbolOfNode(node.parent); } if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 195 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); + return node.parent.kind === 192 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImport(node); } switch (node.kind) { case 63 /* Identifier */: - case 145 /* PropertyAccess */: - case 121 /* QualifiedName */: - return getSymbolOfEntityName(node); + case 143 /* PropertyAccessExpression */: + case 120 /* QualifiedName */: + return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 91 /* ThisKeyword */: case 89 /* SuperKeyword */: var type = checkExpression(node); @@ -16465,14 +18040,14 @@ var ts; } return undefined; case 7 /* StringLiteral */: - if (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node) { - var importSymbol = getSymbolOfNode(node.parent); + if (ts.isExternalModuleImportDeclaration(node.parent.parent) && ts.getExternalModuleImportDeclarationExpression(node.parent.parent) === node) { + var importSymbol = getSymbolOfNode(node.parent.parent); var moduleType = getTypeOfSymbol(importSymbol); return moduleType ? moduleType.symbol : undefined; } case 6 /* NumericLiteral */: - if (node.parent.kind == 146 /* IndexedAccess */ && node.parent.index === node) { - var objectType = checkExpression(node.parent.object); + if (node.parent.kind == 144 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; var apparentType = getApparentType(objectType); @@ -16485,7 +18060,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 144 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 199 /* ShorthandPropertyAssignment */) { return resolveEntityName(location, location.name, 107455 /* Value */); } return undefined; @@ -16559,7 +18134,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 197 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 201 /* SourceFile */; } function isNodeDescendentOf(node, ancestor) { while (node) { @@ -16592,7 +18167,7 @@ var ts; function getLocalNameForSymbol(symbol, location) { var node = location; while (node) { - if ((node.kind === 192 /* ModuleDeclaration */ || node.kind === 191 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { + if ((node.kind === 189 /* ModuleDeclaration */ || node.kind === 188 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { return getLocalNameOfContainer(node); } node = node.parent; @@ -16616,13 +18191,13 @@ var ts; return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined; } function isTopLevelValueImportWithEntityName(node) { - if (node.parent.kind !== 197 /* SourceFile */ || !node.entityName) { + if (node.parent.kind !== 201 /* SourceFile */ || !ts.isInternalModuleImportDeclaration(node)) { return false; } return isImportResolvedToValue(getSymbolOfNode(node)); } - function hasSemanticErrors() { - return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0; + function hasSemanticErrors(sourceFile) { + return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0; } function isEmitBlocked(sourceFile) { return program.getDiagnostics(sourceFile).length !== 0 || hasEarlyErrors(sourceFile) || (compilerOptions.noEmitOnError && getDiagnostics(sourceFile).length !== 0); @@ -16667,15 +18242,15 @@ var ts; if (symbol && (symbol.flags & 8 /* EnumMember */)) { var declaration = symbol.valueDeclaration; var constantValue; - if (declaration.kind === 196 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + if (declaration.kind === 200 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { return constantValue; } } return undefined; } - function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { - var symbol = getSymbolOfNode(location); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* CallSignature */ | 262144 /* ConstructSignature */)) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); + function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { + var symbol = getSymbolOfNode(declaration); + var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* CallSignature */ | 262144 /* ConstructSignature */)) ? getTypeOfSymbol(symbol) : unknownType; getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -16696,7 +18271,7 @@ var ts; isEmitBlocked: isEmitBlocked, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, - writeTypeAtLocation: writeTypeAtLocation, + writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, @@ -16705,7 +18280,6 @@ var ts; } function invokeEmitter(targetSourceFile) { var resolver = createResolver(); - checkProgram(); return ts.emitFiles(resolver, targetSourceFile); } function initializeTypeChecker() { @@ -16738,123 +18312,6 @@ var ts; ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); var ts; -(function (ts) { - var TextSpan = (function () { - function TextSpan(start, length) { - ts.Debug.assert(start >= 0, "start"); - ts.Debug.assert(length >= 0, "length"); - this._start = start; - this._length = length; - } - TextSpan.prototype.toJSON = function (key) { - return { start: this._start, length: this._length }; - }; - TextSpan.prototype.start = function () { - return this._start; - }; - TextSpan.prototype.length = function () { - return this._length; - }; - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = Math.max(this._start, span._start); - var overlapEnd = Math.min(this.end(), span.end()); - return overlapStart < overlapEnd; - }; - TextSpan.prototype.overlap = function (span) { - var overlapStart = Math.max(this._start, span._start); - var overlapEnd = Math.min(this.end(), span.end()); - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - return undefined; - }; - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - TextSpan.prototype.intersection = function (span) { - var intersectStart = Math.max(this._start, span._start); - var intersectEnd = Math.min(this.end(), span.end()); - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - return undefined; - }; - TextSpan.fromBounds = function (start, end) { - ts.Debug.assert(start >= 0); - ts.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - ts.TextSpan = TextSpan; - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - ts.Debug.assert(newLength >= 0, "newLength"); - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - TextChangeRange.prototype.newSpan = function () { - return new TextSpan(this.span().start(), this.newLength()); - }; - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return new TextChangeRange(TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TextSpan(0, 0), 0); - return TextChangeRange; - })(); - ts.TextChangeRange = TextChangeRange; -})(ts || (ts = {})); -var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { @@ -16874,10 +18331,10 @@ var ts; } function autoCollapse(node) { switch (node.kind) { - case 193 /* ModuleBlock */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: + case 190 /* ModuleBlock */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: return false; } return true; @@ -16889,42 +18346,42 @@ var ts; return; } switch (n.kind) { - case 162 /* Block */: - var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); - if (parent.kind === 167 /* DoStatement */ || parent.kind === 170 /* ForInStatement */ || parent.kind === 169 /* ForStatement */ || parent.kind === 166 /* IfStatement */ || parent.kind === 168 /* WhileStatement */ || parent.kind === 174 /* WithStatement */) { - addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + case 163 /* Block */: + if (!ts.isFunctionBlock(n)) { + var parent = n.parent; + var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); + if (parent.kind === 168 /* DoStatement */ || parent.kind === 171 /* ForInStatement */ || parent.kind === 170 /* ForStatement */ || parent.kind === 167 /* IfStatement */ || parent.kind === 169 /* WhileStatement */ || parent.kind === 175 /* WithStatement */ || parent.kind === 197 /* CatchClause */) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + } + else { + var span = ts.TextSpan.fromBounds(n.getStart(), n.end); + elements.push({ + textSpan: span, + hintSpan: span, + bannerText: collapseText, + autoCollapse: autoCollapse(n) + }); + } + break; } - else { - var span = ts.TextSpan.fromBounds(n.getStart(), n.end); - elements.push({ - textSpan: span, - hintSpan: span, - bannerText: collapseText, - autoCollapse: autoCollapse(n) - }); - } - break; - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 190 /* ModuleBlock */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 142 /* ObjectLiteral */: - case 175 /* SwitchStatement */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: + case 142 /* ObjectLiteralExpression */: + case 176 /* SwitchStatement */: var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; - case 141 /* ArrayLiteral */: + case 141 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 17 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 18 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -16952,14 +18409,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: do { current = current.parent; - } while (current.kind === 192 /* ModuleDeclaration */); - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: - case 186 /* FunctionDeclaration */: + } while (current.kind === 189 /* ModuleDeclaration */); + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: + case 186 /* InterfaceDeclaration */: + case 184 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -16970,10 +18427,10 @@ var ts; var childNodes = []; for (var i = 0, n = nodes.length; i < n; i++) { var node = nodes[i]; - if (node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */ || node.kind === 189 /* InterfaceDeclaration */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 186 /* FunctionDeclaration */) { + if (node.kind === 185 /* ClassDeclaration */ || node.kind === 188 /* EnumDeclaration */ || node.kind === 186 /* InterfaceDeclaration */ || node.kind === 189 /* ModuleDeclaration */ || node.kind === 184 /* FunctionDeclaration */) { childNodes.push(node); } - else if (node.kind === 163 /* VariableStatement */) { + else if (node.kind === 164 /* VariableStatement */) { childNodes.push.apply(childNodes, node.declarations); } } @@ -17006,17 +18463,17 @@ var ts; for (var i = 0, n = nodes.length; i < n; i++) { var node = nodes[i]; switch (node.kind) { - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: + case 186 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -17027,12 +18484,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 186 /* FunctionDeclaration */) { - if (functionDeclaration.body && functionDeclaration.body.kind === 187 /* FunctionBlock */) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 186 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 184 /* FunctionDeclaration */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 163 /* Block */) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 184 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } - if (functionDeclaration.parent.kind !== 187 /* FunctionBlock */) { + if (!ts.isFunctionBlock(functionDeclaration.parent)) { return true; } } @@ -17095,7 +18552,7 @@ var ts; return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); case 131 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 196 /* EnumMember */: + case 200 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); case 129 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); @@ -17103,9 +18560,9 @@ var ts; return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); case 124 /* Property */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: if (ts.isConst(node)) { return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.constElement); } @@ -17145,17 +18602,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: return createSourceFileItem(node); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: return createClassItem(node); - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: return createEnumItem(node); - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return createModuleItem(node); - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -17165,7 +18622,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 189 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -17177,7 +18634,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.name && node.body && node.body.kind === 187 /* FunctionBlock */) { + if (node.name && node.body && node.body.kind === 163 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -17198,28 +18655,34 @@ var ts; var constructor = ts.forEach(node.members, function (member) { return member.kind === 126 /* Constructor */ && member; }); - var nodes = constructor ? node.members.concat(constructor.parameters) : node.members; + var nodes = removeComputedProperties(node); + if (constructor) { + nodes.push.apply(nodes, constructor.parameters); + } var childItems = getItemsWorker(sortNodes(nodes), createChildItem); } return getNavigationBarItem(node.name.text, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createEnumItem(node) { - var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createIterfaceItem(node) { - var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem); return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } } + function removeComputedProperties(node) { + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 121 /* ComputedPropertyName */; }); + } function getInnermostModule(node) { - while (node.body.kind === 192 /* ModuleDeclaration */) { + while (node.body.kind === 189 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 197 /* SourceFile */ ? ts.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : ts.TextSpan.fromBounds(node.getStart(), node.getEnd()); + return node.kind === 201 /* SourceFile */ ? ts.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : ts.TextSpan.fromBounds(node.getStart(), node.getEnd()); } function getTextOfNode(node) { return ts.getTextOfNodeFromSourceText(sourceFile.text, node); @@ -17233,6 +18696,12 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + var ArgumentListKind; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + })(ArgumentListKind || (ArgumentListKind = {})); function getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken) { var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); if (!startingToken) { @@ -17252,7 +18721,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 147 /* CallExpression */ || node.parent.kind === 148 /* NewExpression */) { + if (node.parent.kind === 145 /* CallExpression */ || node.parent.kind === 146 /* NewExpression */) { var callExpression = node.parent; if (node.kind === 23 /* LessThanToken */ || node.kind === 15 /* OpenParenToken */) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -17280,24 +18749,24 @@ var ts; }; } } - else if (node.kind === 9 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 9 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 147 /* TaggedTemplateExpression */) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 10 /* TemplateHead */ && node.parent.parent.kind === 149 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* TemplateHead */ && node.parent.parent.kind === 147 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 158 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 159 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 159 /* TemplateSpan */ && node.parent.parent.parent.kind === 149 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 162 /* TemplateSpan */ && node.parent.parent.parent.kind === 147 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 158 /* TemplateExpression */); - if (node.kind === 12 /* TemplateTail */ && position >= node.getEnd() && !ts.isUnterminatedTemplateEnd(node)) { + ts.Debug.assert(templateExpression.kind === 159 /* TemplateExpression */); + if (node.kind === 12 /* TemplateTail */ && position >= node.getEnd() && !node.isUnterminated) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -17338,17 +18807,17 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 158 /* TemplateExpression */) { + if (template.kind === 159 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); - if (lastSpan.literal.kind === 120 /* Missing */) { + if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); } } return new ts.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 197 /* SourceFile */; n = n.parent) { - if (n.kind === 187 /* FunctionBlock */) { + for (var n = node; n.kind !== 201 /* SourceFile */; n = n.parent) { + if (ts.isFunctionBlock(n)) { return undefined; } if (n.pos < n.parent.pos || n.end > n.parent.end) { @@ -17387,7 +18856,7 @@ var ts; var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTarget); + var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget); var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeInfoResolver, callTargetSymbol, undefined, undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; @@ -17438,7 +18907,7 @@ var ts; }; function createSignatureHelpParameterForParameter(parameter) { var displayParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = !!(parameter.valueDeclaration.flags & 4 /* QuestionMark */); + var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), @@ -17532,24 +19001,13 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 199 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 203 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); return syntaxList; } ts.findContainingList = findContainingList; - function findListItemIndexContainingPosition(list, position) { - ts.Debug.assert(list.kind === 199 /* SyntaxList */); - var children = list.getChildren(); - for (var i = 0; i < children.length; i++) { - if (children[i].pos <= position && children[i].end > position) { - return i; - } - } - return -1; - } - ts.findListItemIndexContainingPosition = findListItemIndexContainingPosition; function getTouchingWord(sourceFile, position) { return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }); } @@ -17647,7 +19105,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 197 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 201 /* SourceFile */); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -17663,23 +19121,38 @@ var ts; } ts.findPrecedingToken = findPrecedingToken; function nodeHasTokens(n) { - if (n.kind === 0 /* Unknown */) { - return false; - } return n.getWidth() !== 0; } + function getNodeModifiers(node) { + var flags = node.flags; + var result = []; + if (flags & 32 /* Private */) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 64 /* Protected */) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 16 /* Public */) + result.push(ts.ScriptElementKindModifier.publicMemberModifier); + if (flags & 128 /* Static */) + result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 1 /* Export */) + result.push(ts.ScriptElementKindModifier.exportedModifier); + if (ts.isInAmbientContext(node)) + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; + } + ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 132 /* TypeReference */ || node.kind === 147 /* CallExpression */) { + if (node.kind === 132 /* TypeReference */ || node.kind === 145 /* CallExpression */) { return node.typeArguments; } - if (ts.isAnyFunction(node) || node.kind === 188 /* ClassDeclaration */ || node.kind === 189 /* InterfaceDeclaration */) { + if (ts.isAnyFunction(node) || node.kind === 185 /* ClassDeclaration */ || node.kind === 186 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 1 /* FirstToken */ && n.kind <= 119 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 119 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -17697,406 +19170,204 @@ var ts; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { - return (node.getStart() < position && position < node.getEnd()) || (ts.isUnterminatedTemplateEnd(node) && position === node.getEnd()); + return ts.isTemplateLiteralKind(node.kind) && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var SmartIndenter; - (function (SmartIndenter) { - function getIndentation(position, sourceFile, options) { - if (position > sourceFile.text.length) { - return 0; - } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken) { - return 0; - } - if ((precedingToken.kind === 7 /* StringLiteral */ || precedingToken.kind === 8 /* RegularExpressionLiteral */) && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return 0; - } - var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line; - if (precedingToken.kind === 22 /* CommaToken */ && precedingToken.parent.kind !== 156 /* BinaryExpression */) { - var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; - } - } - var previous; - var current = precedingToken; - var currentStart; - var indentationDelta; - while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; - } - break; - } - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; - } - previous = current; - current = current.parent; - } - if (!current) { - return 0; - } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); - } - SmartIndenter.getIndentation = getIndentation; - function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { - var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); - } - SmartIndenter.getIndentationForNode = getIndentationForNode; - function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var parent = current.parent; - var parentStart; - while (parent) { - var useActualIndentation = true; - if (ignoreActualIndentationRange) { - var start = current.getStart(sourceFile); - useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; - } - if (useActualIndentation) { - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - parentStart = getParentStart(parent, current, sourceFile); - var parentAndChildShareLine = parentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); - if (useActualIndentation) { - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; - } - current = parent; - currentStart = parentStart; - parent = current.parent; - } - return indentationDelta; - } - function getParentStart(parent, child, sourceFile) { - var containingList = getContainingList(child, sourceFile); - if (containingList) { - return sourceFile.getLineAndCharacterFromPosition(containingList.pos); - } - return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile)); - } - function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { - var commaItemInfo = ts.findListItemInfo(commaToken); - ts.Debug.assert(commaItemInfo && commaItemInfo.listItemIndex > 0); - return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); - } - function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { - var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 197 /* SourceFile */ || !parentAndChildShareLine); - if (!useActualIndentation) { - return -1; - } - return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); - } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { - var nextToken = ts.findNextToken(precedingToken, current); - if (!nextToken) { + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) { return false; } - if (nextToken.kind === 13 /* OpenBraceToken */) { - return true; - } - else if (nextToken.kind === 14 /* CloseBraceToken */) { - var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; - } - return false; } - function getStartLineAndCharacterForNode(n, sourceFile) { - return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); - } - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } - function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 166 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 74 /* ElseKeyword */, sourceFile); - ts.Debug.assert(elseKeyword !== undefined); - var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; - return elseKeywordStartLine === childStartLine; - } - return false; - } - SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getContainingList(node, sourceFile) { - if (node.parent) { - switch (node.parent.kind) { - case 132 /* TypeReference */: - if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 142 /* ObjectLiteral */: - return node.parent.properties; - case 141 /* ArrayLiteral */: - return node.parent.elements; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 125 /* Method */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - var start = node.getStart(sourceFile); - if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; - case 148 /* NewExpression */: - case 147 /* CallExpression */: - var start = node.getStart(sourceFile); - if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; - } - } - return undefined; - } - function getActualIndentationForListItem(node, sourceFile, options) { - var containingList = getContainingList(node, sourceFile); - return containingList ? getActualIndentationFromList(containingList) : -1; - function getActualIndentationFromList(list) { - var index = ts.indexOf(list, node); - return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; + else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) { + return false; } } - function deriveActualIndentationFromList(list, index, sourceFile, options) { - ts.Debug.assert(index >= 0 && index < list.length); - var node = list[index]; - var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); - for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 22 /* CommaToken */) { - continue; - } - var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line; - if (prevEndLine !== lineAndCharacter.line) { - return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); - } - lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); - } - return -1; - } - function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { - var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1); - return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); - } - function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { - var column = 0; - for (var pos = startPos; pos < endPos; ++pos) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpace(ch)) { - return column; - } - if (ch === 9 /* tab */) { - column += options.TabSize + (column % options.TabSize); - } - else { - column++; - } - } - return column; - } - SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 141 /* ArrayLiteral */: - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: - case 142 /* ObjectLiteral */: - case 136 /* TypeLiteral */: - case 175 /* SwitchStatement */: - case 177 /* DefaultClause */: - case 176 /* CaseClause */: - case 151 /* ParenExpression */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: - case 163 /* VariableStatement */: - case 185 /* VariableDeclaration */: - case 195 /* ExportAssignment */: - case 173 /* ReturnStatement */: - return true; - } - return false; - } - function shouldIndentChildNode(parent, child) { - if (nodeContentIsAlwaysIndented(parent)) { - return true; - } - switch (parent) { - case 167 /* DoStatement */: - case 168 /* WhileStatement */: - case 170 /* ForInStatement */: - case 169 /* ForStatement */: - case 166 /* IfStatement */: - return child !== 162 /* Block */; - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 125 /* Method */: - case 153 /* ArrowFunction */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return child !== 187 /* FunctionBlock */; - default: - return false; - } - } - SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = children[children.length - 1]; - if (last.kind === expectedLastToken) { - return true; - } - else if (last.kind === 21 /* SemicolonToken */ && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; - } - } - return false; - } - function isCompletedNode(n, sourceFile) { - switch (n.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 142 /* ObjectLiteral */: - case 162 /* Block */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 175 /* SwitchStatement */: - return nodeEndsWith(n, 14 /* CloseBraceToken */, sourceFile); - case 151 /* ParenExpression */: - case 129 /* CallSignature */: - case 147 /* CallExpression */: - case 130 /* ConstructSignature */: - return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 125 /* Method */: - case 153 /* ArrowFunction */: - return !n.body || isCompletedNode(n.body, sourceFile); - case 192 /* ModuleDeclaration */: - return n.body && isCompletedNode(n.body, sourceFile); - case 166 /* IfStatement */: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); - } - return isCompletedNode(n.thenStatement, sourceFile); - case 165 /* ExpressionStatement */: - return isCompletedNode(n.expression, sourceFile); - case 141 /* ArrayLiteral */: - return nodeEndsWith(n, 18 /* CloseBracketToken */, sourceFile); - case 120 /* Missing */: - return false; - case 176 /* CaseClause */: - case 177 /* DefaultClause */: - return false; - case 168 /* WhileStatement */: - return isCompletedNode(n.statement, sourceFile); - case 167 /* DoStatement */: - var hasWhileKeyword = ts.findChildOfKind(n, 98 /* WhileKeyword */, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); - } - return isCompletedNode(n.statement, sourceFile); - default: - return true; - } - } - })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); - })(formatting = ts.formatting || (ts.formatting = {})); + } + return true; + } + ts.compareDataObjects = compareDataObjects; })(ts || (ts = {})); var ts; (function (ts) { - var formatting; - (function (formatting) { - var internedTabsIndentation; - var internedSpacesIndentation; - function getIndentationString(indentation, options) { - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; - var tabString; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); - } - else { - tabString = internedTabsIndentation[tabs]; - } - return spaces ? tabString + repeat(" ", spaces) : tabString; + function isFirstDeclarationOfSymbolParameter(symbol) { + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 123 /* Parameter */; + } + ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; + var displayPartWriter = getDisplayPartWriter(); + function getDisplayPartWriter() { + var displayParts; + var lineStart; + var indent; + resetWriter(); + return { + displayParts: function () { return displayParts; }, + writeKeyword: function (text) { return writeKind(text, 5 /* keyword */); }, + writeOperator: function (text) { return writeKind(text, 12 /* operator */); }, + writePunctuation: function (text) { return writeKind(text, 15 /* punctuation */); }, + writeSpace: function (text) { return writeKind(text, 16 /* space */); }, + writeStringLiteral: function (text) { return writeKind(text, 8 /* stringLiteral */); }, + writeParameter: function (text) { return writeKind(text, 13 /* parameterName */); }, + writeSymbol: writeSymbol, + writeLine: writeLine, + increaseIndent: function () { + indent++; + }, + decreaseIndent: function () { + indent--; + }, + clear: resetWriter, + trackSymbol: function () { } - else { - var spacesString; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; + }; + function writeIndent() { + if (lineStart) { + var indentString = ts.getIndentString(indent); + if (indentString) { + displayParts.push(displayPart(indentString, 16 /* space */)); } - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; - } - else { - spacesString = internedSpacesIndentation[quotient]; - } - return remainder ? spacesString + repeat(" ", remainder) : spacesString; - } - function repeat(value, count) { - var s = ""; - for (var i = 0; i < count; ++i) { - s += value; - } - return s; + lineStart = false; } } - formatting.getIndentationString = getIndentationString; - })(formatting = ts.formatting || (ts.formatting = {})); + function writeKind(text, kind) { + writeIndent(); + displayParts.push(displayPart(text, kind)); + } + function writeSymbol(text, symbol) { + writeIndent(); + displayParts.push(symbolPart(text, symbol)); + } + function writeLine() { + displayParts.push(lineBreakPart()); + lineStart = true; + } + function resetWriter() { + displayParts = []; + lineStart = true; + indent = 0; + } + } + function symbolPart(text, symbol) { + return displayPart(text, displayPartKind(symbol), symbol); + function displayPartKind(symbol) { + var flags = symbol.flags; + if (flags & 3 /* Variable */) { + return isFirstDeclarationOfSymbolParameter(symbol) ? 13 /* parameterName */ : 9 /* localName */; + } + else if (flags & 4 /* Property */) { + return 14 /* propertyName */; + } + else if (flags & 32768 /* GetAccessor */) { + return 14 /* propertyName */; + } + else if (flags & 65536 /* SetAccessor */) { + return 14 /* propertyName */; + } + else if (flags & 8 /* EnumMember */) { + return 19 /* enumMemberName */; + } + else if (flags & 16 /* Function */) { + return 20 /* functionName */; + } + else if (flags & 32 /* Class */) { + return 1 /* className */; + } + else if (flags & 64 /* Interface */) { + return 4 /* interfaceName */; + } + else if (flags & 384 /* Enum */) { + return 2 /* enumName */; + } + else if (flags & 1536 /* Module */) { + return 11 /* moduleName */; + } + else if (flags & 8192 /* Method */) { + return 10 /* methodName */; + } + else if (flags & 1048576 /* TypeParameter */) { + return 18 /* typeParameterName */; + } + else if (flags & 2097152 /* TypeAlias */) { + return 0 /* aliasName */; + } + else if (flags & 33554432 /* Import */) { + return 0 /* aliasName */; + } + return 17 /* text */; + } + } + ts.symbolPart = symbolPart; + function displayPart(text, kind, symbol) { + return { + text: text, + kind: ts.SymbolDisplayPartKind[kind] + }; + } + ts.displayPart = displayPart; + function spacePart() { + return displayPart(" ", 16 /* space */); + } + ts.spacePart = spacePart; + function keywordPart(kind) { + return displayPart(ts.tokenToString(kind), 5 /* keyword */); + } + ts.keywordPart = keywordPart; + function punctuationPart(kind) { + return displayPart(ts.tokenToString(kind), 15 /* punctuation */); + } + ts.punctuationPart = punctuationPart; + function operatorPart(kind) { + return displayPart(ts.tokenToString(kind), 12 /* operator */); + } + ts.operatorPart = operatorPart; + function textPart(text) { + return displayPart(text, 17 /* text */); + } + ts.textPart = textPart; + function lineBreakPart() { + return displayPart("\n", 6 /* lineBreak */); + } + ts.lineBreakPart = lineBreakPart; + function mapToDisplayParts(writeDisplayParts) { + writeDisplayParts(displayPartWriter); + var result = displayPartWriter.displayParts(); + displayPartWriter.clear(); + return result; + } + ts.mapToDisplayParts = mapToDisplayParts; + function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + }); + } + ts.typeToDisplayParts = typeToDisplayParts; + function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + return mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); + }); + } + ts.symbolToDisplayParts = symbolToDisplayParts; + function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + }); + } + ts.signatureToDisplayParts = signatureToDisplayParts; })(ts || (ts = {})); var ts; (function (ts) { var formatting; (function (formatting) { var scanner = ts.createScanner(2 /* Latest */, false); + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -18155,7 +19426,7 @@ var ts; savedPos = scanner.getStartPos(); } function shouldRescanGreaterThanToken(container) { - if (container.kind !== 156 /* BinaryExpression */) { + if (container.kind !== 157 /* BinaryExpression */) { return false; } switch (container.operator) { @@ -18172,7 +19443,7 @@ var ts; return container.kind === 8 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 159 /* TemplateSpan */; + return container.kind === 11 /* TemplateMiddle */ || container.kind === 12 /* TemplateTail */; } function startsWithSlashToken(t) { return t === 35 /* SlashToken */ || t === 55 /* SlashEqualsToken */; @@ -18187,7 +19458,7 @@ var ts; } var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { - return lastTokenInfo; + return fixTokenKind(lastTokenInfo, n); } if (scanner.getStartPos() !== savedPos) { ts.Debug.assert(lastTokenInfo !== undefined); @@ -18236,17 +19507,24 @@ var ts; break; } } - return lastTokenInfo = { + lastTokenInfo = { leadingTrivia: leadingTrivia, trailingTrivia: trailingTrivia, token: token }; + return fixTokenKind(lastTokenInfo, n); } function isOnToken() { var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function fixTokenKind(tokenInfo, container) { + if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { + tokenInfo.token.kind = container.kind; + } + return tokenInfo; + } } formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); @@ -18330,6 +19608,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (FormattingRequestKind) { + FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; + FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; + FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; + FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; + FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; + })(formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + var FormattingRequestKind = formatting.FormattingRequestKind; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -18349,6 +19641,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(formatting.RuleAction || (formatting.RuleAction = {})); + var RuleAction = formatting.RuleAction; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -18378,6 +19683,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(formatting.RuleFlags || (formatting.RuleFlags = {})); + var RuleFlags = formatting.RuleFlags; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -18605,23 +19921,23 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 169 /* ForStatement */; + return context.contextNode.kind === 170 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 156 /* BinaryExpression */: - case 157 /* ConditionalExpression */: + case 157 /* BinaryExpression */: + case 158 /* ConditionalExpression */: return true; - case 194 /* ImportDeclaration */: - case 185 /* VariableDeclaration */: + case 191 /* ImportDeclaration */: + case 183 /* VariableDeclaration */: case 123 /* Parameter */: - case 196 /* EnumMember */: + case 200 /* EnumMember */: case 124 /* Property */: return context.currentTokenSpan.kind === 51 /* EqualsToken */ || context.nextTokenSpan.kind === 51 /* EqualsToken */; - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return context.currentTokenSpan.kind === 84 /* InKeyword */ || context.nextTokenSpan.kind === 84 /* InKeyword */; } return false; @@ -18652,29 +19968,27 @@ var ts; return true; } switch (node.kind) { - case 162 /* Block */: - case 175 /* SwitchStatement */: - case 142 /* ObjectLiteral */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: + case 163 /* Block */: + case 176 /* SwitchStatement */: + case 142 /* ObjectLiteralExpression */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: case 129 /* CallSignature */: - case 152 /* FunctionExpression */: + case 150 /* FunctionExpression */: case 126 /* Constructor */: - case 153 /* ArrowFunction */: - case 189 /* InterfaceDeclaration */: + case 151 /* ArrowFunction */: + case 186 /* InterfaceDeclaration */: return true; } return false; @@ -18684,56 +19998,55 @@ var ts; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: case 136 /* TypeLiteral */: - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 188 /* ClassDeclaration */: - case 192 /* ModuleDeclaration */: - case 191 /* EnumDeclaration */: - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 187 /* FunctionBlock */: - case 193 /* ModuleBlock */: - case 175 /* SwitchStatement */: + case 185 /* ClassDeclaration */: + case 189 /* ModuleDeclaration */: + case 188 /* EnumDeclaration */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: + case 176 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 166 /* IfStatement */: - case 175 /* SwitchStatement */: - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 168 /* WhileStatement */: - case 180 /* TryStatement */: - case 167 /* DoStatement */: - case 174 /* WithStatement */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 167 /* IfStatement */: + case 176 /* SwitchStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 169 /* WhileStatement */: + case 179 /* TryStatement */: + case 168 /* DoStatement */: + case 175 /* WithStatement */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 142 /* ObjectLiteral */; + return context.contextNode.kind === 142 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 147 /* CallExpression */; + return context.contextNode.kind === 145 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 148 /* NewExpression */; + return context.contextNode.kind === 146 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -18745,7 +20058,7 @@ var ts; return context.formattingRequestKind != 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 192 /* ModuleDeclaration */; + return context.contextNode.kind === 189 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 136 /* TypeLiteral */; @@ -18756,16 +20069,16 @@ var ts; } switch (parent.kind) { case 132 /* TypeReference */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: case 125 /* Method */: case 129 /* CallSignature */: case 130 /* ConstructSignature */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return true; default: return false; @@ -18775,7 +20088,7 @@ var ts; return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 97 /* VoidKeyword */ && context.currentTokenParent.kind === 154 /* PrefixOperator */; + return context.currentTokenSpan.kind === 97 /* VoidKeyword */ && context.currentTokenParent.kind === 154 /* VoidExpression */; }; return Rules; })(); @@ -18965,7 +20278,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 1 /* FirstToken */; token <= 119 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 119 /* LastToken */; token++) { result.push(token); } return result; @@ -19026,27 +20339,6 @@ var ts; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var TokenSpan = (function (_super) { - __extends(TokenSpan, _super); - function TokenSpan(kind, start, length) { - _super.call(this, start, length); - this.kind = kind; - } - return TokenSpan; - })(ts.TextSpan); - formatting.TokenSpan = TokenSpan; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); var ts; (function (ts) { var formatting; @@ -19137,6 +20429,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterFromPosition(position).line; ts.Debug.assert(line >= 2); @@ -19195,19 +20491,20 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 162 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 197 /* SourceFile */: - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: + return body && body.kind === 163 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 201 /* SourceFile */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); + case 197 /* CatchClause */: + return ts.rangeContainsRange(parent.block.statements, node); } return false; } @@ -19228,7 +20525,7 @@ var ts; if (!errors.length) { return rangeHasNoErrors; } - var sorted = errors.filter(function (d) { return d.isParseError && ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }).sort(function (e1, e2) { return e1.start - e2.start; }); + var sorted = errors.filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }).sort(function (e1, e2) { return e1.start - e2.start; }); if (!sorted.length) { return rangeHasNoErrors; } @@ -19260,8 +20557,25 @@ var ts; var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); return precedingToken ? precedingToken.end : enclosingNode.pos; } + function getOwnOrInheritedDelta(n, options, sourceFile) { + var previousLine = -1 /* Unknown */; + var childKind = 0 /* Unknown */; + while (n) { + var line = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)).line; + if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + break; + } + if (formatting.SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { + return options.IndentSize; + } + previousLine = line; + childKind = n.kind; + n = n.parent; + } + return 0; + } function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.getSyntacticDiagnostics(), originalRange); + var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); var enclosingNode = findEnclosingNode(originalRange, sourceFile); var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); @@ -19274,7 +20588,7 @@ var ts; formattingScanner.advance(); if (formattingScanner.isOnToken()) { var startLine = sourceFile.getLineAndCharacterFromPosition(enclosingNode.getStart(sourceFile)).line; - var delta = formatting.SmartIndenter.shouldIndentChildNode(enclosingNode.kind, 0 /* Unknown */) ? options.IndentSize : 0; + var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta); } formattingScanner.close(); @@ -19299,7 +20613,7 @@ var ts; var indentation = inheritedIndentation; if (indentation === -1 /* Unknown */) { if (isSomeBlock(node.kind)) { - if (isSomeBlock(parent.kind) || parent.kind === 197 /* SourceFile */ || parent.kind === 176 /* CaseClause */ || parent.kind === 177 /* DefaultClause */) { + if (isSomeBlock(parent.kind) || parent.kind === 201 /* SourceFile */ || parent.kind === 194 /* CaseClause */ || parent.kind === 195 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -19399,7 +20713,7 @@ var ts; if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { return inheritedIndentation; } - if (child.kind === 120 /* Missing */) { + if (child.getFullWidth() === 0) { return inheritedIndentation; } while (formattingScanner.isOnToken()) { @@ -19413,7 +20727,7 @@ var ts; return inheritedIndentation; } if (ts.isToken(child)) { - var tokenInfo = formattingScanner.readTokenInfo(node); + var tokenInfo = formattingScanner.readTokenInfo(child); ts.Debug.assert(tokenInfo.token.end === child.end); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; @@ -19469,13 +20783,19 @@ var ts; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterFromPosition(currentTokenInfo.token.pos); if (isTokenInRange) { + var rangeHasError = rangeContainsError(currentTokenInfo.token); var prevStartLine = previousRangeStartLine; lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); - if (lineAdded !== undefined) { - indentToken = lineAdded; + if (rangeHasError) { + indentToken = false; } else { - indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine; + if (lineAdded !== undefined) { + indentToken = lineAdded; + } + else { + indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine; + } } } if (currentTokenInfo.trailingTrivia) { @@ -19553,18 +20873,17 @@ var ts; if (rule) { applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (rule.Operation.Action & (2 /* Space */ | 8 /* Delete */) && currentStartLine !== previousStartLine) { + lineAdded = false; if (currentParent.getStart(sourceFile) === currentItem.pos) { - lineAdded = false; + dynamicIndentation.recomputeIndentation(false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { + lineAdded = true; if (currentParent.getStart(sourceFile) === currentItem.pos) { - lineAdded = true; + dynamicIndentation.recomputeIndentation(true); } } - if (lineAdded !== undefined) { - dynamicIndentation.recomputeIndentation(lineAdded); - } trimTrailingWhitespaces = (rule.Operation.Action & (4 /* NewLine */ | 2 /* Space */)) && rule.Flag !== 1 /* CanDeleteNewLines */; } else { @@ -19576,7 +20895,7 @@ var ts; return lineAdded; } function insertIndentation(pos, indentation, lineAdded) { - var indentationString = formatting.getIndentationString(indentation, options); + var indentationString = getIndentationString(indentation, options); if (lineAdded) { recordReplace(pos, 0, indentationString); } @@ -19623,7 +20942,7 @@ var ts; var nonWhitespaceColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceColumn(parts[i].pos, parts[i].end, sourceFile, options); var newIndentation = nonWhitespaceColumn + delta; if (newIndentation > 0) { - var indentationString = formatting.getIndentationString(newIndentation, options); + var indentationString = getIndentationString(newIndentation, options); recordReplace(startLinePos, nonWhitespaceColumn, indentationString); } else { @@ -19694,12 +21013,11 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 162 /* Block */: - case 187 /* FunctionBlock */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: + case 163 /* Block */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: return true; } return false; @@ -19707,10 +21025,10 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 126 /* Constructor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: case 125 /* Method */: - case 153 /* ArrowFunction */: + case 151 /* ArrowFunction */: if (node.typeParameters === list) { return 23 /* LessThanToken */; } @@ -19718,8 +21036,8 @@ var ts; return 15 /* OpenParenToken */; } break; - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: if (node.typeArguments === list) { return 23 /* LessThanToken */; } @@ -19743,10 +21061,401 @@ var ts; } return 0 /* Unknown */; } + var internedTabsIndentation; + var internedSpacesIndentation; + function getIndentationString(indentation, options) { + if (!options.ConvertTabsToSpaces) { + var tabs = Math.floor(indentation / options.TabSize); + var spaces = indentation - tabs * options.TabSize; + var tabString; + if (!internedTabsIndentation) { + internedTabsIndentation = []; + } + if (internedTabsIndentation[tabs] === undefined) { + internedTabsIndentation[tabs] = tabString = repeat('\t', tabs); + } + else { + tabString = internedTabsIndentation[tabs]; + } + return spaces ? tabString + repeat(" ", spaces) : tabString; + } + else { + var spacesString; + var quotient = Math.floor(indentation / options.IndentSize); + var remainder = indentation % options.IndentSize; + if (!internedSpacesIndentation) { + internedSpacesIndentation = []; + } + if (internedSpacesIndentation[quotient] === undefined) { + spacesString = repeat(" ", options.IndentSize * quotient); + internedSpacesIndentation[quotient] = spacesString; + } + else { + spacesString = internedSpacesIndentation[quotient]; + } + return remainder ? spacesString + repeat(" ", remainder) : spacesString; + } + function repeat(value, count) { + var s = ""; + for (var i = 0; i < count; ++i) { + s += value; + } + return s; + } + } + formatting.getIndentationString = getIndentationString; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; (function (ts) { + var formatting; + (function (formatting) { + var SmartIndenter; + (function (SmartIndenter) { + function getIndentation(position, sourceFile, options) { + if (position > sourceFile.text.length) { + return 0; + } + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken) { + return 0; + } + if ((precedingToken.kind === 7 /* StringLiteral */ || precedingToken.kind === 8 /* RegularExpressionLiteral */) && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + return 0; + } + var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line; + if (precedingToken.kind === 22 /* CommaToken */ && precedingToken.parent.kind !== 157 /* BinaryExpression */) { + var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; + } + } + var previous; + var current = precedingToken; + var currentStart; + var indentationDelta; + while (current) { + if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : 0 /* Unknown */)) { + currentStart = getStartLineAndCharacterForNode(current, sourceFile); + if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { + indentationDelta = 0; + } + else { + indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + } + break; + } + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; + } + previous = current; + current = current.parent; + } + if (!current) { + return 0; + } + return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + } + SmartIndenter.getIndentation = getIndentation; + function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { + var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + } + SmartIndenter.getIndentationForNode = getIndentationForNode; + function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { + var parent = current.parent; + var parentStart; + while (parent) { + var useActualIndentation = true; + if (ignoreActualIndentationRange) { + var start = current.getStart(sourceFile); + useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; + } + if (useActualIndentation) { + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + parentStart = getParentStart(parent, current, sourceFile); + var parentAndChildShareLine = parentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); + if (useActualIndentation) { + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { + indentationDelta += options.IndentSize; + } + current = parent; + currentStart = parentStart; + parent = current.parent; + } + return indentationDelta; + } + function getParentStart(parent, child, sourceFile) { + var containingList = getContainingList(child, sourceFile); + if (containingList) { + return sourceFile.getLineAndCharacterFromPosition(containingList.pos); + } + return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile)); + } + function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { + var commaItemInfo = ts.findListItemInfo(commaToken); + ts.Debug.assert(commaItemInfo && commaItemInfo.listItemIndex > 0); + return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); + } + function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { + var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 201 /* SourceFile */ || !parentAndChildShareLine); + if (!useActualIndentation) { + return -1; + } + return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); + } + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { + var nextToken = ts.findNextToken(precedingToken, current); + if (!nextToken) { + return false; + } + if (nextToken.kind === 13 /* OpenBraceToken */) { + return true; + } + else if (nextToken.kind === 14 /* CloseBraceToken */) { + var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; + return lineAtPosition === nextTokenStartLine; + } + return false; + } + function getStartLineAndCharacterForNode(n, sourceFile) { + return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); + } + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { + if (parent.kind === 167 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 74 /* ElseKeyword */, sourceFile); + ts.Debug.assert(elseKeyword !== undefined); + var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; + return elseKeywordStartLine === childStartLine; + } + return false; + } + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getContainingList(node, sourceFile) { + if (node.parent) { + switch (node.parent.kind) { + case 132 /* TypeReference */: + if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { + return node.parent.typeArguments; + } + break; + case 142 /* ObjectLiteralExpression */: + return node.parent.properties; + case 141 /* ArrayLiteralExpression */: + return node.parent.elements; + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + case 125 /* Method */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + var start = node.getStart(sourceFile); + if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { + return node.parent.typeParameters; + } + if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { + return node.parent.parameters; + } + break; + case 146 /* NewExpression */: + case 145 /* CallExpression */: + var start = node.getStart(sourceFile); + if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { + return node.parent.typeArguments; + } + if (node.parent.arguments && ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { + return node.parent.arguments; + } + break; + } + } + return undefined; + } + function getActualIndentationForListItem(node, sourceFile, options) { + var containingList = getContainingList(node, sourceFile); + return containingList ? getActualIndentationFromList(containingList) : -1; + function getActualIndentationFromList(list) { + var index = ts.indexOf(list, node); + return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; + } + } + function deriveActualIndentationFromList(list, index, sourceFile, options) { + ts.Debug.assert(index >= 0 && index < list.length); + var node = list[index]; + var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); + for (var i = index - 1; i >= 0; --i) { + if (list[i].kind === 22 /* CommaToken */) { + continue; + } + var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line; + if (prevEndLine !== lineAndCharacter.line) { + return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); + } + lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); + } + return -1; + } + function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { + var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1); + return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); + } + function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { + var column = 0; + for (var pos = startPos; pos < endPos; ++pos) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch)) { + return column; + } + if (ch === 9 /* tab */) { + column += options.TabSize + (column % options.TabSize); + } + else { + column++; + } + } + return column; + } + SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; + function nodeContentIsAlwaysIndented(kind) { + switch (kind) { + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: + case 141 /* ArrayLiteralExpression */: + case 163 /* Block */: + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: + case 142 /* ObjectLiteralExpression */: + case 136 /* TypeLiteral */: + case 176 /* SwitchStatement */: + case 195 /* DefaultClause */: + case 194 /* CaseClause */: + case 149 /* ParenthesizedExpression */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: + case 164 /* VariableStatement */: + case 183 /* VariableDeclaration */: + case 192 /* ExportAssignment */: + case 174 /* ReturnStatement */: + case 158 /* ConditionalExpression */: + return true; + } + return false; + } + function shouldIndentChildNode(parent, child) { + if (nodeContentIsAlwaysIndented(parent)) { + return true; + } + switch (parent) { + case 168 /* DoStatement */: + case 169 /* WhileStatement */: + case 171 /* ForInStatement */: + case 170 /* ForStatement */: + case 167 /* IfStatement */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 125 /* Method */: + case 151 /* ArrowFunction */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + return child !== 163 /* Block */; + default: + return false; + } + } + SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = children[children.length - 1]; + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 21 /* SemicolonToken */ && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } + function isCompletedNode(n, sourceFile) { + if (n.getFullWidth() === 0) { + return false; + } + switch (n.kind) { + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: + case 142 /* ObjectLiteralExpression */: + case 163 /* Block */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: + case 176 /* SwitchStatement */: + return nodeEndsWith(n, 14 /* CloseBraceToken */, sourceFile); + case 197 /* CatchClause */: + return isCompletedNode(n.block, sourceFile); + case 149 /* ParenthesizedExpression */: + case 129 /* CallSignature */: + case 145 /* CallExpression */: + case 130 /* ConstructSignature */: + return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 125 /* Method */: + case 151 /* ArrowFunction */: + return !n.body || isCompletedNode(n.body, sourceFile); + case 189 /* ModuleDeclaration */: + return n.body && isCompletedNode(n.body, sourceFile); + case 167 /* IfStatement */: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); + } + return isCompletedNode(n.thenStatement, sourceFile); + case 166 /* ExpressionStatement */: + return isCompletedNode(n.expression, sourceFile); + case 141 /* ArrayLiteralExpression */: + return nodeEndsWith(n, 18 /* CloseBracketToken */, sourceFile); + case 194 /* CaseClause */: + case 195 /* DefaultClause */: + return false; + case 169 /* WhileStatement */: + return isCompletedNode(n.statement, sourceFile); + case 168 /* DoStatement */: + var hasWhileKeyword = ts.findChildOfKind(n, 98 /* WhileKeyword */, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + default: + return true; + } + } + })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var ts; +(function (ts) { + ts.servicesVersion = "0.4"; var ScriptSnapshot; (function (ScriptSnapshot) { var StringScriptSnapshot = (function () { @@ -19827,7 +21536,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(199 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this); + var list = createNode(203 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var i = 0, len = nodes.length; i < len; i++) { @@ -19845,7 +21554,7 @@ var ts; }; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; - if (this.kind > 120 /* Missing */) { + if (this.kind >= 120 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); var children = []; var pos = this.pos; @@ -19890,20 +21599,20 @@ var ts; var children = this.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - if (child.kind < 120 /* Missing */) + if (child.kind < 120 /* FirstNode */) { return child; - if (child.kind > 120 /* Missing */) - return child.getFirstToken(sourceFile); + } + return child.getFirstToken(sourceFile); } }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 120 /* Missing */) + if (child.kind < 120 /* FirstNode */) { return child; - if (child.kind > 120 /* Missing */) - return child.getLastToken(sourceFile); + } + return child.getLastToken(sourceFile); } }; return NodeObject; @@ -19935,7 +21644,7 @@ var ts; var docComments = getJsDocCommentsSeparatedByNewLines(); ts.forEach(docComments, function (docComment) { if (documentationComment.length) { - documentationComment.push(lineBreakPart()); + documentationComment.push(ts.lineBreakPart()); } documentationComment.push(docComment); }); @@ -19953,13 +21662,13 @@ var ts; } }); } - if (declaration.kind === 192 /* ModuleDeclaration */ && declaration.body.kind === 192 /* ModuleDeclaration */) { + if (declaration.kind === 189 /* ModuleDeclaration */ && declaration.body.kind === 189 /* ModuleDeclaration */) { return; } - while (declaration.kind === 192 /* ModuleDeclaration */ && declaration.parent.kind === 192 /* ModuleDeclaration */) { + while (declaration.kind === 189 /* ModuleDeclaration */ && declaration.parent.kind === 189 /* ModuleDeclaration */) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 185 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 183 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -20001,8 +21710,8 @@ var ts; } function pushDocCommentLineText(docComments, text, blankLineCount) { while (blankLineCount--) - docComments.push(textPart("")); - docComments.push(textPart(text)); + docComments.push(ts.textPart("")); + docComments.push(ts.textPart(text)); } function getCleanedJsDocComment(pos, end, sourceFile) { var spacesToRemoveAfterAsterisk; @@ -20230,10 +21939,10 @@ var ts; var namedDeclarations = []; ts.forEachChild(sourceFile, function visit(node) { switch (node.kind) { - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: var functionDeclaration = node; - if (functionDeclaration.name && functionDeclaration.name.kind !== 120 /* Missing */) { + if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) { var lastDeclaration = namedDeclarations.length > 0 ? namedDeclarations[namedDeclarations.length - 1] : undefined; if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) { if (functionDeclaration.body && !lastDeclaration.body) { @@ -20241,17 +21950,17 @@ var ts; } } else { - namedDeclarations.push(node); + namedDeclarations.push(functionDeclaration); } ts.forEachChild(node, visit); } break; - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: - case 194 /* ImportDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: + case 188 /* EnumDeclaration */: + case 189 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: case 136 /* TypeLiteral */: @@ -20259,17 +21968,21 @@ var ts; namedDeclarations.push(node); } case 126 /* Constructor */: - case 163 /* VariableStatement */: - case 193 /* ModuleBlock */: - case 187 /* FunctionBlock */: + case 164 /* VariableStatement */: + case 190 /* ModuleBlock */: ts.forEachChild(node, visit); break; + case 163 /* Block */: + if (ts.isFunctionBlock(node)) { + ts.forEachChild(node, visit); + } + break; case 123 /* Parameter */: if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } - case 185 /* VariableDeclaration */: - case 196 /* EnumMember */: + case 183 /* VariableDeclaration */: + case 200 /* EnumMember */: case 124 /* Property */: namedDeclarations.push(node); break; @@ -20302,6 +22015,120 @@ var ts; }; return SourceFileObject; })(NodeObject); + var TextSpan = (function () { + function TextSpan(start, length) { + ts.Debug.assert(start >= 0, "start"); + ts.Debug.assert(length >= 0, "length"); + this._start = start; + this._length = length; + } + TextSpan.prototype.toJSON = function (key) { + return { start: this._start, length: this._length }; + }; + TextSpan.prototype.start = function () { + return this._start; + }; + TextSpan.prototype.length = function () { + return this._length; + }; + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = Math.max(this._start, span._start); + var overlapEnd = Math.min(this.end(), span.end()); + return overlapStart < overlapEnd; + }; + TextSpan.prototype.overlap = function (span) { + var overlapStart = Math.max(this._start, span._start); + var overlapEnd = Math.min(this.end(), span.end()); + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + return undefined; + }; + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + TextSpan.prototype.intersection = function (span) { + var intersectStart = Math.max(this._start, span._start); + var intersectEnd = Math.min(this.end(), span.end()); + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + return undefined; + }; + TextSpan.fromBounds = function (start, end) { + ts.Debug.assert(start >= 0); + ts.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + ts.TextSpan = TextSpan; + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + ts.Debug.assert(newLength >= 0, "newLength"); + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + TextChangeRange.prototype.newSpan = function () { + return new TextSpan(this.span().start(), this.newLength()); + }; + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return new TextChangeRange(TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TextSpan(0, 0), 0); + return TextChangeRange; + })(); + ts.TextChangeRange = TextChangeRange; var TextChange = (function () { function TextChange() { } @@ -20333,6 +22160,19 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(ts.OutputFileType || (ts.OutputFileType = {})); + var OutputFileType = ts.OutputFileType; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["Start"] = 0] = "Start"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + })(ts.EndOfLineState || (ts.EndOfLineState = {})); + var EndOfLineState = ts.EndOfLineState; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -20408,6 +22248,7 @@ var ts; ClassificationTypeNames.interfaceName = "interface name"; ClassificationTypeNames.moduleName = "module name"; ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAlias = "type alias name"; return ClassificationTypeNames; })(); ts.ClassificationTypeNames = ClassificationTypeNames; @@ -20425,170 +22266,25 @@ var ts; return ""; } ts.displayPartsToString = displayPartsToString; - var displayPartWriter = getDisplayPartWriter(); - function getDisplayPartWriter() { - var displayParts; - var lineStart; - var indent; - resetWriter(); - return { - displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, 5 /* keyword */); }, - writeOperator: function (text) { return writeKind(text, 12 /* operator */); }, - writePunctuation: function (text) { return writeKind(text, 15 /* punctuation */); }, - writeSpace: function (text) { return writeKind(text, 16 /* space */); }, - writeStringLiteral: function (text) { return writeKind(text, 8 /* stringLiteral */); }, - writeParameter: function (text) { return writeKind(text, 13 /* parameterName */); }, - writeSymbol: writeSymbol, - writeLine: writeLine, - increaseIndent: function () { - indent++; - }, - decreaseIndent: function () { - indent--; - }, - clear: resetWriter, - trackSymbol: function () { - } - }; - function writeIndent() { - if (lineStart) { - displayParts.push(displayPart(ts.getIndentString(indent), 16 /* space */)); - lineStart = false; - } - } - function writeKind(text, kind) { - writeIndent(); - displayParts.push(displayPart(text, kind)); - } - function writeSymbol(text, symbol) { - writeIndent(); - displayParts.push(symbolPart(text, symbol)); - } - function writeLine() { - displayParts.push(lineBreakPart()); - lineStart = true; - } - function resetWriter() { - displayParts = []; - lineStart = true; - indent = 0; - } - } - function displayPart(text, kind, symbol) { - return { - text: text, - kind: SymbolDisplayPartKind[kind] - }; - } - function spacePart() { - return displayPart(" ", 16 /* space */); - } - ts.spacePart = spacePart; - function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), 5 /* keyword */); - } - ts.keywordPart = keywordPart; - function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), 15 /* punctuation */); - } - ts.punctuationPart = punctuationPart; - function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), 12 /* operator */); - } - ts.operatorPart = operatorPart; - function textPart(text) { - return displayPart(text, 17 /* text */); - } - ts.textPart = textPart; - function lineBreakPart() { - return displayPart("\n", 6 /* lineBreak */); - } - ts.lineBreakPart = lineBreakPart; - function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 123 /* Parameter */; - } function isLocalVariableOrFunction(symbol) { if (symbol.parent) { return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 152 /* FunctionExpression */) { + if (declaration.kind === 150 /* FunctionExpression */) { return true; } - if (declaration.kind !== 185 /* VariableDeclaration */ && declaration.kind !== 186 /* FunctionDeclaration */) { + if (declaration.kind !== 183 /* VariableDeclaration */ && declaration.kind !== 184 /* FunctionDeclaration */) { return false; } - for (var parent = declaration.parent; parent.kind !== 187 /* FunctionBlock */; parent = parent.parent) { - if (parent.kind === 197 /* SourceFile */ || parent.kind === 193 /* ModuleBlock */) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { + if (parent.kind === 201 /* SourceFile */ || parent.kind === 190 /* ModuleBlock */) { return false; } } return true; }); } - function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); - function displayPartKind(symbol) { - var flags = symbol.flags; - if (flags & 3 /* Variable */) { - return isFirstDeclarationOfSymbolParameter(symbol) ? 13 /* parameterName */ : 9 /* localName */; - } - else if (flags & 4 /* Property */) { - return 14 /* propertyName */; - } - else if (flags & 8 /* EnumMember */) { - return 19 /* enumMemberName */; - } - else if (flags & 16 /* Function */) { - return 20 /* functionName */; - } - else if (flags & 32 /* Class */) { - return 1 /* className */; - } - else if (flags & 64 /* Interface */) { - return 4 /* interfaceName */; - } - else if (flags & 384 /* Enum */) { - return 2 /* enumName */; - } - else if (flags & 1536 /* Module */) { - return 11 /* moduleName */; - } - else if (flags & 8192 /* Method */) { - return 10 /* methodName */; - } - else if (flags & 1048576 /* TypeParameter */) { - return 18 /* typeParameterName */; - } - return 17 /* text */; - } - } - ts.symbolPart = symbolPart; - function mapToDisplayParts(writeDisplayParts) { - writeDisplayParts(displayPartWriter); - var result = displayPartWriter.displayParts(); - displayPartWriter.clear(); - return result; - } - ts.mapToDisplayParts = mapToDisplayParts; - function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - }); - } - ts.typeToDisplayParts = typeToDisplayParts; - function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - return mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); - }); - } - ts.symbolToDisplayParts = symbolToDisplayParts; - function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - }); - } function getDefaultCompilerOptions() { return { target: 2 /* Latest */, @@ -20596,20 +22292,6 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } - else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - ts.compareDataObjects = compareDataObjects; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -20689,7 +22371,7 @@ var ts; HostCache.prototype.getChangeRange = function (filename, lastKnownVersion, oldScriptSnapshot) { var currentVersion = this.getVersion(filename); if (lastKnownVersion === currentVersion) { - return ts.TextChangeRange.unchanged; + return TextChangeRange.unchanged; } var scriptSnapshot = this.getScriptSnapshot(filename); return scriptSnapshot.getChangeRange(oldScriptSnapshot); @@ -20702,7 +22384,6 @@ var ts; this.currentFilename = ""; this.currentFileVersion = null; this.currentSourceFile = null; - this.hostCache = new HostCache(host); } SyntaxTreeCache.prototype.initialize = function (filename) { var start = new Date().getTime(); @@ -20892,27 +22573,9 @@ var ts; return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; } ts.preProcessFile = preProcessFile; - function getNodeModifiers(node) { - var flags = node.flags; - var result = []; - if (flags & 32 /* Private */) - result.push(ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) - result.push(ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) - result.push(ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) - result.push(ScriptElementKindModifier.staticModifier); - if (flags & 1 /* Export */) - result.push(ScriptElementKindModifier.exportedModifier); - if (ts.isInAmbientContext(node)) - result.push(ScriptElementKindModifier.ambientModifier); - return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none; - } - ts.getNodeModifiers = getNodeModifiers; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 178 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 177 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -20920,13 +22583,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 63 /* Identifier */ && (node.parent.kind === 172 /* BreakStatement */ || node.parent.kind === 171 /* ContinueStatement */) && node.parent.label === node; + return node.kind === 63 /* Identifier */ && (node.parent.kind === 173 /* BreakStatement */ || node.parent.kind === 172 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 63 /* Identifier */ && node.parent.kind === 178 /* LabeledStatement */ && node.parent.label === node; + return node.kind === 63 /* Identifier */ && node.parent.kind === 177 /* LabeledStatement */ && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 178 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 177 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -20937,51 +22600,54 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 145 /* PropertyAccess */ && node.parent.right === node; + return node && node.parent && node.parent.kind === 143 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 147 /* CallExpression */ && node.parent.func === node; + return node && node.parent && node.parent.kind === 145 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 148 /* NewExpression */ && node.parent.func === node; + return node && node.parent && node.parent.kind === 146 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 192 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 189 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 63 /* Identifier */ && ts.isAnyFunction(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 63 /* Identifier */ || node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) && (node.parent.kind === 143 /* PropertyAssignment */ || node.parent.kind === 144 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 63 /* Identifier */ || node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) && (node.parent.kind === 198 /* PropertyAssignment */ || node.parent.kind === 199 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) { switch (node.parent.kind) { case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 196 /* EnumMember */: + case 198 /* PropertyAssignment */: + case 200 /* EnumMember */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: return node.parent.name === node; - case 146 /* IndexedAccess */: - return node.parent.index === node; + case 144 /* ElementAccessExpression */: + return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - return node.kind === 7 /* StringLiteral */ && (isNameOfModuleDeclaration(node) || (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node)); + if (node.kind === 7 /* StringLiteral */) { + return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportDeclaration(node.parent.parent) && ts.getExternalModuleImportDeclarationExpression(node.parent.parent) === node); + } + return false; } function isInsideComment(sourceFile, token, position) { return position <= token.getStart(sourceFile) && (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); @@ -21004,6 +22670,21 @@ var ts; }); } } + var SemanticMeaning; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; + })(SemanticMeaning || (SemanticMeaning = {})); + var BreakContinueSearchType; + (function (BreakContinueSearchType) { + BreakContinueSearchType[BreakContinueSearchType["None"] = 0] = "None"; + BreakContinueSearchType[BreakContinueSearchType["Unlabeled"] = 1] = "Unlabeled"; + BreakContinueSearchType[BreakContinueSearchType["Labeled"] = 2] = "Labeled"; + BreakContinueSearchType[BreakContinueSearchType["All"] = 3] = "All"; + })(BreakContinueSearchType || (BreakContinueSearchType = {})); var keywordCompletions = []; for (var i = 64 /* FirstKeyword */; i <= 119 /* LastKeyword */; i++) { keywordCompletions.push({ @@ -21022,10 +22703,10 @@ var ts; var useCaseSensitivefilenames = false; var sourceFilesByName = {}; var documentRegistry = documentRegistry; - var cancellationToken = new CancellationTokenObject(host.getCancellationToken()); + var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); var activeCompletionSession; var writer = undefined; - if (!ts.localizedDiagnosticMessages) { + if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } function getCanonicalFileName(filename) { @@ -21054,8 +22735,8 @@ var ts; getCanonicalFileName: function (filename) { return useCaseSensitivefilenames ? filename : filename.toLowerCase(); }, useCaseSensitiveFileNames: function () { return useCaseSensitivefilenames; }, getNewLine: function () { return "\r\n"; }, - getDefaultLibFilename: function () { - return host.getDefaultLibFilename(); + getDefaultLibFilename: function (options) { + return host.getDefaultLibFilename(options); }, writeFile: function (filename, data, writeByteOrderMark) { writer(filename, data, writeByteOrderMark); @@ -21081,7 +22762,7 @@ var ts; return false; } } - return compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); + return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); } function synchronizeHostData() { hostCache = new HostCache(host); @@ -21093,7 +22774,7 @@ var ts; if (oldProgram) { var oldSettings = program.getCompilerOptions(); var settingsChangeAffectsSyntax = oldSettings.target !== compilationSettings.target || oldSettings.module !== compilationSettings.module; - var changesInCompilationSettingsAffectSyntax = oldSettings && compilationSettings && !compareDataObjects(oldSettings, compilationSettings) && settingsChangeAffectsSyntax; + var changesInCompilationSettingsAffectSyntax = oldSettings && compilationSettings && !ts.compareDataObjects(oldSettings, compilationSettings) && settingsChangeAffectsSyntax; var oldSourceFiles = program.getSourceFiles(); for (var i = 0, n = oldSourceFiles.length; i < n; i++) { cancellationToken.throwIfCancellationRequested(); @@ -21146,7 +22827,7 @@ var ts; function getSyntacticDiagnostics(filename) { synchronizeHostData(); filename = ts.normalizeSlashes(filename); - return program.getDiagnostics(getSourceFile(filename).getSourceFile()); + return program.getDiagnostics(getSourceFile(filename)); } function getSemanticDiagnostics(filename) { synchronizeHostData(); @@ -21195,7 +22876,7 @@ var ts; kindModifiers: getSymbolModifiers(symbol) }; } - function getCompletionsAtPosition(filename, position, isMemberCompletion) { + function getCompletionsAtPosition(filename, position) { synchronizeHostData(); filename = ts.normalizeSlashes(filename); var syntacticStart = new Date().getTime(); @@ -21224,7 +22905,11 @@ var ts; } var node; var isRightOfDot; - if (previousToken && previousToken.kind === 19 /* DotToken */ && (previousToken.parent.kind === 145 /* PropertyAccess */ || previousToken.parent.kind === 121 /* QualifiedName */)) { + if (previousToken && previousToken.kind === 19 /* DotToken */ && previousToken.parent.kind === 143 /* PropertyAccessExpression */) { + node = previousToken.parent.expression; + isRightOfDot = true; + } + else if (previousToken && previousToken.kind === 19 /* DotToken */ && previousToken.parent.kind === 120 /* QualifiedName */) { node = previousToken.parent.left; isRightOfDot = true; } @@ -21244,9 +22929,9 @@ var ts; var semanticStart = new Date().getTime(); if (isRightOfDot) { var symbols = []; - isMemberCompletion = true; - if (node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */ || node.kind === 145 /* PropertyAccess */) { - var symbol = typeInfoResolver.getSymbolInfo(node); + var isMemberCompletion = true; + if (node.kind === 63 /* Identifier */ || node.kind === 120 /* QualifiedName */ || node.kind === 143 /* PropertyAccessExpression */) { + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol && symbol.flags & 33554432 /* Import */) { symbol = typeInfoResolver.getAliasedSymbol(symbol); } @@ -21258,7 +22943,7 @@ var ts; }); } } - var type = typeInfoResolver.getTypeOfNode(node); + var type = typeInfoResolver.getTypeAtLocation(node); if (type) { ts.forEach(type.getApparentProperties(), function (symbol) { if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { @@ -21318,34 +23003,16 @@ var ts; return result; } function isInStringOrRegularExpressionOrTemplateLiteral(previousToken) { - if (previousToken.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(previousToken.kind)) { + if (previousToken.kind === 7 /* StringLiteral */ || previousToken.kind === 8 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(previousToken.kind)) { var start = previousToken.getStart(); var end = previousToken.getEnd(); if (start < position && position < end) { return true; } else if (position === end) { - var width = end - start; - var text = previousToken.getSourceFile().text; - if (width <= 1 || text.charCodeAt(end - 2) === 92 /* backslash */) { - return true; - } - switch (previousToken.kind) { - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - return text.charCodeAt(start) !== text.charCodeAt(end - 1); - case 10 /* TemplateHead */: - case 11 /* TemplateMiddle */: - return text.charCodeAt(end - 1) !== 123 /* openBrace */ || text.charCodeAt(end - 2) !== 36 /* $ */; - case 12 /* TemplateTail */: - return text.charCodeAt(end - 1) !== 96 /* backtick */; - } - return false; + return !!previousToken.isUnterminated; } } - else if (previousToken.kind === 8 /* RegularExpressionLiteral */) { - return previousToken.getStart() < position && position < previousToken.getEnd(); - } return false; } function getContainingObjectLiteralApplicableForCompletion(previousToken) { @@ -21354,7 +23021,7 @@ var ts; switch (previousToken.kind) { case 13 /* OpenBraceToken */: case 22 /* CommaToken */: - if (parent && parent.kind === 142 /* ObjectLiteral */) { + if (parent && parent.kind === 142 /* ObjectLiteralExpression */) { return parent; } break; @@ -21364,9 +23031,9 @@ var ts; } function isFunction(kind) { switch (kind) { - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 186 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: case 126 /* Constructor */: case 127 /* GetAccessor */: @@ -21383,13 +23050,13 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 22 /* CommaToken */: - return containingNodeKind === 185 /* VariableDeclaration */ || containingNodeKind === 163 /* VariableStatement */ || containingNodeKind === 191 /* EnumDeclaration */ || isFunction(containingNodeKind); + return containingNodeKind === 183 /* VariableDeclaration */ || containingNodeKind === 164 /* VariableStatement */ || containingNodeKind === 188 /* EnumDeclaration */ || isFunction(containingNodeKind); case 15 /* OpenParenToken */: - return containingNodeKind === 182 /* CatchBlock */ || isFunction(containingNodeKind); + return containingNodeKind === 197 /* CatchClause */ || isFunction(containingNodeKind); case 13 /* OpenBraceToken */: - return containingNodeKind === 191 /* EnumDeclaration */ || containingNodeKind === 189 /* InterfaceDeclaration */; + return containingNodeKind === 188 /* EnumDeclaration */ || containingNodeKind === 186 /* InterfaceDeclaration */; case 21 /* SemicolonToken */: - return containingNodeKind === 124 /* Property */ && previousToken.parent.parent.kind === 189 /* InterfaceDeclaration */; + return containingNodeKind === 124 /* Property */ && previousToken.parent.parent.kind === 186 /* InterfaceDeclaration */; case 106 /* PublicKeyword */: case 104 /* PrivateKeyword */: case 107 /* StaticKeyword */: @@ -21431,7 +23098,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 143 /* PropertyAssignment */ && m.kind !== 144 /* ShorthandPropertyAssignment */) { + if (m.kind !== 198 /* PropertyAssignment */ && m.kind !== 199 /* ShorthandPropertyAssignment */) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -21459,7 +23126,7 @@ var ts; if (symbol) { var location = ts.getTouchingPropertyName(sourceFile, position); var completionEntry = createCompletionEntry(symbol, session.typeChecker, location); - ts.Debug.assert(session.typeChecker.getNarrowedTypeOfSymbol(symbol, location) !== undefined, "Could not find type for symbol"); + ts.Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, location) !== undefined, "Could not find type for symbol"); var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), location, session.typeChecker, location, 7 /* All */); return { name: entryName, @@ -21474,7 +23141,7 @@ var ts; name: entryName, kind: ScriptElementKind.keyword, kindModifiers: ScriptElementKindModifier.none, - displayParts: [displayPart(entryName, 5 /* keyword */)], + displayParts: [ts.displayPart(entryName, 5 /* keyword */)], documentation: undefined }; } @@ -21486,16 +23153,16 @@ var ts; return undefined; } switch (node.kind) { - case 197 /* SourceFile */: + case 201 /* SourceFile */: case 125 /* Method */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 188 /* ClassDeclaration */: - case 189 /* InterfaceDeclaration */: - case 191 /* EnumDeclaration */: - case 192 /* ModuleDeclaration */: + case 185 /* ClassDeclaration */: + case 186 /* InterfaceDeclaration */: + case 188 /* EnumDeclaration */: + case 189 /* ModuleDeclaration */: return node; } } @@ -21520,6 +23187,8 @@ var ts; return ScriptElementKind.variableElement; if (flags & 33554432 /* Import */) return ScriptElementKind.alias; + if (flags & 1536 /* Module */) + return ScriptElementKind.moduleElement; } return result; } @@ -21531,7 +23200,7 @@ var ts; return ScriptElementKind.localVariableElement; } if (flags & 3 /* Variable */) { - if (isFirstDeclarationOfSymbolParameter(symbol)) { + if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { @@ -21562,7 +23231,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - var typeOfUnionProperty = typeInfoResolver.getNarrowedTypeOfSymbol(symbol, location); + var typeOfUnionProperty = typeInfoResolver.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { return ScriptElementKind.memberFunctionElement; } @@ -21592,13 +23261,13 @@ var ts; } function getNodeKind(node) { switch (node.kind) { - case 192 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 188 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 189 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 190 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 191 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 185 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : node.flags & 2048 /* Let */ ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 186 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 189 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 185 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 186 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 187 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 188 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 183 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : node.flags & 2048 /* Let */ ? ScriptElementKind.letElement : ScriptElementKind.variableElement; + case 184 /* FunctionDeclaration */: return ScriptElementKind.functionElement; case 127 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; case 128 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; case 125 /* Method */: return ScriptElementKind.memberFunctionElement; @@ -21608,13 +23277,13 @@ var ts; case 129 /* CallSignature */: return ScriptElementKind.callSignatureElement; case 126 /* Constructor */: return ScriptElementKind.constructorImplementationElement; case 122 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 196 /* EnumMember */: return ScriptElementKind.variableElement; + case 200 /* EnumMember */: return ScriptElementKind.variableElement; case 123 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; } return ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { - return symbol && symbol.declarations && symbol.declarations.length > 0 ? getNodeModifiers(symbol.declarations[0]) : ScriptElementKindModifier.none; + return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) : ScriptElementKindModifier.none; } function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, typeResolver, location, semanticMeaning) { if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); } @@ -21627,16 +23296,16 @@ var ts; if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; } - var type = typeResolver.getNarrowedTypeOfSymbol(symbol, location); + var type = typeResolver.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 145 /* PropertyAccess */) { - var right = location.parent.right; - if (right === location || (right && right.kind === 120 /* Missing */)) { + if (location.parent && location.parent.kind === 143 /* PropertyAccessExpression */) { + var right = location.parent.name; + if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 147 /* CallExpression */ || location.kind === 148 /* NewExpression */) { + if (location.kind === 145 /* CallExpression */ || location.kind === 146 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -21648,7 +23317,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 148 /* NewExpression */ || callExpression.func.kind === 89 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 146 /* NewExpression */ || callExpression.expression.kind === 89 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -21660,13 +23329,13 @@ var ts; } else if (symbolFlags & 33554432 /* Import */) { symbolKind = ScriptElementKind.alias; - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(15 /* OpenParenToken */)); + displayParts.push(ts.textPart(symbolKind)); + displayParts.push(ts.punctuationPart(16 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(keywordPart(86 /* NewKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(86 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); } @@ -21677,16 +23346,17 @@ var ts; case ScriptElementKind.memberVariableElement: case ScriptElementKind.variableElement: case ScriptElementKind.constElement: + case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(punctuationPart(50 /* ColonToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(50 /* ColonToken */)); + displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(keywordPart(86 /* NewKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(86 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } if (!(type.flags & 32768 /* Anonymous */)) { - displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -21707,7 +23377,8 @@ var ts; signature = allSignatures[0]; } if (functionDeclaration.kind === 126 /* Constructor */) { - addPrefixForAnyFunctionOrVar(type.symbol, ScriptElementKind.constructorImplementationElement); + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 129 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); @@ -21718,54 +23389,54 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - displayParts.push(keywordPart(67 /* ClassKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(67 /* ClassKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(101 /* InterfaceKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(101 /* InterfaceKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 2097152 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(119 /* TypeKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(119 /* TypeKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(spacePart()); - displayParts.push(punctuationPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); - displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(51 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, function (declaration) { return ts.isConstEnumDeclaration(declaration); })) { - displayParts.push(keywordPart(68 /* ConstKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(68 /* ConstKeyword */)); + displayParts.push(ts.spacePart()); } - displayParts.push(keywordPart(75 /* EnumKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(75 /* EnumKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(114 /* ModuleKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(114 /* ModuleKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 1048576 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(textPart("type parameter")); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(15 /* OpenParenToken */)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(16 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(spacePart()); - displayParts.push(keywordPart(84 /* InKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(84 /* InKeyword */)); + displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); @@ -21774,51 +23445,51 @@ var ts; var signatureDeclaration = ts.getDeclarationOfKind(symbol, 122 /* TypeParameter */).parent; var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); if (signatureDeclaration.kind === 130 /* ConstructSignature */) { - displayParts.push(keywordPart(86 /* NewKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(86 /* NewKeyword */)); + displayParts.push(ts.spacePart()); } else if (signatureDeclaration.kind !== 129 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 196 /* EnumMember */) { + if (declaration.kind === 200 /* EnumMember */) { var constantValue = typeResolver.getEnumMemberValue(declaration); if (constantValue !== undefined) { - displayParts.push(spacePart()); - displayParts.push(operatorPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); - displayParts.push(displayPart(constantValue.toString(), 7 /* numericLiteral */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(51 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.displayPart(constantValue.toString(), 7 /* numericLiteral */)); } } } if (symbolFlags & 33554432 /* Import */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(83 /* ImportKeyword */)); - displayParts.push(spacePart()); + displayParts.push(ts.keywordPart(83 /* ImportKeyword */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 194 /* ImportDeclaration */) { + if (declaration.kind === 191 /* ImportDeclaration */) { var importDeclaration = declaration; - if (importDeclaration.externalModuleName) { - displayParts.push(spacePart()); - displayParts.push(punctuationPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); - displayParts.push(keywordPart(115 /* RequireKeyword */)); - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(displayPart(ts.getTextOfNode(importDeclaration.externalModuleName), 8 /* stringLiteral */)); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); + if (ts.isExternalModuleImportDeclaration(importDeclaration)) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(51 /* EqualsToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(115 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(15 /* OpenParenToken */)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportDeclarationExpression(importDeclaration)), 8 /* stringLiteral */)); + displayParts.push(ts.punctuationPart(16 /* CloseParenToken */)); } else { - var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName); + var internalAliasSymbol = typeResolver.getSymbolAtLocation(importDeclaration.moduleReference); if (internalAliasSymbol) { - displayParts.push(spacePart()); - displayParts.push(punctuationPart(51 /* EqualsToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(51 /* EqualsToken */)); + displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } } @@ -21831,16 +23502,16 @@ var ts; if (type) { addPrefixForAnyFunctionOrVar(symbol, symbolKind); if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(punctuationPart(50 /* ColonToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(50 /* ColonToken */)); + displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 1048576 /* TypeParameter */) { - var typeParameterParts = mapToDisplayParts(function (writer) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); displayParts.push.apply(displayParts, typeParameterParts); } else { - displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, type, enclosingDeclaration)); + displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, type, enclosingDeclaration)); } } else if (symbolFlags & 16 /* Function */ || symbolFlags & 8192 /* Method */ || symbolFlags & 16384 /* Constructor */ || symbolFlags & 917504 /* Signature */ || symbolFlags & 98304 /* Accessor */ || symbolKind === ScriptElementKind.memberFunctionElement) { @@ -21859,38 +23530,38 @@ var ts; return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { - displayParts.push(lineBreakPart()); + displayParts.push(ts.lineBreakPart()); } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); displayParts.push.apply(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); if (symbolKind) { - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); - displayParts.push(spacePart()); + displayParts.push(ts.punctuationPart(15 /* OpenParenToken */)); + displayParts.push(ts.textPart(symbolKind)); + displayParts.push(ts.punctuationPart(16 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } } function addSignatureDisplayParts(signature, allSignatures, flags) { - displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { - displayParts.push(spacePart()); - displayParts.push(punctuationPart(15 /* OpenParenToken */)); - displayParts.push(operatorPart(32 /* PlusToken */)); - displayParts.push(displayPart((allSignatures.length - 1).toString(), 7 /* numericLiteral */)); - displayParts.push(spacePart()); - displayParts.push(textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(punctuationPart(16 /* CloseParenToken */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.punctuationPart(15 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(32 /* PlusToken */)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), 7 /* numericLiteral */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); + displayParts.push(ts.punctuationPart(16 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var typeParameterParts = mapToDisplayParts(function (writer) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); displayParts.push.apply(displayParts, typeParameterParts); @@ -21904,21 +23575,21 @@ var ts; if (!node) { return undefined; } - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { case 63 /* Identifier */: - case 145 /* PropertyAccess */: - case 121 /* QualifiedName */: + case 143 /* PropertyAccessExpression */: + case 120 /* QualifiedName */: case 91 /* ThisKeyword */: case 89 /* SuperKeyword */: - var type = typeInfoResolver.getTypeOfNode(node); + var type = typeInfoResolver.getTypeAtLocation(node); if (type) { return { kind: ScriptElementKind.unknown, kindModifiers: ScriptElementKindModifier.none, - textSpan: new ts.TextSpan(node.getStart(), node.getWidth()), - displayParts: typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)), + textSpan: new TextSpan(node.getStart(), node.getWidth()), + displayParts: ts.typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined }; } @@ -21929,7 +23600,7 @@ var ts; return { kind: displayPartsDocumentationsAndKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - textSpan: new ts.TextSpan(node.getStart(), node.getWidth()), + textSpan: new TextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, documentation: displayPartsDocumentationsAndKind.documentation }; @@ -21938,7 +23609,7 @@ var ts; function getDefinitionInfo(node, symbolKind, symbolName, containerName) { return { fileName: node.getSourceFile().filename, - textSpan: ts.TextSpan.fromBounds(node.getStart(), node.getEnd()), + textSpan: TextSpan.fromBounds(node.getStart(), node.getEnd()), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -21949,7 +23620,7 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 126 /* Constructor */) || (!selectConstructors && (d.kind === 186 /* FunctionDeclaration */ || d.kind === 125 /* Method */))) { + if ((selectConstructors && d.kind === 126 /* Constructor */) || (!selectConstructors && (d.kind === 184 /* FunctionDeclaration */ || d.kind === 125 /* Method */))) { declarations.push(d); if (d.body) definition = d; @@ -21969,7 +23640,7 @@ var ts; if (isNewExpressionTarget(location) || location.kind === 111 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 188 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 185 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -21999,7 +23670,7 @@ var ts; if (referenceFile) { return [{ fileName: referenceFile.filename, - textSpan: ts.TextSpan.fromBounds(0, 0), + textSpan: TextSpan.fromBounds(0, 0), kind: ScriptElementKind.scriptElement, name: comment.filename, containerName: undefined, @@ -22008,12 +23679,12 @@ var ts; } return undefined; } - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { return undefined; } var result = []; - if (node.parent.kind === 144 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 199 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); var shorthandDeclarations = shorthandSymbol.getDeclarations(); var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver); @@ -22050,52 +23721,52 @@ var ts; switch (node.kind) { case 82 /* IfKeyword */: case 74 /* ElseKeyword */: - if (hasKind(node.parent, 166 /* IfStatement */)) { + if (hasKind(node.parent, 167 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 88 /* ReturnKeyword */: - if (hasKind(node.parent, 173 /* ReturnStatement */)) { + if (hasKind(node.parent, 174 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 92 /* ThrowKeyword */: - if (hasKind(node.parent, 179 /* ThrowStatement */)) { + if (hasKind(node.parent, 178 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 94 /* TryKeyword */: case 66 /* CatchKeyword */: case 79 /* FinallyKeyword */: - if (hasKind(parent(parent(node)), 180 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 179 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 90 /* SwitchKeyword */: - if (hasKind(node.parent, 175 /* SwitchStatement */)) { + if (hasKind(node.parent, 176 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 65 /* CaseKeyword */: case 71 /* DefaultKeyword */: - if (hasKind(parent(parent(node)), 175 /* SwitchStatement */)) { + if (hasKind(parent(parent(node)), 176 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent); } break; case 64 /* BreakKeyword */: case 69 /* ContinueKeyword */: - if (hasKind(node.parent, 172 /* BreakStatement */) || hasKind(node.parent, 171 /* ContinueStatement */)) { + if (hasKind(node.parent, 173 /* BreakStatement */) || hasKind(node.parent, 172 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; case 80 /* ForKeyword */: - if (hasKind(node.parent, 169 /* ForStatement */) || hasKind(node.parent, 170 /* ForInStatement */)) { + if (hasKind(node.parent, 170 /* ForStatement */) || hasKind(node.parent, 171 /* ForInStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 98 /* WhileKeyword */: case 73 /* DoKeyword */: - if (hasKind(node.parent, 168 /* WhileStatement */) || hasKind(node.parent, 167 /* DoStatement */)) { + if (hasKind(node.parent, 169 /* WhileStatement */) || hasKind(node.parent, 168 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -22110,14 +23781,14 @@ var ts; return getGetAndSetOccurrences(node.parent); } default: - if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 163 /* VariableStatement */)) { + if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 164 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } return undefined; function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 166 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 167 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -22128,7 +23799,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 166 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 167 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -22148,7 +23819,7 @@ var ts; if (shouldHighlightNextKeyword) { result.push({ fileName: filename, - textSpan: ts.TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), + textSpan: TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), isWriteAccess: false }); i++; @@ -22161,7 +23832,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 187 /* FunctionBlock */))) { + if (!(func && hasKind(func.body, 163 /* Block */))) { return undefined; } var keywords = []; @@ -22182,7 +23853,7 @@ var ts; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { pushKeywordIf(keywords, throwStatement.getFirstToken(), 92 /* ThrowKeyword */); }); - if (owner.kind === 187 /* FunctionBlock */) { + if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { pushKeywordIf(keywords, returnStatement.getFirstToken(), 88 /* ReturnKeyword */); }); @@ -22194,13 +23865,13 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 179 /* ThrowStatement */) { + if (node.kind === 178 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 180 /* TryStatement */) { + else if (node.kind === 179 /* TryStatement */) { var tryStatement = node; - if (tryStatement.catchBlock) { - aggregate(tryStatement.catchBlock); + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { aggregate(tryStatement.tryBlock); @@ -22219,12 +23890,12 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (parent.kind === 187 /* FunctionBlock */ || parent.kind === 197 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 201 /* SourceFile */) { return parent; } - if (parent.kind === 180 /* TryStatement */) { + if (parent.kind === 179 /* TryStatement */) { var tryStatement = parent; - if (tryStatement.tryBlock === child && tryStatement.catchBlock) { + if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } @@ -22235,8 +23906,8 @@ var ts; function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; pushKeywordIf(keywords, tryStatement.getFirstToken(), 94 /* TryKeyword */); - if (tryStatement.catchBlock) { - pushKeywordIf(keywords, tryStatement.catchBlock.getFirstToken(), 66 /* CatchKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 66 /* CatchKeyword */); } if (tryStatement.finallyBlock) { pushKeywordIf(keywords, tryStatement.finallyBlock.getFirstToken(), 79 /* FinallyKeyword */); @@ -22246,7 +23917,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 80 /* ForKeyword */, 98 /* WhileKeyword */, 73 /* DoKeyword */)) { - if (loopNode.kind === 167 /* DoStatement */) { + if (loopNode.kind === 168 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 98 /* WhileKeyword */)) { @@ -22281,12 +23952,12 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 167 /* DoStatement */: - case 168 /* WhileStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 168 /* DoStatement */: + case 169 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -22297,7 +23968,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 172 /* BreakStatement */ || node.kind === 171 /* ContinueStatement */) { + if (node.kind === 173 /* BreakStatement */ || node.kind === 172 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isAnyFunction(node)) { @@ -22313,14 +23984,14 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node = statement.parent; node; node = node.parent) { switch (node.kind) { - case 175 /* SwitchStatement */: - if (statement.kind === 171 /* ContinueStatement */) { + case 176 /* SwitchStatement */: + if (statement.kind === 172 /* ContinueStatement */) { continue; } - case 169 /* ForStatement */: - case 170 /* ForInStatement */: - case 168 /* WhileStatement */: - case 167 /* DoStatement */: + case 170 /* ForStatement */: + case 171 /* ForInStatement */: + case 169 /* WhileStatement */: + case 168 /* DoStatement */: if (!statement.label || isLabeledBy(node, statement.label.text)) { return node; } @@ -22359,32 +24030,35 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (declaration.flags & 112 /* AccessibilityModifier */) { - if (!(container.kind === 188 /* ClassDeclaration */ || (declaration.kind === 123 /* Parameter */ && hasKind(container, 126 /* Constructor */)))) { + if (!(container.kind === 185 /* ClassDeclaration */ || (declaration.kind === 123 /* Parameter */ && hasKind(container, 126 /* Constructor */)))) { return undefined; } } else if (declaration.flags & 128 /* Static */) { - if (container.kind !== 188 /* ClassDeclaration */) { + if (container.kind !== 185 /* ClassDeclaration */) { return undefined; } } else if (declaration.flags & (1 /* Export */ | 2 /* Ambient */)) { - if (!(container.kind === 193 /* ModuleBlock */ || container.kind === 197 /* SourceFile */)) { + if (!(container.kind === 190 /* ModuleBlock */ || container.kind === 201 /* SourceFile */)) { return undefined; } } + else { + return undefined; + } var keywords = []; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 193 /* ModuleBlock */: - case 197 /* SourceFile */: + case 190 /* ModuleBlock */: + case 201 /* SourceFile */: nodes = container.statements; break; case 126 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: nodes = container.members; if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { @@ -22399,8 +24073,8 @@ var ts; ts.Debug.fail("Invalid container kind."); } ts.forEach(nodes, function (node) { - if (node.flags & modifierFlag) { - ts.forEach(node.getChildren(), function (child) { return pushKeywordIf(keywords, child, modifier); }); + if (node.modifiers && node.flags & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); } }); return ts.map(keywords, getReferenceEntryFromNode); @@ -22477,7 +24151,7 @@ var ts; if (node.kind === 89 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { return [getReferenceEntryFromNode(node)]; } @@ -22509,7 +24183,7 @@ var ts; return stripQuotes(name); } function getInternedName(symbol, declarations) { - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 152 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 150 /* FunctionExpression */ ? d : undefined; }); if (functionExpression && functionExpression.name) { var name = functionExpression.name.text; } @@ -22530,7 +24204,7 @@ var ts; if (symbol.getFlags() && (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 188 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 185 /* ClassDeclaration */); } } if (symbol.parent) { @@ -22547,7 +24221,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 197 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 201 /* SourceFile */ && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -22625,7 +24299,7 @@ var ts; if ((findInStrings && isInString(position)) || (findInComments && isInComment(position))) { result.push({ fileName: sourceFile.filename, - textSpan: new ts.TextSpan(position, searchText.length), + textSpan: new TextSpan(position, searchText.length), isWriteAccess: false }); } @@ -22634,7 +24308,7 @@ var ts; if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { return; } - var referenceSymbol = typeInfoResolver.getSymbolInfo(referenceLocation); + var referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation); if (referenceSymbol) { var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); @@ -22705,26 +24379,29 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 124 /* Property */: case 125 /* Method */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + case 124 /* Property */: case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 197 /* SourceFile */: + case 201 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: break; default: return undefined; } var result = []; - if (searchSpaceNode.kind === 197 /* SourceFile */) { + if (searchSpaceNode.kind === 201 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, result); @@ -22745,19 +24422,24 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 188 /* ClassDeclaration */: + case 125 /* Method */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 185 /* ClassDeclaration */: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 197 /* SourceFile */: - if (container.kind === 197 /* SourceFile */ && !ts.isExternalModule(container)) { + case 201 /* SourceFile */: + if (container.kind === 201 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -22789,19 +24471,19 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 188 /* ClassDeclaration */) { - getPropertySymbolFromTypeReference(declaration.baseType); - ts.forEach(declaration.implementedTypes, getPropertySymbolFromTypeReference); + if (declaration.kind === 185 /* ClassDeclaration */) { + getPropertySymbolFromTypeReference(ts.getClassBaseTypeNode(declaration)); + ts.forEach(ts.getClassImplementedTypeNodes(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 189 /* InterfaceDeclaration */) { - ts.forEach(declaration.baseTypes, getPropertySymbolFromTypeReference); + else if (declaration.kind === 186 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); } return; function getPropertySymbolFromTypeReference(typeReference) { if (typeReference) { - var type = typeInfoResolver.getTypeOfNode(typeReference); + var type = typeInfoResolver.getTypeAtLocation(typeReference); if (type) { var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName); if (propertySymbol) { @@ -22889,7 +24571,7 @@ var ts; } return { fileName: node.getSourceFile().filename, - textSpan: ts.TextSpan.fromBounds(start, end), + textSpan: TextSpan.fromBounds(start, end), isWriteAccess: isWriteAccess(node) }; } @@ -22899,10 +24581,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 155 /* PostfixOperator */ || parent.kind === 154 /* PrefixOperator */) { + if (parent.kind === 156 /* PostfixUnaryExpression */ || parent.kind === 155 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 156 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 157 /* BinaryExpression */ && parent.left === node) { var operator = parent.operator; return 51 /* FirstAssignment */ <= operator && operator <= 62 /* LastAssignment */; } @@ -22927,10 +24609,10 @@ var ts; items.push({ name: name, kind: getNodeKind(declaration), - kindModifiers: getNodeModifiers(declaration), + kindModifiers: ts.getNodeModifiers(declaration), matchKind: MatchKind[matchKind], fileName: filename, - textSpan: ts.TextSpan.fromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: TextSpan.fromBounds(declaration.getStart(), declaration.getEnd()), containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? getNodeKind(container) : "" }); @@ -22975,69 +24657,49 @@ var ts; function getEmitOutput(filename) { synchronizeHostData(); filename = ts.normalizeSlashes(filename); - var compilerOptions = program.getCompilerOptions(); - var targetSourceFile = program.getSourceFile(filename); - var shouldEmitToOwnFile = ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions); - var emitOutput = { - outputFiles: [], - emitOutputStatus: undefined - }; + var sourceFile = getSourceFile(filename); + var outputFiles = []; function getEmitOutputWriter(filename, data, writeByteOrderMark) { - emitOutput.outputFiles.push({ + outputFiles.push({ name: filename, writeByteOrderMark: writeByteOrderMark, text: data }); } writer = getEmitOutputWriter; - var containSyntacticErrors = false; - if (shouldEmitToOwnFile) { - containSyntacticErrors = containErrors(program.getDiagnostics(targetSourceFile)); - } - else { - containSyntacticErrors = ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (!ts.isExternalModuleOrDeclarationFile(sourceFile)) { - return containErrors(program.getDiagnostics(sourceFile)); - } - return false; - }); - } - if (containSyntacticErrors) { - emitOutput.emitOutputStatus = 1 /* AllOutputGenerationSkipped */; - writer = undefined; - return emitOutput; - } - var emitFilesResult = getFullTypeCheckChecker().emitFiles(targetSourceFile); - emitOutput.emitOutputStatus = emitFilesResult.emitResultStatus; + var emitOutput = getFullTypeCheckChecker().emitFiles(sourceFile); writer = undefined; - return emitOutput; + return { + outputFiles: outputFiles, + emitOutputStatus: emitOutput.emitResultStatus + }; } function getMeaningFromDeclaration(node) { switch (node.kind) { case 123 /* Parameter */: - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 124 /* Property */: - case 143 /* PropertyAssignment */: - case 144 /* ShorthandPropertyAssignment */: - case 196 /* EnumMember */: + case 198 /* PropertyAssignment */: + case 199 /* ShorthandPropertyAssignment */: + case 200 /* EnumMember */: case 125 /* Method */: case 126 /* Constructor */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: - case 186 /* FunctionDeclaration */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: - case 182 /* CatchBlock */: + case 184 /* FunctionDeclaration */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: + case 197 /* CatchClause */: return 1 /* Value */; case 122 /* TypeParameter */: - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: case 136 /* TypeLiteral */: return 2 /* Type */; - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: if (node.name.kind === 7 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -23047,9 +24709,9 @@ var ts; else { return 4 /* Namespace */; } - case 194 /* ImportDeclaration */: + case 191 /* ImportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - case 197 /* SourceFile */: + case 201 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } ts.Debug.fail("Unknown declaration type"); @@ -23063,28 +24725,28 @@ var ts; function isNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 121 /* QualifiedName */) { - while (root.parent && root.parent.kind === 121 /* QualifiedName */) + if (root.parent.kind === 120 /* QualifiedName */) { + while (root.parent && root.parent.kind === 120 /* QualifiedName */) root = root.parent; isLastClause = root.right === node; } return root.parent.kind === 132 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 121 /* QualifiedName */) { + while (node.parent.kind === 120 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 194 /* ImportDeclaration */ && node.parent.entityName === node; + return ts.isInternalModuleImportDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImport(node) { ts.Debug.assert(node.kind === 63 /* Identifier */); - if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 194 /* ImportDeclaration */) { + if (node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 191 /* ImportDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 195 /* ExportAssignment */) { + if (node.parent.kind === 192 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -23121,8 +24783,8 @@ var ts; return; } switch (node.kind) { - case 145 /* PropertyAccess */: - case 121 /* QualifiedName */: + case 143 /* PropertyAccessExpression */: + case 120 /* QualifiedName */: case 7 /* StringLiteral */: case 78 /* FalseKeyword */: case 93 /* TrueKeyword */: @@ -23140,7 +24802,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 192 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { + if (nodeForStartPos.parent.parent.kind === 189 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } else { @@ -23151,7 +24813,7 @@ var ts; break; } } - return ts.TextSpan.fromBounds(nodeForStartPos.getStart(), node.getEnd()); + return TextSpan.fromBounds(nodeForStartPos.getStart(), node.getEnd()); } function getBreakpointStatementAtPosition(filename, position) { filename = ts.normalizeSlashes(filename); @@ -23176,6 +24838,9 @@ var ts; else if (flags & 384 /* Enum */) { return ClassificationTypeNames.enumName; } + else if (flags & 2097152 /* TypeAlias */) { + return ClassificationTypeNames.typeAlias; + } else if (meaningAtPosition & 2 /* Type */) { if (flags & 64 /* Interface */) { return ClassificationTypeNames.interfaceName; @@ -23192,19 +24857,19 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; + return declaration.kind === 189 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; }); } } function processNode(node) { if (node && span.intersectsWith(node.getStart(), node.getWidth())) { if (node.kind === 63 /* Identifier */ && node.getWidth() > 0) { - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); if (type) { result.push({ - textSpan: new ts.TextSpan(node.getStart(), node.getWidth()), + textSpan: new TextSpan(node.getStart(), node.getWidth()), classificationType: type }); } @@ -23224,7 +24889,7 @@ var ts; var width = comment.end - comment.pos; if (span.intersectsWith(comment.pos, width)) { result.push({ - textSpan: new ts.TextSpan(comment.pos, width), + textSpan: new TextSpan(comment.pos, width), classificationType: ClassificationTypeNames.comment }); } @@ -23235,7 +24900,7 @@ var ts; var type = classifyTokenType(token); if (type) { result.push({ - textSpan: new ts.TextSpan(token.getStart(), token.getWidth()), + textSpan: new TextSpan(token.getStart(), token.getWidth()), classificationType: type }); } @@ -23253,7 +24918,7 @@ var ts; } } if (ts.isPunctuation(token.kind)) { - if (token.parent.kind === 156 /* BinaryExpression */ || token.parent.kind === 185 /* VariableDeclaration */ || token.parent.kind === 154 /* PrefixOperator */ || token.parent.kind === 155 /* PostfixOperator */ || token.parent.kind === 157 /* ConditionalExpression */) { + if (token.parent.kind === 157 /* BinaryExpression */ || token.parent.kind === 183 /* VariableDeclaration */ || token.parent.kind === 155 /* PrefixUnaryExpression */ || token.parent.kind === 156 /* PostfixUnaryExpression */ || token.parent.kind === 158 /* ConditionalExpression */) { return ClassificationTypeNames.operator; } else { @@ -23274,7 +24939,7 @@ var ts; } else if (tokenKind === 63 /* Identifier */) { switch (token.parent.kind) { - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.className; } @@ -23284,17 +24949,17 @@ var ts; return ClassificationTypeNames.typeParameterName; } return; - case 189 /* InterfaceDeclaration */: + case 186 /* InterfaceDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.interfaceName; } return; - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.enumName; } return; - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.moduleName; } @@ -23337,8 +25002,8 @@ var ts; 33; var current = childNodes[i]; if (current.kind === matchKind) { - var range1 = new ts.TextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); - var range2 = new ts.TextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); + var range1 = new TextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); + var range2 = new TextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); if (range1.start() < range2.start()) { result.push(range1, range2); } @@ -23454,17 +25119,6 @@ var ts; var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; return new RegExp(regExpString, "gim"); } - function getContainingComment(comments, position) { - if (comments) { - for (var i = 0, n = comments.length; i < n; i++) { - var comment = comments[i]; - if (comment.pos <= position && position < comment.end) { - return comment; - } - } - } - return undefined; - } function isLetterOrDigit(char) { return (char >= 97 /* a */ && char <= 122 /* z */) || (char >= 65 /* A */ && char <= 90 /* Z */) || (char >= 48 /* _0 */ && char <= 57 /* _9 */); } @@ -23475,11 +25129,11 @@ var ts; var sourceFile = getSourceFile(fileName); var node = ts.getTouchingWord(sourceFile, position); if (node && node.kind === 63 /* Identifier */) { - var symbol = typeInfoResolver.getSymbolInfo(node); + var symbol = typeInfoResolver.getSymbolAtLocation(node); if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) { var kind = getSymbolKind(symbol, typeInfoResolver); if (kind) { - return getRenameInfo(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind, getSymbolModifiers(symbol), new ts.TextSpan(node.getStart(), node.getWidth())); + return getRenameInfo(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind, getSymbolModifiers(symbol), new TextSpan(node.getStart(), node.getWidth())); } } } @@ -23634,14 +25288,20 @@ var ts; if (end >= text.length) { if (token === 7 /* StringLiteral */) { var tokenText = scanner.getTokenText(); - if (tokenText.length > 0 && tokenText.charCodeAt(tokenText.length - 1) === 92 /* backslash */) { - var quoteChar = tokenText.charCodeAt(0); - result.finalLexState = quoteChar === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + if (scanner.isUnterminated()) { + var lastCharIndex = tokenText.length - 1; + var numBackslashes = 0; + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + numBackslashes++; + } + if (numBackslashes & 1) { + var quoteChar = tokenText.charCodeAt(0); + result.finalLexState = quoteChar === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + } } } else if (token === 3 /* MultiLineCommentTrivia */) { - var tokenText = scanner.getTokenText(); - if (!(tokenText.length > 3 && tokenText.charCodeAt(tokenText.length - 2) === 42 /* asterisk */ && tokenText.charCodeAt(tokenText.length - 1) === 47 /* slash */)) { + if (scanner.isUnterminated()) { result.finalLexState = 1 /* InMultiLineCommentTrivia */; } } @@ -23749,7 +25409,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 197 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 201 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -23803,91 +25463,93 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 167 /* DoStatement */) { + if (node.parent.kind === 168 /* DoStatement */) { return spanInPreviousNode(node); } - if (node.parent.kind === 169 /* ForStatement */) { + if (node.parent.kind === 170 /* ForStatement */) { return textSpan(node); } - if (node.parent.kind === 156 /* BinaryExpression */ && node.parent.operator === 22 /* CommaToken */) { + if (node.parent.kind === 157 /* BinaryExpression */ && node.parent.operator === 22 /* CommaToken */) { return textSpan(node); } - if (node.parent.kind == 153 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind == 151 /* ArrowFunction */ && node.parent.body == node) { return textSpan(node); } } switch (node.kind) { - case 163 /* VariableStatement */: + case 164 /* VariableStatement */: return spanInVariableDeclaration(node.declarations[0]); - case 185 /* VariableDeclaration */: + case 183 /* VariableDeclaration */: case 124 /* Property */: return spanInVariableDeclaration(node); case 123 /* Parameter */: return spanInParameterDeclaration(node); - case 186 /* FunctionDeclaration */: + case 184 /* FunctionDeclaration */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: case 126 /* Constructor */: - case 152 /* FunctionExpression */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 151 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 187 /* FunctionBlock */: - return spanInFunctionBlock(node); - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: - case 193 /* ModuleBlock */: + case 163 /* Block */: + if (ts.isFunctionBlock(node)) { + return spanInFunctionBlock(node); + } + case 180 /* TryBlock */: + case 181 /* FinallyBlock */: + case 190 /* ModuleBlock */: return spanInBlock(node); - case 165 /* ExpressionStatement */: + case 197 /* CatchClause */: + return spanInBlock(node.block); + case 166 /* ExpressionStatement */: return textSpan(node.expression); - case 173 /* ReturnStatement */: + case 174 /* ReturnStatement */: return textSpan(node.getChildAt(0), node.expression); - case 168 /* WhileStatement */: + case 169 /* WhileStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 167 /* DoStatement */: + case 168 /* DoStatement */: return spanInNode(node.statement); - case 184 /* DebuggerStatement */: + case 182 /* DebuggerStatement */: return textSpan(node.getChildAt(0)); - case 166 /* IfStatement */: + case 167 /* IfStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 178 /* LabeledStatement */: + case 177 /* LabeledStatement */: return spanInNode(node.statement); - case 172 /* BreakStatement */: - case 171 /* ContinueStatement */: + case 173 /* BreakStatement */: + case 172 /* ContinueStatement */: return textSpan(node.getChildAt(0), node.label); - case 169 /* ForStatement */: + case 170 /* ForStatement */: return spanInForStatement(node); - case 170 /* ForInStatement */: + case 171 /* ForInStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 176 /* CaseClause */: - case 177 /* DefaultClause */: + case 194 /* CaseClause */: + case 195 /* DefaultClause */: return spanInNode(node.statements[0]); - case 180 /* TryStatement */: + case 179 /* TryStatement */: return spanInBlock(node.tryBlock); - case 179 /* ThrowStatement */: + case 178 /* ThrowStatement */: return textSpan(node, node.expression); - case 195 /* ExportAssignment */: + case 192 /* ExportAssignment */: return textSpan(node, node.exportName); - case 194 /* ImportDeclaration */: - return textSpan(node, node.entityName || node.externalModuleName); - case 192 /* ModuleDeclaration */: + case 191 /* ImportDeclaration */: + return textSpan(node, node.moduleReference); + case 189 /* ModuleDeclaration */: if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 188 /* ClassDeclaration */: - case 191 /* EnumDeclaration */: - case 196 /* EnumMember */: - case 147 /* CallExpression */: - case 148 /* NewExpression */: + case 185 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: + case 200 /* EnumMember */: + case 145 /* CallExpression */: + case 146 /* NewExpression */: return textSpan(node); - case 174 /* WithStatement */: + case 175 /* WithStatement */: return spanInNode(node.statement); - case 189 /* InterfaceDeclaration */: - case 190 /* TypeAliasDeclaration */: + case 186 /* InterfaceDeclaration */: + case 187 /* TypeAliasDeclaration */: return undefined; case 21 /* SemicolonToken */: case 1 /* EndOfFileToken */: @@ -23914,11 +25576,11 @@ var ts; case 79 /* FinallyKeyword */: return spanInNextNode(node); default: - if (node.parent.kind === 143 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 198 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 150 /* TypeAssertion */ && node.parent.type === node) { - return spanInNode(node.parent.operand); + if (node.parent.kind === 148 /* TypeAssertionExpression */ && node.parent.type === node) { + return spanInNode(node.parent.expression); } if (ts.isAnyFunction(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); @@ -23927,11 +25589,11 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.kind === 170 /* ForInStatement */) { + if (variableDeclaration.parent.kind === 171 /* ForInStatement */) { return spanInNode(variableDeclaration.parent); } - var isParentVariableStatement = variableDeclaration.parent.kind === 163 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.kind === 169 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.kind === 164 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.kind === 170 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.declarations : isDeclarationOfForStatement ? variableDeclaration.parent.declarations : undefined; if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { if (declarations && declarations[0] === variableDeclaration) { @@ -23953,7 +25615,7 @@ var ts; } } function canHaveSpanInParameterDeclaration(parameter) { - return !!parameter.initializer || !!(parameter.flags & 8 /* Rest */) || !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + return !!parameter.initializer || parameter.dotDotDotToken !== undefined || !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -23971,7 +25633,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 188 /* ClassDeclaration */ && functionDeclaration.kind !== 126 /* Constructor */); + return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 185 /* ClassDeclaration */ && functionDeclaration.kind !== 126 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -23991,15 +25653,15 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 192 /* ModuleDeclaration */: + case 189 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - case 168 /* WhileStatement */: - case 166 /* IfStatement */: - case 170 /* ForInStatement */: + case 169 /* WhileStatement */: + case 167 /* IfStatement */: + case 171 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 169 /* ForStatement */: + case 170 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); @@ -24020,34 +25682,36 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 191 /* EnumDeclaration */: + case 188 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 188 /* ClassDeclaration */: + case 185 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: return spanInNodeIfStartsOnSameLine(node.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 193 /* ModuleBlock */: + case 190 /* ModuleBlock */: if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 187 /* FunctionBlock */: - case 191 /* EnumDeclaration */: - case 188 /* ClassDeclaration */: + case 188 /* EnumDeclaration */: + case 185 /* ClassDeclaration */: return textSpan(node); - case 162 /* Block */: - case 181 /* TryBlock */: - case 182 /* CatchBlock */: - case 183 /* FinallyBlock */: + case 163 /* Block */: + if (ts.isFunctionBlock(node.parent)) { + return textSpan(node); + } + case 180 /* TryBlock */: + case 197 /* CatchClause */: + case 181 /* FinallyBlock */: return spanInNode(node.parent.statements[node.parent.statements.length - 1]); ; - case 175 /* SwitchStatement */: + case 176 /* SwitchStatement */: var switchStatement = node.parent; var lastClause = switchStatement.clauses[switchStatement.clauses.length - 1]; if (lastClause) { @@ -24059,23 +25723,23 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 167 /* DoStatement */) { + if (node.parent.kind === 168 /* DoStatement */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 152 /* FunctionExpression */: - case 186 /* FunctionDeclaration */: - case 153 /* ArrowFunction */: + case 150 /* FunctionExpression */: + case 184 /* FunctionDeclaration */: + case 151 /* ArrowFunction */: case 125 /* Method */: case 127 /* GetAccessor */: case 128 /* SetAccessor */: case 126 /* Constructor */: - case 168 /* WhileStatement */: - case 167 /* DoStatement */: - case 169 /* ForStatement */: + case 169 /* WhileStatement */: + case 168 /* DoStatement */: + case 170 /* ForStatement */: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -24083,19 +25747,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isAnyFunction(node.parent) || node.parent.kind === 143 /* PropertyAssignment */) { + if (ts.isAnyFunction(node.parent) || node.parent.kind === 198 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 150 /* TypeAssertion */) { - return spanInNode(node.parent.operand); + if (node.parent.kind === 148 /* TypeAssertionExpression */) { + return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 167 /* DoStatement */) { + if (node.parent.kind === 168 /* DoStatement */) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -24108,82 +25772,6 @@ var ts; var debugObjectHost = this; var ts; (function (ts) { - function languageVersionToScriptTarget(languageVersion) { - if (typeof languageVersion === "undefined") - return undefined; - switch (languageVersion) { - case 0 /* EcmaScript3 */: return 0 /* ES3 */; - case 1 /* EcmaScript5 */: return 1 /* ES5 */; - case 2 /* EcmaScript6 */: return 2 /* ES6 */; - default: throw Error("unsupported LanguageVersion value: " + languageVersion); - } - } - function moduleGenTargetToModuleKind(moduleGenTarget) { - if (typeof moduleGenTarget === "undefined") - return undefined; - switch (moduleGenTarget) { - case 2 /* Asynchronous */: return 2 /* AMD */; - case 1 /* Synchronous */: return 1 /* CommonJS */; - case 0 /* Unspecified */: return 0 /* None */; - default: throw Error("unsupported ModuleGenTarget value: " + moduleGenTarget); - } - } - function scriptTargetTolanguageVersion(scriptTarget) { - if (typeof scriptTarget === "undefined") - return undefined; - switch (scriptTarget) { - case 0 /* ES3 */: return 0 /* EcmaScript3 */; - case 1 /* ES5 */: return 1 /* EcmaScript5 */; - case 2 /* ES6 */: return 2 /* EcmaScript6 */; - default: throw Error("unsupported ScriptTarget value: " + scriptTarget); - } - } - function moduleKindToModuleGenTarget(moduleKind) { - if (typeof moduleKind === "undefined") - return undefined; - switch (moduleKind) { - case 2 /* AMD */: return 2 /* Asynchronous */; - case 1 /* CommonJS */: return 1 /* Synchronous */; - case 0 /* None */: return 0 /* Unspecified */; - default: throw Error("unsupported ModuleKind value: " + moduleKind); - } - } - function compilationSettingsToCompilerOptions(settings) { - var options = {}; - options.removeComments = settings.removeComments; - options.noResolve = settings.noResolve; - options.noImplicitAny = settings.noImplicitAny; - options.noLib = settings.noLib; - options.target = languageVersionToScriptTarget(settings.codeGenTarget); - options.module = moduleGenTargetToModuleKind(settings.moduleGenTarget); - options.out = settings.outFileOption; - options.outDir = settings.outDirOption; - options.sourceMap = settings.mapSourceFiles; - options.mapRoot = settings.mapRoot; - options.sourceRoot = settings.sourceRoot; - options.declaration = settings.generateDeclarationFiles; - options.codepage = settings.codepage; - options.emitBOM = settings.emitBOM; - return options; - } - function compilerOptionsToCompilationSettings(options) { - var settings = {}; - settings.removeComments = options.removeComments; - settings.noResolve = options.noResolve; - settings.noImplicitAny = options.noImplicitAny; - settings.noLib = options.noLib; - settings.codeGenTarget = scriptTargetTolanguageVersion(options.target); - settings.moduleGenTarget = moduleKindToModuleGenTarget(options.module); - settings.outFileOption = options.out; - settings.outDirOption = options.outDir; - settings.mapSourceFiles = options.sourceMap; - settings.mapRoot = options.mapRoot; - settings.sourceRoot = options.sourceRoot; - settings.generateDeclarationFiles = options.declaration; - settings.codepage = options.codepage; - settings.emitBOM = options.emitBOM; - return settings; - } function logInternalError(logger, err) { logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); } @@ -24228,8 +25816,7 @@ var ts; throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null; } - var options = compilationSettingsToCompilerOptions(JSON.parse(settingsJson)); - return options; + return JSON.parse(settingsJson); }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -24260,8 +25847,8 @@ var ts; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { return this.shimHost.getCancellationToken(); }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFilename = function () { - return this.shimHost.getDefaultLibFilename(); + LanguageServiceShimHostAdapter.prototype.getDefaultLibFilename = function (options) { + return this.shimHost.getDefaultLibFilename(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -24458,10 +26045,10 @@ var ts; return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, isMemberCompletion) { + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + isMemberCompletion + ")", function () { - var completion = _this.languageService.getCompletionsAtPosition(fileName, position, isMemberCompletion); + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { + var completion = _this.languageService.getCompletionsAtPosition(fileName, position); return completion; }); }; @@ -24589,7 +26176,7 @@ var ts; }; CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { return this.forwardJSONCall("getDefaultCompilationSettings()", function () { - return compilerOptionsToCompilationSettings(ts.getDefaultCompilerOptions()); + return ts.getDefaultCompilerOptions(); }); }; return CoreServicesShimObject; @@ -24599,6 +26186,9 @@ var ts; this._shims = []; this.documentRegistry = ts.createDocumentRegistry(); } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { try { var hostAdapter = new LanguageServiceShimHostAdapter(host); @@ -24647,6 +26237,9 @@ var ts; return TypeScriptServicesFactory; })(); ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } })(ts || (ts = {})); var TypeScript; (function (TypeScript) { From eaf1c5aa5fd71b48fb5f5c9f67d215228ea08380 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 16 Dec 2014 11:25:22 -0800 Subject: [PATCH 15/93] Change the order of switch statements instead of converting to if-else --- src/compiler/parser.ts | 62 +++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1a3a87952d1..491735882f8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2669,41 +2669,35 @@ module ts { } function parsePrimaryExpression(): PrimaryExpression { - if (token === SyntaxKind.ThisKeyword || - token === SyntaxKind.SuperKeyword || - token === SyntaxKind.NullKeyword || - token === SyntaxKind.TrueKeyword || - token === SyntaxKind.FalseKeyword) { - return parseTokenNode(); - } - else if (token === SyntaxKind.NumericLiteral || - token === SyntaxKind.StringLiteral || - token === SyntaxKind.NoSubstitutionTemplateLiteral) { - return parseLiteralNode(); - } - else if (token === SyntaxKind.OpenParenToken) { - return parseParenthesizedExpression(); - } - else if (token === SyntaxKind.OpenBracketToken) { - return parseArrayLiteralExpression(); - } - else if (token === SyntaxKind.OpenBraceToken) { - return parseObjectLiteralExpression(); - } - else if (token === SyntaxKind.FunctionKeyword) { - return parseFunctionExpression(); - } - else if (token === SyntaxKind.NewKeyword) { - return parseNewExpression(); - } - else if (token === SyntaxKind.SlashToken || - token === SyntaxKind.SlashEqualsToken) { - if (reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { + switch (token) { + case SyntaxKind.NumericLiteral: + case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: return parseLiteralNode(); - } - } - else if (token === SyntaxKind.TemplateHead) { - return parseTemplateExpression(); + case SyntaxKind.ThisKeyword: + case SyntaxKind.SuperKeyword: + case SyntaxKind.NullKeyword: + case SyntaxKind.TrueKeyword: + case SyntaxKind.FalseKeyword: + return parseTokenNode(); + case SyntaxKind.OpenParenToken: + return parseParenthesizedExpression(); + case SyntaxKind.OpenBracketToken: + return parseArrayLiteralExpression(); + case SyntaxKind.OpenBraceToken: + return parseObjectLiteralExpression(); + case SyntaxKind.FunctionKeyword: + return parseFunctionExpression(); + case SyntaxKind.NewKeyword: + return parseNewExpression(); + case SyntaxKind.SlashToken: + case SyntaxKind.SlashEqualsToken: + if (reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) { + return parseLiteralNode(); + } + break; + case SyntaxKind.TemplateHead: + return parseTemplateExpression(); } return parseIdentifier(Diagnostics.Expression_expected); From ab33a65d30e2d4a1a989033ab49d3d89a33a7431 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 16 Dec 2014 14:59:21 -0800 Subject: [PATCH 16/93] Fix issue #1503 with modules and imports sharing a name --- src/compiler/checker.ts | 16 +++++++- ...SharesNameWithImportDeclarationInsideIt.js | 35 ++++++++++++++++ ...resNameWithImportDeclarationInsideIt.types | 29 ++++++++++++++ ...haresNameWithImportDeclarationInsideIt2.js | 35 ++++++++++++++++ ...esNameWithImportDeclarationInsideIt2.types | 29 ++++++++++++++ ...eWithImportDeclarationInsideIt3.errors.txt | 25 ++++++++++++ ...haresNameWithImportDeclarationInsideIt3.js | 40 +++++++++++++++++++ ...haresNameWithImportDeclarationInsideIt4.js | 36 +++++++++++++++++ ...esNameWithImportDeclarationInsideIt4.types | 32 +++++++++++++++ ...eWithImportDeclarationInsideIt5.errors.txt | 25 ++++++++++++ ...haresNameWithImportDeclarationInsideIt5.js | 39 ++++++++++++++++++ ...SharesNameWithImportDeclarationInsideIt.ts | 11 +++++ ...haresNameWithImportDeclarationInsideIt2.ts | 11 +++++ ...haresNameWithImportDeclarationInsideIt3.ts | 16 ++++++++ ...haresNameWithImportDeclarationInsideIt4.ts | 12 ++++++ ...haresNameWithImportDeclarationInsideIt5.ts | 16 ++++++++ 16 files changed, 405 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.js create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.errors.txt create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.errors.txt create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js create mode 100644 tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts create mode 100644 tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt2.ts create mode 100644 tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts create mode 100644 tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.ts create mode 100644 tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b0c0305670e..119b60f71cf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9178,8 +9178,20 @@ module ts { function isUniqueLocalName(name: string, container: Node): boolean { for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && hasProperty(node.locals, name) && node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue)) { - return false; + if (node.locals && hasProperty(node.locals, name)) { + var symbolWithRelevantName = node.locals[name]; + if (symbolWithRelevantName.flags & (SymbolFlags.Value | SymbolFlags.ExportValue)) { + return false; + } + + // An import can be emitted too, if it is referenced as a value. + // Make sure the name in question does not collide with an import. + if (symbolWithRelevantName.flags & SymbolFlags.Import) { + var importDeclarationWithRelevantName = getDeclarationOfKind(symbolWithRelevantName, SyntaxKind.ImportDeclaration); + if (isReferencedImportDeclaration(importDeclarationWithRelevantName)) { + return false; + } + } } } return true; diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js new file mode 100644 index 00000000000..983dc004acf --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.js @@ -0,0 +1,35 @@ +//// [moduleSharesNameWithImportDeclarationInsideIt.ts] +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + import M = Z.M; + export function bar() { + } + M.bar(); // Should call Z.M.bar +} + +//// [moduleSharesNameWithImportDeclarationInsideIt.js] +var Z; +(function (Z) { + var M; + (function (M) { + function bar() { + return ""; + } + M.bar = bar; + })(M = Z.M || (Z.M = {})); +})(Z || (Z = {})); +var A; +(function (A) { + var M; + (function (_M) { + var M = Z.M; + function bar() { + } + _M.bar = bar; + M.bar(); // Should call Z.M.bar + })(M = A.M || (A.M = {})); +})(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types new file mode 100644 index 00000000000..5a29a01cec7 --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts === +module Z.M { +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => string + + return ""; + } +} +module A.M { +>A : typeof A +>M : typeof A.M + + import M = Z.M; +>M : typeof M +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => void + } + M.bar(); // Should call Z.M.bar +>M.bar() : string +>M.bar : () => string +>M : typeof M +>bar : () => string +} diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.js new file mode 100644 index 00000000000..1366f52e7f8 --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.js @@ -0,0 +1,35 @@ +//// [moduleSharesNameWithImportDeclarationInsideIt2.ts] +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + export import M = Z.M; + export function bar() { + } + M.bar(); // Should call Z.M.bar +} + +//// [moduleSharesNameWithImportDeclarationInsideIt2.js] +var Z; +(function (Z) { + var M; + (function (M) { + function bar() { + return ""; + } + M.bar = bar; + })(M = Z.M || (Z.M = {})); +})(Z || (Z = {})); +var A; +(function (A) { + var M; + (function (M) { + M.M = Z.M; + function bar() { + } + M.bar = bar; + M.M.bar(); // Should call Z.M.bar + })(M = A.M || (A.M = {})); +})(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types new file mode 100644 index 00000000000..75aba0e2d0e --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt2.ts === +module Z.M { +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => string + + return ""; + } +} +module A.M { +>A : typeof A +>M : typeof A.M + + export import M = Z.M; +>M : typeof M +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => void + } + M.bar(); // Should call Z.M.bar +>M.bar() : string +>M.bar : () => string +>M : typeof M +>bar : () => string +} diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.errors.txt b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.errors.txt new file mode 100644 index 00000000000..f8fa117c024 --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts(10,12): error TS2300: Duplicate identifier 'M'. +tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts(11,12): error TS2300: Duplicate identifier 'M'. + + +==== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts (2 errors) ==== + module Z { + export module M { + export function bar() { + return ""; + } + } + export interface I { } + } + module A.M { + import M = Z.M; + ~ +!!! error TS2300: Duplicate identifier 'M'. + import M = Z.I; + ~ +!!! error TS2300: Duplicate identifier 'M'. + + export function bar() { + } + M.bar(); // Should call Z.M.bar + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js new file mode 100644 index 00000000000..c11b36f643a --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt3.js @@ -0,0 +1,40 @@ +//// [moduleSharesNameWithImportDeclarationInsideIt3.ts] +module Z { + export module M { + export function bar() { + return ""; + } + } + export interface I { } +} +module A.M { + import M = Z.M; + import M = Z.I; + + export function bar() { + } + M.bar(); // Should call Z.M.bar +} + +//// [moduleSharesNameWithImportDeclarationInsideIt3.js] +var Z; +(function (Z) { + var M; + (function (M) { + function bar() { + return ""; + } + M.bar = bar; + })(M = Z.M || (Z.M = {})); +})(Z || (Z = {})); +var A; +(function (A) { + var M; + (function (_M) { + var M = Z.M; + function bar() { + } + _M.bar = bar; + M.bar(); // Should call Z.M.bar + })(M = A.M || (A.M = {})); +})(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js new file mode 100644 index 00000000000..c61f3d4dd9d --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.js @@ -0,0 +1,36 @@ +//// [moduleSharesNameWithImportDeclarationInsideIt4.ts] +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + interface M { } + import M = Z.M; + export function bar() { + } + M.bar(); // Should call Z.M.bar +} + +//// [moduleSharesNameWithImportDeclarationInsideIt4.js] +var Z; +(function (Z) { + var M; + (function (M) { + function bar() { + return ""; + } + M.bar = bar; + })(M = Z.M || (Z.M = {})); +})(Z || (Z = {})); +var A; +(function (A) { + var M; + (function (_M) { + var M = Z.M; + function bar() { + } + _M.bar = bar; + M.bar(); // Should call Z.M.bar + })(M = A.M || (A.M = {})); +})(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types new file mode 100644 index 00000000000..b4df2e0ae08 --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.ts === +module Z.M { +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => string + + return ""; + } +} +module A.M { +>A : typeof A +>M : typeof A.M + + interface M { } +>M : M + + import M = Z.M; +>M : typeof M +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => void + } + M.bar(); // Should call Z.M.bar +>M.bar() : string +>M.bar : () => string +>M : typeof M +>bar : () => string +} diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.errors.txt b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.errors.txt new file mode 100644 index 00000000000..5e548809e9c --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts(10,12): error TS2300: Duplicate identifier 'M'. +tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts(11,12): error TS2300: Duplicate identifier 'M'. + + +==== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts (2 errors) ==== + module Z { + export module M { + export function bar() { + return ""; + } + } + export interface I { } + } + module A.M { + import M = Z.I; + ~ +!!! error TS2300: Duplicate identifier 'M'. + import M = Z.M; + ~ +!!! error TS2300: Duplicate identifier 'M'. + + export function bar() { + } + M.bar(); // Should call Z.M.bar + } \ No newline at end of file diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js new file mode 100644 index 00000000000..0995dcbb9c0 --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt5.js @@ -0,0 +1,39 @@ +//// [moduleSharesNameWithImportDeclarationInsideIt5.ts] +module Z { + export module M { + export function bar() { + return ""; + } + } + export interface I { } +} +module A.M { + import M = Z.I; + import M = Z.M; + + export function bar() { + } + M.bar(); // Should call Z.M.bar +} + +//// [moduleSharesNameWithImportDeclarationInsideIt5.js] +var Z; +(function (Z) { + var M; + (function (M) { + function bar() { + return ""; + } + M.bar = bar; + })(M = Z.M || (Z.M = {})); +})(Z || (Z = {})); +var A; +(function (A) { + var M; + (function (M) { + function bar() { + } + M.bar = bar; + M.bar(); // Should call Z.M.bar + })(M = A.M || (A.M = {})); +})(A || (A = {})); diff --git a/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts new file mode 100644 index 00000000000..dfb21cccbe7 --- /dev/null +++ b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts @@ -0,0 +1,11 @@ +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + import M = Z.M; + export function bar() { + } + M.bar(); // Should call Z.M.bar +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt2.ts b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt2.ts new file mode 100644 index 00000000000..f81fe17a624 --- /dev/null +++ b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt2.ts @@ -0,0 +1,11 @@ +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + export import M = Z.M; + export function bar() { + } + M.bar(); // Should call Z.M.bar +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts new file mode 100644 index 00000000000..417d6aad8fd --- /dev/null +++ b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts @@ -0,0 +1,16 @@ +module Z { + export module M { + export function bar() { + return ""; + } + } + export interface I { } +} +module A.M { + import M = Z.M; + import M = Z.I; + + export function bar() { + } + M.bar(); // Should call Z.M.bar +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.ts b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.ts new file mode 100644 index 00000000000..1c7993c596e --- /dev/null +++ b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.ts @@ -0,0 +1,12 @@ +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + interface M { } + import M = Z.M; + export function bar() { + } + M.bar(); // Should call Z.M.bar +} \ No newline at end of file diff --git a/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts new file mode 100644 index 00000000000..fa224b1b7f9 --- /dev/null +++ b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts @@ -0,0 +1,16 @@ +module Z { + export module M { + export function bar() { + return ""; + } + } + export interface I { } +} +module A.M { + import M = Z.I; + import M = Z.M; + + export function bar() { + } + M.bar(); // Should call Z.M.bar +} \ No newline at end of file From c5b702d06695d6a6f8e1229bf3d9a56373cb72a2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 16 Dec 2014 21:51:10 -0800 Subject: [PATCH 17/93] Update LKG --- bin/tsc.js | 21 ++- bin/typescriptServices.js | 21 ++- bin/typescriptServices_internal.d.ts | 258 +++++++++++++++++++++++++++ bin/typescript_internal.d.ts | 258 +++++++++++++++++++++++++++ 4 files changed, 548 insertions(+), 10 deletions(-) create mode 100644 bin/typescriptServices_internal.d.ts create mode 100644 bin/typescript_internal.d.ts diff --git a/bin/tsc.js b/bin/tsc.js index 370b62f59bd..69ed196f789 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -14333,15 +14333,21 @@ var ts; } return undefined; } - function getContextualTypeForArgument(node) { - var callExpression = node.parent; - var argIndex = ts.indexOf(callExpression.arguments, node); + function getContextualTypeForArgument(callTarget, arg) { + var args = getEffectiveCallArguments(callTarget); + var argIndex = ts.indexOf(args, arg); if (argIndex >= 0) { - var signature = getResolvedSignature(callExpression); + var signature = getResolvedSignature(callTarget); return getTypeAtPosition(signature, argIndex); } return undefined; } + function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { + if (template.parent.kind === 147 /* TaggedTemplateExpression */) { + return getContextualTypeForArgument(template.parent, substitutionExpression); + } + return undefined; + } function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operator; @@ -14444,7 +14450,7 @@ var ts; return getContextualTypeForReturnExpression(node); case 145 /* CallExpression */: case 146 /* NewExpression */: - return getContextualTypeForArgument(node); + return getContextualTypeForArgument(parent, node); case 148 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); case 157 /* BinaryExpression */: @@ -14455,6 +14461,9 @@ var ts; return getContextualTypeForElementExpression(node); case 158 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); + case 162 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 159 /* TemplateExpression */); + return getContextualTypeForSubstitutionExpression(parent.parent, node); } return undefined; } @@ -17132,6 +17141,8 @@ var ts; case 145 /* CallExpression */: case 146 /* NewExpression */: case 147 /* TaggedTemplateExpression */: + case 159 /* TemplateExpression */: + case 162 /* TemplateSpan */: case 148 /* TypeAssertionExpression */: case 149 /* ParenthesizedExpression */: case 153 /* TypeOfExpression */: diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index a07dba93a1c..6f26fe9c403 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -14921,15 +14921,21 @@ var ts; } return undefined; } - function getContextualTypeForArgument(node) { - var callExpression = node.parent; - var argIndex = ts.indexOf(callExpression.arguments, node); + function getContextualTypeForArgument(callTarget, arg) { + var args = getEffectiveCallArguments(callTarget); + var argIndex = ts.indexOf(args, arg); if (argIndex >= 0) { - var signature = getResolvedSignature(callExpression); + var signature = getResolvedSignature(callTarget); return getTypeAtPosition(signature, argIndex); } return undefined; } + function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { + if (template.parent.kind === 147 /* TaggedTemplateExpression */) { + return getContextualTypeForArgument(template.parent, substitutionExpression); + } + return undefined; + } function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operator; @@ -15032,7 +15038,7 @@ var ts; return getContextualTypeForReturnExpression(node); case 145 /* CallExpression */: case 146 /* NewExpression */: - return getContextualTypeForArgument(node); + return getContextualTypeForArgument(parent, node); case 148 /* TypeAssertionExpression */: return getTypeFromTypeNode(parent.type); case 157 /* BinaryExpression */: @@ -15043,6 +15049,9 @@ var ts; return getContextualTypeForElementExpression(node); case 158 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); + case 162 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 159 /* TemplateExpression */); + return getContextualTypeForSubstitutionExpression(parent.parent, node); } return undefined; } @@ -17720,6 +17729,8 @@ var ts; case 145 /* CallExpression */: case 146 /* NewExpression */: case 147 /* TaggedTemplateExpression */: + case 159 /* TemplateExpression */: + case 162 /* TemplateSpan */: case 148 /* TypeAssertionExpression */: case 149 /* ParenthesizedExpression */: case 153 /* TypeOfExpression */: diff --git a/bin/typescriptServices_internal.d.ts b/bin/typescriptServices_internal.d.ts new file mode 100644 index 00000000000..5a0c80aa9df --- /dev/null +++ b/bin/typescriptServices_internal.d.ts @@ -0,0 +1,258 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +declare module ts { + const enum Ternary { + False = 0, + Maybe = 1, + True = -1, + } + const enum Comparison { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1, + } + interface StringSet extends Map { + } + function forEach(array: T[], callback: (element: T) => U): U; + function contains(array: T[], value: T): boolean; + function indexOf(array: T[], value: T): number; + function countWhere(array: T[], predicate: (x: T) => boolean): number; + function filter(array: T[], f: (x: T) => boolean): T[]; + function map(array: T[], f: (x: T) => U): U[]; + function concatenate(array1: T[], array2: T[]): T[]; + function deduplicate(array: T[]): T[]; + function sum(array: any[], prop: string): number; + /** + * Returns the last element of an array if non-empty, undefined otherwise. + */ + function lastOrUndefined(array: T[]): T; + function binarySearch(array: number[], value: number): number; + function hasProperty(map: Map, key: string): boolean; + function getProperty(map: Map, key: string): T; + function isEmpty(map: Map): boolean; + function clone(object: T): T; + function forEachValue(map: Map, callback: (value: T) => U): U; + function forEachKey(map: Map, callback: (key: string) => U): U; + function lookUp(map: Map, key: string): T; + function mapToArray(map: Map): T[]; + /** + * Creates a map from the elements of an array. + * + * @param array the array of input elements. + * @param makeKey a function that produces a key for a given element. + * + * This function makes no effort to avoid collisions; if any two elements produce + * the same key with the given 'makeKey' function, then the element with the higher + * index in the array will be the one associated with the produced key. + */ + function arrayToMap(array: T[], makeKey: (value: T) => string): Map; + var localizedDiagnosticMessages: Map; + function getLocaleSpecificMessage(message: string): string; + function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; + function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic; + function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; + function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; + function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic; + function compareValues(a: T, b: T): Comparison; + function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): number; + function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; + function normalizeSlashes(path: string): string; + function getRootLength(path: string): number; + var directorySeparator: string; + function normalizePath(path: string): string; + function getDirectoryPath(path: string): string; + function isUrl(path: string): boolean; + function isRootedDiskPath(path: string): boolean; + function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; + function getNormalizedAbsolutePath(filename: string, currentDirectory: string): string; + function getNormalizedPathFromPathComponents(pathComponents: string[]): string; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string; + function getBaseFilename(path: string): string; + function combinePaths(path1: string, path2: string): string; + function fileExtensionIs(path: string, extension: string): boolean; + function removeFileExtension(path: string): string; + /** NOTE: This *does not* support the full escape characters, it only supports the subset that can be used in file names + * or string literals. If the information encoded in the map changes, this needs to be revisited. */ + function escapeString(s: string): string; + interface ObjectAllocator { + getNodeConstructor(kind: SyntaxKind): new () => Node; + getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; + getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; + getSignatureConstructor(): new (checker: TypeChecker) => Signature; + } + var objectAllocator: ObjectAllocator; + const enum AssertionLevel { + None = 0, + Normal = 1, + Aggressive = 2, + VeryAggressive = 3, + } + module Debug { + function shouldAssert(level: AssertionLevel): boolean; + function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; + function fail(message?: string): void; + } +} +declare module ts { + interface System { + args: string[]; + newLine: string; + useCaseSensitiveFileNames: boolean; + write(s: string): void; + readFile(fileName: string, encoding?: string): string; + writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void; + watchFile?(fileName: string, callback: (fileName: string) => void): FileWatcher; + resolvePath(path: string): string; + fileExists(path: string): boolean; + directoryExists(path: string): boolean; + createDirectory(directoryName: string): void; + getExecutingFilePath(): string; + getCurrentDirectory(): string; + getMemoryUsage?(): number; + exit(exitCode?: number): void; + } + interface FileWatcher { + close(): void; + } + var sys: System; +} +declare module ts { + interface ReferencePathMatchResult { + fileReference?: FileReference; + diagnosticMessage?: DiagnosticMessage; + isNoDefaultLib?: boolean; + } + function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration; + interface StringSymbolWriter extends SymbolWriter { + string(): string; + } + function getSingleLineStringWriter(): StringSymbolWriter; + function releaseStringWriter(writer: StringSymbolWriter): void; + function getFullWidth(node: Node): number; + function hasFlag(val: number, flag: number): boolean; + function containsParseError(node: Node): boolean; + function getSourceFileOfNode(node: Node): SourceFile; + function nodePosToString(node: Node): string; + function getStartPosOfNode(node: Node): number; + function isMissingNode(node: Node): boolean; + function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number; + function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string; + function getTextOfNodeFromSourceText(sourceText: string, node: Node): string; + function getTextOfNode(node: Node): string; + function escapeIdentifier(identifier: string): string; + function unescapeIdentifier(identifier: string): string; + function declarationNameToString(name: DeclarationName): string; + function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic; + function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): Diagnostic; + function getErrorSpanForNode(node: Node): Node; + function isExternalModule(file: SourceFile): boolean; + function isDeclarationFile(file: SourceFile): boolean; + function isConstEnumDeclaration(node: Node): boolean; + function isConst(node: Node): boolean; + function isLet(node: Node): boolean; + function isPrologueDirective(node: Node): boolean; + function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[]; + function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; + var fullTripleSlashReferencePathRegEx: RegExp; + function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; + function isAnyFunction(node: Node): boolean; + function isFunctionBlock(node: Node): boolean; + function isObjectLiteralMethod(node: Node): boolean; + function getContainingFunction(node: Node): FunctionLikeDeclaration; + function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; + function getSuperContainer(node: Node): Node; + function getInvokedExpression(node: CallLikeExpression): Expression; + function isExpression(node: Node): boolean; + function isExternalModuleImportDeclaration(node: Node): boolean; + function getExternalModuleImportDeclarationExpression(node: Node): Expression; + function isInternalModuleImportDeclaration(node: Node): boolean; + function hasDotDotDotToken(node: Node): boolean; + function hasQuestionToken(node: Node): boolean; + function hasRestParameters(s: SignatureDeclaration): boolean; + function isLiteralKind(kind: SyntaxKind): boolean; + function isTextualLiteralKind(kind: SyntaxKind): boolean; + function isTemplateLiteralKind(kind: SyntaxKind): boolean; + function isInAmbientContext(node: Node): boolean; + function isDeclaration(node: Node): boolean; + function isStatement(n: Node): boolean; + function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean; + function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode; + function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray; + function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; + function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; + function tryResolveScriptReference(program: Program, sourceFile: SourceFile, reference: FileReference): SourceFile; + function getAncestor(node: Node, kind: SyntaxKind): Node; + function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; + function isKeyword(token: SyntaxKind): boolean; + function isTrivia(token: SyntaxKind): boolean; + function isModifier(token: SyntaxKind): boolean; +} +declare module ts { + interface ListItemInfo { + listItemIndex: number; + list: Node; + } + function getEndLinePosition(line: number, sourceFile: SourceFile): number; + function getStartPositionOfLine(line: number, sourceFile: SourceFile): number; + function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number; + function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; + function startEndContainsRange(start: number, end: number, range: TextRange): boolean; + function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; + function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; + function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; + function findListItemInfo(node: Node): ListItemInfo; + function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; + function findContainingList(node: Node): Node; + function getTouchingWord(sourceFile: SourceFile, position: number): Node; + function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node; + /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ + function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean): Node; + /** Returns a token if position is in [start-of-leading-trivia, end) */ + function getTokenAtPosition(sourceFile: SourceFile, position: number): Node; + /** + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ + function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; + function findNextToken(previousToken: Node, parent: Node): Node; + function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; + function getNodeModifiers(node: Node): string; + function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; + function isToken(n: Node): boolean; + function isComment(kind: SyntaxKind): boolean; + function isPunctuation(kind: SyntaxKind): boolean; + function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; + function compareDataObjects(dst: any, src: any): boolean; +} +declare module ts { + function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; + function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; + function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart; + function spacePart(): SymbolDisplayPart; + function keywordPart(kind: SyntaxKind): SymbolDisplayPart; + function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; + function operatorPart(kind: SyntaxKind): SymbolDisplayPart; + function textPart(text: string): SymbolDisplayPart; + function lineBreakPart(): SymbolDisplayPart; + function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; + function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; + function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; +} diff --git a/bin/typescript_internal.d.ts b/bin/typescript_internal.d.ts new file mode 100644 index 00000000000..f64aaf2b888 --- /dev/null +++ b/bin/typescript_internal.d.ts @@ -0,0 +1,258 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +declare module "typescript" { + const enum Ternary { + False = 0, + Maybe = 1, + True = -1, + } + const enum Comparison { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1, + } + interface StringSet extends Map { + } + function forEach(array: T[], callback: (element: T) => U): U; + function contains(array: T[], value: T): boolean; + function indexOf(array: T[], value: T): number; + function countWhere(array: T[], predicate: (x: T) => boolean): number; + function filter(array: T[], f: (x: T) => boolean): T[]; + function map(array: T[], f: (x: T) => U): U[]; + function concatenate(array1: T[], array2: T[]): T[]; + function deduplicate(array: T[]): T[]; + function sum(array: any[], prop: string): number; + /** + * Returns the last element of an array if non-empty, undefined otherwise. + */ + function lastOrUndefined(array: T[]): T; + function binarySearch(array: number[], value: number): number; + function hasProperty(map: Map, key: string): boolean; + function getProperty(map: Map, key: string): T; + function isEmpty(map: Map): boolean; + function clone(object: T): T; + function forEachValue(map: Map, callback: (value: T) => U): U; + function forEachKey(map: Map, callback: (key: string) => U): U; + function lookUp(map: Map, key: string): T; + function mapToArray(map: Map): T[]; + /** + * Creates a map from the elements of an array. + * + * @param array the array of input elements. + * @param makeKey a function that produces a key for a given element. + * + * This function makes no effort to avoid collisions; if any two elements produce + * the same key with the given 'makeKey' function, then the element with the higher + * index in the array will be the one associated with the produced key. + */ + function arrayToMap(array: T[], makeKey: (value: T) => string): Map; + var localizedDiagnosticMessages: Map; + function getLocaleSpecificMessage(message: string): string; + function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; + function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic; + function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; + function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; + function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic; + function compareValues(a: T, b: T): Comparison; + function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): number; + function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; + function normalizeSlashes(path: string): string; + function getRootLength(path: string): number; + var directorySeparator: string; + function normalizePath(path: string): string; + function getDirectoryPath(path: string): string; + function isUrl(path: string): boolean; + function isRootedDiskPath(path: string): boolean; + function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; + function getNormalizedAbsolutePath(filename: string, currentDirectory: string): string; + function getNormalizedPathFromPathComponents(pathComponents: string[]): string; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string; + function getBaseFilename(path: string): string; + function combinePaths(path1: string, path2: string): string; + function fileExtensionIs(path: string, extension: string): boolean; + function removeFileExtension(path: string): string; + /** NOTE: This *does not* support the full escape characters, it only supports the subset that can be used in file names + * or string literals. If the information encoded in the map changes, this needs to be revisited. */ + function escapeString(s: string): string; + interface ObjectAllocator { + getNodeConstructor(kind: SyntaxKind): new () => Node; + getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; + getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; + getSignatureConstructor(): new (checker: TypeChecker) => Signature; + } + var objectAllocator: ObjectAllocator; + const enum AssertionLevel { + None = 0, + Normal = 1, + Aggressive = 2, + VeryAggressive = 3, + } + module Debug { + function shouldAssert(level: AssertionLevel): boolean; + function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; + function fail(message?: string): void; + } +} +declare module "typescript" { + interface System { + args: string[]; + newLine: string; + useCaseSensitiveFileNames: boolean; + write(s: string): void; + readFile(fileName: string, encoding?: string): string; + writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void; + watchFile?(fileName: string, callback: (fileName: string) => void): FileWatcher; + resolvePath(path: string): string; + fileExists(path: string): boolean; + directoryExists(path: string): boolean; + createDirectory(directoryName: string): void; + getExecutingFilePath(): string; + getCurrentDirectory(): string; + getMemoryUsage?(): number; + exit(exitCode?: number): void; + } + interface FileWatcher { + close(): void; + } + var sys: System; +} +declare module "typescript" { + interface ReferencePathMatchResult { + fileReference?: FileReference; + diagnosticMessage?: DiagnosticMessage; + isNoDefaultLib?: boolean; + } + function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration; + interface StringSymbolWriter extends SymbolWriter { + string(): string; + } + function getSingleLineStringWriter(): StringSymbolWriter; + function releaseStringWriter(writer: StringSymbolWriter): void; + function getFullWidth(node: Node): number; + function hasFlag(val: number, flag: number): boolean; + function containsParseError(node: Node): boolean; + function getSourceFileOfNode(node: Node): SourceFile; + function nodePosToString(node: Node): string; + function getStartPosOfNode(node: Node): number; + function isMissingNode(node: Node): boolean; + function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number; + function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string; + function getTextOfNodeFromSourceText(sourceText: string, node: Node): string; + function getTextOfNode(node: Node): string; + function escapeIdentifier(identifier: string): string; + function unescapeIdentifier(identifier: string): string; + function declarationNameToString(name: DeclarationName): string; + function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic; + function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): Diagnostic; + function getErrorSpanForNode(node: Node): Node; + function isExternalModule(file: SourceFile): boolean; + function isDeclarationFile(file: SourceFile): boolean; + function isConstEnumDeclaration(node: Node): boolean; + function isConst(node: Node): boolean; + function isLet(node: Node): boolean; + function isPrologueDirective(node: Node): boolean; + function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[]; + function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; + var fullTripleSlashReferencePathRegEx: RegExp; + function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; + function isAnyFunction(node: Node): boolean; + function isFunctionBlock(node: Node): boolean; + function isObjectLiteralMethod(node: Node): boolean; + function getContainingFunction(node: Node): FunctionLikeDeclaration; + function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; + function getSuperContainer(node: Node): Node; + function getInvokedExpression(node: CallLikeExpression): Expression; + function isExpression(node: Node): boolean; + function isExternalModuleImportDeclaration(node: Node): boolean; + function getExternalModuleImportDeclarationExpression(node: Node): Expression; + function isInternalModuleImportDeclaration(node: Node): boolean; + function hasDotDotDotToken(node: Node): boolean; + function hasQuestionToken(node: Node): boolean; + function hasRestParameters(s: SignatureDeclaration): boolean; + function isLiteralKind(kind: SyntaxKind): boolean; + function isTextualLiteralKind(kind: SyntaxKind): boolean; + function isTemplateLiteralKind(kind: SyntaxKind): boolean; + function isInAmbientContext(node: Node): boolean; + function isDeclaration(node: Node): boolean; + function isStatement(n: Node): boolean; + function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean; + function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode; + function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray; + function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; + function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; + function tryResolveScriptReference(program: Program, sourceFile: SourceFile, reference: FileReference): SourceFile; + function getAncestor(node: Node, kind: SyntaxKind): Node; + function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; + function isKeyword(token: SyntaxKind): boolean; + function isTrivia(token: SyntaxKind): boolean; + function isModifier(token: SyntaxKind): boolean; +} +declare module "typescript" { + interface ListItemInfo { + listItemIndex: number; + list: Node; + } + function getEndLinePosition(line: number, sourceFile: SourceFile): number; + function getStartPositionOfLine(line: number, sourceFile: SourceFile): number; + function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number; + function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; + function startEndContainsRange(start: number, end: number, range: TextRange): boolean; + function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; + function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; + function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; + function findListItemInfo(node: Node): ListItemInfo; + function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; + function findContainingList(node: Node): Node; + function getTouchingWord(sourceFile: SourceFile, position: number): Node; + function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node; + /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ + function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean): Node; + /** Returns a token if position is in [start-of-leading-trivia, end) */ + function getTokenAtPosition(sourceFile: SourceFile, position: number): Node; + /** + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ + function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; + function findNextToken(previousToken: Node, parent: Node): Node; + function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; + function getNodeModifiers(node: Node): string; + function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; + function isToken(n: Node): boolean; + function isComment(kind: SyntaxKind): boolean; + function isPunctuation(kind: SyntaxKind): boolean; + function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; + function compareDataObjects(dst: any, src: any): boolean; +} +declare module "typescript" { + function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; + function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; + function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart; + function spacePart(): SymbolDisplayPart; + function keywordPart(kind: SyntaxKind): SymbolDisplayPart; + function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; + function operatorPart(kind: SyntaxKind): SymbolDisplayPart; + function textPart(text: string): SymbolDisplayPart; + function lineBreakPart(): SymbolDisplayPart; + function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; + function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; + function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; +} From 29dfa3d6c035d784b0fab8da7b89065e806f0a39 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 17 Dec 2014 14:33:32 -0800 Subject: [PATCH 18/93] Add module emit test --- ...haresNameWithImportDeclarationInsideIt6.js | 32 +++++++++++++++++++ ...esNameWithImportDeclarationInsideIt6.types | 24 ++++++++++++++ ...haresNameWithImportDeclarationInsideIt6.ts | 10 ++++++ 3 files changed, 66 insertions(+) create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js create mode 100644 tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types create mode 100644 tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt6.ts diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js new file mode 100644 index 00000000000..51b2d4f89f9 --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.js @@ -0,0 +1,32 @@ +//// [moduleSharesNameWithImportDeclarationInsideIt6.ts] +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + import M = Z.M; + export function bar() { + } +} + +//// [moduleSharesNameWithImportDeclarationInsideIt6.js] +var Z; +(function (Z) { + var M; + (function (M) { + function bar() { + return ""; + } + M.bar = bar; + })(M = Z.M || (Z.M = {})); +})(Z || (Z = {})); +var A; +(function (A) { + var M; + (function (M) { + function bar() { + } + M.bar = bar; + })(M = A.M || (A.M = {})); +})(A || (A = {})); diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types new file mode 100644 index 00000000000..01879d2db11 --- /dev/null +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt6.ts === +module Z.M { +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => string + + return ""; + } +} +module A.M { +>A : typeof A +>M : typeof A.M + + import M = Z.M; +>M : typeof M +>Z : typeof Z +>M : typeof M + + export function bar() { +>bar : () => void + } +} diff --git a/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt6.ts b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt6.ts new file mode 100644 index 00000000000..f488a5de070 --- /dev/null +++ b/tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt6.ts @@ -0,0 +1,10 @@ +module Z.M { + export function bar() { + return ""; + } +} +module A.M { + import M = Z.M; + export function bar() { + } +} \ No newline at end of file From ca5d243ca7afdad7c51cb9378ccf44b1663fcd06 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 17 Dec 2014 15:49:00 -0800 Subject: [PATCH 19/93] Added test from original issue. --- ...leWithPriorUninstantiatedModule.errors.txt | 21 ++++++++++++ .../cloduleWithPriorUninstantiatedModule.js | 33 +++++++++++++++++++ .../cloduleWithPriorUninstantiatedModule.ts | 15 +++++++++ 3 files changed, 69 insertions(+) create mode 100644 tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt create mode 100644 tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js create mode 100644 tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts diff --git a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt new file mode 100644 index 00000000000..cae69212f2f --- /dev/null +++ b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts(2,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged + + +==== tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts (1 errors) ==== + // Ambient/uninstantiated module. + module Moclodule { + ~~~~~~~~~ +!!! error TS2434: A module declaration cannot be located prior to a class or function with which it is merged + export interface Someinterface { + foo(): void; + } + } + + class Moclodule { + } + + // Instantiated module. + module Moclodule { + export class Manager { + } + } \ No newline at end of file diff --git a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js new file mode 100644 index 00000000000..37bfb617375 --- /dev/null +++ b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js @@ -0,0 +1,33 @@ +//// [cloduleWithPriorUninstantiatedModule.ts] +// Ambient/uninstantiated module. +module Moclodule { + export interface Someinterface { + foo(): void; + } +} + +class Moclodule { +} + +// Instantiated module. +module Moclodule { + export class Manager { + } +} + +//// [cloduleWithPriorUninstantiatedModule.js] +var Moclodule = (function () { + function Moclodule() { + } + return Moclodule; +})(); +// Instantiated module. +var Moclodule; +(function (Moclodule) { + var Manager = (function () { + function Manager() { + } + return Manager; + })(); + Moclodule.Manager = Manager; +})(Moclodule || (Moclodule = {})); diff --git a/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts b/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts new file mode 100644 index 00000000000..8c9c646b687 --- /dev/null +++ b/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts @@ -0,0 +1,15 @@ +// Ambient/uninstantiated module. +module Moclodule { + export interface Someinterface { + foo(): void; + } +} + +class Moclodule { +} + +// Instantiated module. +module Moclodule { + export class Manager { + } +} \ No newline at end of file From fac52017653a97a2c95013b76c8d62a55bf228a7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 17 Dec 2014 17:00:42 -0800 Subject: [PATCH 20/93] Only error on non-ambient instantiated modules preceding clodules. --- src/compiler/checker.ts | 9 ++++++- src/compiler/emitter.ts | 4 +-- src/compiler/utilities.ts | 6 +++++ ...leWithPriorUninstantiatedModule.errors.txt | 21 ---------------- ...cloduleWithPriorUninstantiatedModule.types | 25 +++++++++++++++++++ 5 files changed, 41 insertions(+), 24 deletions(-) delete mode 100644 tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt create mode 100644 tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ccc67ba3881..e5334c454d3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9003,7 +9003,12 @@ module ts { checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node)) { + + // The following checks only apply on a non-ambient instantiated module declaration. + if (symbol.flags & SymbolFlags.ValueModule + && symbol.declarations.length > 1 + && !isInAmbientContext(node) + && isInstantiatedModule(node, compilerOptions.preserveConstEnums)) { var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (classOrFunc) { if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunc)) { @@ -9014,6 +9019,8 @@ module ts { } } } + + // Checks for ambient external modules. if (node.name.kind === SyntaxKind.StringLiteral) { if (!isGlobalSourceFile(node.parent)) { error(node.name, Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b713fddf676..005c7aa5f15 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3680,8 +3680,8 @@ module ts { } function emitModuleDeclaration(node: ModuleDeclaration) { - var shouldEmit = getModuleInstanceState(node) === ModuleInstanceState.Instantiated || - (getModuleInstanceState(node) === ModuleInstanceState.ConstEnumOnly && compilerOptions.preserveConstEnums); + // Emit only if this module is non-ambient. + var shouldEmit = isInstantiatedModule(node, compilerOptions.preserveConstEnums); if (!shouldEmit) { return emitPinnedOrTripleSlashComments(node); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bbe4d7dbf35..114e1dae1b3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -525,6 +525,12 @@ module ts { return false; } + export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) { + var moduleState = getModuleInstanceState(node) + return moduleState === ModuleInstanceState.Instantiated || + (preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly); + } + export function isExternalModuleImportDeclaration(node: Node) { return node.kind === SyntaxKind.ImportDeclaration && (node).moduleReference.kind === SyntaxKind.ExternalModuleReference; } diff --git a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt deleted file mode 100644 index cae69212f2f..00000000000 --- a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts(2,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged - - -==== tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts (1 errors) ==== - // Ambient/uninstantiated module. - module Moclodule { - ~~~~~~~~~ -!!! error TS2434: A module declaration cannot be located prior to a class or function with which it is merged - export interface Someinterface { - foo(): void; - } - } - - class Moclodule { - } - - // Instantiated module. - module Moclodule { - export class Manager { - } - } \ No newline at end of file diff --git a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types new file mode 100644 index 00000000000..1ab286b5964 --- /dev/null +++ b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts === +// Ambient/uninstantiated module. +module Moclodule { +>Moclodule : typeof Moclodule + + export interface Someinterface { +>Someinterface : Someinterface + + foo(): void; +>foo : () => void + } +} + +class Moclodule { +>Moclodule : Moclodule +} + +// Instantiated module. +module Moclodule { +>Moclodule : typeof Moclodule + + export class Manager { +>Manager : Manager + } +} From 46cd90daf080b2f8e3bd88cb7eda4193e4a05fc9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 17 Dec 2014 17:05:05 -0800 Subject: [PATCH 21/93] Added test, modified test, updated baselines. --- ...duleWithPriorInstantiatedModule.errors.txt | 22 +++++++++++ .../cloduleWithPriorInstantiatedModule.js | 39 +++++++++++++++++++ .../cloduleWithPriorUninstantiatedModule.js | 2 +- ...cloduleWithPriorUninstantiatedModule.types | 2 +- .../cloduleWithPriorInstantiatedModule.ts | 16 ++++++++ .../cloduleWithPriorUninstantiatedModule.ts | 2 +- 6 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/cloduleWithPriorInstantiatedModule.errors.txt create mode 100644 tests/baselines/reference/cloduleWithPriorInstantiatedModule.js create mode 100644 tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts diff --git a/tests/baselines/reference/cloduleWithPriorInstantiatedModule.errors.txt b/tests/baselines/reference/cloduleWithPriorInstantiatedModule.errors.txt new file mode 100644 index 00000000000..1b0d9cf13ca --- /dev/null +++ b/tests/baselines/reference/cloduleWithPriorInstantiatedModule.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts(2,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged + + +==== tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts (1 errors) ==== + // Non-ambient & instantiated module. + module Moclodule { + ~~~~~~~~~ +!!! error TS2434: A module declaration cannot be located prior to a class or function with which it is merged + export interface Someinterface { + foo(): void; + } + var x = 10; + } + + class Moclodule { + } + + // Instantiated module. + module Moclodule { + export class Manager { + } + } \ No newline at end of file diff --git a/tests/baselines/reference/cloduleWithPriorInstantiatedModule.js b/tests/baselines/reference/cloduleWithPriorInstantiatedModule.js new file mode 100644 index 00000000000..601ab0a7536 --- /dev/null +++ b/tests/baselines/reference/cloduleWithPriorInstantiatedModule.js @@ -0,0 +1,39 @@ +//// [cloduleWithPriorInstantiatedModule.ts] +// Non-ambient & instantiated module. +module Moclodule { + export interface Someinterface { + foo(): void; + } + var x = 10; +} + +class Moclodule { +} + +// Instantiated module. +module Moclodule { + export class Manager { + } +} + +//// [cloduleWithPriorInstantiatedModule.js] +// Non-ambient & instantiated module. +var Moclodule; +(function (Moclodule) { + var x = 10; +})(Moclodule || (Moclodule = {})); +var Moclodule = (function () { + function Moclodule() { + } + return Moclodule; +})(); +// Instantiated module. +var Moclodule; +(function (Moclodule) { + var Manager = (function () { + function Manager() { + } + return Manager; + })(); + Moclodule.Manager = Manager; +})(Moclodule || (Moclodule = {})); diff --git a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js index 37bfb617375..cf06f1134fb 100644 --- a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js +++ b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.js @@ -1,5 +1,5 @@ //// [cloduleWithPriorUninstantiatedModule.ts] -// Ambient/uninstantiated module. +// Non-ambient & uninstantiated module. module Moclodule { export interface Someinterface { foo(): void; diff --git a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types index 1ab286b5964..8dc14646a6b 100644 --- a/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types +++ b/tests/baselines/reference/cloduleWithPriorUninstantiatedModule.types @@ -1,5 +1,5 @@ === tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts === -// Ambient/uninstantiated module. +// Non-ambient & uninstantiated module. module Moclodule { >Moclodule : typeof Moclodule diff --git a/tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts b/tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts new file mode 100644 index 00000000000..c6423ce41a7 --- /dev/null +++ b/tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts @@ -0,0 +1,16 @@ +// Non-ambient & instantiated module. +module Moclodule { + export interface Someinterface { + foo(): void; + } + var x = 10; +} + +class Moclodule { +} + +// Instantiated module. +module Moclodule { + export class Manager { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts b/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts index 8c9c646b687..0c603b71a4d 100644 --- a/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts +++ b/tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts @@ -1,4 +1,4 @@ -// Ambient/uninstantiated module. +// Non-ambient & uninstantiated module. module Moclodule { export interface Someinterface { foo(): void; From d907f99693aac97f714fef0c72af433326ad681a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 22 Dec 2014 13:58:14 -0800 Subject: [PATCH 22/93] Moved EmitHost to types.ts so that utilities can be edited as a standalone file through dependency resolution. --- src/compiler/emitter.ts | 13 +------------ src/compiler/types.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 237f3ab509a..1065a1e0e60 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1461,18 +1461,7 @@ module ts { referencePathsOutput, } } - - export interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; - isEmitBlocked(sourceFile?: SourceFile): boolean; - - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - - writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; - } - + export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] { var diagnostics: Diagnostic[] = []; var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index cc1b37aef5d..f95200c4cb3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -951,6 +951,18 @@ module ts { isEmitBlocked(sourceFile?: SourceFile): boolean; } + export interface EmitHost extends ScriptReferenceHost { + getSourceFiles(): SourceFile[]; + isEmitBlocked(sourceFile?: SourceFile): boolean; + + getCommonSourceDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + } + + export interface SourceMapSpan { emittedLine: number; // Line number in the .js file emittedColumn: number; // Column number in the .js file From 8aefbe9a86999654a0b4858ecf6db9a13cd37ac0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 22 Dec 2014 14:02:40 -0800 Subject: [PATCH 23/93] Removed newline. --- src/compiler/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f95200c4cb3..dbdd71ed363 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -962,7 +962,6 @@ module ts { writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } - export interface SourceMapSpan { emittedLine: number; // Line number in the .js file emittedColumn: number; // Column number in the .js file From 435b44ce57d0b028d97823afe3a6c3d2ae67892f Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Thu, 25 Dec 2014 22:29:38 +0000 Subject: [PATCH 24/93] Put specialized signatures at the top of the list of call candidates Fixes #1133. --- src/compiler/checker.ts | 19 ++++- ...nheritedOverloadedSpecializedSignatures.js | 49 +++++++---- ...ritedOverloadedSpecializedSignatures.types | 81 ++++++++++++++----- ...nheritedOverloadedSpecializedSignatures.ts | 30 +++++-- .../fourslash/overloadOnConstCallSignature.ts | 4 +- 5 files changed, 140 insertions(+), 43 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8c4caa9630..2f16de1b1c1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6112,6 +6112,8 @@ module ts { var lastSymbol: Symbol; var cutoffPos: number = 0; var pos: number; + var specializedPos: number = -1; + var splicePos: number; Debug.assert(!result.length); for (var i = 0; i < signatures.length; i++) { var signature = signatures[i]; @@ -6134,10 +6136,23 @@ module ts { } lastSymbol = symbol; - for (var j = result.length; j > pos; j--) { + // specialized signatures always need to be placed before non-specialized signatures regardless + // of the cutoff position; see GH#1133 + if (signature.hasStringLiterals) { + splicePos = ++specializedPos; + // The cutoff position needs to be increased to account for the fact that we are adding things + // before the cutoff point. If the cutoff position is not incremented, merged interfaces will + // start adding their merged signatures at the wrong position + ++cutoffPos; + } + else { + splicePos = pos; + } + + for (var j = result.length; j > splicePos; j--) { result[j] = result[j - 1]; } - result[pos] = signature; + result[splicePos] = signature; } } } diff --git a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.js b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.js index 792c9232fa2..da16ad0d0e5 100644 --- a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.js +++ b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.js @@ -28,22 +28,43 @@ interface B { (x: 'B2'): string[]; } -var b: B; -// non of these lines should error -var x1: string[] = b('B2'); -var x2: number = b('B1'); -var x3: boolean = b('A2'); -var x4: string = b('A1'); -var x5: void = b('A0'); +interface C1 extends B { + (x: 'C1'): number[]; +} + +interface C2 extends B { + (x: 'C2'): boolean[]; +} + +interface C extends C1, C2 { + (x: 'C'): string; +} + +var c: C; +// none of these lines should error +var x1: string[] = c('B2'); +var x2: number = c('B1'); +var x3: boolean = c('A2'); +var x4: string = c('A1'); +var x5: void = c('A0'); +var x6: number[] = c('C1'); +var x7: boolean[] = c('C2'); +var x8: string = c('C'); +var x9: void = c('generic'); + //// [inheritedOverloadedSpecializedSignatures.js] var b; // Should not error b('foo').charAt(0); -var b; -// non of these lines should error -var x1 = b('B2'); -var x2 = b('B1'); -var x3 = b('A2'); -var x4 = b('A1'); -var x5 = b('A0'); +var c; +// none of these lines should error +var x1 = c('B2'); +var x2 = c('B1'); +var x3 = c('A2'); +var x4 = c('A1'); +var x5 = c('A0'); +var x6 = c('C1'); +var x7 = c('C2'); +var x8 = c('C'); +var x9 = c('generic'); diff --git a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types index 0284fa4bc43..dcbab74b681 100644 --- a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types +++ b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types @@ -58,33 +58,78 @@ interface B { >x : 'B2' } -var b: B; ->b : B +interface C1 extends B { +>C1 : C1 >B : B -// non of these lines should error -var x1: string[] = b('B2'); + (x: 'C1'): number[]; +>x : 'C1' +} + +interface C2 extends B { +>C2 : C2 +>B : B + + (x: 'C2'): boolean[]; +>x : 'C2' +} + +interface C extends C1, C2 { +>C : C +>C1 : C1 +>C2 : C2 + + (x: 'C'): string; +>x : 'C' +} + +var c: C; +>c : C +>C : C + +// none of these lines should error +var x1: string[] = c('B2'); >x1 : string[] ->b('B2') : string[] ->b : B +>c('B2') : string[] +>c : C -var x2: number = b('B1'); +var x2: number = c('B1'); >x2 : number ->b('B1') : number ->b : B +>c('B1') : number +>c : C -var x3: boolean = b('A2'); +var x3: boolean = c('A2'); >x3 : boolean ->b('A2') : boolean ->b : B +>c('A2') : boolean +>c : C -var x4: string = b('A1'); +var x4: string = c('A1'); >x4 : string ->b('A1') : string ->b : B +>c('A1') : string +>c : C -var x5: void = b('A0'); +var x5: void = c('A0'); >x5 : void ->b('A0') : void ->b : B +>c('A0') : void +>c : C + +var x6: number[] = c('C1'); +>x6 : number[] +>c('C1') : number[] +>c : C + +var x7: boolean[] = c('C2'); +>x7 : boolean[] +>c('C2') : boolean[] +>c : C + +var x8: string = c('C'); +>x8 : string +>c('C') : string +>c : C + +var x9: void = c('generic'); +>x9 : void +>c('generic') : void +>c : C diff --git a/tests/cases/compiler/inheritedOverloadedSpecializedSignatures.ts b/tests/cases/compiler/inheritedOverloadedSpecializedSignatures.ts index c513cecb2cb..03a433382ce 100644 --- a/tests/cases/compiler/inheritedOverloadedSpecializedSignatures.ts +++ b/tests/cases/compiler/inheritedOverloadedSpecializedSignatures.ts @@ -27,10 +27,26 @@ interface B { (x: 'B2'): string[]; } -var b: B; -// non of these lines should error -var x1: string[] = b('B2'); -var x2: number = b('B1'); -var x3: boolean = b('A2'); -var x4: string = b('A1'); -var x5: void = b('A0'); \ No newline at end of file +interface C1 extends B { + (x: 'C1'): number[]; +} + +interface C2 extends B { + (x: 'C2'): boolean[]; +} + +interface C extends C1, C2 { + (x: 'C'): string; +} + +var c: C; +// none of these lines should error +var x1: string[] = c('B2'); +var x2: number = c('B1'); +var x3: boolean = c('A2'); +var x4: string = c('A1'); +var x5: void = c('A0'); +var x6: number[] = c('C1'); +var x7: boolean[] = c('C2'); +var x8: string = c('C'); +var x9: void = c('generic'); diff --git a/tests/cases/fourslash/overloadOnConstCallSignature.ts b/tests/cases/fourslash/overloadOnConstCallSignature.ts index 52e0f3c02e0..7e8075e3652 100644 --- a/tests/cases/fourslash/overloadOnConstCallSignature.ts +++ b/tests/cases/fourslash/overloadOnConstCallSignature.ts @@ -11,8 +11,8 @@ goTo.marker('1'); verify.signatureHelpCountIs(4); -verify.currentSignatureHelpIs('foo(name: string): string'); +verify.currentSignatureHelpIs('foo(name: \'order\'): string'); edit.insert('"hi"'); goTo.marker('2'); -verify.quickInfoIs('(var) x: string'); \ No newline at end of file +verify.quickInfoIs('(var) x: string'); From 363587163b4e83d6e6abdf92ce3f96653fca1e65 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 2 Jan 2015 12:14:02 -0800 Subject: [PATCH 25/93] extract map copying logic to a separate function --- src/compiler/checker.ts | 4 +--- src/compiler/core.ts | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8c4caa9630..351f5188748 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3651,9 +3651,7 @@ module ts { var maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up var destinationCache = result === Ternary.True || depth === 0 ? relation : maybeStack[depth - 1]; - for (var p in maybeCache) { - destinationCache[p] = maybeCache[p]; - } + copyMap(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4ba93729c36..2e5a471bb27 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -208,6 +208,12 @@ module ts { return result; } + export function copyMap(source: Map, target: Map): void { + for (var p in source) { + target[p] = source[p]; + } + } + /** * Creates a map from the elements of an array. * From 06258b8c106385924077c4a17d908114612dea0b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 5 Jan 2015 11:48:46 -0800 Subject: [PATCH 26/93] added parameter names to 'copymap' call site --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 351f5188748..2911322052d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3651,7 +3651,7 @@ module ts { var maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up var destinationCache = result === Ternary.True || depth === 0 ? relation : maybeStack[depth - 1]; - copyMap(maybeCache, destinationCache); + copyMap(/*source*/maybeCache, /*target*/destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it From 22bf60e43101e0f668af0dcff99f90672f46cec8 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 5 Jan 2015 13:22:15 -0800 Subject: [PATCH 27/93] Add tests covering emitting default parameters natively in ES6 --- .../emitDefaultParametersFunction.js | 27 ++++++++ .../emitDefaultParametersFunction.types | 21 +++++++ .../emitDefaultParametersFunctionES6.js | 15 +++++ .../emitDefaultParametersFunctionES6.types | 21 +++++++ ...emitDefaultParametersFunctionExpression.js | 54 ++++++++++++++++ ...tDefaultParametersFunctionExpression.types | 49 +++++++++++++++ ...tDefaultParametersFunctionExpressionES6.js | 25 ++++++++ ...faultParametersFunctionExpressionES6.types | 49 +++++++++++++++ .../emitDefaultParametersFunctionProperty.js | 32 ++++++++++ ...mitDefaultParametersFunctionProperty.types | 28 +++++++++ ...mitDefaultParametersFunctionPropertyES6.js | 19 ++++++ ...DefaultParametersFunctionPropertyES6.types | 27 ++++++++ .../reference/emitDefaultParametersMethod.js | 62 +++++++++++++++++++ .../emitDefaultParametersMethod.types | 46 ++++++++++++++ .../emitDefaultParametersMethodES6.js | 42 +++++++++++++ .../emitDefaultParametersMethodES6.types | 45 ++++++++++++++ .../emitDefaultParametersFunction.ts | 5 ++ .../emitDefaultParametersFunctionES6.ts | 5 ++ ...emitDefaultParametersFunctionExpression.ts | 9 +++ ...tDefaultParametersFunctionExpressionES6.ts | 9 +++ .../emitDefaultParametersFunctionProperty.ts | 7 +++ ...mitDefaultParametersFunctionPropertyES6.ts | 7 +++ .../emitDefaultParametersMethod.ts | 17 +++++ .../emitDefaultParametersMethodES6.ts | 17 +++++ 24 files changed, 638 insertions(+) create mode 100644 tests/baselines/reference/emitDefaultParametersFunction.js create mode 100644 tests/baselines/reference/emitDefaultParametersFunction.types create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionES6.js create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionES6.types create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionExpression.js create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionExpression.types create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.js create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionProperty.js create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionProperty.types create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.js create mode 100644 tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types create mode 100644 tests/baselines/reference/emitDefaultParametersMethod.js create mode 100644 tests/baselines/reference/emitDefaultParametersMethod.types create mode 100644 tests/baselines/reference/emitDefaultParametersMethodES6.js create mode 100644 tests/baselines/reference/emitDefaultParametersMethodES6.types create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunction.ts create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionES6.ts create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpression.ts create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6.ts create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionProperty.ts create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6.ts create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethod.ts create mode 100644 tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethodES6.ts diff --git a/tests/baselines/reference/emitDefaultParametersFunction.js b/tests/baselines/reference/emitDefaultParametersFunction.js new file mode 100644 index 00000000000..6be7ae9dbfe --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunction.js @@ -0,0 +1,27 @@ +//// [emitDefaultParametersFunction.ts] +function foo(x: string, y = 10) { } +function baz(x: string, y = 5, ...rest) { } +function bar(y = 10) { } +function bar1(y = 10, ...rest) { } + +//// [emitDefaultParametersFunction.js] +function foo(x, y) { + if (y === void 0) { y = 10; } +} +function baz(x, y) { + if (y === void 0) { y = 5; } + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } +} +function bar(y) { + if (y === void 0) { y = 10; } +} +function bar1(y) { + if (y === void 0) { y = 10; } + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } +} diff --git a/tests/baselines/reference/emitDefaultParametersFunction.types b/tests/baselines/reference/emitDefaultParametersFunction.types new file mode 100644 index 00000000000..a8dec6335a9 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunction.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunction.ts === +function foo(x: string, y = 10) { } +>foo : (x: string, y?: number) => void +>x : string +>y : number + +function baz(x: string, y = 5, ...rest) { } +>baz : (x: string, y?: number, ...rest: any[]) => void +>x : string +>y : number +>rest : any[] + +function bar(y = 10) { } +>bar : (y?: number) => void +>y : number + +function bar1(y = 10, ...rest) { } +>bar1 : (y?: number, ...rest: any[]) => void +>y : number +>rest : any[] + diff --git a/tests/baselines/reference/emitDefaultParametersFunctionES6.js b/tests/baselines/reference/emitDefaultParametersFunctionES6.js new file mode 100644 index 00000000000..f4084a16f6f --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionES6.js @@ -0,0 +1,15 @@ +//// [emitDefaultParametersFunctionES6.ts] +function foo(x: string, y = 10) { } +function baz(x: string, y = 5, ...rest) { } +function bar(y = 10) { } +function bar1(y = 10, ...rest) { } + +//// [emitDefaultParametersFunctionES6.js] +function foo(x, y = 10) { +} +function baz(x, y = 5, ...rest) { +} +function bar(y = 10) { +} +function bar1(y = 10, ...rest) { +} diff --git a/tests/baselines/reference/emitDefaultParametersFunctionES6.types b/tests/baselines/reference/emitDefaultParametersFunctionES6.types new file mode 100644 index 00000000000..1c67032264f --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionES6.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionES6.ts === +function foo(x: string, y = 10) { } +>foo : (x: string, y?: number) => void +>x : string +>y : number + +function baz(x: string, y = 5, ...rest) { } +>baz : (x: string, y?: number, ...rest: any[]) => void +>x : string +>y : number +>rest : any[] + +function bar(y = 10) { } +>bar : (y?: number) => void +>y : number + +function bar1(y = 10, ...rest) { } +>bar1 : (y?: number, ...rest: any[]) => void +>y : number +>rest : any[] + diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpression.js b/tests/baselines/reference/emitDefaultParametersFunctionExpression.js new file mode 100644 index 00000000000..bcfe5b240f2 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpression.js @@ -0,0 +1,54 @@ +//// [emitDefaultParametersFunctionExpression.ts] +var lambda1 = (y = "hello") => { } +var lambda2 = (x: number, y = "hello") => { } +var lambda3 = (x: number, y = "hello", ...rest) => { } +var lambda4 = (y = "hello", ...rest) => { } + +var x = function (str = "hello", ...rest) { } +var y = (function (num = 10, boo = false, ...rest) { })() +var z = (function (num: number, boo = false, ...rest) { })(10) + + +//// [emitDefaultParametersFunctionExpression.js] +var lambda1 = function (y) { + if (y === void 0) { y = "hello"; } +}; +var lambda2 = function (x, y) { + if (y === void 0) { y = "hello"; } +}; +var lambda3 = function (x, y) { + if (y === void 0) { y = "hello"; } + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } +}; +var lambda4 = function (y) { + if (y === void 0) { y = "hello"; } + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } +}; +var x = function (str) { + if (str === void 0) { str = "hello"; } + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } +}; +var y = (function (num, boo) { + if (num === void 0) { num = 10; } + if (boo === void 0) { boo = false; } + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } +})(); +var z = (function (num, boo) { + if (boo === void 0) { boo = false; } + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } +})(10); diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpression.types b/tests/baselines/reference/emitDefaultParametersFunctionExpression.types new file mode 100644 index 00000000000..5c223ff1344 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpression.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpression.ts === +var lambda1 = (y = "hello") => { } +>lambda1 : (y?: string) => void +>(y = "hello") => { } : (y?: string) => void +>y : string + +var lambda2 = (x: number, y = "hello") => { } +>lambda2 : (x: number, y?: string) => void +>(x: number, y = "hello") => { } : (x: number, y?: string) => void +>x : number +>y : string + +var lambda3 = (x: number, y = "hello", ...rest) => { } +>lambda3 : (x: number, y?: string, ...rest: any[]) => void +>(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void +>x : number +>y : string +>rest : any[] + +var lambda4 = (y = "hello", ...rest) => { } +>lambda4 : (y?: string, ...rest: any[]) => void +>(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void +>y : string +>rest : any[] + +var x = function (str = "hello", ...rest) { } +>x : (str?: string, ...rest: any[]) => void +>function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void +>str : string +>rest : any[] + +var y = (function (num = 10, boo = false, ...rest) { })() +>y : void +>(function (num = 10, boo = false, ...rest) { })() : void +>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void +>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void +>num : number +>boo : boolean +>rest : any[] + +var z = (function (num: number, boo = false, ...rest) { })(10) +>z : void +>(function (num: number, boo = false, ...rest) { })(10) : void +>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void +>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void +>num : number +>boo : boolean +>rest : any[] + diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.js b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.js new file mode 100644 index 00000000000..eabb0e1e344 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.js @@ -0,0 +1,25 @@ +//// [emitDefaultParametersFunctionExpressionES6.ts] +var lambda1 = (y = "hello") => { } +var lambda2 = (x: number, y = "hello") => { } +var lambda3 = (x: number, y = "hello", ...rest) => { } +var lambda4 = (y = "hello", ...rest) => { } + +var x = function (str = "hello", ...rest) { } +var y = (function (num = 10, boo = false, ...rest) { })() +var z = (function (num: number, boo = false, ...rest) { })(10) + +//// [emitDefaultParametersFunctionExpressionES6.js] +var lambda1 = function (y = "hello") { +}; +var lambda2 = function (x, y = "hello") { +}; +var lambda3 = function (x, y = "hello", ...rest) { +}; +var lambda4 = function (y = "hello", ...rest) { +}; +var x = function (str = "hello", ...rest) { +}; +var y = (function (num = 10, boo = false, ...rest) { +})(); +var z = (function (num, boo = false, ...rest) { +})(10); diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types new file mode 100644 index 00000000000..9b8805dfa2b --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6.ts === +var lambda1 = (y = "hello") => { } +>lambda1 : (y?: string) => void +>(y = "hello") => { } : (y?: string) => void +>y : string + +var lambda2 = (x: number, y = "hello") => { } +>lambda2 : (x: number, y?: string) => void +>(x: number, y = "hello") => { } : (x: number, y?: string) => void +>x : number +>y : string + +var lambda3 = (x: number, y = "hello", ...rest) => { } +>lambda3 : (x: number, y?: string, ...rest: any[]) => void +>(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void +>x : number +>y : string +>rest : any[] + +var lambda4 = (y = "hello", ...rest) => { } +>lambda4 : (y?: string, ...rest: any[]) => void +>(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void +>y : string +>rest : any[] + +var x = function (str = "hello", ...rest) { } +>x : (str?: string, ...rest: any[]) => void +>function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void +>str : string +>rest : any[] + +var y = (function (num = 10, boo = false, ...rest) { })() +>y : void +>(function (num = 10, boo = false, ...rest) { })() : void +>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void +>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void +>num : number +>boo : boolean +>rest : any[] + +var z = (function (num: number, boo = false, ...rest) { })(10) +>z : void +>(function (num: number, boo = false, ...rest) { })(10) : void +>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void +>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void +>num : number +>boo : boolean +>rest : any[] + diff --git a/tests/baselines/reference/emitDefaultParametersFunctionProperty.js b/tests/baselines/reference/emitDefaultParametersFunctionProperty.js new file mode 100644 index 00000000000..16cac41a4ce --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionProperty.js @@ -0,0 +1,32 @@ +//// [emitDefaultParametersFunctionProperty.ts] +var obj2 = { + func1(y = 10, ...rest) { }, + func2(x = "hello") { }, + func3(x: string, z: number, y = "hello") { }, + func4(x: string, z: number, y = "hello", ...rest) { }, +} + + +//// [emitDefaultParametersFunctionProperty.js] +var obj2 = { + func1: function (y) { + if (y === void 0) { y = 10; } + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + }, + func2: function (x) { + if (x === void 0) { x = "hello"; } + }, + func3: function (x, z, y) { + if (y === void 0) { y = "hello"; } + }, + func4: function (x, z, y) { + if (y === void 0) { y = "hello"; } + var rest = []; + for (var _i = 3; _i < arguments.length; _i++) { + rest[_i - 3] = arguments[_i]; + } + }, +}; diff --git a/tests/baselines/reference/emitDefaultParametersFunctionProperty.types b/tests/baselines/reference/emitDefaultParametersFunctionProperty.types new file mode 100644 index 00000000000..7c1ea6a5da3 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionProperty.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionProperty.ts === +var obj2 = { +>obj2 : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; } +>{ func1(y = 10, ...rest) { }, func2(x = "hello") { }, func3(x: string, z: number, y = "hello") { }, func4(x: string, z: number, y = "hello", ...rest) { },} : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; } + + func1(y = 10, ...rest) { }, +>func1 : (y?: number, ...rest: any[]) => void +>y : number +>rest : any[] + + func2(x = "hello") { }, +>func2 : (x?: string) => void +>x : string + + func3(x: string, z: number, y = "hello") { }, +>func3 : (x: string, z: number, y?: string) => void +>x : string +>z : number +>y : string + + func4(x: string, z: number, y = "hello", ...rest) { }, +>func4 : (x: string, z: number, y?: string, ...rest: any[]) => void +>x : string +>z : number +>y : string +>rest : any[] +} + diff --git a/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.js b/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.js new file mode 100644 index 00000000000..fce694a453a --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.js @@ -0,0 +1,19 @@ +//// [emitDefaultParametersFunctionPropertyES6.ts] +var obj2 = { + func1(y = 10, ...rest) { }, + func2(x = "hello") { }, + func3(x: string, z: number, y = "hello") { }, + func4(x: string, z: number, y = "hello", ...rest) { }, +} + +//// [emitDefaultParametersFunctionPropertyES6.js] +var obj2 = { + func1(y = 10, ...rest) { + }, + func2(x = "hello") { + }, + func3(x, z, y = "hello") { + }, + func4(x, z, y = "hello", ...rest) { + }, +}; diff --git a/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types b/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types new file mode 100644 index 00000000000..ed80158ffd1 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6.ts === +var obj2 = { +>obj2 : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; } +>{ func1(y = 10, ...rest) { }, func2(x = "hello") { }, func3(x: string, z: number, y = "hello") { }, func4(x: string, z: number, y = "hello", ...rest) { },} : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; } + + func1(y = 10, ...rest) { }, +>func1 : (y?: number, ...rest: any[]) => void +>y : number +>rest : any[] + + func2(x = "hello") { }, +>func2 : (x?: string) => void +>x : string + + func3(x: string, z: number, y = "hello") { }, +>func3 : (x: string, z: number, y?: string) => void +>x : string +>z : number +>y : string + + func4(x: string, z: number, y = "hello", ...rest) { }, +>func4 : (x: string, z: number, y?: string, ...rest: any[]) => void +>x : string +>z : number +>y : string +>rest : any[] +} diff --git a/tests/baselines/reference/emitDefaultParametersMethod.js b/tests/baselines/reference/emitDefaultParametersMethod.js new file mode 100644 index 00000000000..126c19305b3 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersMethod.js @@ -0,0 +1,62 @@ +//// [emitDefaultParametersMethod.ts] +class C { + constructor(t: boolean, z: string, x: number, y = "hello") { } + + public foo(x: string, t = false) { } + public foo1(x: string, t = false, ...rest) { } + public bar(t = false) { } + public boo(t = false, ...rest) { } +} + +class D { + constructor(y = "hello") { } +} + +class E { + constructor(y = "hello", ...rest) { } +} + + +//// [emitDefaultParametersMethod.js] +var C = (function () { + function C(t, z, x, y) { + if (y === void 0) { y = "hello"; } + } + C.prototype.foo = function (x, t) { + if (t === void 0) { t = false; } + }; + C.prototype.foo1 = function (x, t) { + if (t === void 0) { t = false; } + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } + }; + C.prototype.bar = function (t) { + if (t === void 0) { t = false; } + }; + C.prototype.boo = function (t) { + if (t === void 0) { t = false; } + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + }; + return C; +})(); +var D = (function () { + function D(y) { + if (y === void 0) { y = "hello"; } + } + return D; +})(); +var E = (function () { + function E(y) { + if (y === void 0) { y = "hello"; } + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + } + return E; +})(); diff --git a/tests/baselines/reference/emitDefaultParametersMethod.types b/tests/baselines/reference/emitDefaultParametersMethod.types new file mode 100644 index 00000000000..5b2f08d4f70 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersMethod.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethod.ts === +class C { +>C : C + + constructor(t: boolean, z: string, x: number, y = "hello") { } +>t : boolean +>z : string +>x : number +>y : string + + public foo(x: string, t = false) { } +>foo : (x: string, t?: boolean) => void +>x : string +>t : boolean + + public foo1(x: string, t = false, ...rest) { } +>foo1 : (x: string, t?: boolean, ...rest: any[]) => void +>x : string +>t : boolean +>rest : any[] + + public bar(t = false) { } +>bar : (t?: boolean) => void +>t : boolean + + public boo(t = false, ...rest) { } +>boo : (t?: boolean, ...rest: any[]) => void +>t : boolean +>rest : any[] +} + +class D { +>D : D + + constructor(y = "hello") { } +>y : string +} + +class E { +>E : E + + constructor(y = "hello", ...rest) { } +>y : string +>rest : any[] +} + diff --git a/tests/baselines/reference/emitDefaultParametersMethodES6.js b/tests/baselines/reference/emitDefaultParametersMethodES6.js new file mode 100644 index 00000000000..bf96e00e375 --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersMethodES6.js @@ -0,0 +1,42 @@ +//// [emitDefaultParametersMethodES6.ts] +class C { + constructor(t: boolean, z: string, x: number, y = "hello") { } + + public foo(x: string, t = false) { } + public foo1(x: string, t = false, ...rest) { } + public bar(t = false) { } + public boo(t = false, ...rest) { } +} + +class D { + constructor(y = "hello") { } +} + +class E { + constructor(y = "hello", ...rest) { } +} + +//// [emitDefaultParametersMethodES6.js] +var C = (function () { + function C(t, z, x, y = "hello") { + } + C.prototype.foo = function (x, t = false) { + }; + C.prototype.foo1 = function (x, t = false, ...rest) { + }; + C.prototype.bar = function (t = false) { + }; + C.prototype.boo = function (t = false, ...rest) { + }; + return C; +})(); +var D = (function () { + function D(y = "hello") { + } + return D; +})(); +var E = (function () { + function E(y = "hello", ...rest) { + } + return E; +})(); diff --git a/tests/baselines/reference/emitDefaultParametersMethodES6.types b/tests/baselines/reference/emitDefaultParametersMethodES6.types new file mode 100644 index 00000000000..54312714b1d --- /dev/null +++ b/tests/baselines/reference/emitDefaultParametersMethodES6.types @@ -0,0 +1,45 @@ +=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethodES6.ts === +class C { +>C : C + + constructor(t: boolean, z: string, x: number, y = "hello") { } +>t : boolean +>z : string +>x : number +>y : string + + public foo(x: string, t = false) { } +>foo : (x: string, t?: boolean) => void +>x : string +>t : boolean + + public foo1(x: string, t = false, ...rest) { } +>foo1 : (x: string, t?: boolean, ...rest: any[]) => void +>x : string +>t : boolean +>rest : any[] + + public bar(t = false) { } +>bar : (t?: boolean) => void +>t : boolean + + public boo(t = false, ...rest) { } +>boo : (t?: boolean, ...rest: any[]) => void +>t : boolean +>rest : any[] +} + +class D { +>D : D + + constructor(y = "hello") { } +>y : string +} + +class E { +>E : E + + constructor(y = "hello", ...rest) { } +>y : string +>rest : any[] +} diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunction.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunction.ts new file mode 100644 index 00000000000..12480939a39 --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunction.ts @@ -0,0 +1,5 @@ +// @target: es5 +function foo(x: string, y = 10) { } +function baz(x: string, y = 5, ...rest) { } +function bar(y = 10) { } +function bar1(y = 10, ...rest) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionES6.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionES6.ts new file mode 100644 index 00000000000..00afc306546 --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionES6.ts @@ -0,0 +1,5 @@ +// @target:es6 +function foo(x: string, y = 10) { } +function baz(x: string, y = 5, ...rest) { } +function bar(y = 10) { } +function bar1(y = 10, ...rest) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpression.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpression.ts new file mode 100644 index 00000000000..f8e10c0ae14 --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpression.ts @@ -0,0 +1,9 @@ +// @target: es5 +var lambda1 = (y = "hello") => { } +var lambda2 = (x: number, y = "hello") => { } +var lambda3 = (x: number, y = "hello", ...rest) => { } +var lambda4 = (y = "hello", ...rest) => { } + +var x = function (str = "hello", ...rest) { } +var y = (function (num = 10, boo = false, ...rest) { })() +var z = (function (num: number, boo = false, ...rest) { })(10) diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6.ts new file mode 100644 index 00000000000..aebed249a65 --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6.ts @@ -0,0 +1,9 @@ +// @target:es6 +var lambda1 = (y = "hello") => { } +var lambda2 = (x: number, y = "hello") => { } +var lambda3 = (x: number, y = "hello", ...rest) => { } +var lambda4 = (y = "hello", ...rest) => { } + +var x = function (str = "hello", ...rest) { } +var y = (function (num = 10, boo = false, ...rest) { })() +var z = (function (num: number, boo = false, ...rest) { })(10) \ No newline at end of file diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionProperty.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionProperty.ts new file mode 100644 index 00000000000..8e280894af0 --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionProperty.ts @@ -0,0 +1,7 @@ +// @target: es5 +var obj2 = { + func1(y = 10, ...rest) { }, + func2(x = "hello") { }, + func3(x: string, z: number, y = "hello") { }, + func4(x: string, z: number, y = "hello", ...rest) { }, +} diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6.ts new file mode 100644 index 00000000000..cb1cfb78546 --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6.ts @@ -0,0 +1,7 @@ +// @target:es6 +var obj2 = { + func1(y = 10, ...rest) { }, + func2(x = "hello") { }, + func3(x: string, z: number, y = "hello") { }, + func4(x: string, z: number, y = "hello", ...rest) { }, +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethod.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethod.ts new file mode 100644 index 00000000000..be4a563836f --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethod.ts @@ -0,0 +1,17 @@ +// @target: es5 +class C { + constructor(t: boolean, z: string, x: number, y = "hello") { } + + public foo(x: string, t = false) { } + public foo1(x: string, t = false, ...rest) { } + public bar(t = false) { } + public boo(t = false, ...rest) { } +} + +class D { + constructor(y = "hello") { } +} + +class E { + constructor(y = "hello", ...rest) { } +} diff --git a/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethodES6.ts b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethodES6.ts new file mode 100644 index 00000000000..886b2e9235b --- /dev/null +++ b/tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethodES6.ts @@ -0,0 +1,17 @@ +// @target:es6 +class C { + constructor(t: boolean, z: string, x: number, y = "hello") { } + + public foo(x: string, t = false) { } + public foo1(x: string, t = false, ...rest) { } + public bar(t = false) { } + public boo(t = false, ...rest) { } +} + +class D { + constructor(y = "hello") { } +} + +class E { + constructor(y = "hello", ...rest) { } +} \ No newline at end of file From ec5c115cfa27373b7fe4f80b715fd2b51af51caa Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 5 Jan 2015 13:33:44 -0800 Subject: [PATCH 28/93] Add tests covering emitting rest parameters natively in ES6 --- .../reference/emitRestParametersFunction.js | 17 ++++++ .../emitRestParametersFunction.types | 11 ++++ .../emitRestParametersFunctionES6.js | 9 +++ .../emitRestParametersFunctionES6.types | 11 ++++ .../emitRestParametersFunctionExpression.js | 32 ++++++++++ ...emitRestParametersFunctionExpression.types | 24 ++++++++ ...emitRestParametersFunctionExpressionES6.js | 15 +++++ ...tRestParametersFunctionExpressionES6.types | 24 ++++++++ .../emitRestParametersFunctionProperty.js | 19 ++++++ .../emitRestParametersFunctionProperty.types | 17 ++++++ .../emitRestParametersFunctionPropertyES6.js | 15 +++++ ...mitRestParametersFunctionPropertyES6.types | 17 ++++++ .../reference/emitRestParametersMethod.js | 58 +++++++++++++++++++ .../reference/emitRestParametersMethod.types | 33 +++++++++++ .../reference/emitRestParametersMethodES6.js | 35 +++++++++++ .../emitRestParametersMethodES6.types | 34 +++++++++++ .../emitRestParametersFunction.ts | 3 + .../emitRestParametersFunctionES6.ts | 3 + .../emitRestParametersFunctionExpression.ts | 5 ++ ...emitRestParametersFunctionExpressionES6.ts | 5 ++ .../emitRestParametersFunctionProperty.ts | 8 +++ .../emitRestParametersFunctionPropertyES6.ts | 8 +++ .../emitRestParametersMethod.ts | 14 +++++ .../emitRestParametersMethodES6.ts | 14 +++++ 24 files changed, 431 insertions(+) create mode 100644 tests/baselines/reference/emitRestParametersFunction.js create mode 100644 tests/baselines/reference/emitRestParametersFunction.types create mode 100644 tests/baselines/reference/emitRestParametersFunctionES6.js create mode 100644 tests/baselines/reference/emitRestParametersFunctionES6.types create mode 100644 tests/baselines/reference/emitRestParametersFunctionExpression.js create mode 100644 tests/baselines/reference/emitRestParametersFunctionExpression.types create mode 100644 tests/baselines/reference/emitRestParametersFunctionExpressionES6.js create mode 100644 tests/baselines/reference/emitRestParametersFunctionExpressionES6.types create mode 100644 tests/baselines/reference/emitRestParametersFunctionProperty.js create mode 100644 tests/baselines/reference/emitRestParametersFunctionProperty.types create mode 100644 tests/baselines/reference/emitRestParametersFunctionPropertyES6.js create mode 100644 tests/baselines/reference/emitRestParametersFunctionPropertyES6.types create mode 100644 tests/baselines/reference/emitRestParametersMethod.js create mode 100644 tests/baselines/reference/emitRestParametersMethod.types create mode 100644 tests/baselines/reference/emitRestParametersMethodES6.js create mode 100644 tests/baselines/reference/emitRestParametersMethodES6.types create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersFunction.ts create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersFunctionES6.ts create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpression.ts create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpressionES6.ts create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersFunctionProperty.ts create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersFunctionPropertyES6.ts create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersMethod.ts create mode 100644 tests/cases/conformance/es6/restParameters/emitRestParametersMethodES6.ts diff --git a/tests/baselines/reference/emitRestParametersFunction.js b/tests/baselines/reference/emitRestParametersFunction.js new file mode 100644 index 00000000000..01116f2ac92 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunction.js @@ -0,0 +1,17 @@ +//// [emitRestParametersFunction.ts] +function bar(...rest) { } +function foo(x: number, y: string, ...rest) { } + +//// [emitRestParametersFunction.js] +function bar() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +} +function foo(x, y) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } +} diff --git a/tests/baselines/reference/emitRestParametersFunction.types b/tests/baselines/reference/emitRestParametersFunction.types new file mode 100644 index 00000000000..a65adb57702 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunction.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersFunction.ts === +function bar(...rest) { } +>bar : (...rest: any[]) => void +>rest : any[] + +function foo(x: number, y: string, ...rest) { } +>foo : (x: number, y: string, ...rest: any[]) => void +>x : number +>y : string +>rest : any[] + diff --git a/tests/baselines/reference/emitRestParametersFunctionES6.js b/tests/baselines/reference/emitRestParametersFunctionES6.js new file mode 100644 index 00000000000..242c40f252d --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionES6.js @@ -0,0 +1,9 @@ +//// [emitRestParametersFunctionES6.ts] +function bar(...rest) { } +function foo(x: number, y: string, ...rest) { } + +//// [emitRestParametersFunctionES6.js] +function bar(...rest) { +} +function foo(x, y, ...rest) { +} diff --git a/tests/baselines/reference/emitRestParametersFunctionES6.types b/tests/baselines/reference/emitRestParametersFunctionES6.types new file mode 100644 index 00000000000..5689d64c4df --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionES6.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionES6.ts === +function bar(...rest) { } +>bar : (...rest: any[]) => void +>rest : any[] + +function foo(x: number, y: string, ...rest) { } +>foo : (x: number, y: string, ...rest: any[]) => void +>x : number +>y : string +>rest : any[] + diff --git a/tests/baselines/reference/emitRestParametersFunctionExpression.js b/tests/baselines/reference/emitRestParametersFunctionExpression.js new file mode 100644 index 00000000000..da87cc79f2d --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionExpression.js @@ -0,0 +1,32 @@ +//// [emitRestParametersFunctionExpression.ts] +var funcExp = (...rest) => { } +var funcExp1 = (X: number, ...rest) => { } +var funcExp2 = function (...rest) { } +var funcExp3 = (function (...rest) { })() + + +//// [emitRestParametersFunctionExpression.js] +var funcExp = function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +}; +var funcExp1 = function (X) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } +}; +var funcExp2 = function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +}; +var funcExp3 = (function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +})(); diff --git a/tests/baselines/reference/emitRestParametersFunctionExpression.types b/tests/baselines/reference/emitRestParametersFunctionExpression.types new file mode 100644 index 00000000000..9f08b9d9d83 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionExpression.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpression.ts === +var funcExp = (...rest) => { } +>funcExp : (...rest: any[]) => void +>(...rest) => { } : (...rest: any[]) => void +>rest : any[] + +var funcExp1 = (X: number, ...rest) => { } +>funcExp1 : (X: number, ...rest: any[]) => void +>(X: number, ...rest) => { } : (X: number, ...rest: any[]) => void +>X : number +>rest : any[] + +var funcExp2 = function (...rest) { } +>funcExp2 : (...rest: any[]) => void +>function (...rest) { } : (...rest: any[]) => void +>rest : any[] + +var funcExp3 = (function (...rest) { })() +>funcExp3 : void +>(function (...rest) { })() : void +>(function (...rest) { }) : (...rest: any[]) => void +>function (...rest) { } : (...rest: any[]) => void +>rest : any[] + diff --git a/tests/baselines/reference/emitRestParametersFunctionExpressionES6.js b/tests/baselines/reference/emitRestParametersFunctionExpressionES6.js new file mode 100644 index 00000000000..6c79e4956ae --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionExpressionES6.js @@ -0,0 +1,15 @@ +//// [emitRestParametersFunctionExpressionES6.ts] +var funcExp = (...rest) => { } +var funcExp1 = (X: number, ...rest) => { } +var funcExp2 = function (...rest) { } +var funcExp3 = (function (...rest) { })() + +//// [emitRestParametersFunctionExpressionES6.js] +var funcExp = function (...rest) { +}; +var funcExp1 = function (X, ...rest) { +}; +var funcExp2 = function (...rest) { +}; +var funcExp3 = (function (...rest) { +})(); diff --git a/tests/baselines/reference/emitRestParametersFunctionExpressionES6.types b/tests/baselines/reference/emitRestParametersFunctionExpressionES6.types new file mode 100644 index 00000000000..224cb37367a --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionExpressionES6.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpressionES6.ts === +var funcExp = (...rest) => { } +>funcExp : (...rest: any[]) => void +>(...rest) => { } : (...rest: any[]) => void +>rest : any[] + +var funcExp1 = (X: number, ...rest) => { } +>funcExp1 : (X: number, ...rest: any[]) => void +>(X: number, ...rest) => { } : (X: number, ...rest: any[]) => void +>X : number +>rest : any[] + +var funcExp2 = function (...rest) { } +>funcExp2 : (...rest: any[]) => void +>function (...rest) { } : (...rest: any[]) => void +>rest : any[] + +var funcExp3 = (function (...rest) { })() +>funcExp3 : void +>(function (...rest) { })() : void +>(function (...rest) { }) : (...rest: any[]) => void +>function (...rest) { } : (...rest: any[]) => void +>rest : any[] + diff --git a/tests/baselines/reference/emitRestParametersFunctionProperty.js b/tests/baselines/reference/emitRestParametersFunctionProperty.js new file mode 100644 index 00000000000..4fd60a9269d --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionProperty.js @@ -0,0 +1,19 @@ +//// [emitRestParametersFunctionProperty.ts] +var obj: { + func1: (...rest) => void +} + +var obj2 = { + func(...rest) { } +} + +//// [emitRestParametersFunctionProperty.js] +var obj; +var obj2 = { + func: function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + } +}; diff --git a/tests/baselines/reference/emitRestParametersFunctionProperty.types b/tests/baselines/reference/emitRestParametersFunctionProperty.types new file mode 100644 index 00000000000..8242e742ee0 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionProperty.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionProperty.ts === +var obj: { +>obj : { func1: (...rest: any[]) => void; } + + func1: (...rest) => void +>func1 : (...rest: any[]) => void +>rest : any[] +} + +var obj2 = { +>obj2 : { func(...rest: any[]): void; } +>{ func(...rest) { }} : { func(...rest: any[]): void; } + + func(...rest) { } +>func : (...rest: any[]) => void +>rest : any[] +} diff --git a/tests/baselines/reference/emitRestParametersFunctionPropertyES6.js b/tests/baselines/reference/emitRestParametersFunctionPropertyES6.js new file mode 100644 index 00000000000..87aa489ecf3 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionPropertyES6.js @@ -0,0 +1,15 @@ +//// [emitRestParametersFunctionPropertyES6.ts] +var obj: { + func1: (...rest) => void +} + +var obj2 = { + func(...rest) { } +} + +//// [emitRestParametersFunctionPropertyES6.js] +var obj; +var obj2 = { + func(...rest) { + } +}; diff --git a/tests/baselines/reference/emitRestParametersFunctionPropertyES6.types b/tests/baselines/reference/emitRestParametersFunctionPropertyES6.types new file mode 100644 index 00000000000..07a008cd4c0 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersFunctionPropertyES6.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionPropertyES6.ts === +var obj: { +>obj : { func1: (...rest: any[]) => void; } + + func1: (...rest) => void +>func1 : (...rest: any[]) => void +>rest : any[] +} + +var obj2 = { +>obj2 : { func(...rest: any[]): void; } +>{ func(...rest) { }} : { func(...rest: any[]): void; } + + func(...rest) { } +>func : (...rest: any[]) => void +>rest : any[] +} diff --git a/tests/baselines/reference/emitRestParametersMethod.js b/tests/baselines/reference/emitRestParametersMethod.js new file mode 100644 index 00000000000..5ceb6d768f8 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersMethod.js @@ -0,0 +1,58 @@ +//// [emitRestParametersMethod.ts] +class C { + constructor(name: string, ...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} + +class D { + constructor(...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} + +//// [emitRestParametersMethod.js] +var C = (function () { + function C(name) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + } + C.prototype.bar = function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + }; + C.prototype.foo = function (x) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + }; + return C; +})(); +var D = (function () { + function D() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + } + D.prototype.bar = function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + }; + D.prototype.foo = function (x) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + }; + return D; +})(); diff --git a/tests/baselines/reference/emitRestParametersMethod.types b/tests/baselines/reference/emitRestParametersMethod.types new file mode 100644 index 00000000000..c94561ca737 --- /dev/null +++ b/tests/baselines/reference/emitRestParametersMethod.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersMethod.ts === +class C { +>C : C + + constructor(name: string, ...rest) { } +>name : string +>rest : any[] + + public bar(...rest) { } +>bar : (...rest: any[]) => void +>rest : any[] + + public foo(x: number, ...rest) { } +>foo : (x: number, ...rest: any[]) => void +>x : number +>rest : any[] +} + +class D { +>D : D + + constructor(...rest) { } +>rest : any[] + + public bar(...rest) { } +>bar : (...rest: any[]) => void +>rest : any[] + + public foo(x: number, ...rest) { } +>foo : (x: number, ...rest: any[]) => void +>x : number +>rest : any[] +} diff --git a/tests/baselines/reference/emitRestParametersMethodES6.js b/tests/baselines/reference/emitRestParametersMethodES6.js new file mode 100644 index 00000000000..d0a0e2a120c --- /dev/null +++ b/tests/baselines/reference/emitRestParametersMethodES6.js @@ -0,0 +1,35 @@ +//// [emitRestParametersMethodES6.ts] +class C { + constructor(name: string, ...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} + +class D { + constructor(...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} + + +//// [emitRestParametersMethodES6.js] +var C = (function () { + function C(name, ...rest) { + } + C.prototype.bar = function (...rest) { + }; + C.prototype.foo = function (x, ...rest) { + }; + return C; +})(); +var D = (function () { + function D(...rest) { + } + D.prototype.bar = function (...rest) { + }; + D.prototype.foo = function (x, ...rest) { + }; + return D; +})(); diff --git a/tests/baselines/reference/emitRestParametersMethodES6.types b/tests/baselines/reference/emitRestParametersMethodES6.types new file mode 100644 index 00000000000..4555a5c666d --- /dev/null +++ b/tests/baselines/reference/emitRestParametersMethodES6.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/es6/restParameters/emitRestParametersMethodES6.ts === +class C { +>C : C + + constructor(name: string, ...rest) { } +>name : string +>rest : any[] + + public bar(...rest) { } +>bar : (...rest: any[]) => void +>rest : any[] + + public foo(x: number, ...rest) { } +>foo : (x: number, ...rest: any[]) => void +>x : number +>rest : any[] +} + +class D { +>D : D + + constructor(...rest) { } +>rest : any[] + + public bar(...rest) { } +>bar : (...rest: any[]) => void +>rest : any[] + + public foo(x: number, ...rest) { } +>foo : (x: number, ...rest: any[]) => void +>x : number +>rest : any[] +} + diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersFunction.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersFunction.ts new file mode 100644 index 00000000000..ee170d2bcb9 --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersFunction.ts @@ -0,0 +1,3 @@ +// @target: es5 +function bar(...rest) { } +function foo(x: number, y: string, ...rest) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionES6.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionES6.ts new file mode 100644 index 00000000000..366905d764b --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionES6.ts @@ -0,0 +1,3 @@ +// @target: es6 +function bar(...rest) { } +function foo(x: number, y: string, ...rest) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpression.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpression.ts new file mode 100644 index 00000000000..a9ddf83c816 --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpression.ts @@ -0,0 +1,5 @@ +// @target: es5 +var funcExp = (...rest) => { } +var funcExp1 = (X: number, ...rest) => { } +var funcExp2 = function (...rest) { } +var funcExp3 = (function (...rest) { })() diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpressionES6.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpressionES6.ts new file mode 100644 index 00000000000..310dcfd1557 --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpressionES6.ts @@ -0,0 +1,5 @@ +// @target: es6 +var funcExp = (...rest) => { } +var funcExp1 = (X: number, ...rest) => { } +var funcExp2 = function (...rest) { } +var funcExp3 = (function (...rest) { })() \ No newline at end of file diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionProperty.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionProperty.ts new file mode 100644 index 00000000000..c8a8ed16e7b --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionProperty.ts @@ -0,0 +1,8 @@ +// @target: es5 +var obj: { + func1: (...rest) => void +} + +var obj2 = { + func(...rest) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionPropertyES6.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionPropertyES6.ts new file mode 100644 index 00000000000..34bb0cae6b7 --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersFunctionPropertyES6.ts @@ -0,0 +1,8 @@ +// @target: es6 +var obj: { + func1: (...rest) => void +} + +var obj2 = { + func(...rest) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersMethod.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersMethod.ts new file mode 100644 index 00000000000..6b9e70fd196 --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersMethod.ts @@ -0,0 +1,14 @@ +// @target: es5 +class C { + constructor(name: string, ...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} + +class D { + constructor(...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/restParameters/emitRestParametersMethodES6.ts b/tests/cases/conformance/es6/restParameters/emitRestParametersMethodES6.ts new file mode 100644 index 00000000000..df2f2293c75 --- /dev/null +++ b/tests/cases/conformance/es6/restParameters/emitRestParametersMethodES6.ts @@ -0,0 +1,14 @@ +// @target: es6 +class C { + constructor(name: string, ...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} + +class D { + constructor(...rest) { } + + public bar(...rest) { } + public foo(x: number, ...rest) { } +} From 6f6c46a99f446144702bb324f6b50d94a000a690 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 5 Jan 2015 18:25:28 -0800 Subject: [PATCH 29/93] Use getSourceFile instead of getSourceFiles in compileDeclarationFiles --- src/harness/harness.ts | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index d0c2db1e8a7..ba84a3c9ffd 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1127,29 +1127,27 @@ module Harness { } function findResultCodeFile(fileName: string) { - var dTsFileName = ts.forEach(result.program.getSourceFiles(), sourceFile => { - if (sourceFile.filename === fileName) { - // Is this file going to be emitted separately - var sourceFileName: string; - if (ts.isExternalModule(sourceFile) || !options.out) { - if (options.outDir) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, result.currentDirectoryForProgram); - sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); - sourceFileName = ts.combinePaths(options.outDir, sourceFilePath); - } - else { - sourceFileName = sourceFile.filename; - } - } - else { - // Goes to single --out file - sourceFileName = options.out; - } - - return ts.removeFileExtension(sourceFileName) + ".d.ts"; + var sourceFile = result.program.getSourceFile(fileName); + assert(sourceFile, "Program has no source file with name '" + fileName + "'"); + // Is this file going to be emitted separately + var sourceFileName: string; + if (ts.isExternalModule(sourceFile) || !options.out) { + if (options.outDir) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, result.currentDirectoryForProgram); + sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); + sourceFileName = ts.combinePaths(options.outDir, sourceFilePath); } - }); + else { + sourceFileName = sourceFile.filename; + } + } + else { + // Goes to single --out file + sourceFileName = options.out; + } + var dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; + return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); } From 7518d15620d21d81c8224f2fdbf67080db7cbf33 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 5 Jan 2015 18:26:09 -0800 Subject: [PATCH 30/93] Remove unnecessary it block in generated .d.ts compilation in harness --- src/harness/compilerRunner.ts | 18 ++++-------------- src/harness/rwcRunner.ts | 19 +++++-------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 29861d3e556..a88620c4e6c 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -61,12 +61,6 @@ class CompilerBaselineRunner extends RunnerBase { var otherFiles: { unitName: string; content: string }[]; var harnessCompiler: Harness.Compiler.HarnessCompiler; - var declFileCompilationResult: { - declInputFiles: { unitName: string; content: string }[]; - declOtherFiles: { unitName: string; content: string }[]; - declResult: Harness.Compiler.CompilerResult; - }; - var createNewInstance = false; before(() => { @@ -143,7 +137,6 @@ class CompilerBaselineRunner extends RunnerBase { toBeCompiled = undefined; otherFiles = undefined; harnessCompiler = undefined; - declFileCompilationResult = undefined; }); function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string { @@ -179,13 +172,6 @@ class CompilerBaselineRunner extends RunnerBase { } }); - // Compile .d.ts files - it('Correct compiler generated.d.ts for ' + fileName, () => { - declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) { - harnessCompiler.setCompilerSettings(tcSettings); - }, options); - }); - it('Correct JS output for ' + fileName, () => { if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) { @@ -223,6 +209,10 @@ class CompilerBaselineRunner extends RunnerBase { } } + var declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) { + harnessCompiler.setCompilerSettings(tcSettings); + }, options); + if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { jsCode += '\r\n\r\n//// [DtsFileErrors]\r\n'; jsCode += '\r\n\r\n'; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 8d22b1da1d8..085f66f1a3e 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -28,12 +28,6 @@ module RWC { var compilerOptions: ts.CompilerOptions; var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' }; var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; - // Compile .d.ts files - var declFileCompilationResult: { - declInputFiles: { unitName: string; content: string }[]; - declOtherFiles: { unitName: string; content: string }[]; - declResult: Harness.Compiler.CompilerResult; - }; after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. @@ -44,7 +38,6 @@ module RWC { compilerOptions = undefined; baselineOpts = undefined; baseName = undefined; - declFileCompilationResult = undefined; }); it('can compile', () => { @@ -103,11 +96,6 @@ module RWC { } }); - // Baselines - it('Correct compiler generated.d.ts', () => { - declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions); - }); - it('has the expected emitted code', () => { Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => { @@ -152,9 +140,12 @@ module RWC { }, false, baselineOpts); }); - it('has no errors in generated declaration files', () => { + // Ideally, a generated declaration file will have no errors. But we allow generated + // declaration file errors as part of the baseline. + it('has the expected errors in generated declaration files', () => { if (compilerOptions.declaration && !compilerResult.errors.length) { - Harness.Baseline.runBaseline('has no errors in generated declaration files', baseName + '.dts.errors.txt', () => { + Harness.Baseline.runBaseline('has the expected errors in generated declaration files', baseName + '.dts.errors.txt', () => { + var declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions); if (declFileCompilationResult.declResult.errors.length === 0) { return null; } From 33534be26824b8dea146fd857029c203fa147adf Mon Sep 17 00:00:00 2001 From: Arnavion Date: Tue, 6 Jan 2015 02:42:02 -0800 Subject: [PATCH 31/93] Give MinusToken the same precedence as PlusToken for template expressions. Fixes #1577 --- src/compiler/emitter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 237f3ab509a..f3e45a85b6a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2117,7 +2117,8 @@ module ts { * or equal precedence to the binary '+' operator */ function comparePrecedenceToBinaryPlus(expression: Expression): Comparison { - // All binary expressions have lower precedence than '+' apart from '*', '/', and '%'. + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' + // which have greater precedence and '-' which has equal precedence. // All unary operators have a higher precedence apart from yield. // Arrow functions and conditionals have a lower precedence, // although we convert the former into regular function expressions in ES5 mode, @@ -2134,6 +2135,7 @@ module ts { case SyntaxKind.PercentToken: return Comparison.GreaterThan; case SyntaxKind.PlusToken: + case SyntaxKind.MinusToken: return Comparison.EqualTo; default: return Comparison.LessThan; From 4dfb0cc3d80156203141f6de338fb566d22c7f3a Mon Sep 17 00:00:00 2001 From: Arnavion Date: Tue, 6 Jan 2015 02:42:22 -0800 Subject: [PATCH 32/93] Update tests and baselines. --- .../templateStringBinaryOperations.js | 103 +++++ .../templateStringBinaryOperations.types | 245 +++++++++++ .../templateStringBinaryOperationsES6.js | 103 +++++ .../templateStringBinaryOperationsES6.types | 245 +++++++++++ ...tringBinaryOperationsES6Invalid.errors.txt | 399 ++++++++++++++++++ ...emplateStringBinaryOperationsES6Invalid.js | 207 +++++++++ ...teStringBinaryOperationsInvalid.errors.txt | 399 ++++++++++++++++++ .../templateStringBinaryOperationsInvalid.js | 207 +++++++++ .../templateStringInBinaryAddition.js | 5 - .../templateStringInBinaryAddition.types | 5 - .../templateStringInBinaryAdditionES6.js | 5 - .../templateStringInBinaryAdditionES6.types | 5 - .../templateStringBinaryOperations.ts | 51 +++ .../templateStringBinaryOperationsES6.ts | 52 +++ ...emplateStringBinaryOperationsES6Invalid.ts | 108 +++++ .../templateStringBinaryOperationsInvalid.ts | 107 +++++ .../templateStringInBinaryAddition.ts | 1 - .../templateStringInBinaryAdditionES6.ts | 2 - 18 files changed, 2226 insertions(+), 23 deletions(-) create mode 100644 tests/baselines/reference/templateStringBinaryOperations.js create mode 100644 tests/baselines/reference/templateStringBinaryOperations.types create mode 100644 tests/baselines/reference/templateStringBinaryOperationsES6.js create mode 100644 tests/baselines/reference/templateStringBinaryOperationsES6.types create mode 100644 tests/baselines/reference/templateStringBinaryOperationsES6Invalid.errors.txt create mode 100644 tests/baselines/reference/templateStringBinaryOperationsES6Invalid.js create mode 100644 tests/baselines/reference/templateStringBinaryOperationsInvalid.errors.txt create mode 100644 tests/baselines/reference/templateStringBinaryOperationsInvalid.js delete mode 100644 tests/baselines/reference/templateStringInBinaryAddition.js delete mode 100644 tests/baselines/reference/templateStringInBinaryAddition.types delete mode 100644 tests/baselines/reference/templateStringInBinaryAdditionES6.js delete mode 100644 tests/baselines/reference/templateStringInBinaryAdditionES6.types create mode 100644 tests/cases/conformance/es6/templates/templateStringBinaryOperations.ts create mode 100644 tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6.ts create mode 100644 tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts create mode 100644 tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts delete mode 100644 tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts delete mode 100644 tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts diff --git a/tests/baselines/reference/templateStringBinaryOperations.js b/tests/baselines/reference/templateStringBinaryOperations.js new file mode 100644 index 00000000000..d155ba9eedd --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperations.js @@ -0,0 +1,103 @@ +//// [templateStringBinaryOperations.ts] +var a = 1 + `${ 3 }`; +var b = 1 + `2${ 3 }`; +var c = 1 + `${ 3 }4`; +var d = 1 + `2${ 3 }4`; +var e = `${ 3 }` + 5; +var f = `2${ 3 }` + 5; +var g = `${ 3 }4` + 5; +var h = `2${ 3 }4` + 5; +var i = 1 + `${ 3 }` + 5; +var j = 1 + `2${ 3 }` + 5; +var k = 1 + `${ 3 }4` + 5; +var l = 1 + `2${ 3 }4` + 5; + +var a2 = 1 + `${ 3 - 4 }`; +var b2 = 1 + `2${ 3 - 4 }`; +var c2 = 1 + `${ 3 - 4 }5`; +var d2 = 1 + `2${ 3 - 4 }5`; +var e2 = `${ 3 - 4 }` + 6; +var f2 = `2${ 3 - 4 }` + 6; +var g2 = `${ 3 - 4 }5` + 6; +var h2 = `2${ 3 - 4 }5` + 6; +var i2 = 1 + `${ 3 - 4 }` + 6; +var j2 = 1 + `2${ 3 - 4 }` + 6; +var k2 = 1 + `${ 3 - 4 }5` + 6; +var l2 = 1 + `2${ 3 - 4 }5` + 6; + +var a3 = 1 + `${ 3 * 4 }`; +var b3 = 1 + `2${ 3 * 4 }`; +var c3 = 1 + `${ 3 * 4 }5`; +var d3 = 1 + `2${ 3 * 4 }5`; +var e3 = `${ 3 * 4 }` + 6; +var f3 = `2${ 3 * 4 }` + 6; +var g3 = `${ 3 * 4 }5` + 6; +var h3 = `2${ 3 * 4 }5` + 6; +var i3 = 1 + `${ 3 * 4 }` + 6; +var j3 = 1 + `2${ 3 * 4 }` + 6; +var k3 = 1 + `${ 3 * 4 }5` + 6; +var l3 = 1 + `2${ 3 * 4 }5` + 6; + +var a4 = 1 + `${ 3 & 4 }`; +var b4 = 1 + `2${ 3 & 4 }`; +var c4 = 1 + `${ 3 & 4 }5`; +var d4 = 1 + `2${ 3 & 4 }5`; +var e4 = `${ 3 & 4 }` + 6; +var f4 = `2${ 3 & 4 }` + 6; +var g4 = `${ 3 & 4 }5` + 6; +var h4 = `2${ 3 & 4 }5` + 6; +var i4 = 1 + `${ 3 & 4 }` + 6; +var j4 = 1 + `2${ 3 & 4 }` + 6; +var k4 = 1 + `${ 3 & 4 }5` + 6; +var l4 = 1 + `2${ 3 & 4 }5` + 6; + + +//// [templateStringBinaryOperations.js] +var a = 1 + ("" + 3); +var b = 1 + ("2" + 3); +var c = 1 + ("" + 3 + "4"); +var d = 1 + ("2" + 3 + "4"); +var e = ("" + 3) + 5; +var f = ("2" + 3) + 5; +var g = ("" + 3 + "4") + 5; +var h = ("2" + 3 + "4") + 5; +var i = 1 + ("" + 3) + 5; +var j = 1 + ("2" + 3) + 5; +var k = 1 + ("" + 3 + "4") + 5; +var l = 1 + ("2" + 3 + "4") + 5; +var a2 = 1 + ("" + (3 - 4)); +var b2 = 1 + ("2" + (3 - 4)); +var c2 = 1 + ("" + (3 - 4) + "5"); +var d2 = 1 + ("2" + (3 - 4) + "5"); +var e2 = ("" + (3 - 4)) + 6; +var f2 = ("2" + (3 - 4)) + 6; +var g2 = ("" + (3 - 4) + "5") + 6; +var h2 = ("2" + (3 - 4) + "5") + 6; +var i2 = 1 + ("" + (3 - 4)) + 6; +var j2 = 1 + ("2" + (3 - 4)) + 6; +var k2 = 1 + ("" + (3 - 4) + "5") + 6; +var l2 = 1 + ("2" + (3 - 4) + "5") + 6; +var a3 = 1 + ("" + 3 * 4); +var b3 = 1 + ("2" + 3 * 4); +var c3 = 1 + ("" + 3 * 4 + "5"); +var d3 = 1 + ("2" + 3 * 4 + "5"); +var e3 = ("" + 3 * 4) + 6; +var f3 = ("2" + 3 * 4) + 6; +var g3 = ("" + 3 * 4 + "5") + 6; +var h3 = ("2" + 3 * 4 + "5") + 6; +var i3 = 1 + ("" + 3 * 4) + 6; +var j3 = 1 + ("2" + 3 * 4) + 6; +var k3 = 1 + ("" + 3 * 4 + "5") + 6; +var l3 = 1 + ("2" + 3 * 4 + "5") + 6; +var a4 = 1 + ("" + (3 & 4)); +var b4 = 1 + ("2" + (3 & 4)); +var c4 = 1 + ("" + (3 & 4) + "5"); +var d4 = 1 + ("2" + (3 & 4) + "5"); +var e4 = ("" + (3 & 4)) + 6; +var f4 = ("2" + (3 & 4)) + 6; +var g4 = ("" + (3 & 4) + "5") + 6; +var h4 = ("2" + (3 & 4) + "5") + 6; +var i4 = 1 + ("" + (3 & 4)) + 6; +var j4 = 1 + ("2" + (3 & 4)) + 6; +var k4 = 1 + ("" + (3 & 4) + "5") + 6; +var l4 = 1 + ("2" + (3 & 4) + "5") + 6; diff --git a/tests/baselines/reference/templateStringBinaryOperations.types b/tests/baselines/reference/templateStringBinaryOperations.types new file mode 100644 index 00000000000..094c82f3678 --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperations.types @@ -0,0 +1,245 @@ +=== tests/cases/conformance/es6/templates/templateStringBinaryOperations.ts === +var a = 1 + `${ 3 }`; +>a : string +>1 + `${ 3 }` : string + +var b = 1 + `2${ 3 }`; +>b : string +>1 + `2${ 3 }` : string + +var c = 1 + `${ 3 }4`; +>c : string +>1 + `${ 3 }4` : string + +var d = 1 + `2${ 3 }4`; +>d : string +>1 + `2${ 3 }4` : string + +var e = `${ 3 }` + 5; +>e : string +>`${ 3 }` + 5 : string + +var f = `2${ 3 }` + 5; +>f : string +>`2${ 3 }` + 5 : string + +var g = `${ 3 }4` + 5; +>g : string +>`${ 3 }4` + 5 : string + +var h = `2${ 3 }4` + 5; +>h : string +>`2${ 3 }4` + 5 : string + +var i = 1 + `${ 3 }` + 5; +>i : string +>1 + `${ 3 }` + 5 : string +>1 + `${ 3 }` : string + +var j = 1 + `2${ 3 }` + 5; +>j : string +>1 + `2${ 3 }` + 5 : string +>1 + `2${ 3 }` : string + +var k = 1 + `${ 3 }4` + 5; +>k : string +>1 + `${ 3 }4` + 5 : string +>1 + `${ 3 }4` : string + +var l = 1 + `2${ 3 }4` + 5; +>l : string +>1 + `2${ 3 }4` + 5 : string +>1 + `2${ 3 }4` : string + +var a2 = 1 + `${ 3 - 4 }`; +>a2 : string +>1 + `${ 3 - 4 }` : string +>3 - 4 : number + +var b2 = 1 + `2${ 3 - 4 }`; +>b2 : string +>1 + `2${ 3 - 4 }` : string +>3 - 4 : number + +var c2 = 1 + `${ 3 - 4 }5`; +>c2 : string +>1 + `${ 3 - 4 }5` : string +>3 - 4 : number + +var d2 = 1 + `2${ 3 - 4 }5`; +>d2 : string +>1 + `2${ 3 - 4 }5` : string +>3 - 4 : number + +var e2 = `${ 3 - 4 }` + 6; +>e2 : string +>`${ 3 - 4 }` + 6 : string +>3 - 4 : number + +var f2 = `2${ 3 - 4 }` + 6; +>f2 : string +>`2${ 3 - 4 }` + 6 : string +>3 - 4 : number + +var g2 = `${ 3 - 4 }5` + 6; +>g2 : string +>`${ 3 - 4 }5` + 6 : string +>3 - 4 : number + +var h2 = `2${ 3 - 4 }5` + 6; +>h2 : string +>`2${ 3 - 4 }5` + 6 : string +>3 - 4 : number + +var i2 = 1 + `${ 3 - 4 }` + 6; +>i2 : string +>1 + `${ 3 - 4 }` + 6 : string +>1 + `${ 3 - 4 }` : string +>3 - 4 : number + +var j2 = 1 + `2${ 3 - 4 }` + 6; +>j2 : string +>1 + `2${ 3 - 4 }` + 6 : string +>1 + `2${ 3 - 4 }` : string +>3 - 4 : number + +var k2 = 1 + `${ 3 - 4 }5` + 6; +>k2 : string +>1 + `${ 3 - 4 }5` + 6 : string +>1 + `${ 3 - 4 }5` : string +>3 - 4 : number + +var l2 = 1 + `2${ 3 - 4 }5` + 6; +>l2 : string +>1 + `2${ 3 - 4 }5` + 6 : string +>1 + `2${ 3 - 4 }5` : string +>3 - 4 : number + +var a3 = 1 + `${ 3 * 4 }`; +>a3 : string +>1 + `${ 3 * 4 }` : string +>3 * 4 : number + +var b3 = 1 + `2${ 3 * 4 }`; +>b3 : string +>1 + `2${ 3 * 4 }` : string +>3 * 4 : number + +var c3 = 1 + `${ 3 * 4 }5`; +>c3 : string +>1 + `${ 3 * 4 }5` : string +>3 * 4 : number + +var d3 = 1 + `2${ 3 * 4 }5`; +>d3 : string +>1 + `2${ 3 * 4 }5` : string +>3 * 4 : number + +var e3 = `${ 3 * 4 }` + 6; +>e3 : string +>`${ 3 * 4 }` + 6 : string +>3 * 4 : number + +var f3 = `2${ 3 * 4 }` + 6; +>f3 : string +>`2${ 3 * 4 }` + 6 : string +>3 * 4 : number + +var g3 = `${ 3 * 4 }5` + 6; +>g3 : string +>`${ 3 * 4 }5` + 6 : string +>3 * 4 : number + +var h3 = `2${ 3 * 4 }5` + 6; +>h3 : string +>`2${ 3 * 4 }5` + 6 : string +>3 * 4 : number + +var i3 = 1 + `${ 3 * 4 }` + 6; +>i3 : string +>1 + `${ 3 * 4 }` + 6 : string +>1 + `${ 3 * 4 }` : string +>3 * 4 : number + +var j3 = 1 + `2${ 3 * 4 }` + 6; +>j3 : string +>1 + `2${ 3 * 4 }` + 6 : string +>1 + `2${ 3 * 4 }` : string +>3 * 4 : number + +var k3 = 1 + `${ 3 * 4 }5` + 6; +>k3 : string +>1 + `${ 3 * 4 }5` + 6 : string +>1 + `${ 3 * 4 }5` : string +>3 * 4 : number + +var l3 = 1 + `2${ 3 * 4 }5` + 6; +>l3 : string +>1 + `2${ 3 * 4 }5` + 6 : string +>1 + `2${ 3 * 4 }5` : string +>3 * 4 : number + +var a4 = 1 + `${ 3 & 4 }`; +>a4 : string +>1 + `${ 3 & 4 }` : string +>3 & 4 : number + +var b4 = 1 + `2${ 3 & 4 }`; +>b4 : string +>1 + `2${ 3 & 4 }` : string +>3 & 4 : number + +var c4 = 1 + `${ 3 & 4 }5`; +>c4 : string +>1 + `${ 3 & 4 }5` : string +>3 & 4 : number + +var d4 = 1 + `2${ 3 & 4 }5`; +>d4 : string +>1 + `2${ 3 & 4 }5` : string +>3 & 4 : number + +var e4 = `${ 3 & 4 }` + 6; +>e4 : string +>`${ 3 & 4 }` + 6 : string +>3 & 4 : number + +var f4 = `2${ 3 & 4 }` + 6; +>f4 : string +>`2${ 3 & 4 }` + 6 : string +>3 & 4 : number + +var g4 = `${ 3 & 4 }5` + 6; +>g4 : string +>`${ 3 & 4 }5` + 6 : string +>3 & 4 : number + +var h4 = `2${ 3 & 4 }5` + 6; +>h4 : string +>`2${ 3 & 4 }5` + 6 : string +>3 & 4 : number + +var i4 = 1 + `${ 3 & 4 }` + 6; +>i4 : string +>1 + `${ 3 & 4 }` + 6 : string +>1 + `${ 3 & 4 }` : string +>3 & 4 : number + +var j4 = 1 + `2${ 3 & 4 }` + 6; +>j4 : string +>1 + `2${ 3 & 4 }` + 6 : string +>1 + `2${ 3 & 4 }` : string +>3 & 4 : number + +var k4 = 1 + `${ 3 & 4 }5` + 6; +>k4 : string +>1 + `${ 3 & 4 }5` + 6 : string +>1 + `${ 3 & 4 }5` : string +>3 & 4 : number + +var l4 = 1 + `2${ 3 & 4 }5` + 6; +>l4 : string +>1 + `2${ 3 & 4 }5` + 6 : string +>1 + `2${ 3 & 4 }5` : string +>3 & 4 : number + diff --git a/tests/baselines/reference/templateStringBinaryOperationsES6.js b/tests/baselines/reference/templateStringBinaryOperationsES6.js new file mode 100644 index 00000000000..8dcdd8a2aa7 --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperationsES6.js @@ -0,0 +1,103 @@ +//// [templateStringBinaryOperationsES6.ts] +var a = 1 + `${ 3 }`; +var b = 1 + `2${ 3 }`; +var c = 1 + `${ 3 }4`; +var d = 1 + `2${ 3 }4`; +var e = `${ 3 }` + 5; +var f = `2${ 3 }` + 5; +var g = `${ 3 }4` + 5; +var h = `2${ 3 }4` + 5; +var i = 1 + `${ 3 }` + 5; +var j = 1 + `2${ 3 }` + 5; +var k = 1 + `${ 3 }4` + 5; +var l = 1 + `2${ 3 }4` + 5; + +var a2 = 1 + `${ 3 - 4 }`; +var b2 = 1 + `2${ 3 - 4 }`; +var c2 = 1 + `${ 3 - 4 }5`; +var d2 = 1 + `2${ 3 - 4 }5`; +var e2 = `${ 3 - 4 }` + 6; +var f2 = `2${ 3 - 4 }` + 6; +var g2 = `${ 3 - 4 }5` + 6; +var h2 = `2${ 3 - 4 }5` + 6; +var i2 = 1 + `${ 3 - 4 }` + 6; +var j2 = 1 + `2${ 3 - 4 }` + 6; +var k2 = 1 + `${ 3 - 4 }5` + 6; +var l2 = 1 + `2${ 3 - 4 }5` + 6; + +var a3 = 1 + `${ 3 * 4 }`; +var b3 = 1 + `2${ 3 * 4 }`; +var c3 = 1 + `${ 3 * 4 }5`; +var d3 = 1 + `2${ 3 * 4 }5`; +var e3 = `${ 3 * 4 }` + 6; +var f3 = `2${ 3 * 4 }` + 6; +var g3 = `${ 3 * 4 }5` + 6; +var h3 = `2${ 3 * 4 }5` + 6; +var i3 = 1 + `${ 3 * 4 }` + 6; +var j3 = 1 + `2${ 3 * 4 }` + 6; +var k3 = 1 + `${ 3 * 4 }5` + 6; +var l3 = 1 + `2${ 3 * 4 }5` + 6; + +var a4 = 1 + `${ 3 & 4 }`; +var b4 = 1 + `2${ 3 & 4 }`; +var c4 = 1 + `${ 3 & 4 }5`; +var d4 = 1 + `2${ 3 & 4 }5`; +var e4 = `${ 3 & 4 }` + 6; +var f4 = `2${ 3 & 4 }` + 6; +var g4 = `${ 3 & 4 }5` + 6; +var h4 = `2${ 3 & 4 }5` + 6; +var i4 = 1 + `${ 3 & 4 }` + 6; +var j4 = 1 + `2${ 3 & 4 }` + 6; +var k4 = 1 + `${ 3 & 4 }5` + 6; +var l4 = 1 + `2${ 3 & 4 }5` + 6; + + +//// [templateStringBinaryOperationsES6.js] +var a = 1 + `${3}`; +var b = 1 + `2${3}`; +var c = 1 + `${3}4`; +var d = 1 + `2${3}4`; +var e = `${3}` + 5; +var f = `2${3}` + 5; +var g = `${3}4` + 5; +var h = `2${3}4` + 5; +var i = 1 + `${3}` + 5; +var j = 1 + `2${3}` + 5; +var k = 1 + `${3}4` + 5; +var l = 1 + `2${3}4` + 5; +var a2 = 1 + `${3 - 4}`; +var b2 = 1 + `2${3 - 4}`; +var c2 = 1 + `${3 - 4}5`; +var d2 = 1 + `2${3 - 4}5`; +var e2 = `${3 - 4}` + 6; +var f2 = `2${3 - 4}` + 6; +var g2 = `${3 - 4}5` + 6; +var h2 = `2${3 - 4}5` + 6; +var i2 = 1 + `${3 - 4}` + 6; +var j2 = 1 + `2${3 - 4}` + 6; +var k2 = 1 + `${3 - 4}5` + 6; +var l2 = 1 + `2${3 - 4}5` + 6; +var a3 = 1 + `${3 * 4}`; +var b3 = 1 + `2${3 * 4}`; +var c3 = 1 + `${3 * 4}5`; +var d3 = 1 + `2${3 * 4}5`; +var e3 = `${3 * 4}` + 6; +var f3 = `2${3 * 4}` + 6; +var g3 = `${3 * 4}5` + 6; +var h3 = `2${3 * 4}5` + 6; +var i3 = 1 + `${3 * 4}` + 6; +var j3 = 1 + `2${3 * 4}` + 6; +var k3 = 1 + `${3 * 4}5` + 6; +var l3 = 1 + `2${3 * 4}5` + 6; +var a4 = 1 + `${3 & 4}`; +var b4 = 1 + `2${3 & 4}`; +var c4 = 1 + `${3 & 4}5`; +var d4 = 1 + `2${3 & 4}5`; +var e4 = `${3 & 4}` + 6; +var f4 = `2${3 & 4}` + 6; +var g4 = `${3 & 4}5` + 6; +var h4 = `2${3 & 4}5` + 6; +var i4 = 1 + `${3 & 4}` + 6; +var j4 = 1 + `2${3 & 4}` + 6; +var k4 = 1 + `${3 & 4}5` + 6; +var l4 = 1 + `2${3 & 4}5` + 6; diff --git a/tests/baselines/reference/templateStringBinaryOperationsES6.types b/tests/baselines/reference/templateStringBinaryOperationsES6.types new file mode 100644 index 00000000000..a79885904e2 --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperationsES6.types @@ -0,0 +1,245 @@ +=== tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6.ts === +var a = 1 + `${ 3 }`; +>a : string +>1 + `${ 3 }` : string + +var b = 1 + `2${ 3 }`; +>b : string +>1 + `2${ 3 }` : string + +var c = 1 + `${ 3 }4`; +>c : string +>1 + `${ 3 }4` : string + +var d = 1 + `2${ 3 }4`; +>d : string +>1 + `2${ 3 }4` : string + +var e = `${ 3 }` + 5; +>e : string +>`${ 3 }` + 5 : string + +var f = `2${ 3 }` + 5; +>f : string +>`2${ 3 }` + 5 : string + +var g = `${ 3 }4` + 5; +>g : string +>`${ 3 }4` + 5 : string + +var h = `2${ 3 }4` + 5; +>h : string +>`2${ 3 }4` + 5 : string + +var i = 1 + `${ 3 }` + 5; +>i : string +>1 + `${ 3 }` + 5 : string +>1 + `${ 3 }` : string + +var j = 1 + `2${ 3 }` + 5; +>j : string +>1 + `2${ 3 }` + 5 : string +>1 + `2${ 3 }` : string + +var k = 1 + `${ 3 }4` + 5; +>k : string +>1 + `${ 3 }4` + 5 : string +>1 + `${ 3 }4` : string + +var l = 1 + `2${ 3 }4` + 5; +>l : string +>1 + `2${ 3 }4` + 5 : string +>1 + `2${ 3 }4` : string + +var a2 = 1 + `${ 3 - 4 }`; +>a2 : string +>1 + `${ 3 - 4 }` : string +>3 - 4 : number + +var b2 = 1 + `2${ 3 - 4 }`; +>b2 : string +>1 + `2${ 3 - 4 }` : string +>3 - 4 : number + +var c2 = 1 + `${ 3 - 4 }5`; +>c2 : string +>1 + `${ 3 - 4 }5` : string +>3 - 4 : number + +var d2 = 1 + `2${ 3 - 4 }5`; +>d2 : string +>1 + `2${ 3 - 4 }5` : string +>3 - 4 : number + +var e2 = `${ 3 - 4 }` + 6; +>e2 : string +>`${ 3 - 4 }` + 6 : string +>3 - 4 : number + +var f2 = `2${ 3 - 4 }` + 6; +>f2 : string +>`2${ 3 - 4 }` + 6 : string +>3 - 4 : number + +var g2 = `${ 3 - 4 }5` + 6; +>g2 : string +>`${ 3 - 4 }5` + 6 : string +>3 - 4 : number + +var h2 = `2${ 3 - 4 }5` + 6; +>h2 : string +>`2${ 3 - 4 }5` + 6 : string +>3 - 4 : number + +var i2 = 1 + `${ 3 - 4 }` + 6; +>i2 : string +>1 + `${ 3 - 4 }` + 6 : string +>1 + `${ 3 - 4 }` : string +>3 - 4 : number + +var j2 = 1 + `2${ 3 - 4 }` + 6; +>j2 : string +>1 + `2${ 3 - 4 }` + 6 : string +>1 + `2${ 3 - 4 }` : string +>3 - 4 : number + +var k2 = 1 + `${ 3 - 4 }5` + 6; +>k2 : string +>1 + `${ 3 - 4 }5` + 6 : string +>1 + `${ 3 - 4 }5` : string +>3 - 4 : number + +var l2 = 1 + `2${ 3 - 4 }5` + 6; +>l2 : string +>1 + `2${ 3 - 4 }5` + 6 : string +>1 + `2${ 3 - 4 }5` : string +>3 - 4 : number + +var a3 = 1 + `${ 3 * 4 }`; +>a3 : string +>1 + `${ 3 * 4 }` : string +>3 * 4 : number + +var b3 = 1 + `2${ 3 * 4 }`; +>b3 : string +>1 + `2${ 3 * 4 }` : string +>3 * 4 : number + +var c3 = 1 + `${ 3 * 4 }5`; +>c3 : string +>1 + `${ 3 * 4 }5` : string +>3 * 4 : number + +var d3 = 1 + `2${ 3 * 4 }5`; +>d3 : string +>1 + `2${ 3 * 4 }5` : string +>3 * 4 : number + +var e3 = `${ 3 * 4 }` + 6; +>e3 : string +>`${ 3 * 4 }` + 6 : string +>3 * 4 : number + +var f3 = `2${ 3 * 4 }` + 6; +>f3 : string +>`2${ 3 * 4 }` + 6 : string +>3 * 4 : number + +var g3 = `${ 3 * 4 }5` + 6; +>g3 : string +>`${ 3 * 4 }5` + 6 : string +>3 * 4 : number + +var h3 = `2${ 3 * 4 }5` + 6; +>h3 : string +>`2${ 3 * 4 }5` + 6 : string +>3 * 4 : number + +var i3 = 1 + `${ 3 * 4 }` + 6; +>i3 : string +>1 + `${ 3 * 4 }` + 6 : string +>1 + `${ 3 * 4 }` : string +>3 * 4 : number + +var j3 = 1 + `2${ 3 * 4 }` + 6; +>j3 : string +>1 + `2${ 3 * 4 }` + 6 : string +>1 + `2${ 3 * 4 }` : string +>3 * 4 : number + +var k3 = 1 + `${ 3 * 4 }5` + 6; +>k3 : string +>1 + `${ 3 * 4 }5` + 6 : string +>1 + `${ 3 * 4 }5` : string +>3 * 4 : number + +var l3 = 1 + `2${ 3 * 4 }5` + 6; +>l3 : string +>1 + `2${ 3 * 4 }5` + 6 : string +>1 + `2${ 3 * 4 }5` : string +>3 * 4 : number + +var a4 = 1 + `${ 3 & 4 }`; +>a4 : string +>1 + `${ 3 & 4 }` : string +>3 & 4 : number + +var b4 = 1 + `2${ 3 & 4 }`; +>b4 : string +>1 + `2${ 3 & 4 }` : string +>3 & 4 : number + +var c4 = 1 + `${ 3 & 4 }5`; +>c4 : string +>1 + `${ 3 & 4 }5` : string +>3 & 4 : number + +var d4 = 1 + `2${ 3 & 4 }5`; +>d4 : string +>1 + `2${ 3 & 4 }5` : string +>3 & 4 : number + +var e4 = `${ 3 & 4 }` + 6; +>e4 : string +>`${ 3 & 4 }` + 6 : string +>3 & 4 : number + +var f4 = `2${ 3 & 4 }` + 6; +>f4 : string +>`2${ 3 & 4 }` + 6 : string +>3 & 4 : number + +var g4 = `${ 3 & 4 }5` + 6; +>g4 : string +>`${ 3 & 4 }5` + 6 : string +>3 & 4 : number + +var h4 = `2${ 3 & 4 }5` + 6; +>h4 : string +>`2${ 3 & 4 }5` + 6 : string +>3 & 4 : number + +var i4 = 1 + `${ 3 & 4 }` + 6; +>i4 : string +>1 + `${ 3 & 4 }` + 6 : string +>1 + `${ 3 & 4 }` : string +>3 & 4 : number + +var j4 = 1 + `2${ 3 & 4 }` + 6; +>j4 : string +>1 + `2${ 3 & 4 }` + 6 : string +>1 + `2${ 3 & 4 }` : string +>3 & 4 : number + +var k4 = 1 + `${ 3 & 4 }5` + 6; +>k4 : string +>1 + `${ 3 & 4 }5` + 6 : string +>1 + `${ 3 & 4 }5` : string +>3 & 4 : number + +var l4 = 1 + `2${ 3 & 4 }5` + 6; +>l4 : string +>1 + `2${ 3 & 4 }5` + 6 : string +>1 + `2${ 3 & 4 }5` : string +>3 & 4 : number + diff --git a/tests/baselines/reference/templateStringBinaryOperationsES6Invalid.errors.txt b/tests/baselines/reference/templateStringBinaryOperationsES6Invalid.errors.txt new file mode 100644 index 00000000000..261eb6bd558 --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperationsES6Invalid.errors.txt @@ -0,0 +1,399 @@ +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(1,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(2,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(4,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(5,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(6,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(7,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(8,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(10,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(11,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(12,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(13,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(14,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(15,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(16,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(17,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(19,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(20,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(21,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(22,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(23,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(24,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(25,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(26,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(28,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(29,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(30,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(31,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(32,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(33,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(34,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(35,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(37,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(38,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(39,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(40,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(41,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(42,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(43,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(44,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(46,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(47,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(48,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(49,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(50,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(51,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(52,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(53,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(55,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(56,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(57,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(58,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(59,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(60,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(61,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(62,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(64,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(65,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(66,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(67,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(68,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(69,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(70,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(71,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(73,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(74,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(75,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(76,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(77,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(78,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(79,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(80,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(82,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(83,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(84,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(85,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(86,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(87,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(88,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(89,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(91,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(92,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(93,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(94,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(95,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(96,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(97,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(98,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(100,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(101,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(102,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(103,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(104,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(105,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(106,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(107,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + +==== tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts (96 errors) ==== + var a = 1 - `${ 3 }`; + ~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b = 1 - `2${ 3 }`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c = 1 - `${ 3 }4`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d = 1 - `2${ 3 }4`; + ~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e = `${ 3 }` - 5; + ~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f = `2${ 3 }` - 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g = `${ 3 }4` - 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h = `2${ 3 }4` - 5; + ~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a2 = 1 * `${ 3 }`; + ~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b2 = 1 * `2${ 3 }`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c2 = 1 * `${ 3 }4`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d2 = 1 * `2${ 3 }4`; + ~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e2 = `${ 3 }` * 5; + ~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f2 = `2${ 3 }` * 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g2 = `${ 3 }4` * 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h2 = `2${ 3 }4` * 5; + ~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a3 = 1 & `${ 3 }`; + ~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b3 = 1 & `2${ 3 }`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c3 = 1 & `${ 3 }4`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d3 = 1 & `2${ 3 }4`; + ~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e3 = `${ 3 }` & 5; + ~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f3 = `2${ 3 }` & 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g3 = `${ 3 }4` & 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h3 = `2${ 3 }4` & 5; + ~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a4 = 1 - `${ 3 - 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b4 = 1 - `2${ 3 - 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c4 = 1 - `${ 3 - 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d4 = 1 - `2${ 3 - 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e4 = `${ 3 - 4 }` - 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f4 = `2${ 3 - 4 }` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g4 = `${ 3 - 4 }5` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h4 = `2${ 3 - 4 }5` - 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a5 = 1 - `${ 3 * 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b5 = 1 - `2${ 3 * 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c5 = 1 - `${ 3 * 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d5 = 1 - `2${ 3 * 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e5 = `${ 3 * 4 }` - 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f5 = `2${ 3 * 4 }` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g5 = `${ 3 * 4 }5` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h5 = `2${ 3 * 4 }5` - 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a6 = 1 - `${ 3 & 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b6 = 1 - `2${ 3 & 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c6 = 1 - `${ 3 & 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d6 = 1 - `2${ 3 & 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e6 = `${ 3 & 4 }` - 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f6 = `2${ 3 & 4 }` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g6 = `${ 3 & 4 }5` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h6 = `2${ 3 & 4 }5` - 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a7 = 1 * `${ 3 - 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b7 = 1 * `2${ 3 - 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c7 = 1 * `${ 3 - 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d7 = 1 * `2${ 3 - 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e7 = `${ 3 - 4 }` * 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f7 = `2${ 3 - 4 }` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g7 = `${ 3 - 4 }5` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h7 = `2${ 3 - 4 }5` * 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a8 = 1 * `${ 3 * 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b8 = 1 * `2${ 3 * 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c8 = 1 * `${ 3 * 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d8 = 1 * `2${ 3 * 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e8 = `${ 3 * 4 }` * 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f8 = `2${ 3 * 4 }` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g8 = `${ 3 * 4 }5` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h8 = `2${ 3 * 4 }5` * 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a9 = 1 * `${ 3 & 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b9 = 1 * `2${ 3 & 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c9 = 1 * `${ 3 & 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d9 = 1 * `2${ 3 & 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e9 = `${ 3 & 4 }` * 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f9 = `2${ 3 & 4 }` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g9 = `${ 3 & 4 }5` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h9 = `2${ 3 & 4 }5` * 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var aa = 1 & `${ 3 - 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ba = 1 & `2${ 3 - 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ca = 1 & `${ 3 - 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var da = 1 & `2${ 3 - 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ea = `${ 3 - 4 }` & 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var fa = `2${ 3 - 4 }` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ga = `${ 3 - 4 }5` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ha = `2${ 3 - 4 }5` & 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var ab = 1 & `${ 3 * 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var bb = 1 & `2${ 3 * 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var cb = 1 & `${ 3 * 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var db = 1 & `2${ 3 * 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var eb = `${ 3 * 4 }` & 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var fb = `2${ 3 * 4 }` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var gb = `${ 3 * 4 }5` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var hb = `2${ 3 * 4 }5` & 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var ac = 1 & `${ 3 & 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var bc = 1 & `2${ 3 & 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var cc = 1 & `${ 3 & 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var dc = 1 & `2${ 3 & 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ec = `${ 3 & 4 }` & 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var fc = `2${ 3 & 4 }` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var gc = `${ 3 & 4 }5` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var hc = `2${ 3 & 4 }5` & 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + \ No newline at end of file diff --git a/tests/baselines/reference/templateStringBinaryOperationsES6Invalid.js b/tests/baselines/reference/templateStringBinaryOperationsES6Invalid.js new file mode 100644 index 00000000000..4408fd1ffe9 --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperationsES6Invalid.js @@ -0,0 +1,207 @@ +//// [templateStringBinaryOperationsES6Invalid.ts] +var a = 1 - `${ 3 }`; +var b = 1 - `2${ 3 }`; +var c = 1 - `${ 3 }4`; +var d = 1 - `2${ 3 }4`; +var e = `${ 3 }` - 5; +var f = `2${ 3 }` - 5; +var g = `${ 3 }4` - 5; +var h = `2${ 3 }4` - 5; + +var a2 = 1 * `${ 3 }`; +var b2 = 1 * `2${ 3 }`; +var c2 = 1 * `${ 3 }4`; +var d2 = 1 * `2${ 3 }4`; +var e2 = `${ 3 }` * 5; +var f2 = `2${ 3 }` * 5; +var g2 = `${ 3 }4` * 5; +var h2 = `2${ 3 }4` * 5; + +var a3 = 1 & `${ 3 }`; +var b3 = 1 & `2${ 3 }`; +var c3 = 1 & `${ 3 }4`; +var d3 = 1 & `2${ 3 }4`; +var e3 = `${ 3 }` & 5; +var f3 = `2${ 3 }` & 5; +var g3 = `${ 3 }4` & 5; +var h3 = `2${ 3 }4` & 5; + +var a4 = 1 - `${ 3 - 4 }`; +var b4 = 1 - `2${ 3 - 4 }`; +var c4 = 1 - `${ 3 - 4 }5`; +var d4 = 1 - `2${ 3 - 4 }5`; +var e4 = `${ 3 - 4 }` - 6; +var f4 = `2${ 3 - 4 }` - 6; +var g4 = `${ 3 - 4 }5` - 6; +var h4 = `2${ 3 - 4 }5` - 6; + +var a5 = 1 - `${ 3 * 4 }`; +var b5 = 1 - `2${ 3 * 4 }`; +var c5 = 1 - `${ 3 * 4 }5`; +var d5 = 1 - `2${ 3 * 4 }5`; +var e5 = `${ 3 * 4 }` - 6; +var f5 = `2${ 3 * 4 }` - 6; +var g5 = `${ 3 * 4 }5` - 6; +var h5 = `2${ 3 * 4 }5` - 6; + +var a6 = 1 - `${ 3 & 4 }`; +var b6 = 1 - `2${ 3 & 4 }`; +var c6 = 1 - `${ 3 & 4 }5`; +var d6 = 1 - `2${ 3 & 4 }5`; +var e6 = `${ 3 & 4 }` - 6; +var f6 = `2${ 3 & 4 }` - 6; +var g6 = `${ 3 & 4 }5` - 6; +var h6 = `2${ 3 & 4 }5` - 6; + +var a7 = 1 * `${ 3 - 4 }`; +var b7 = 1 * `2${ 3 - 4 }`; +var c7 = 1 * `${ 3 - 4 }5`; +var d7 = 1 * `2${ 3 - 4 }5`; +var e7 = `${ 3 - 4 }` * 6; +var f7 = `2${ 3 - 4 }` * 6; +var g7 = `${ 3 - 4 }5` * 6; +var h7 = `2${ 3 - 4 }5` * 6; + +var a8 = 1 * `${ 3 * 4 }`; +var b8 = 1 * `2${ 3 * 4 }`; +var c8 = 1 * `${ 3 * 4 }5`; +var d8 = 1 * `2${ 3 * 4 }5`; +var e8 = `${ 3 * 4 }` * 6; +var f8 = `2${ 3 * 4 }` * 6; +var g8 = `${ 3 * 4 }5` * 6; +var h8 = `2${ 3 * 4 }5` * 6; + +var a9 = 1 * `${ 3 & 4 }`; +var b9 = 1 * `2${ 3 & 4 }`; +var c9 = 1 * `${ 3 & 4 }5`; +var d9 = 1 * `2${ 3 & 4 }5`; +var e9 = `${ 3 & 4 }` * 6; +var f9 = `2${ 3 & 4 }` * 6; +var g9 = `${ 3 & 4 }5` * 6; +var h9 = `2${ 3 & 4 }5` * 6; + +var aa = 1 & `${ 3 - 4 }`; +var ba = 1 & `2${ 3 - 4 }`; +var ca = 1 & `${ 3 - 4 }5`; +var da = 1 & `2${ 3 - 4 }5`; +var ea = `${ 3 - 4 }` & 6; +var fa = `2${ 3 - 4 }` & 6; +var ga = `${ 3 - 4 }5` & 6; +var ha = `2${ 3 - 4 }5` & 6; + +var ab = 1 & `${ 3 * 4 }`; +var bb = 1 & `2${ 3 * 4 }`; +var cb = 1 & `${ 3 * 4 }5`; +var db = 1 & `2${ 3 * 4 }5`; +var eb = `${ 3 * 4 }` & 6; +var fb = `2${ 3 * 4 }` & 6; +var gb = `${ 3 * 4 }5` & 6; +var hb = `2${ 3 * 4 }5` & 6; + +var ac = 1 & `${ 3 & 4 }`; +var bc = 1 & `2${ 3 & 4 }`; +var cc = 1 & `${ 3 & 4 }5`; +var dc = 1 & `2${ 3 & 4 }5`; +var ec = `${ 3 & 4 }` & 6; +var fc = `2${ 3 & 4 }` & 6; +var gc = `${ 3 & 4 }5` & 6; +var hc = `2${ 3 & 4 }5` & 6; + + +//// [templateStringBinaryOperationsES6Invalid.js] +var a = 1 - `${3}`; +var b = 1 - `2${3}`; +var c = 1 - `${3}4`; +var d = 1 - `2${3}4`; +var e = `${3}` - 5; +var f = `2${3}` - 5; +var g = `${3}4` - 5; +var h = `2${3}4` - 5; +var a2 = 1 * `${3}`; +var b2 = 1 * `2${3}`; +var c2 = 1 * `${3}4`; +var d2 = 1 * `2${3}4`; +var e2 = `${3}` * 5; +var f2 = `2${3}` * 5; +var g2 = `${3}4` * 5; +var h2 = `2${3}4` * 5; +var a3 = 1 & `${3}`; +var b3 = 1 & `2${3}`; +var c3 = 1 & `${3}4`; +var d3 = 1 & `2${3}4`; +var e3 = `${3}` & 5; +var f3 = `2${3}` & 5; +var g3 = `${3}4` & 5; +var h3 = `2${3}4` & 5; +var a4 = 1 - `${3 - 4}`; +var b4 = 1 - `2${3 - 4}`; +var c4 = 1 - `${3 - 4}5`; +var d4 = 1 - `2${3 - 4}5`; +var e4 = `${3 - 4}` - 6; +var f4 = `2${3 - 4}` - 6; +var g4 = `${3 - 4}5` - 6; +var h4 = `2${3 - 4}5` - 6; +var a5 = 1 - `${3 * 4}`; +var b5 = 1 - `2${3 * 4}`; +var c5 = 1 - `${3 * 4}5`; +var d5 = 1 - `2${3 * 4}5`; +var e5 = `${3 * 4}` - 6; +var f5 = `2${3 * 4}` - 6; +var g5 = `${3 * 4}5` - 6; +var h5 = `2${3 * 4}5` - 6; +var a6 = 1 - `${3 & 4}`; +var b6 = 1 - `2${3 & 4}`; +var c6 = 1 - `${3 & 4}5`; +var d6 = 1 - `2${3 & 4}5`; +var e6 = `${3 & 4}` - 6; +var f6 = `2${3 & 4}` - 6; +var g6 = `${3 & 4}5` - 6; +var h6 = `2${3 & 4}5` - 6; +var a7 = 1 * `${3 - 4}`; +var b7 = 1 * `2${3 - 4}`; +var c7 = 1 * `${3 - 4}5`; +var d7 = 1 * `2${3 - 4}5`; +var e7 = `${3 - 4}` * 6; +var f7 = `2${3 - 4}` * 6; +var g7 = `${3 - 4}5` * 6; +var h7 = `2${3 - 4}5` * 6; +var a8 = 1 * `${3 * 4}`; +var b8 = 1 * `2${3 * 4}`; +var c8 = 1 * `${3 * 4}5`; +var d8 = 1 * `2${3 * 4}5`; +var e8 = `${3 * 4}` * 6; +var f8 = `2${3 * 4}` * 6; +var g8 = `${3 * 4}5` * 6; +var h8 = `2${3 * 4}5` * 6; +var a9 = 1 * `${3 & 4}`; +var b9 = 1 * `2${3 & 4}`; +var c9 = 1 * `${3 & 4}5`; +var d9 = 1 * `2${3 & 4}5`; +var e9 = `${3 & 4}` * 6; +var f9 = `2${3 & 4}` * 6; +var g9 = `${3 & 4}5` * 6; +var h9 = `2${3 & 4}5` * 6; +var aa = 1 & `${3 - 4}`; +var ba = 1 & `2${3 - 4}`; +var ca = 1 & `${3 - 4}5`; +var da = 1 & `2${3 - 4}5`; +var ea = `${3 - 4}` & 6; +var fa = `2${3 - 4}` & 6; +var ga = `${3 - 4}5` & 6; +var ha = `2${3 - 4}5` & 6; +var ab = 1 & `${3 * 4}`; +var bb = 1 & `2${3 * 4}`; +var cb = 1 & `${3 * 4}5`; +var db = 1 & `2${3 * 4}5`; +var eb = `${3 * 4}` & 6; +var fb = `2${3 * 4}` & 6; +var gb = `${3 * 4}5` & 6; +var hb = `2${3 * 4}5` & 6; +var ac = 1 & `${3 & 4}`; +var bc = 1 & `2${3 & 4}`; +var cc = 1 & `${3 & 4}5`; +var dc = 1 & `2${3 & 4}5`; +var ec = `${3 & 4}` & 6; +var fc = `2${3 & 4}` & 6; +var gc = `${3 & 4}5` & 6; +var hc = `2${3 & 4}5` & 6; diff --git a/tests/baselines/reference/templateStringBinaryOperationsInvalid.errors.txt b/tests/baselines/reference/templateStringBinaryOperationsInvalid.errors.txt new file mode 100644 index 00000000000..8a6a9719a57 --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperationsInvalid.errors.txt @@ -0,0 +1,399 @@ +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(1,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(2,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(4,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(5,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(6,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(7,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(8,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(10,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(11,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(12,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(13,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(14,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(15,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(16,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(17,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(19,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(20,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(21,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(22,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(23,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(24,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(25,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(26,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(28,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(29,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(30,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(31,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(32,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(33,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(34,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(35,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(37,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(38,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(39,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(40,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(41,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(42,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(43,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(44,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(46,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(47,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(48,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(49,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(50,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(51,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(52,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(53,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(55,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(56,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(57,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(58,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(59,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(60,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(61,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(62,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(64,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(65,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(66,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(67,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(68,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(69,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(70,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(71,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(73,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(74,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(75,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(76,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(77,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(78,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(79,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(80,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(82,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(83,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(84,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(85,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(86,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(87,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(88,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(89,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(91,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(92,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(93,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(94,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(95,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(96,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(97,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(98,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(100,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(101,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(102,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(103,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(104,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(105,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(106,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(107,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + +==== tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts (96 errors) ==== + var a = 1 - `${ 3 }`; + ~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b = 1 - `2${ 3 }`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c = 1 - `${ 3 }4`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d = 1 - `2${ 3 }4`; + ~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e = `${ 3 }` - 5; + ~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f = `2${ 3 }` - 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g = `${ 3 }4` - 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h = `2${ 3 }4` - 5; + ~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a2 = 1 * `${ 3 }`; + ~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b2 = 1 * `2${ 3 }`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c2 = 1 * `${ 3 }4`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d2 = 1 * `2${ 3 }4`; + ~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e2 = `${ 3 }` * 5; + ~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f2 = `2${ 3 }` * 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g2 = `${ 3 }4` * 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h2 = `2${ 3 }4` * 5; + ~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a3 = 1 & `${ 3 }`; + ~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b3 = 1 & `2${ 3 }`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c3 = 1 & `${ 3 }4`; + ~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d3 = 1 & `2${ 3 }4`; + ~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e3 = `${ 3 }` & 5; + ~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f3 = `2${ 3 }` & 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g3 = `${ 3 }4` & 5; + ~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h3 = `2${ 3 }4` & 5; + ~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a4 = 1 - `${ 3 - 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b4 = 1 - `2${ 3 - 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c4 = 1 - `${ 3 - 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d4 = 1 - `2${ 3 - 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e4 = `${ 3 - 4 }` - 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f4 = `2${ 3 - 4 }` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g4 = `${ 3 - 4 }5` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h4 = `2${ 3 - 4 }5` - 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a5 = 1 - `${ 3 * 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b5 = 1 - `2${ 3 * 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c5 = 1 - `${ 3 * 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d5 = 1 - `2${ 3 * 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e5 = `${ 3 * 4 }` - 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f5 = `2${ 3 * 4 }` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g5 = `${ 3 * 4 }5` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h5 = `2${ 3 * 4 }5` - 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a6 = 1 - `${ 3 & 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b6 = 1 - `2${ 3 & 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c6 = 1 - `${ 3 & 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d6 = 1 - `2${ 3 & 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e6 = `${ 3 & 4 }` - 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f6 = `2${ 3 & 4 }` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g6 = `${ 3 & 4 }5` - 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h6 = `2${ 3 & 4 }5` - 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a7 = 1 * `${ 3 - 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b7 = 1 * `2${ 3 - 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c7 = 1 * `${ 3 - 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d7 = 1 * `2${ 3 - 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e7 = `${ 3 - 4 }` * 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f7 = `2${ 3 - 4 }` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g7 = `${ 3 - 4 }5` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h7 = `2${ 3 - 4 }5` * 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a8 = 1 * `${ 3 * 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b8 = 1 * `2${ 3 * 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c8 = 1 * `${ 3 * 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d8 = 1 * `2${ 3 * 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e8 = `${ 3 * 4 }` * 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f8 = `2${ 3 * 4 }` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g8 = `${ 3 * 4 }5` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h8 = `2${ 3 * 4 }5` * 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var a9 = 1 * `${ 3 & 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var b9 = 1 * `2${ 3 & 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var c9 = 1 * `${ 3 & 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var d9 = 1 * `2${ 3 & 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var e9 = `${ 3 & 4 }` * 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var f9 = `2${ 3 & 4 }` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var g9 = `${ 3 & 4 }5` * 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var h9 = `2${ 3 & 4 }5` * 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var aa = 1 & `${ 3 - 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ba = 1 & `2${ 3 - 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ca = 1 & `${ 3 - 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var da = 1 & `2${ 3 - 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ea = `${ 3 - 4 }` & 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var fa = `2${ 3 - 4 }` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ga = `${ 3 - 4 }5` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ha = `2${ 3 - 4 }5` & 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var ab = 1 & `${ 3 * 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var bb = 1 & `2${ 3 * 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var cb = 1 & `${ 3 * 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var db = 1 & `2${ 3 * 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var eb = `${ 3 * 4 }` & 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var fb = `2${ 3 * 4 }` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var gb = `${ 3 * 4 }5` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var hb = `2${ 3 * 4 }5` & 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + + var ac = 1 & `${ 3 & 4 }`; + ~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var bc = 1 & `2${ 3 & 4 }`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var cc = 1 & `${ 3 & 4 }5`; + ~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var dc = 1 & `2${ 3 & 4 }5`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var ec = `${ 3 & 4 }` & 6; + ~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var fc = `2${ 3 & 4 }` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var gc = `${ 3 & 4 }5` & 6; + ~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + var hc = `2${ 3 & 4 }5` & 6; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + \ No newline at end of file diff --git a/tests/baselines/reference/templateStringBinaryOperationsInvalid.js b/tests/baselines/reference/templateStringBinaryOperationsInvalid.js new file mode 100644 index 00000000000..1edf1d3a563 --- /dev/null +++ b/tests/baselines/reference/templateStringBinaryOperationsInvalid.js @@ -0,0 +1,207 @@ +//// [templateStringBinaryOperationsInvalid.ts] +var a = 1 - `${ 3 }`; +var b = 1 - `2${ 3 }`; +var c = 1 - `${ 3 }4`; +var d = 1 - `2${ 3 }4`; +var e = `${ 3 }` - 5; +var f = `2${ 3 }` - 5; +var g = `${ 3 }4` - 5; +var h = `2${ 3 }4` - 5; + +var a2 = 1 * `${ 3 }`; +var b2 = 1 * `2${ 3 }`; +var c2 = 1 * `${ 3 }4`; +var d2 = 1 * `2${ 3 }4`; +var e2 = `${ 3 }` * 5; +var f2 = `2${ 3 }` * 5; +var g2 = `${ 3 }4` * 5; +var h2 = `2${ 3 }4` * 5; + +var a3 = 1 & `${ 3 }`; +var b3 = 1 & `2${ 3 }`; +var c3 = 1 & `${ 3 }4`; +var d3 = 1 & `2${ 3 }4`; +var e3 = `${ 3 }` & 5; +var f3 = `2${ 3 }` & 5; +var g3 = `${ 3 }4` & 5; +var h3 = `2${ 3 }4` & 5; + +var a4 = 1 - `${ 3 - 4 }`; +var b4 = 1 - `2${ 3 - 4 }`; +var c4 = 1 - `${ 3 - 4 }5`; +var d4 = 1 - `2${ 3 - 4 }5`; +var e4 = `${ 3 - 4 }` - 6; +var f4 = `2${ 3 - 4 }` - 6; +var g4 = `${ 3 - 4 }5` - 6; +var h4 = `2${ 3 - 4 }5` - 6; + +var a5 = 1 - `${ 3 * 4 }`; +var b5 = 1 - `2${ 3 * 4 }`; +var c5 = 1 - `${ 3 * 4 }5`; +var d5 = 1 - `2${ 3 * 4 }5`; +var e5 = `${ 3 * 4 }` - 6; +var f5 = `2${ 3 * 4 }` - 6; +var g5 = `${ 3 * 4 }5` - 6; +var h5 = `2${ 3 * 4 }5` - 6; + +var a6 = 1 - `${ 3 & 4 }`; +var b6 = 1 - `2${ 3 & 4 }`; +var c6 = 1 - `${ 3 & 4 }5`; +var d6 = 1 - `2${ 3 & 4 }5`; +var e6 = `${ 3 & 4 }` - 6; +var f6 = `2${ 3 & 4 }` - 6; +var g6 = `${ 3 & 4 }5` - 6; +var h6 = `2${ 3 & 4 }5` - 6; + +var a7 = 1 * `${ 3 - 4 }`; +var b7 = 1 * `2${ 3 - 4 }`; +var c7 = 1 * `${ 3 - 4 }5`; +var d7 = 1 * `2${ 3 - 4 }5`; +var e7 = `${ 3 - 4 }` * 6; +var f7 = `2${ 3 - 4 }` * 6; +var g7 = `${ 3 - 4 }5` * 6; +var h7 = `2${ 3 - 4 }5` * 6; + +var a8 = 1 * `${ 3 * 4 }`; +var b8 = 1 * `2${ 3 * 4 }`; +var c8 = 1 * `${ 3 * 4 }5`; +var d8 = 1 * `2${ 3 * 4 }5`; +var e8 = `${ 3 * 4 }` * 6; +var f8 = `2${ 3 * 4 }` * 6; +var g8 = `${ 3 * 4 }5` * 6; +var h8 = `2${ 3 * 4 }5` * 6; + +var a9 = 1 * `${ 3 & 4 }`; +var b9 = 1 * `2${ 3 & 4 }`; +var c9 = 1 * `${ 3 & 4 }5`; +var d9 = 1 * `2${ 3 & 4 }5`; +var e9 = `${ 3 & 4 }` * 6; +var f9 = `2${ 3 & 4 }` * 6; +var g9 = `${ 3 & 4 }5` * 6; +var h9 = `2${ 3 & 4 }5` * 6; + +var aa = 1 & `${ 3 - 4 }`; +var ba = 1 & `2${ 3 - 4 }`; +var ca = 1 & `${ 3 - 4 }5`; +var da = 1 & `2${ 3 - 4 }5`; +var ea = `${ 3 - 4 }` & 6; +var fa = `2${ 3 - 4 }` & 6; +var ga = `${ 3 - 4 }5` & 6; +var ha = `2${ 3 - 4 }5` & 6; + +var ab = 1 & `${ 3 * 4 }`; +var bb = 1 & `2${ 3 * 4 }`; +var cb = 1 & `${ 3 * 4 }5`; +var db = 1 & `2${ 3 * 4 }5`; +var eb = `${ 3 * 4 }` & 6; +var fb = `2${ 3 * 4 }` & 6; +var gb = `${ 3 * 4 }5` & 6; +var hb = `2${ 3 * 4 }5` & 6; + +var ac = 1 & `${ 3 & 4 }`; +var bc = 1 & `2${ 3 & 4 }`; +var cc = 1 & `${ 3 & 4 }5`; +var dc = 1 & `2${ 3 & 4 }5`; +var ec = `${ 3 & 4 }` & 6; +var fc = `2${ 3 & 4 }` & 6; +var gc = `${ 3 & 4 }5` & 6; +var hc = `2${ 3 & 4 }5` & 6; + + +//// [templateStringBinaryOperationsInvalid.js] +var a = 1 - ("" + 3); +var b = 1 - ("2" + 3); +var c = 1 - ("" + 3 + "4"); +var d = 1 - ("2" + 3 + "4"); +var e = ("" + 3) - 5; +var f = ("2" + 3) - 5; +var g = ("" + 3 + "4") - 5; +var h = ("2" + 3 + "4") - 5; +var a2 = 1 * ("" + 3); +var b2 = 1 * ("2" + 3); +var c2 = 1 * ("" + 3 + "4"); +var d2 = 1 * ("2" + 3 + "4"); +var e2 = ("" + 3) * 5; +var f2 = ("2" + 3) * 5; +var g2 = ("" + 3 + "4") * 5; +var h2 = ("2" + 3 + "4") * 5; +var a3 = 1 & "" + 3; +var b3 = 1 & "2" + 3; +var c3 = 1 & "" + 3 + "4"; +var d3 = 1 & "2" + 3 + "4"; +var e3 = "" + 3 & 5; +var f3 = "2" + 3 & 5; +var g3 = "" + 3 + "4" & 5; +var h3 = "2" + 3 + "4" & 5; +var a4 = 1 - ("" + (3 - 4)); +var b4 = 1 - ("2" + (3 - 4)); +var c4 = 1 - ("" + (3 - 4) + "5"); +var d4 = 1 - ("2" + (3 - 4) + "5"); +var e4 = ("" + (3 - 4)) - 6; +var f4 = ("2" + (3 - 4)) - 6; +var g4 = ("" + (3 - 4) + "5") - 6; +var h4 = ("2" + (3 - 4) + "5") - 6; +var a5 = 1 - ("" + 3 * 4); +var b5 = 1 - ("2" + 3 * 4); +var c5 = 1 - ("" + 3 * 4 + "5"); +var d5 = 1 - ("2" + 3 * 4 + "5"); +var e5 = ("" + 3 * 4) - 6; +var f5 = ("2" + 3 * 4) - 6; +var g5 = ("" + 3 * 4 + "5") - 6; +var h5 = ("2" + 3 * 4 + "5") - 6; +var a6 = 1 - ("" + (3 & 4)); +var b6 = 1 - ("2" + (3 & 4)); +var c6 = 1 - ("" + (3 & 4) + "5"); +var d6 = 1 - ("2" + (3 & 4) + "5"); +var e6 = ("" + (3 & 4)) - 6; +var f6 = ("2" + (3 & 4)) - 6; +var g6 = ("" + (3 & 4) + "5") - 6; +var h6 = ("2" + (3 & 4) + "5") - 6; +var a7 = 1 * ("" + (3 - 4)); +var b7 = 1 * ("2" + (3 - 4)); +var c7 = 1 * ("" + (3 - 4) + "5"); +var d7 = 1 * ("2" + (3 - 4) + "5"); +var e7 = ("" + (3 - 4)) * 6; +var f7 = ("2" + (3 - 4)) * 6; +var g7 = ("" + (3 - 4) + "5") * 6; +var h7 = ("2" + (3 - 4) + "5") * 6; +var a8 = 1 * ("" + 3 * 4); +var b8 = 1 * ("2" + 3 * 4); +var c8 = 1 * ("" + 3 * 4 + "5"); +var d8 = 1 * ("2" + 3 * 4 + "5"); +var e8 = ("" + 3 * 4) * 6; +var f8 = ("2" + 3 * 4) * 6; +var g8 = ("" + 3 * 4 + "5") * 6; +var h8 = ("2" + 3 * 4 + "5") * 6; +var a9 = 1 * ("" + (3 & 4)); +var b9 = 1 * ("2" + (3 & 4)); +var c9 = 1 * ("" + (3 & 4) + "5"); +var d9 = 1 * ("2" + (3 & 4) + "5"); +var e9 = ("" + (3 & 4)) * 6; +var f9 = ("2" + (3 & 4)) * 6; +var g9 = ("" + (3 & 4) + "5") * 6; +var h9 = ("2" + (3 & 4) + "5") * 6; +var aa = 1 & "" + (3 - 4); +var ba = 1 & "2" + (3 - 4); +var ca = 1 & "" + (3 - 4) + "5"; +var da = 1 & "2" + (3 - 4) + "5"; +var ea = "" + (3 - 4) & 6; +var fa = "2" + (3 - 4) & 6; +var ga = "" + (3 - 4) + "5" & 6; +var ha = "2" + (3 - 4) + "5" & 6; +var ab = 1 & "" + 3 * 4; +var bb = 1 & "2" + 3 * 4; +var cb = 1 & "" + 3 * 4 + "5"; +var db = 1 & "2" + 3 * 4 + "5"; +var eb = "" + 3 * 4 & 6; +var fb = "2" + 3 * 4 & 6; +var gb = "" + 3 * 4 + "5" & 6; +var hb = "2" + 3 * 4 + "5" & 6; +var ac = 1 & "" + (3 & 4); +var bc = 1 & "2" + (3 & 4); +var cc = 1 & "" + (3 & 4) + "5"; +var dc = 1 & "2" + (3 & 4) + "5"; +var ec = "" + (3 & 4) & 6; +var fc = "2" + (3 & 4) & 6; +var gc = "" + (3 & 4) + "5" & 6; +var hc = "2" + (3 & 4) + "5" & 6; diff --git a/tests/baselines/reference/templateStringInBinaryAddition.js b/tests/baselines/reference/templateStringInBinaryAddition.js deleted file mode 100644 index 0e1f728005c..00000000000 --- a/tests/baselines/reference/templateStringInBinaryAddition.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [templateStringInBinaryAddition.ts] -var x = 10 + `abc${ 10 }def`; - -//// [templateStringInBinaryAddition.js] -var x = 10 + ("abc" + 10 + "def"); diff --git a/tests/baselines/reference/templateStringInBinaryAddition.types b/tests/baselines/reference/templateStringInBinaryAddition.types deleted file mode 100644 index f722ff696f4..00000000000 --- a/tests/baselines/reference/templateStringInBinaryAddition.types +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts === -var x = 10 + `abc${ 10 }def`; ->x : string ->10 + `abc${ 10 }def` : string - diff --git a/tests/baselines/reference/templateStringInBinaryAdditionES6.js b/tests/baselines/reference/templateStringInBinaryAdditionES6.js deleted file mode 100644 index 7a40d4cc54f..00000000000 --- a/tests/baselines/reference/templateStringInBinaryAdditionES6.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [templateStringInBinaryAdditionES6.ts] -var x = 10 + `abc${ 10 }def`; - -//// [templateStringInBinaryAdditionES6.js] -var x = 10 + `abc${10}def`; diff --git a/tests/baselines/reference/templateStringInBinaryAdditionES6.types b/tests/baselines/reference/templateStringInBinaryAdditionES6.types deleted file mode 100644 index b421d7dc70e..00000000000 --- a/tests/baselines/reference/templateStringInBinaryAdditionES6.types +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts === -var x = 10 + `abc${ 10 }def`; ->x : string ->10 + `abc${ 10 }def` : string - diff --git a/tests/cases/conformance/es6/templates/templateStringBinaryOperations.ts b/tests/cases/conformance/es6/templates/templateStringBinaryOperations.ts new file mode 100644 index 00000000000..28313595f99 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringBinaryOperations.ts @@ -0,0 +1,51 @@ +var a = 1 + `${ 3 }`; +var b = 1 + `2${ 3 }`; +var c = 1 + `${ 3 }4`; +var d = 1 + `2${ 3 }4`; +var e = `${ 3 }` + 5; +var f = `2${ 3 }` + 5; +var g = `${ 3 }4` + 5; +var h = `2${ 3 }4` + 5; +var i = 1 + `${ 3 }` + 5; +var j = 1 + `2${ 3 }` + 5; +var k = 1 + `${ 3 }4` + 5; +var l = 1 + `2${ 3 }4` + 5; + +var a2 = 1 + `${ 3 - 4 }`; +var b2 = 1 + `2${ 3 - 4 }`; +var c2 = 1 + `${ 3 - 4 }5`; +var d2 = 1 + `2${ 3 - 4 }5`; +var e2 = `${ 3 - 4 }` + 6; +var f2 = `2${ 3 - 4 }` + 6; +var g2 = `${ 3 - 4 }5` + 6; +var h2 = `2${ 3 - 4 }5` + 6; +var i2 = 1 + `${ 3 - 4 }` + 6; +var j2 = 1 + `2${ 3 - 4 }` + 6; +var k2 = 1 + `${ 3 - 4 }5` + 6; +var l2 = 1 + `2${ 3 - 4 }5` + 6; + +var a3 = 1 + `${ 3 * 4 }`; +var b3 = 1 + `2${ 3 * 4 }`; +var c3 = 1 + `${ 3 * 4 }5`; +var d3 = 1 + `2${ 3 * 4 }5`; +var e3 = `${ 3 * 4 }` + 6; +var f3 = `2${ 3 * 4 }` + 6; +var g3 = `${ 3 * 4 }5` + 6; +var h3 = `2${ 3 * 4 }5` + 6; +var i3 = 1 + `${ 3 * 4 }` + 6; +var j3 = 1 + `2${ 3 * 4 }` + 6; +var k3 = 1 + `${ 3 * 4 }5` + 6; +var l3 = 1 + `2${ 3 * 4 }5` + 6; + +var a4 = 1 + `${ 3 & 4 }`; +var b4 = 1 + `2${ 3 & 4 }`; +var c4 = 1 + `${ 3 & 4 }5`; +var d4 = 1 + `2${ 3 & 4 }5`; +var e4 = `${ 3 & 4 }` + 6; +var f4 = `2${ 3 & 4 }` + 6; +var g4 = `${ 3 & 4 }5` + 6; +var h4 = `2${ 3 & 4 }5` + 6; +var i4 = 1 + `${ 3 & 4 }` + 6; +var j4 = 1 + `2${ 3 & 4 }` + 6; +var k4 = 1 + `${ 3 & 4 }5` + 6; +var l4 = 1 + `2${ 3 & 4 }5` + 6; diff --git a/tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6.ts b/tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6.ts new file mode 100644 index 00000000000..d734c9b4cb9 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6.ts @@ -0,0 +1,52 @@ +// @target: ES6 +var a = 1 + `${ 3 }`; +var b = 1 + `2${ 3 }`; +var c = 1 + `${ 3 }4`; +var d = 1 + `2${ 3 }4`; +var e = `${ 3 }` + 5; +var f = `2${ 3 }` + 5; +var g = `${ 3 }4` + 5; +var h = `2${ 3 }4` + 5; +var i = 1 + `${ 3 }` + 5; +var j = 1 + `2${ 3 }` + 5; +var k = 1 + `${ 3 }4` + 5; +var l = 1 + `2${ 3 }4` + 5; + +var a2 = 1 + `${ 3 - 4 }`; +var b2 = 1 + `2${ 3 - 4 }`; +var c2 = 1 + `${ 3 - 4 }5`; +var d2 = 1 + `2${ 3 - 4 }5`; +var e2 = `${ 3 - 4 }` + 6; +var f2 = `2${ 3 - 4 }` + 6; +var g2 = `${ 3 - 4 }5` + 6; +var h2 = `2${ 3 - 4 }5` + 6; +var i2 = 1 + `${ 3 - 4 }` + 6; +var j2 = 1 + `2${ 3 - 4 }` + 6; +var k2 = 1 + `${ 3 - 4 }5` + 6; +var l2 = 1 + `2${ 3 - 4 }5` + 6; + +var a3 = 1 + `${ 3 * 4 }`; +var b3 = 1 + `2${ 3 * 4 }`; +var c3 = 1 + `${ 3 * 4 }5`; +var d3 = 1 + `2${ 3 * 4 }5`; +var e3 = `${ 3 * 4 }` + 6; +var f3 = `2${ 3 * 4 }` + 6; +var g3 = `${ 3 * 4 }5` + 6; +var h3 = `2${ 3 * 4 }5` + 6; +var i3 = 1 + `${ 3 * 4 }` + 6; +var j3 = 1 + `2${ 3 * 4 }` + 6; +var k3 = 1 + `${ 3 * 4 }5` + 6; +var l3 = 1 + `2${ 3 * 4 }5` + 6; + +var a4 = 1 + `${ 3 & 4 }`; +var b4 = 1 + `2${ 3 & 4 }`; +var c4 = 1 + `${ 3 & 4 }5`; +var d4 = 1 + `2${ 3 & 4 }5`; +var e4 = `${ 3 & 4 }` + 6; +var f4 = `2${ 3 & 4 }` + 6; +var g4 = `${ 3 & 4 }5` + 6; +var h4 = `2${ 3 & 4 }5` + 6; +var i4 = 1 + `${ 3 & 4 }` + 6; +var j4 = 1 + `2${ 3 & 4 }` + 6; +var k4 = 1 + `${ 3 & 4 }5` + 6; +var l4 = 1 + `2${ 3 & 4 }5` + 6; diff --git a/tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts b/tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts new file mode 100644 index 00000000000..0bfa84e05a5 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts @@ -0,0 +1,108 @@ +// @target: ES6 +var a = 1 - `${ 3 }`; +var b = 1 - `2${ 3 }`; +var c = 1 - `${ 3 }4`; +var d = 1 - `2${ 3 }4`; +var e = `${ 3 }` - 5; +var f = `2${ 3 }` - 5; +var g = `${ 3 }4` - 5; +var h = `2${ 3 }4` - 5; + +var a2 = 1 * `${ 3 }`; +var b2 = 1 * `2${ 3 }`; +var c2 = 1 * `${ 3 }4`; +var d2 = 1 * `2${ 3 }4`; +var e2 = `${ 3 }` * 5; +var f2 = `2${ 3 }` * 5; +var g2 = `${ 3 }4` * 5; +var h2 = `2${ 3 }4` * 5; + +var a3 = 1 & `${ 3 }`; +var b3 = 1 & `2${ 3 }`; +var c3 = 1 & `${ 3 }4`; +var d3 = 1 & `2${ 3 }4`; +var e3 = `${ 3 }` & 5; +var f3 = `2${ 3 }` & 5; +var g3 = `${ 3 }4` & 5; +var h3 = `2${ 3 }4` & 5; + +var a4 = 1 - `${ 3 - 4 }`; +var b4 = 1 - `2${ 3 - 4 }`; +var c4 = 1 - `${ 3 - 4 }5`; +var d4 = 1 - `2${ 3 - 4 }5`; +var e4 = `${ 3 - 4 }` - 6; +var f4 = `2${ 3 - 4 }` - 6; +var g4 = `${ 3 - 4 }5` - 6; +var h4 = `2${ 3 - 4 }5` - 6; + +var a5 = 1 - `${ 3 * 4 }`; +var b5 = 1 - `2${ 3 * 4 }`; +var c5 = 1 - `${ 3 * 4 }5`; +var d5 = 1 - `2${ 3 * 4 }5`; +var e5 = `${ 3 * 4 }` - 6; +var f5 = `2${ 3 * 4 }` - 6; +var g5 = `${ 3 * 4 }5` - 6; +var h5 = `2${ 3 * 4 }5` - 6; + +var a6 = 1 - `${ 3 & 4 }`; +var b6 = 1 - `2${ 3 & 4 }`; +var c6 = 1 - `${ 3 & 4 }5`; +var d6 = 1 - `2${ 3 & 4 }5`; +var e6 = `${ 3 & 4 }` - 6; +var f6 = `2${ 3 & 4 }` - 6; +var g6 = `${ 3 & 4 }5` - 6; +var h6 = `2${ 3 & 4 }5` - 6; + +var a7 = 1 * `${ 3 - 4 }`; +var b7 = 1 * `2${ 3 - 4 }`; +var c7 = 1 * `${ 3 - 4 }5`; +var d7 = 1 * `2${ 3 - 4 }5`; +var e7 = `${ 3 - 4 }` * 6; +var f7 = `2${ 3 - 4 }` * 6; +var g7 = `${ 3 - 4 }5` * 6; +var h7 = `2${ 3 - 4 }5` * 6; + +var a8 = 1 * `${ 3 * 4 }`; +var b8 = 1 * `2${ 3 * 4 }`; +var c8 = 1 * `${ 3 * 4 }5`; +var d8 = 1 * `2${ 3 * 4 }5`; +var e8 = `${ 3 * 4 }` * 6; +var f8 = `2${ 3 * 4 }` * 6; +var g8 = `${ 3 * 4 }5` * 6; +var h8 = `2${ 3 * 4 }5` * 6; + +var a9 = 1 * `${ 3 & 4 }`; +var b9 = 1 * `2${ 3 & 4 }`; +var c9 = 1 * `${ 3 & 4 }5`; +var d9 = 1 * `2${ 3 & 4 }5`; +var e9 = `${ 3 & 4 }` * 6; +var f9 = `2${ 3 & 4 }` * 6; +var g9 = `${ 3 & 4 }5` * 6; +var h9 = `2${ 3 & 4 }5` * 6; + +var aa = 1 & `${ 3 - 4 }`; +var ba = 1 & `2${ 3 - 4 }`; +var ca = 1 & `${ 3 - 4 }5`; +var da = 1 & `2${ 3 - 4 }5`; +var ea = `${ 3 - 4 }` & 6; +var fa = `2${ 3 - 4 }` & 6; +var ga = `${ 3 - 4 }5` & 6; +var ha = `2${ 3 - 4 }5` & 6; + +var ab = 1 & `${ 3 * 4 }`; +var bb = 1 & `2${ 3 * 4 }`; +var cb = 1 & `${ 3 * 4 }5`; +var db = 1 & `2${ 3 * 4 }5`; +var eb = `${ 3 * 4 }` & 6; +var fb = `2${ 3 * 4 }` & 6; +var gb = `${ 3 * 4 }5` & 6; +var hb = `2${ 3 * 4 }5` & 6; + +var ac = 1 & `${ 3 & 4 }`; +var bc = 1 & `2${ 3 & 4 }`; +var cc = 1 & `${ 3 & 4 }5`; +var dc = 1 & `2${ 3 & 4 }5`; +var ec = `${ 3 & 4 }` & 6; +var fc = `2${ 3 & 4 }` & 6; +var gc = `${ 3 & 4 }5` & 6; +var hc = `2${ 3 & 4 }5` & 6; diff --git a/tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts b/tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts new file mode 100644 index 00000000000..8770edcbd37 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts @@ -0,0 +1,107 @@ +var a = 1 - `${ 3 }`; +var b = 1 - `2${ 3 }`; +var c = 1 - `${ 3 }4`; +var d = 1 - `2${ 3 }4`; +var e = `${ 3 }` - 5; +var f = `2${ 3 }` - 5; +var g = `${ 3 }4` - 5; +var h = `2${ 3 }4` - 5; + +var a2 = 1 * `${ 3 }`; +var b2 = 1 * `2${ 3 }`; +var c2 = 1 * `${ 3 }4`; +var d2 = 1 * `2${ 3 }4`; +var e2 = `${ 3 }` * 5; +var f2 = `2${ 3 }` * 5; +var g2 = `${ 3 }4` * 5; +var h2 = `2${ 3 }4` * 5; + +var a3 = 1 & `${ 3 }`; +var b3 = 1 & `2${ 3 }`; +var c3 = 1 & `${ 3 }4`; +var d3 = 1 & `2${ 3 }4`; +var e3 = `${ 3 }` & 5; +var f3 = `2${ 3 }` & 5; +var g3 = `${ 3 }4` & 5; +var h3 = `2${ 3 }4` & 5; + +var a4 = 1 - `${ 3 - 4 }`; +var b4 = 1 - `2${ 3 - 4 }`; +var c4 = 1 - `${ 3 - 4 }5`; +var d4 = 1 - `2${ 3 - 4 }5`; +var e4 = `${ 3 - 4 }` - 6; +var f4 = `2${ 3 - 4 }` - 6; +var g4 = `${ 3 - 4 }5` - 6; +var h4 = `2${ 3 - 4 }5` - 6; + +var a5 = 1 - `${ 3 * 4 }`; +var b5 = 1 - `2${ 3 * 4 }`; +var c5 = 1 - `${ 3 * 4 }5`; +var d5 = 1 - `2${ 3 * 4 }5`; +var e5 = `${ 3 * 4 }` - 6; +var f5 = `2${ 3 * 4 }` - 6; +var g5 = `${ 3 * 4 }5` - 6; +var h5 = `2${ 3 * 4 }5` - 6; + +var a6 = 1 - `${ 3 & 4 }`; +var b6 = 1 - `2${ 3 & 4 }`; +var c6 = 1 - `${ 3 & 4 }5`; +var d6 = 1 - `2${ 3 & 4 }5`; +var e6 = `${ 3 & 4 }` - 6; +var f6 = `2${ 3 & 4 }` - 6; +var g6 = `${ 3 & 4 }5` - 6; +var h6 = `2${ 3 & 4 }5` - 6; + +var a7 = 1 * `${ 3 - 4 }`; +var b7 = 1 * `2${ 3 - 4 }`; +var c7 = 1 * `${ 3 - 4 }5`; +var d7 = 1 * `2${ 3 - 4 }5`; +var e7 = `${ 3 - 4 }` * 6; +var f7 = `2${ 3 - 4 }` * 6; +var g7 = `${ 3 - 4 }5` * 6; +var h7 = `2${ 3 - 4 }5` * 6; + +var a8 = 1 * `${ 3 * 4 }`; +var b8 = 1 * `2${ 3 * 4 }`; +var c8 = 1 * `${ 3 * 4 }5`; +var d8 = 1 * `2${ 3 * 4 }5`; +var e8 = `${ 3 * 4 }` * 6; +var f8 = `2${ 3 * 4 }` * 6; +var g8 = `${ 3 * 4 }5` * 6; +var h8 = `2${ 3 * 4 }5` * 6; + +var a9 = 1 * `${ 3 & 4 }`; +var b9 = 1 * `2${ 3 & 4 }`; +var c9 = 1 * `${ 3 & 4 }5`; +var d9 = 1 * `2${ 3 & 4 }5`; +var e9 = `${ 3 & 4 }` * 6; +var f9 = `2${ 3 & 4 }` * 6; +var g9 = `${ 3 & 4 }5` * 6; +var h9 = `2${ 3 & 4 }5` * 6; + +var aa = 1 & `${ 3 - 4 }`; +var ba = 1 & `2${ 3 - 4 }`; +var ca = 1 & `${ 3 - 4 }5`; +var da = 1 & `2${ 3 - 4 }5`; +var ea = `${ 3 - 4 }` & 6; +var fa = `2${ 3 - 4 }` & 6; +var ga = `${ 3 - 4 }5` & 6; +var ha = `2${ 3 - 4 }5` & 6; + +var ab = 1 & `${ 3 * 4 }`; +var bb = 1 & `2${ 3 * 4 }`; +var cb = 1 & `${ 3 * 4 }5`; +var db = 1 & `2${ 3 * 4 }5`; +var eb = `${ 3 * 4 }` & 6; +var fb = `2${ 3 * 4 }` & 6; +var gb = `${ 3 * 4 }5` & 6; +var hb = `2${ 3 * 4 }5` & 6; + +var ac = 1 & `${ 3 & 4 }`; +var bc = 1 & `2${ 3 & 4 }`; +var cc = 1 & `${ 3 & 4 }5`; +var dc = 1 & `2${ 3 & 4 }5`; +var ec = `${ 3 & 4 }` & 6; +var fc = `2${ 3 & 4 }` & 6; +var gc = `${ 3 & 4 }5` & 6; +var hc = `2${ 3 & 4 }5` & 6; diff --git a/tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts b/tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts deleted file mode 100644 index 7f00313ca86..00000000000 --- a/tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts +++ /dev/null @@ -1 +0,0 @@ -var x = 10 + `abc${ 10 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts b/tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts deleted file mode 100644 index 5f44e3cb9d4..00000000000 --- a/tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts +++ /dev/null @@ -1,2 +0,0 @@ -// @target: ES6 -var x = 10 + `abc${ 10 }def`; \ No newline at end of file From b442d14e440cd3db7a797016e9b11de2b3f12cb3 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Tue, 6 Jan 2015 15:28:06 -0800 Subject: [PATCH 33/93] Don't emit an empty template head literal if there's a template span with a non-empty literal. Fixes #1570 --- src/compiler/emitter.ts | 43 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f3e45a85b6a..ba32e46065e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2068,9 +2068,15 @@ module ts { write("("); } - emitLiteral(node.head); + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + + for (var i = 0; i < node.templateSpans.length; i++) { + var templateSpan = node.templateSpans[i]; - forEach(node.templateSpans, templateSpan => { // Check if the expression has operands and binds its operands less closely than binary '+'. // If it does, we need to wrap the expression in parentheses. Otherwise, something like // `abc${ 1 << 2 }` @@ -2082,7 +2088,14 @@ module ts { // "abc" + (1 << 2) + "" var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression && comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan; - write(" + "); + + if (i > 0 || headEmitted) { + // If this is the first span and the head was not emitted, then this templateSpan's + // expression will be the first to be emitted. Don't emit the preceding ' + ' in that + // case. + write(" + "); + } + emitParenthesized(templateSpan.expression, needsParens); // Only emit if the literal is non-empty. // The binary '+' operator is left-associative, so the first string concatenation @@ -2092,12 +2105,34 @@ module ts { write(" + ") emitLiteral(templateSpan.literal); } - }); + } if (emitOuterParens) { write(")"); } + function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + + // There is always atleast one templateSpan in this code path, since + // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() + Debug.assert(node.templateSpans.length !== 0); + + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function templateNeedsParens(template: TemplateExpression, parent: Expression) { switch (parent.kind) { case SyntaxKind.CallExpression: From d07151f87c81247a45d3844c8b079d9c30472884 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Tue, 6 Jan 2015 15:28:06 -0800 Subject: [PATCH 34/93] Update tests and baselines. --- .../templateStringBinaryOperations.js | 24 +++++----- .../templateStringBinaryOperationsInvalid.js | 48 +++++++++---------- .../templateStringWithEmptyLiteralPortions.js | 12 +++-- ...mplateStringWithEmptyLiteralPortions.types | 5 +- ...mplateStringWithEmptyLiteralPortionsES6.js | 8 +++- ...ateStringWithEmptyLiteralPortionsES6.types | 5 +- .../templateStringWithEmptyLiteralPortions.ts | 4 +- ...mplateStringWithEmptyLiteralPortionsES6.ts | 4 +- 8 files changed, 64 insertions(+), 46 deletions(-) diff --git a/tests/baselines/reference/templateStringBinaryOperations.js b/tests/baselines/reference/templateStringBinaryOperations.js index d155ba9eedd..691dad41f77 100644 --- a/tests/baselines/reference/templateStringBinaryOperations.js +++ b/tests/baselines/reference/templateStringBinaryOperations.js @@ -55,49 +55,49 @@ var l4 = 1 + `2${ 3 & 4 }5` + 6; //// [templateStringBinaryOperations.js] var a = 1 + ("" + 3); var b = 1 + ("2" + 3); -var c = 1 + ("" + 3 + "4"); +var c = 1 + (3 + "4"); var d = 1 + ("2" + 3 + "4"); var e = ("" + 3) + 5; var f = ("2" + 3) + 5; -var g = ("" + 3 + "4") + 5; +var g = (3 + "4") + 5; var h = ("2" + 3 + "4") + 5; var i = 1 + ("" + 3) + 5; var j = 1 + ("2" + 3) + 5; -var k = 1 + ("" + 3 + "4") + 5; +var k = 1 + (3 + "4") + 5; var l = 1 + ("2" + 3 + "4") + 5; var a2 = 1 + ("" + (3 - 4)); var b2 = 1 + ("2" + (3 - 4)); -var c2 = 1 + ("" + (3 - 4) + "5"); +var c2 = 1 + ((3 - 4) + "5"); var d2 = 1 + ("2" + (3 - 4) + "5"); var e2 = ("" + (3 - 4)) + 6; var f2 = ("2" + (3 - 4)) + 6; -var g2 = ("" + (3 - 4) + "5") + 6; +var g2 = ((3 - 4) + "5") + 6; var h2 = ("2" + (3 - 4) + "5") + 6; var i2 = 1 + ("" + (3 - 4)) + 6; var j2 = 1 + ("2" + (3 - 4)) + 6; -var k2 = 1 + ("" + (3 - 4) + "5") + 6; +var k2 = 1 + ((3 - 4) + "5") + 6; var l2 = 1 + ("2" + (3 - 4) + "5") + 6; var a3 = 1 + ("" + 3 * 4); var b3 = 1 + ("2" + 3 * 4); -var c3 = 1 + ("" + 3 * 4 + "5"); +var c3 = 1 + (3 * 4 + "5"); var d3 = 1 + ("2" + 3 * 4 + "5"); var e3 = ("" + 3 * 4) + 6; var f3 = ("2" + 3 * 4) + 6; -var g3 = ("" + 3 * 4 + "5") + 6; +var g3 = (3 * 4 + "5") + 6; var h3 = ("2" + 3 * 4 + "5") + 6; var i3 = 1 + ("" + 3 * 4) + 6; var j3 = 1 + ("2" + 3 * 4) + 6; -var k3 = 1 + ("" + 3 * 4 + "5") + 6; +var k3 = 1 + (3 * 4 + "5") + 6; var l3 = 1 + ("2" + 3 * 4 + "5") + 6; var a4 = 1 + ("" + (3 & 4)); var b4 = 1 + ("2" + (3 & 4)); -var c4 = 1 + ("" + (3 & 4) + "5"); +var c4 = 1 + ((3 & 4) + "5"); var d4 = 1 + ("2" + (3 & 4) + "5"); var e4 = ("" + (3 & 4)) + 6; var f4 = ("2" + (3 & 4)) + 6; -var g4 = ("" + (3 & 4) + "5") + 6; +var g4 = ((3 & 4) + "5") + 6; var h4 = ("2" + (3 & 4) + "5") + 6; var i4 = 1 + ("" + (3 & 4)) + 6; var j4 = 1 + ("2" + (3 & 4)) + 6; -var k4 = 1 + ("" + (3 & 4) + "5") + 6; +var k4 = 1 + ((3 & 4) + "5") + 6; var l4 = 1 + ("2" + (3 & 4) + "5") + 6; diff --git a/tests/baselines/reference/templateStringBinaryOperationsInvalid.js b/tests/baselines/reference/templateStringBinaryOperationsInvalid.js index 1edf1d3a563..f8c0344f44b 100644 --- a/tests/baselines/reference/templateStringBinaryOperationsInvalid.js +++ b/tests/baselines/reference/templateStringBinaryOperationsInvalid.js @@ -111,97 +111,97 @@ var hc = `2${ 3 & 4 }5` & 6; //// [templateStringBinaryOperationsInvalid.js] var a = 1 - ("" + 3); var b = 1 - ("2" + 3); -var c = 1 - ("" + 3 + "4"); +var c = 1 - (3 + "4"); var d = 1 - ("2" + 3 + "4"); var e = ("" + 3) - 5; var f = ("2" + 3) - 5; -var g = ("" + 3 + "4") - 5; +var g = (3 + "4") - 5; var h = ("2" + 3 + "4") - 5; var a2 = 1 * ("" + 3); var b2 = 1 * ("2" + 3); -var c2 = 1 * ("" + 3 + "4"); +var c2 = 1 * (3 + "4"); var d2 = 1 * ("2" + 3 + "4"); var e2 = ("" + 3) * 5; var f2 = ("2" + 3) * 5; -var g2 = ("" + 3 + "4") * 5; +var g2 = (3 + "4") * 5; var h2 = ("2" + 3 + "4") * 5; var a3 = 1 & "" + 3; var b3 = 1 & "2" + 3; -var c3 = 1 & "" + 3 + "4"; +var c3 = 1 & 3 + "4"; var d3 = 1 & "2" + 3 + "4"; var e3 = "" + 3 & 5; var f3 = "2" + 3 & 5; -var g3 = "" + 3 + "4" & 5; +var g3 = 3 + "4" & 5; var h3 = "2" + 3 + "4" & 5; var a4 = 1 - ("" + (3 - 4)); var b4 = 1 - ("2" + (3 - 4)); -var c4 = 1 - ("" + (3 - 4) + "5"); +var c4 = 1 - ((3 - 4) + "5"); var d4 = 1 - ("2" + (3 - 4) + "5"); var e4 = ("" + (3 - 4)) - 6; var f4 = ("2" + (3 - 4)) - 6; -var g4 = ("" + (3 - 4) + "5") - 6; +var g4 = ((3 - 4) + "5") - 6; var h4 = ("2" + (3 - 4) + "5") - 6; var a5 = 1 - ("" + 3 * 4); var b5 = 1 - ("2" + 3 * 4); -var c5 = 1 - ("" + 3 * 4 + "5"); +var c5 = 1 - (3 * 4 + "5"); var d5 = 1 - ("2" + 3 * 4 + "5"); var e5 = ("" + 3 * 4) - 6; var f5 = ("2" + 3 * 4) - 6; -var g5 = ("" + 3 * 4 + "5") - 6; +var g5 = (3 * 4 + "5") - 6; var h5 = ("2" + 3 * 4 + "5") - 6; var a6 = 1 - ("" + (3 & 4)); var b6 = 1 - ("2" + (3 & 4)); -var c6 = 1 - ("" + (3 & 4) + "5"); +var c6 = 1 - ((3 & 4) + "5"); var d6 = 1 - ("2" + (3 & 4) + "5"); var e6 = ("" + (3 & 4)) - 6; var f6 = ("2" + (3 & 4)) - 6; -var g6 = ("" + (3 & 4) + "5") - 6; +var g6 = ((3 & 4) + "5") - 6; var h6 = ("2" + (3 & 4) + "5") - 6; var a7 = 1 * ("" + (3 - 4)); var b7 = 1 * ("2" + (3 - 4)); -var c7 = 1 * ("" + (3 - 4) + "5"); +var c7 = 1 * ((3 - 4) + "5"); var d7 = 1 * ("2" + (3 - 4) + "5"); var e7 = ("" + (3 - 4)) * 6; var f7 = ("2" + (3 - 4)) * 6; -var g7 = ("" + (3 - 4) + "5") * 6; +var g7 = ((3 - 4) + "5") * 6; var h7 = ("2" + (3 - 4) + "5") * 6; var a8 = 1 * ("" + 3 * 4); var b8 = 1 * ("2" + 3 * 4); -var c8 = 1 * ("" + 3 * 4 + "5"); +var c8 = 1 * (3 * 4 + "5"); var d8 = 1 * ("2" + 3 * 4 + "5"); var e8 = ("" + 3 * 4) * 6; var f8 = ("2" + 3 * 4) * 6; -var g8 = ("" + 3 * 4 + "5") * 6; +var g8 = (3 * 4 + "5") * 6; var h8 = ("2" + 3 * 4 + "5") * 6; var a9 = 1 * ("" + (3 & 4)); var b9 = 1 * ("2" + (3 & 4)); -var c9 = 1 * ("" + (3 & 4) + "5"); +var c9 = 1 * ((3 & 4) + "5"); var d9 = 1 * ("2" + (3 & 4) + "5"); var e9 = ("" + (3 & 4)) * 6; var f9 = ("2" + (3 & 4)) * 6; -var g9 = ("" + (3 & 4) + "5") * 6; +var g9 = ((3 & 4) + "5") * 6; var h9 = ("2" + (3 & 4) + "5") * 6; var aa = 1 & "" + (3 - 4); var ba = 1 & "2" + (3 - 4); -var ca = 1 & "" + (3 - 4) + "5"; +var ca = 1 & (3 - 4) + "5"; var da = 1 & "2" + (3 - 4) + "5"; var ea = "" + (3 - 4) & 6; var fa = "2" + (3 - 4) & 6; -var ga = "" + (3 - 4) + "5" & 6; +var ga = (3 - 4) + "5" & 6; var ha = "2" + (3 - 4) + "5" & 6; var ab = 1 & "" + 3 * 4; var bb = 1 & "2" + 3 * 4; -var cb = 1 & "" + 3 * 4 + "5"; +var cb = 1 & 3 * 4 + "5"; var db = 1 & "2" + 3 * 4 + "5"; var eb = "" + 3 * 4 & 6; var fb = "2" + 3 * 4 & 6; -var gb = "" + 3 * 4 + "5" & 6; +var gb = 3 * 4 + "5" & 6; var hb = "2" + 3 * 4 + "5" & 6; var ac = 1 & "" + (3 & 4); var bc = 1 & "2" + (3 & 4); -var cc = 1 & "" + (3 & 4) + "5"; +var cc = 1 & (3 & 4) + "5"; var dc = 1 & "2" + (3 & 4) + "5"; var ec = "" + (3 & 4) & 6; var fc = "2" + (3 & 4) & 6; -var gc = "" + (3 & 4) + "5" & 6; +var gc = (3 & 4) + "5" & 6; var hc = "2" + (3 & 4) + "5" & 6; diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.js b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.js index 8bc6e2c4206..e7a35d76f45 100644 --- a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.js +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.js @@ -21,18 +21,22 @@ var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; -var l = `1${ 0 }2${ 0 }3`; +var l = `${ 0 }2${ 0 }3`; + +var m = `1${ 0 }2${ 0 }3`; + //// [templateStringWithEmptyLiteralPortions.js] var a = ""; var b = "" + 0; var c = "1" + 0; -var d = "" + 0 + "2"; +var d = 0 + "2"; var e = "1" + 0 + "2"; var f = "" + 0 + 0; var g = "1" + 0 + 0; -var h = "" + 0 + "2" + 0; +var h = 0 + "2" + 0; var i = "1" + 0 + "2" + 0; var j = "" + 0 + 0 + "3"; var k = "1" + 0 + 0 + "3"; -var l = "1" + 0 + "2" + 0 + "3"; +var l = 0 + "2" + 0 + "3"; +var m = "1" + 0 + "2" + 0 + "3"; diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types index a44bab8fe44..c901d674306 100644 --- a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types @@ -32,6 +32,9 @@ var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; >k : string -var l = `1${ 0 }2${ 0 }3`; +var l = `${ 0 }2${ 0 }3`; >l : string +var m = `1${ 0 }2${ 0 }3`; +>m : string + diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.js b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.js index f0e827cde63..fe1bce291f0 100644 --- a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.js +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.js @@ -21,7 +21,10 @@ var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; -var l = `1${ 0 }2${ 0 }3`; +var l = `${ 0 }2${ 0 }3`; + +var m = `1${ 0 }2${ 0 }3`; + //// [templateStringWithEmptyLiteralPortionsES6.js] var a = ``; @@ -35,4 +38,5 @@ var h = `${0}2${0}`; var i = `1${0}2${0}`; var j = `${0}${0}3`; var k = `1${0}${0}3`; -var l = `1${0}2${0}3`; +var l = `${0}2${0}3`; +var m = `1${0}2${0}3`; diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types index 4074831d410..d70dd29e4da 100644 --- a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types @@ -32,6 +32,9 @@ var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; >k : string -var l = `1${ 0 }2${ 0 }3`; +var l = `${ 0 }2${ 0 }3`; >l : string +var m = `1${ 0 }2${ 0 }3`; +>m : string + diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts index 11dca4caf77..9191ca1934c 100644 --- a/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts +++ b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts @@ -20,4 +20,6 @@ var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; -var l = `1${ 0 }2${ 0 }3`; \ No newline at end of file +var l = `${ 0 }2${ 0 }3`; + +var m = `1${ 0 }2${ 0 }3`; diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts index 183da57dd45..ff178d22432 100644 --- a/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts +++ b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts @@ -21,4 +21,6 @@ var j = `${ 0 }${ 0 }3`; var k = `1${ 0 }${ 0 }3`; -var l = `1${ 0 }2${ 0 }3`; \ No newline at end of file +var l = `${ 0 }2${ 0 }3`; + +var m = `1${ 0 }2${ 0 }3`; From 01218f86ffe2ed6002016a1f3bf3b91bb118830f Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 6 Jan 2015 17:55:54 -0800 Subject: [PATCH 35/93] consider type parameters always visible --- src/compiler/checker.ts | 5 ++-- .../reference/visibilityOfTypeParameters.js | 24 +++++++++++++++++++ .../visibilityOfTypeParameters.types | 16 +++++++++++++ .../compiler/visibilityOfTypeParameters.ts | 8 +++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/visibilityOfTypeParameters.js create mode 100644 tests/baselines/reference/visibilityOfTypeParameters.types create mode 100644 tests/cases/compiler/visibilityOfTypeParameters.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e07c0eb237e..9849e740e9d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1575,7 +1575,6 @@ module ts { case SyntaxKind.IndexSignature: case SyntaxKind.Parameter: case SyntaxKind.ModuleBlock: - case SyntaxKind.TypeParameter: case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.TypeLiteral: @@ -1585,7 +1584,9 @@ module ts { case SyntaxKind.UnionType: case SyntaxKind.ParenthesizedType: return isDeclarationVisible(node.parent); - + + // Type parameters are always visible + case SyntaxKind.TypeParameter: // Source file is always visible case SyntaxKind.SourceFile: return true; diff --git a/tests/baselines/reference/visibilityOfTypeParameters.js b/tests/baselines/reference/visibilityOfTypeParameters.js new file mode 100644 index 00000000000..2cb006737b2 --- /dev/null +++ b/tests/baselines/reference/visibilityOfTypeParameters.js @@ -0,0 +1,24 @@ +//// [visibilityOfTypeParameters.ts] + +export class MyClass { + protected myMethod(val: T): T { + return val; + } +} + +//// [visibilityOfTypeParameters.js] +var MyClass = (function () { + function MyClass() { + } + MyClass.prototype.myMethod = function (val) { + return val; + }; + return MyClass; +})(); +exports.MyClass = MyClass; + + +//// [visibilityOfTypeParameters.d.ts] +export declare class MyClass { + protected myMethod(val: T): T; +} diff --git a/tests/baselines/reference/visibilityOfTypeParameters.types b/tests/baselines/reference/visibilityOfTypeParameters.types new file mode 100644 index 00000000000..60a9330eb7e --- /dev/null +++ b/tests/baselines/reference/visibilityOfTypeParameters.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/visibilityOfTypeParameters.ts === + +export class MyClass { +>MyClass : MyClass + + protected myMethod(val: T): T { +>myMethod : (val: T) => T +>T : T +>val : T +>T : T +>T : T + + return val; +>val : T + } +} diff --git a/tests/cases/compiler/visibilityOfTypeParameters.ts b/tests/cases/compiler/visibilityOfTypeParameters.ts new file mode 100644 index 00000000000..386d0bb9cb4 --- /dev/null +++ b/tests/cases/compiler/visibilityOfTypeParameters.ts @@ -0,0 +1,8 @@ +// @module:commonjs +//@declaration: true + +export class MyClass { + protected myMethod(val: T): T { + return val; + } +} \ No newline at end of file From 06d65c797d91816d4c7b5bfe4f25ee1c01dd9691 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 7 Jan 2015 12:37:46 -0800 Subject: [PATCH 36/93] Moved EmitHost to utilities.ts --- src/compiler/types.ts | 11 ----------- src/compiler/utilities.ts | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dbdd71ed363..cc1b37aef5d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -951,17 +951,6 @@ module ts { isEmitBlocked(sourceFile?: SourceFile): boolean; } - export interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; - isEmitBlocked(sourceFile?: SourceFile): boolean; - - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - - writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; - } - export interface SourceMapSpan { emittedLine: number; // Line number in the .js file emittedColumn: number; // Column number in the .js file diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index edd8bf156cf..9686622decb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -23,6 +23,17 @@ module ts { string(): string; } + export interface EmitHost extends ScriptReferenceHost { + getSourceFiles(): SourceFile[]; + isEmitBlocked(sourceFile?: SourceFile): boolean; + + getCommonSourceDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + } + // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters: StringSymbolWriter[] = []; export function getSingleLineStringWriter(): StringSymbolWriter { From 968a56924f7d723abee27b2d5268ef0a54b85ed8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 8 Jan 2015 14:27:39 -0800 Subject: [PATCH 37/93] Type guard narrows type any in a primitive type check --- src/compiler/checker.ts | 15 ++--- src/compiler/types.ts | 2 - .../reference/typeGuardsWithAny.errors.txt | 49 +++++++++++++++ .../baselines/reference/typeGuardsWithAny.js | 61 +++++++++++++++++-- .../reference/typeGuardsWithAny.types | 23 ------- .../typeGuards/typeGuardsWithAny.ts | 33 +++++++++- 6 files changed, 142 insertions(+), 41 deletions(-) create mode 100644 tests/baselines/reference/typeGuardsWithAny.errors.txt delete mode 100644 tests/baselines/reference/typeGuardsWithAny.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2911322052d..96fab3368ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4589,8 +4589,8 @@ module ts { // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) { var type = getTypeOfSymbol(symbol); - // Only narrow when symbol is variable of an object, union, or type parameter type - if (node && symbol.flags & SymbolFlags.Variable && type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) { + // Only narrow when symbol is variable of type any or an object, union, or type parameter type + if (node && symbol.flags & SymbolFlags.Variable && type.flags & (TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) { loop: while (node.parent) { var child = node; node = node.parent; @@ -4646,21 +4646,16 @@ module ts { if (expr.left.kind !== SyntaxKind.TypeOfExpression || expr.right.kind !== SyntaxKind.StringLiteral) { return type; } - var left = expr.left; var right = expr.right; - if (left.expression.kind !== SyntaxKind.Identifier || - getResolvedSymbol(left.expression) !== symbol) { - + if (left.expression.kind !== SyntaxKind.Identifier || getResolvedSymbol(left.expression) !== symbol) { return type; } - var t = right.text; var checkType: Type = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; if (expr.operator === SyntaxKind.ExclamationEqualsEqualsToken) { assumeTrue = !assumeTrue; } - if (assumeTrue) { // The assumed result is true. If check was for a primitive type, that type is the narrowed type. Otherwise we can // remove the primitive types from the narrowed type. @@ -4704,8 +4699,8 @@ module ts { } function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { - // Check that assumed result is true and we have variable symbol on the left - if (!assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(expr.left) !== symbol) { + // Check that type is not any, assumed result is true, and we have variable symbol on the left + if (type.flags & TypeFlags.Any || !assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 60ed8352b9a..9ebab8dc220 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1331,8 +1331,6 @@ module ts { // Generic class and interface types export interface GenericType extends InterfaceType, TypeReference { instantiations: Map; // Generic instantiation cache - openReferenceTargets: GenericType[]; // Open type reference targets - openReferenceChecks: Map; // Open type reference check cache } export interface TupleType extends ObjectType { diff --git a/tests/baselines/reference/typeGuardsWithAny.errors.txt b/tests/baselines/reference/typeGuardsWithAny.errors.txt new file mode 100644 index 00000000000..653c89c7554 --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithAny.errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(11,7): error TS2339: Property 'p' does not exist on type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(18,7): error TS2339: Property 'p' does not exist on type 'number'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error TS2339: Property 'p' does not exist on type 'boolean'. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts (3 errors) ==== + var x: any = { p: 0 }; + + if (x instanceof Object) { + x.p; // No error, type any unaffected by instanceof type guard + } + else { + x.p; // No error, type any unaffected by instanceof type guard + } + + if (typeof x === "string") { + x.p; // Error, type any narrowed by primitive type check + ~ +!!! error TS2339: Property 'p' does not exist on type 'string'. + } + else { + x.p; // No error, type unaffected in this branch + } + + if (typeof x === "number") { + x.p; // Error, type any narrowed by primitive type check + ~ +!!! error TS2339: Property 'p' does not exist on type 'number'. + } + else { + x.p; // No error, type unaffected in this branch + } + + if (typeof x === "boolean") { + x.p; // Error, type any narrowed by primitive type check + ~ +!!! error TS2339: Property 'p' does not exist on type 'boolean'. + } + else { + x.p; // No error, type unaffected in this branch + } + + if (typeof x === "object") { + x.p; // No error, type any only affected by primitive type check + } + else { + x.p; // No error, type unaffected in this branch + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithAny.js b/tests/baselines/reference/typeGuardsWithAny.js index 56676fb6d68..be3d64b806f 100644 --- a/tests/baselines/reference/typeGuardsWithAny.js +++ b/tests/baselines/reference/typeGuardsWithAny.js @@ -1,18 +1,71 @@ //// [typeGuardsWithAny.ts] var x: any = { p: 0 }; + if (x instanceof Object) { - x.p; // No error, type any unaffected by type guard + x.p; // No error, type any unaffected by instanceof type guard } else { - x.p; // No error, type any unaffected by type guard + x.p; // No error, type any unaffected by instanceof type guard +} + +if (typeof x === "string") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} + +if (typeof x === "number") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} + +if (typeof x === "boolean") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} + +if (typeof x === "object") { + x.p; // No error, type any only affected by primitive type check +} +else { + x.p; // No error, type unaffected in this branch } //// [typeGuardsWithAny.js] var x = { p: 0 }; if (x instanceof Object) { - x.p; // No error, type any unaffected by type guard + x.p; // No error, type any unaffected by instanceof type guard } else { - x.p; // No error, type any unaffected by type guard + x.p; // No error, type any unaffected by instanceof type guard +} +if (typeof x === "string") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} +if (typeof x === "number") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} +if (typeof x === "boolean") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} +if (typeof x === "object") { + x.p; // No error, type any only affected by primitive type check +} +else { + x.p; // No error, type unaffected in this branch } diff --git a/tests/baselines/reference/typeGuardsWithAny.types b/tests/baselines/reference/typeGuardsWithAny.types deleted file mode 100644 index ee628c9c249..00000000000 --- a/tests/baselines/reference/typeGuardsWithAny.types +++ /dev/null @@ -1,23 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts === -var x: any = { p: 0 }; ->x : any ->{ p: 0 } : { p: number; } ->p : number - -if (x instanceof Object) { ->x instanceof Object : boolean ->x : any ->Object : ObjectConstructor - - x.p; // No error, type any unaffected by type guard ->x.p : any ->x : any ->p : any -} -else { - x.p; // No error, type any unaffected by type guard ->x.p : any ->x : any ->p : any -} - diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts index e7e756ea8e0..a6379bf95b0 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts @@ -1,7 +1,36 @@ var x: any = { p: 0 }; + if (x instanceof Object) { - x.p; // No error, type any unaffected by type guard + x.p; // No error, type any unaffected by instanceof type guard } else { - x.p; // No error, type any unaffected by type guard + x.p; // No error, type any unaffected by instanceof type guard +} + +if (typeof x === "string") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} + +if (typeof x === "number") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} + +if (typeof x === "boolean") { + x.p; // Error, type any narrowed by primitive type check +} +else { + x.p; // No error, type unaffected in this branch +} + +if (typeof x === "object") { + x.p; // No error, type any only affected by primitive type check +} +else { + x.p; // No error, type unaffected in this branch } From d5f02813f01f31eb4b72cf2f2f7d7351cb5328b2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Jan 2015 16:39:47 -0800 Subject: [PATCH 38/93] Added tests for contextual typing on parenthesized expressions, added case for tagged templates. --- .../parenthesizedContexualTyping1.js | 52 ++++ .../parenthesizedContexualTyping1.types | 289 ++++++++++++++++++ .../parenthesizedContexualTyping2.errors.txt | 86 ++++++ .../parenthesizedContexualTyping2.js | 126 ++++++++ .../parenthesizedContexualTyping3.js | 35 +++ .../parenthesizedContexualTyping3.types | 142 +++++++++ .../taggedTemplateContextualTyping1.js | 5 + .../taggedTemplateContextualTyping1.types | 9 + .../parenthesizedContexualTyping1.ts | 29 ++ .../parenthesizedContexualTyping2.ts | 35 +++ .../parenthesizedContexualTyping3.ts | 21 ++ .../taggedTemplateContextualTyping1.ts | 1 + 12 files changed, 830 insertions(+) create mode 100644 tests/baselines/reference/parenthesizedContexualTyping1.js create mode 100644 tests/baselines/reference/parenthesizedContexualTyping1.types create mode 100644 tests/baselines/reference/parenthesizedContexualTyping2.errors.txt create mode 100644 tests/baselines/reference/parenthesizedContexualTyping2.js create mode 100644 tests/baselines/reference/parenthesizedContexualTyping3.js create mode 100644 tests/baselines/reference/parenthesizedContexualTyping3.types create mode 100644 tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts create mode 100644 tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts create mode 100644 tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping3.ts diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.js b/tests/baselines/reference/parenthesizedContexualTyping1.js new file mode 100644 index 00000000000..2f1e9ff62fc --- /dev/null +++ b/tests/baselines/reference/parenthesizedContexualTyping1.js @@ -0,0 +1,52 @@ +//// [parenthesizedContexualTyping1.ts] + +function fun(g: (x: T) => T, x: T): T; +function fun(g: (x: T) => T, h: (y: T) => T, x: T): T; +function fun(g: (x: T) => T, x: T): T { + return g(x); +} + +var a = fun(x => x, 10); +var b = fun((x => x), 10); +var c = fun(((x => x)), 10); +var d = fun((((x => x))), 10); + +var e = fun(x => x, x => x, 10); +var f = fun((x => x), (x => x), 10); +var g = fun(((x => x)), ((x => x)), 10); +var h = fun((((x => x))), ((x => x)), 10); + +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); +var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); +var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); +var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10); + +var lambda1: (x: number) => number = x => x; +var lambda2: (x: number) => number = (x => x); + +type ObjType = { x: (p: number) => string; y: (p: string) => number }; +var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; +var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); + +//// [parenthesizedContexualTyping1.js] +function fun(g, x) { + return g(x); +} +var a = fun(function (x) { return x; }, 10); +var b = fun((function (x) { return x; }), 10); +var c = fun(((function (x) { return x; })), 10); +var d = fun((((function (x) { return x; }))), 10); +var e = fun(function (x) { return x; }, function (x) { return x; }, 10); +var f = fun((function (x) { return x; }), (function (x) { return x; }), 10); +var g = fun(((function (x) { return x; })), ((function (x) { return x; })), 10); +var h = fun((((function (x) { return x; }))), ((function (x) { return x; })), 10); +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? function (x) { return x; } : function (x) { return undefined; }), 10); +var j = fun((Math.random() < 0.5 ? (function (x) { return x; }) : (function (x) { return undefined; })), 10); +var k = fun((Math.random() < 0.5 ? (function (x) { return x; }) : (function (x) { return undefined; })), function (x) { return x; }, 10); +var l = fun(((Math.random() < 0.5 ? ((function (x) { return x; })) : ((function (x) { return undefined; })))), ((function (x) { return x; })), 10); +var lambda1 = function (x) { return x; }; +var lambda2 = (function (x) { return x; }); +var obj1 = { x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } }; +var obj2 = ({ x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } }); diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types new file mode 100644 index 00000000000..c8685206c47 --- /dev/null +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -0,0 +1,289 @@ +=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts === + +function fun(g: (x: T) => T, x: T): T; +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>g : (x: T) => T +>x : T +>T : T +>T : T +>x : T +>T : T +>T : T + +function fun(g: (x: T) => T, h: (y: T) => T, x: T): T; +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>g : (x: T) => T +>x : T +>T : T +>T : T +>h : (y: T) => T +>y : T +>T : T +>T : T +>x : T +>T : T +>T : T + +function fun(g: (x: T) => T, x: T): T { +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>g : (x: T) => T +>x : T +>T : T +>T : T +>x : T +>T : T +>T : T + + return g(x); +>g(x) : T +>g : (x: T) => T +>x : T +} + +var a = fun(x => x, 10); +>a : number +>fun(x => x, 10) : number +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: number) => number +>x : number +>x : number + +var b = fun((x => x), 10); +>b : any +>fun((x => x), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var c = fun(((x => x)), 10); +>c : any +>fun(((x => x)), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var d = fun((((x => x))), 10); +>d : any +>fun((((x => x))), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(((x => x))) : (x: any) => any +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var e = fun(x => x, x => x, 10); +>e : number +>fun(x => x, x => x, 10) : number +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: number) => number +>x : number +>x : number +>x => x : (x: number) => number +>x : number +>x : number + +var f = fun((x => x), (x => x), 10); +>f : any +>fun((x => x), (x => x), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var g = fun(((x => x)), ((x => x)), 10); +>g : any +>fun(((x => x)), ((x => x)), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var h = fun((((x => x))), ((x => x)), 10); +>h : any +>fun((((x => x))), ((x => x)), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(((x => x))) : (x: any) => any +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); +>i : any +>fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(Math.random() < 0.5 ? x => x : x => undefined) : (x: any) => any +>Math.random() < 0.5 ? x => x : x => undefined : (x: any) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>x => x : (x: any) => any +>x : any +>x : any +>x => undefined : (x: any) => any +>x : any +>undefined : undefined + +var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); +>j : any +>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: any) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: any) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>(x => undefined) : (x: any) => any +>x => undefined : (x: any) => any +>x : any +>undefined : undefined + +var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); +>k : any +>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: any) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: any) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>(x => undefined) : (x: any) => any +>x => undefined : (x: any) => any +>x : any +>undefined : undefined +>x => x : (x: any) => any +>x : any +>x : any + +var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10); +>l : any +>fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : any +>fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: any) => any +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: any) => any +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: any) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>((x => undefined)) : (x: any) => any +>(x => undefined) : (x: any) => any +>x => undefined : (x: any) => any +>x : any +>undefined : undefined +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var lambda1: (x: number) => number = x => x; +>lambda1 : (x: number) => number +>x : number +>x => x : (x: number) => number +>x : number +>x : number + +var lambda2: (x: number) => number = (x => x); +>lambda2 : (x: number) => number +>x : number +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +type ObjType = { x: (p: number) => string; y: (p: string) => number }; +>ObjType : { x: (p: number) => string; y: (p: string) => number; } +>x : (p: number) => string +>p : number +>y : (p: string) => number +>p : string + +var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; +>obj1 : { x: (p: number) => string; y: (p: string) => number; } +>ObjType : { x: (p: number) => string; y: (p: string) => number; } +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } +>x : (x: number) => any +>x => (x, undefined) : (x: number) => any +>x : number +>(x, undefined) : undefined +>x, undefined : undefined +>x : number +>undefined : undefined +>y : (y: string) => any +>y => (y, undefined) : (y: string) => any +>y : string +>(y, undefined) : undefined +>y, undefined : undefined +>y : string +>undefined : undefined + +var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); +>obj2 : { x: (p: number) => string; y: (p: string) => number; } +>ObjType : { x: (p: number) => string; y: (p: string) => number; } +>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: any) => any; y: (y: any) => any; } +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: any) => any; y: (y: any) => any; } +>x : (x: any) => any +>x => (x, undefined) : (x: any) => any +>x : any +>(x, undefined) : undefined +>x, undefined : undefined +>x : any +>undefined : undefined +>y : (y: any) => any +>y => (y, undefined) : (y: any) => any +>y : any +>(y, undefined) : undefined +>y, undefined : undefined +>y : any +>undefined : undefined + diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt b/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt new file mode 100644 index 00000000000..236dfee0979 --- /dev/null +++ b/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt @@ -0,0 +1,86 @@ +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(15,21): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(16,22): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(17,23): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(20,21): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(20,64): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,22): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,67): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,23): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,69): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(25,43): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(26,44): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(27,44): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,46): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,114): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(30,45): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(31,46): error TS2347: Untyped function calls may not accept type arguments. + + +==== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts (16 errors) ==== + // These tests ensure that in cases where it may *appear* that a value has a type, + // they actually are properly being contextually typed. The way we test this is + // that we invoke contextually typed arguments with type arguments. + // Since 'any' cannot be invoked with type arguments, we should get errors back. + + type FuncType = (x: (p: T) => T) => typeof x; + + function fun(f: FuncType, x: T): T; + function fun(f: FuncType, g: FuncType, x: T): T; + function fun(...rest: any[]): T { + return undefined; + } + + var a = fun(x => { x(undefined); return x; }, 10); + var b = fun((x => { x(undefined); return x; }), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + var c = fun(((x => { x(undefined); return x; })), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + var d = fun((((x => { x(undefined); return x; }))), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + + var e = fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10); + var f = fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + var g = fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + var h = fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + + // Ternaries in parens + var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + + var lambda1: (x: number) => number = x => { x(undefined); return x; }; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + var lambda2: (x: number) => number = (x => { x(undefined); return x; }); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2347: Untyped function calls may not accept type arguments. + + type ObjType = { x: (p: number) => string; y: (p: string) => number }; + var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; + var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); \ No newline at end of file diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.js b/tests/baselines/reference/parenthesizedContexualTyping2.js new file mode 100644 index 00000000000..724cbaba2b6 --- /dev/null +++ b/tests/baselines/reference/parenthesizedContexualTyping2.js @@ -0,0 +1,126 @@ +//// [parenthesizedContexualTyping2.ts] +// These tests ensure that in cases where it may *appear* that a value has a type, +// they actually are properly being contextually typed. The way we test this is +// that we invoke contextually typed arguments with type arguments. +// Since 'any' cannot be invoked with type arguments, we should get errors back. + +type FuncType = (x: (p: T) => T) => typeof x; + +function fun(f: FuncType, x: T): T; +function fun(f: FuncType, g: FuncType, x: T): T; +function fun(...rest: any[]): T { + return undefined; +} + +var a = fun(x => { x(undefined); return x; }, 10); +var b = fun((x => { x(undefined); return x; }), 10); +var c = fun(((x => { x(undefined); return x; })), 10); +var d = fun((((x => { x(undefined); return x; }))), 10); + +var e = fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10); +var f = fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10); +var g = fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10); +var h = fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10); + +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10); +var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10); +var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); +var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); + +var lambda1: (x: number) => number = x => { x(undefined); return x; }; +var lambda2: (x: number) => number = (x => { x(undefined); return x; }); + +type ObjType = { x: (p: number) => string; y: (p: string) => number }; +var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; +var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); + +//// [parenthesizedContexualTyping2.js] +// These tests ensure that in cases where it may *appear* that a value has a type, +// they actually are properly being contextually typed. The way we test this is +// that we invoke contextually typed arguments with type arguments. +// Since 'any' cannot be invoked with type arguments, we should get errors back. +function fun() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } + return undefined; +} +var a = fun(function (x) { + x(undefined); + return x; +}, 10); +var b = fun((function (x) { + x(undefined); + return x; +}), 10); +var c = fun(((function (x) { + x(undefined); + return x; +})), 10); +var d = fun((((function (x) { + x(undefined); + return x; +}))), 10); +var e = fun(function (x) { + x(undefined); + return x; +}, function (x) { + x(undefined); + return x; +}, 10); +var f = fun((function (x) { + x(undefined); + return x; +}), (function (x) { + x(undefined); + return x; +}), 10); +var g = fun(((function (x) { + x(undefined); + return x; +})), ((function (x) { + x(undefined); + return x; +})), 10); +var h = fun((((function (x) { + x(undefined); + return x; +}))), ((function (x) { + x(undefined); + return x; +})), 10); +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? function (x) { + x(undefined); + return x; +} : function (x) { return undefined; }), 10); +var j = fun((Math.random() < 0.5 ? (function (x) { + x(undefined); + return x; +}) : (function (x) { return undefined; })), 10); +var k = fun((Math.random() < 0.5 ? (function (x) { + x(undefined); + return x; +}) : (function (x) { return undefined; })), function (x) { + x(undefined); + return x; +}, 10); +var l = fun(((Math.random() < 0.5 ? ((function (x) { + x(undefined); + return x; +})) : ((function (x) { return undefined; })))), ((function (x) { + x(undefined); + return x; +})), 10); +var lambda1 = function (x) { + x(undefined); + return x; +}; +var lambda2 = (function (x) { + x(undefined); + return x; +}); +var obj1 = { x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } }; +var obj2 = ({ x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } }); diff --git a/tests/baselines/reference/parenthesizedContexualTyping3.js b/tests/baselines/reference/parenthesizedContexualTyping3.js new file mode 100644 index 00000000000..69784d14ce4 --- /dev/null +++ b/tests/baselines/reference/parenthesizedContexualTyping3.js @@ -0,0 +1,35 @@ +//// [parenthesizedContexualTyping3.ts] + +// Contextual typing for parenthesized substitution expressions in tagged templates. + +/** + * tempFun - Can't have fun for too long. + */ +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T { + return g(x); +} + +var a = tempFun `${ x => x } ${ 10 }` +var b = tempFun `${ (x => x) } ${ 10 }` +var c = tempFun `${ ((x => x)) } ${ 10 }` +var d = tempFun `${ x => x } ${ x => x } ${ 10 }` +var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }` +var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }` +var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }` +var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }` + +//// [parenthesizedContexualTyping3.js] +// Contextual typing for parenthesized substitution expressions in tagged templates. +function tempFun(tempStrs, g, x) { + return g(x); +} +var a = tempFun `${function (x) { return x; }} ${10}`; +var b = tempFun `${(function (x) { return x; })} ${10}`; +var c = tempFun `${((function (x) { return x; }))} ${10}`; +var d = tempFun `${function (x) { return x; }} ${function (x) { return x; }} ${10}`; +var e = tempFun `${function (x) { return x; }} ${(function (x) { return x; })} ${10}`; +var f = tempFun `${function (x) { return x; }} ${((function (x) { return x; }))} ${10}`; +var g = tempFun `${(function (x) { return x; })} ${(((function (x) { return x; })))} ${10}`; +var h = tempFun `${(function (x) { return x; })} ${(((function (x) { return x; })))} ${undefined}`; diff --git a/tests/baselines/reference/parenthesizedContexualTyping3.types b/tests/baselines/reference/parenthesizedContexualTyping3.types new file mode 100644 index 00000000000..6f9f24ef90b --- /dev/null +++ b/tests/baselines/reference/parenthesizedContexualTyping3.types @@ -0,0 +1,142 @@ +=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping3.ts === + +// Contextual typing for parenthesized substitution expressions in tagged templates. + +/** + * tempFun - Can't have fun for too long. + */ +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>tempStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>g : (x: T) => T +>x : T +>T : T +>T : T +>x : T +>T : T +>T : T + +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>tempStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>g : (x: T) => T +>x : T +>T : T +>T : T +>h : (y: T) => T +>y : T +>T : T +>T : T +>x : T +>T : T +>T : T + +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T { +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>T : T +>tempStrs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>g : (x: T) => T +>x : T +>T : T +>T : T +>x : T +>T : T +>T : T + + return g(x); +>g(x) : T +>g : (x: T) => T +>x : T +} + +var a = tempFun `${ x => x } ${ 10 }` +>a : number +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: number) => number +>x : number +>x : number + +var b = tempFun `${ (x => x) } ${ 10 }` +>b : any +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var c = tempFun `${ ((x => x)) } ${ 10 }` +>c : any +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var d = tempFun `${ x => x } ${ x => x } ${ 10 }` +>d : number +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: number) => number +>x : number +>x : number +>x => x : (x: number) => number +>x : number +>x : number + +var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }` +>e : any +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: any) => any +>x : any +>x : any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }` +>f : any +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>x => x : (x: any) => any +>x : any +>x : any +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }` +>g : any +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>(((x => x))) : (x: any) => any +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any + +var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }` +>h : any +>tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>(((x => x))) : (x: any) => any +>((x => x)) : (x: any) => any +>(x => x) : (x: any) => any +>x => x : (x: any) => any +>x : any +>x : any +>undefined : undefined + diff --git a/tests/baselines/reference/taggedTemplateContextualTyping1.js b/tests/baselines/reference/taggedTemplateContextualTyping1.js index d631a718bf3..c1ae5c384e4 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping1.js +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.js @@ -12,6 +12,7 @@ function tempTag1(...rest: any[]): T { // Otherwise, the arrow functions' parameters will be typed as 'any', // and it is an error to invoke an any-typed value with type arguments, // so this test will error. +tempTag1 `${ x => { x(undefined); return x; } }${ 10 }`; tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; tempTag1 `${ x => { x(undefined); return x; } }${ (y: (p: T) => T) => { y(undefined); return y } }${ undefined }`; tempTag1 `${ (x: (p: T) => T) => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ undefined }`; @@ -25,6 +26,10 @@ function tempTag1(...rest) { // Otherwise, the arrow functions' parameters will be typed as 'any', // and it is an error to invoke an any-typed value with type arguments, // so this test will error. +tempTag1 `${function (x) { + x(undefined); + return x; +}}${10}`; tempTag1 `${function (x) { x(undefined); return x; diff --git a/tests/baselines/reference/taggedTemplateContextualTyping1.types b/tests/baselines/reference/taggedTemplateContextualTyping1.types index a87d5eaa7a4..a6432d34f81 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping1.types +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.types @@ -47,6 +47,15 @@ function tempTag1(...rest: any[]): T { // Otherwise, the arrow functions' parameters will be typed as 'any', // and it is an error to invoke an any-typed value with type arguments, // so this test will error. +tempTag1 `${ x => { x(undefined); return x; } }${ 10 }`; +>tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; >tempTag1 : { (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, x: T): T; (templateStrs: TemplateStringsArray, f: (x: (p: T) => T) => (p: T) => T, h: (x: (p: T) => T) => (p: T) => T, x: T): T; } >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T diff --git a/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts new file mode 100644 index 00000000000..49dfe75ccc6 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts @@ -0,0 +1,29 @@ + +function fun(g: (x: T) => T, x: T): T; +function fun(g: (x: T) => T, h: (y: T) => T, x: T): T; +function fun(g: (x: T) => T, x: T): T { + return g(x); +} + +var a = fun(x => x, 10); +var b = fun((x => x), 10); +var c = fun(((x => x)), 10); +var d = fun((((x => x))), 10); + +var e = fun(x => x, x => x, 10); +var f = fun((x => x), (x => x), 10); +var g = fun(((x => x)), ((x => x)), 10); +var h = fun((((x => x))), ((x => x)), 10); + +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); +var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); +var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); +var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10); + +var lambda1: (x: number) => number = x => x; +var lambda2: (x: number) => number = (x => x); + +type ObjType = { x: (p: number) => string; y: (p: string) => number }; +var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; +var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts new file mode 100644 index 00000000000..5d235bff348 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts @@ -0,0 +1,35 @@ +// These tests ensure that in cases where it may *appear* that a value has a type, +// they actually are properly being contextually typed. The way we test this is +// that we invoke contextually typed arguments with type arguments. +// Since 'any' cannot be invoked with type arguments, we should get errors back. + +type FuncType = (x: (p: T) => T) => typeof x; + +function fun(f: FuncType, x: T): T; +function fun(f: FuncType, g: FuncType, x: T): T; +function fun(...rest: any[]): T { + return undefined; +} + +var a = fun(x => { x(undefined); return x; }, 10); +var b = fun((x => { x(undefined); return x; }), 10); +var c = fun(((x => { x(undefined); return x; })), 10); +var d = fun((((x => { x(undefined); return x; }))), 10); + +var e = fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10); +var f = fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10); +var g = fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10); +var h = fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10); + +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10); +var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10); +var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); +var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); + +var lambda1: (x: number) => number = x => { x(undefined); return x; }; +var lambda2: (x: number) => number = (x => { x(undefined); return x; }); + +type ObjType = { x: (p: number) => string; y: (p: string) => number }; +var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; +var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping3.ts b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping3.ts new file mode 100644 index 00000000000..004617c3d81 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping3.ts @@ -0,0 +1,21 @@ +// @target: ES6 + +// Contextual typing for parenthesized substitution expressions in tagged templates. + +/** + * tempFun - Can't have fun for too long. + */ +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; +function tempFun(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T { + return g(x); +} + +var a = tempFun `${ x => x } ${ 10 }` +var b = tempFun `${ (x => x) } ${ 10 }` +var c = tempFun `${ ((x => x)) } ${ 10 }` +var d = tempFun `${ x => x } ${ x => x } ${ 10 }` +var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }` +var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }` +var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }` +var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }` \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts index c15d911ee52..84562f788f3 100644 --- a/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts +++ b/tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts @@ -12,6 +12,7 @@ function tempTag1(...rest: any[]): T { // Otherwise, the arrow functions' parameters will be typed as 'any', // and it is an error to invoke an any-typed value with type arguments, // so this test will error. +tempTag1 `${ x => { x(undefined); return x; } }${ 10 }`; tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; tempTag1 `${ x => { x(undefined); return x; } }${ (y: (p: T) => T) => { y(undefined); return y } }${ undefined }`; tempTag1 `${ (x: (p: T) => T) => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ undefined }`; From 78bb71f837ef2677e1ac541370dd19e6637741ec Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 8 Jan 2015 16:43:37 -0800 Subject: [PATCH 39/93] Optimizing forEachChild function to not create closures --- src/compiler/parser.ts | 307 +++++++++++++++++++++-------------------- 1 file changed, 156 insertions(+), 151 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 00cd54b94eb..87f4c20c97d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -12,43 +12,48 @@ module ts { return new (getNodeConstructor(kind))(); } + function child(cbNode: (node: Node) => T, node: Node): T { + return node ? cbNode(node) : void 0; + } + + function children1(cbNodes: (nodes: Node[]) => T, nodes: Node[]) { + return nodes ? cbNodes(nodes) : void 0; + } + + function children2(cbNode: (node: Node) => T, nodes: Node[]) { + if (nodes) { + for (var i = 0, len = nodes.length; i < len; i++) { + var result = cbNode(nodes[i]) + if (result) { + return result; + } + } + } + } + // Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. export function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T { - function child(node: Node): T { - if (node) { - return cbNode(node); - } - } - function children(nodes: Node[]) { - if (nodes) { - if (cbNodes) { - return cbNodes(nodes); - } - - for (var i = 0, len = nodes.length; i < len; i++) { - var result = cbNode(nodes[i]) - if (result) { - return result; - } - } - - return undefined; - } - } if (!node) { return; } + if (cbNodes) { + var children = children1; + } + else { + cbNodes = cbNode; + children = children2; + } switch (node.kind) { case SyntaxKind.QualifiedName: - return child((node).left) || - child((node).right); + return child(cbNode, (node).left) || + child(cbNode, (node).right); case SyntaxKind.TypeParameter: - return child((node).name) || - child((node).constraint) || - child((node).expression); + return child(cbNode, (node).name) || + child(cbNode, (node).constraint) || + child(cbNode, (node).expression); case SyntaxKind.Parameter: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: @@ -56,22 +61,22 @@ module ts { case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: - return children(node.modifiers) || - child((node).propertyName) || - child((node).dotDotDotToken) || - child((node).name) || - child((node).questionToken) || - child((node).type) || - child((node).initializer); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).propertyName) || + child(cbNode, (node).dotDotDotToken) || + child(cbNode, (node).name) || + child(cbNode, (node).questionToken) || + child(cbNode, (node).type) || + child(cbNode, (node).initializer); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - return children(node.modifiers) || - children((node).typeParameters) || - children((node).parameters) || - child((node).type); + return children(cbNodes, node.modifiers) || + children(cbNodes, (node).typeParameters) || + children(cbNodes, (node).parameters) || + child(cbNode, (node).type); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: @@ -80,182 +85,182 @@ module ts { case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: case SyntaxKind.ArrowFunction: - return children(node.modifiers) || - child((node).asteriskToken) || - child((node).name) || - child((node).questionToken) || - children((node).typeParameters) || - children((node).parameters) || - child((node).type) || - child((node).body); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).asteriskToken) || + child(cbNode, (node).name) || + child(cbNode, (node).questionToken) || + children(cbNodes, (node).typeParameters) || + children(cbNodes, (node).parameters) || + child(cbNode, (node).type) || + child(cbNode, (node).body); case SyntaxKind.TypeReference: - return child((node).typeName) || - children((node).typeArguments); + return child(cbNode, (node).typeName) || + children(cbNodes, (node).typeArguments); case SyntaxKind.TypeQuery: - return child((node).exprName); + return child(cbNode, (node).exprName); case SyntaxKind.TypeLiteral: - return children((node).members); + return children(cbNodes, (node).members); case SyntaxKind.ArrayType: - return child((node).elementType); + return child(cbNode, (node).elementType); case SyntaxKind.TupleType: - return children((node).elementTypes); + return children(cbNodes, (node).elementTypes); case SyntaxKind.UnionType: - return children((node).types); + return children(cbNodes, (node).types); case SyntaxKind.ParenthesizedType: - return child((node).type); + return child(cbNode, (node).type); case SyntaxKind.ObjectBindingPattern: case SyntaxKind.ArrayBindingPattern: - return children((node).elements); + return children(cbNodes, (node).elements); case SyntaxKind.ArrayLiteralExpression: - return children((node).elements); + return children(cbNodes, (node).elements); case SyntaxKind.ObjectLiteralExpression: - return children((node).properties); + return children(cbNodes, (node).properties); case SyntaxKind.PropertyAccessExpression: - return child((node).expression) || - child((node).name); + return child(cbNode, (node).expression) || + child(cbNode, (node).name); case SyntaxKind.ElementAccessExpression: - return child((node).expression) || - child((node).argumentExpression); + return child(cbNode, (node).expression) || + child(cbNode, (node).argumentExpression); case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: - return child((node).expression) || - children((node).typeArguments) || - children((node).arguments); + return child(cbNode, (node).expression) || + children(cbNodes, (node).typeArguments) || + children(cbNodes, (node).arguments); case SyntaxKind.TaggedTemplateExpression: - return child((node).tag) || - child((node).template); + return child(cbNode, (node).tag) || + child(cbNode, (node).template); case SyntaxKind.TypeAssertionExpression: - return child((node).type) || - child((node).expression); + return child(cbNode, (node).type) || + child(cbNode, (node).expression); case SyntaxKind.ParenthesizedExpression: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.DeleteExpression: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.TypeOfExpression: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.VoidExpression: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.PrefixUnaryExpression: - return child((node).operand); + return child(cbNode, (node).operand); case SyntaxKind.YieldExpression: - return child((node).asteriskToken) || - child((node).expression); + return child(cbNode, (node).asteriskToken) || + child(cbNode, (node).expression); case SyntaxKind.PostfixUnaryExpression: - return child((node).operand); + return child(cbNode, (node).operand); case SyntaxKind.BinaryExpression: - return child((node).left) || - child((node).right); + return child(cbNode, (node).left) || + child(cbNode, (node).right); case SyntaxKind.ConditionalExpression: - return child((node).condition) || - child((node).whenTrue) || - child((node).whenFalse); + return child(cbNode, (node).condition) || + child(cbNode, (node).whenTrue) || + child(cbNode, (node).whenFalse); case SyntaxKind.SpreadElementExpression: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.Block: case SyntaxKind.ModuleBlock: - return children((node).statements); + return children(cbNodes, (node).statements); case SyntaxKind.SourceFile: - return children((node).statements) || - child((node).endOfFileToken); + return children(cbNodes, (node).statements) || + child(cbNode, (node).endOfFileToken); case SyntaxKind.VariableStatement: - return children(node.modifiers) || - child((node).declarationList); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).declarationList); case SyntaxKind.VariableDeclarationList: - return children((node).declarations); + return children(cbNodes, (node).declarations); case SyntaxKind.ExpressionStatement: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.IfStatement: - return child((node).expression) || - child((node).thenStatement) || - child((node).elseStatement); + return child(cbNode, (node).expression) || + child(cbNode, (node).thenStatement) || + child(cbNode, (node).elseStatement); case SyntaxKind.DoStatement: - return child((node).statement) || - child((node).expression); + return child(cbNode, (node).statement) || + child(cbNode, (node).expression); case SyntaxKind.WhileStatement: - return child((node).expression) || - child((node).statement); + return child(cbNode, (node).expression) || + child(cbNode, (node).statement); case SyntaxKind.ForStatement: - return child((node).initializer) || - child((node).condition) || - child((node).iterator) || - child((node).statement); + return child(cbNode, (node).initializer) || + child(cbNode, (node).condition) || + child(cbNode, (node).iterator) || + child(cbNode, (node).statement); case SyntaxKind.ForInStatement: - return child((node).initializer) || - child((node).expression) || - child((node).statement); + return child(cbNode, (node).initializer) || + child(cbNode, (node).expression) || + child(cbNode, (node).statement); case SyntaxKind.ContinueStatement: case SyntaxKind.BreakStatement: - return child((node).label); + return child(cbNode, (node).label); case SyntaxKind.ReturnStatement: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.WithStatement: - return child((node).expression) || - child((node).statement); + return child(cbNode, (node).expression) || + child(cbNode, (node).statement); case SyntaxKind.SwitchStatement: - return child((node).expression) || - children((node).clauses); + return child(cbNode, (node).expression) || + children(cbNodes, (node).clauses); case SyntaxKind.CaseClause: - return child((node).expression) || - children((node).statements); + return child(cbNode, (node).expression) || + children(cbNodes, (node).statements); case SyntaxKind.DefaultClause: - return children((node).statements); + return children(cbNodes, (node).statements); case SyntaxKind.LabeledStatement: - return child((node).label) || - child((node).statement); + return child(cbNode, (node).label) || + child(cbNode, (node).statement); case SyntaxKind.ThrowStatement: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.TryStatement: - return child((node).tryBlock) || - child((node).catchClause) || - child((node).finallyBlock); + return child(cbNode, (node).tryBlock) || + child(cbNode, (node).catchClause) || + child(cbNode, (node).finallyBlock); case SyntaxKind.CatchClause: - return child((node).name) || - child((node).type) || - child((node).block); + return child(cbNode, (node).name) || + child(cbNode, (node).type) || + child(cbNode, (node).block); case SyntaxKind.ClassDeclaration: - return children(node.modifiers) || - child((node).name) || - children((node).typeParameters) || - children((node).heritageClauses) || - children((node).members); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).name) || + children(cbNodes, (node).typeParameters) || + children(cbNodes, (node).heritageClauses) || + children(cbNodes, (node).members); case SyntaxKind.InterfaceDeclaration: - return children(node.modifiers) || - child((node).name) || - children((node).typeParameters) || - children((node).heritageClauses) || - children((node).members); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).name) || + children(cbNodes, (node).typeParameters) || + children(cbNodes, (node).heritageClauses) || + children(cbNodes, (node).members); case SyntaxKind.TypeAliasDeclaration: - return children(node.modifiers) || - child((node).name) || - child((node).type); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).name) || + child(cbNode, (node).type); case SyntaxKind.EnumDeclaration: - return children(node.modifiers) || - child((node).name) || - children((node).members); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).name) || + children(cbNodes, (node).members); case SyntaxKind.EnumMember: - return child((node).name) || - child((node).initializer); + return child(cbNode, (node).name) || + child(cbNode, (node).initializer); case SyntaxKind.ModuleDeclaration: - return children(node.modifiers) || - child((node).name) || - child((node).body); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).name) || + child(cbNode, (node).body); case SyntaxKind.ImportDeclaration: - return children(node.modifiers) || - child((node).name) || - child((node).moduleReference); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).name) || + child(cbNode, (node).moduleReference); case SyntaxKind.ExportAssignment: - return children(node.modifiers) || - child((node).exportName); + return children(cbNodes, node.modifiers) || + child(cbNode, (node).exportName); case SyntaxKind.TemplateExpression: - return child((node).head) || children((node).templateSpans); + return child(cbNode, (node).head) || children(cbNodes, (node).templateSpans); case SyntaxKind.TemplateSpan: - return child((node).expression) || child((node).literal); + return child(cbNode, (node).expression) || child(cbNode, (node).literal); case SyntaxKind.ComputedPropertyName: - return child((node).expression); + return child(cbNode, (node).expression); case SyntaxKind.HeritageClause: - return children((node).types); + return children(cbNodes, (node).types); case SyntaxKind.ExternalModuleReference: - return child((node).expression); + return child(cbNode, (node).expression); } } From f5f4e28f4f6105292349b8a10f1f316ae889e528 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Jan 2015 16:53:26 -0800 Subject: [PATCH 40/93] Fixed portion of test. --- .../parenthesizedContexualTyping2.errors.txt | 13 +++++-------- .../reference/parenthesizedContexualTyping2.js | 4 ++-- .../parenthesizedContexualTyping2.ts | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt b/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt index 236dfee0979..c651110071d 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt +++ b/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt @@ -12,11 +12,10 @@ tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTypin tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(27,44): error TS2347: Untyped function calls may not accept type arguments. tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,46): error TS2347: Untyped function calls may not accept type arguments. tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,114): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(30,45): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(31,46): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(31,33): error TS2347: Untyped function calls may not accept type arguments. -==== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts (16 errors) ==== +==== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts (15 errors) ==== // These tests ensure that in cases where it may *appear* that a value has a type, // they actually are properly being contextually typed. The way we test this is // that we invoke contextually typed arguments with type arguments. @@ -74,11 +73,9 @@ tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTypin ~~~~~~~~~~~~~~~~~~~~ !!! error TS2347: Untyped function calls may not accept type arguments. - var lambda1: (x: number) => number = x => { x(undefined); return x; }; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - var lambda2: (x: number) => number = (x => { x(undefined); return x; }); - ~~~~~~~~~~~~~~~~~~~~ + var lambda1: FuncType = x => { x(undefined); return x; }; + var lambda2: FuncType = (x => { x(undefined); return x; }); + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2347: Untyped function calls may not accept type arguments. type ObjType = { x: (p: number) => string; y: (p: string) => number }; diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.js b/tests/baselines/reference/parenthesizedContexualTyping2.js index 724cbaba2b6..2ce2e35c906 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.js +++ b/tests/baselines/reference/parenthesizedContexualTyping2.js @@ -28,8 +28,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); -var lambda1: (x: number) => number = x => { x(undefined); return x; }; -var lambda2: (x: number) => number = (x => { x(undefined); return x; }); +var lambda1: FuncType = x => { x(undefined); return x; }; +var lambda2: FuncType = (x => { x(undefined); return x; }); type ObjType = { x: (p: number) => string; y: (p: string) => number }; var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; diff --git a/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts index 5d235bff348..87f3dc6a580 100644 --- a/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts +++ b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts @@ -27,8 +27,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); -var lambda1: (x: number) => number = x => { x(undefined); return x; }; -var lambda2: (x: number) => number = (x => { x(undefined); return x; }); +var lambda1: FuncType = x => { x(undefined); return x; }; +var lambda2: FuncType = (x => { x(undefined); return x; }); type ObjType = { x: (p: number) => string; y: (p: string) => number }; var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; From bdfb655d6659d913f09067cad859b3bc70bb33aa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 8 Jan 2015 18:46:48 -0800 Subject: [PATCH 41/93] Renaming helpers and cleaning up logic --- src/compiler/parser.ts | 279 ++++++++++++++++++++--------------------- 1 file changed, 137 insertions(+), 142 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 87f4c20c97d..3fd2bbf4676 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -12,18 +12,18 @@ module ts { return new (getNodeConstructor(kind))(); } - function child(cbNode: (node: Node) => T, node: Node): T { + function visitNode(cbNode: (node: Node) => T, node: Node): T { return node ? cbNode(node) : void 0; } - function children1(cbNodes: (nodes: Node[]) => T, nodes: Node[]) { + function visitNodeArray(cbNodes: (nodes: Node[]) => T, nodes: Node[]) { return nodes ? cbNodes(nodes) : void 0; } - function children2(cbNode: (node: Node) => T, nodes: Node[]) { + function visitEachNode(cbNode: (node: Node) => T, nodes: Node[]) { if (nodes) { for (var i = 0, len = nodes.length; i < len; i++) { - var result = cbNode(nodes[i]) + var result = cbNode(nodes[i]); if (result) { return result; } @@ -35,25 +35,20 @@ module ts { // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. - export function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T { + export function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T { if (!node) { return; } - if (cbNodes) { - var children = children1; - } - else { - cbNodes = cbNode; - children = children2; - } + var visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; switch (node.kind) { case SyntaxKind.QualifiedName: - return child(cbNode, (node).left) || - child(cbNode, (node).right); + return visitNode(cbNode, (node).left) || + visitNode(cbNode, (node).right); case SyntaxKind.TypeParameter: - return child(cbNode, (node).name) || - child(cbNode, (node).constraint) || - child(cbNode, (node).expression); + return visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).constraint) || + visitNode(cbNode, (node).expression); case SyntaxKind.Parameter: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: @@ -61,22 +56,22 @@ module ts { case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).propertyName) || - child(cbNode, (node).dotDotDotToken) || - child(cbNode, (node).name) || - child(cbNode, (node).questionToken) || - child(cbNode, (node).type) || - child(cbNode, (node).initializer); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).propertyName) || + visitNode(cbNode, (node).dotDotDotToken) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).questionToken) || + visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).initializer); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: - return children(cbNodes, node.modifiers) || - children(cbNodes, (node).typeParameters) || - children(cbNodes, (node).parameters) || - child(cbNode, (node).type); + return visitNodes(cbNodes, node.modifiers) || + visitNodes(cbNodes, (node).typeParameters) || + visitNodes(cbNodes, (node).parameters) || + visitNode(cbNode, (node).type); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: @@ -85,182 +80,182 @@ module ts { case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: case SyntaxKind.ArrowFunction: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).asteriskToken) || - child(cbNode, (node).name) || - child(cbNode, (node).questionToken) || - children(cbNodes, (node).typeParameters) || - children(cbNodes, (node).parameters) || - child(cbNode, (node).type) || - child(cbNode, (node).body); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).asteriskToken) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).questionToken) || + visitNodes(cbNodes, (node).typeParameters) || + visitNodes(cbNodes, (node).parameters) || + visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).body); case SyntaxKind.TypeReference: - return child(cbNode, (node).typeName) || - children(cbNodes, (node).typeArguments); + return visitNode(cbNode, (node).typeName) || + visitNodes(cbNodes, (node).typeArguments); case SyntaxKind.TypeQuery: - return child(cbNode, (node).exprName); + return visitNode(cbNode, (node).exprName); case SyntaxKind.TypeLiteral: - return children(cbNodes, (node).members); + return visitNodes(cbNodes, (node).members); case SyntaxKind.ArrayType: - return child(cbNode, (node).elementType); + return visitNode(cbNode, (node).elementType); case SyntaxKind.TupleType: - return children(cbNodes, (node).elementTypes); + return visitNodes(cbNodes, (node).elementTypes); case SyntaxKind.UnionType: - return children(cbNodes, (node).types); + return visitNodes(cbNodes, (node).types); case SyntaxKind.ParenthesizedType: - return child(cbNode, (node).type); + return visitNode(cbNode, (node).type); case SyntaxKind.ObjectBindingPattern: case SyntaxKind.ArrayBindingPattern: - return children(cbNodes, (node).elements); + return visitNodes(cbNodes, (node).elements); case SyntaxKind.ArrayLiteralExpression: - return children(cbNodes, (node).elements); + return visitNodes(cbNodes, (node).elements); case SyntaxKind.ObjectLiteralExpression: - return children(cbNodes, (node).properties); + return visitNodes(cbNodes, (node).properties); case SyntaxKind.PropertyAccessExpression: - return child(cbNode, (node).expression) || - child(cbNode, (node).name); + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).name); case SyntaxKind.ElementAccessExpression: - return child(cbNode, (node).expression) || - child(cbNode, (node).argumentExpression); + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).argumentExpression); case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: - return child(cbNode, (node).expression) || - children(cbNodes, (node).typeArguments) || - children(cbNodes, (node).arguments); + return visitNode(cbNode, (node).expression) || + visitNodes(cbNodes, (node).typeArguments) || + visitNodes(cbNodes, (node).arguments); case SyntaxKind.TaggedTemplateExpression: - return child(cbNode, (node).tag) || - child(cbNode, (node).template); + return visitNode(cbNode, (node).tag) || + visitNode(cbNode, (node).template); case SyntaxKind.TypeAssertionExpression: - return child(cbNode, (node).type) || - child(cbNode, (node).expression); + return visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).expression); case SyntaxKind.ParenthesizedExpression: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.DeleteExpression: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.TypeOfExpression: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.VoidExpression: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.PrefixUnaryExpression: - return child(cbNode, (node).operand); + return visitNode(cbNode, (node).operand); case SyntaxKind.YieldExpression: - return child(cbNode, (node).asteriskToken) || - child(cbNode, (node).expression); + return visitNode(cbNode, (node).asteriskToken) || + visitNode(cbNode, (node).expression); case SyntaxKind.PostfixUnaryExpression: - return child(cbNode, (node).operand); + return visitNode(cbNode, (node).operand); case SyntaxKind.BinaryExpression: - return child(cbNode, (node).left) || - child(cbNode, (node).right); + return visitNode(cbNode, (node).left) || + visitNode(cbNode, (node).right); case SyntaxKind.ConditionalExpression: - return child(cbNode, (node).condition) || - child(cbNode, (node).whenTrue) || - child(cbNode, (node).whenFalse); + return visitNode(cbNode, (node).condition) || + visitNode(cbNode, (node).whenTrue) || + visitNode(cbNode, (node).whenFalse); case SyntaxKind.SpreadElementExpression: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.Block: case SyntaxKind.ModuleBlock: - return children(cbNodes, (node).statements); + return visitNodes(cbNodes, (node).statements); case SyntaxKind.SourceFile: - return children(cbNodes, (node).statements) || - child(cbNode, (node).endOfFileToken); + return visitNodes(cbNodes, (node).statements) || + visitNode(cbNode, (node).endOfFileToken); case SyntaxKind.VariableStatement: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).declarationList); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).declarationList); case SyntaxKind.VariableDeclarationList: - return children(cbNodes, (node).declarations); + return visitNodes(cbNodes, (node).declarations); case SyntaxKind.ExpressionStatement: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.IfStatement: - return child(cbNode, (node).expression) || - child(cbNode, (node).thenStatement) || - child(cbNode, (node).elseStatement); + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).thenStatement) || + visitNode(cbNode, (node).elseStatement); case SyntaxKind.DoStatement: - return child(cbNode, (node).statement) || - child(cbNode, (node).expression); + return visitNode(cbNode, (node).statement) || + visitNode(cbNode, (node).expression); case SyntaxKind.WhileStatement: - return child(cbNode, (node).expression) || - child(cbNode, (node).statement); + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).statement); case SyntaxKind.ForStatement: - return child(cbNode, (node).initializer) || - child(cbNode, (node).condition) || - child(cbNode, (node).iterator) || - child(cbNode, (node).statement); + return visitNode(cbNode, (node).initializer) || + visitNode(cbNode, (node).condition) || + visitNode(cbNode, (node).iterator) || + visitNode(cbNode, (node).statement); case SyntaxKind.ForInStatement: - return child(cbNode, (node).initializer) || - child(cbNode, (node).expression) || - child(cbNode, (node).statement); + return visitNode(cbNode, (node).initializer) || + visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).statement); case SyntaxKind.ContinueStatement: case SyntaxKind.BreakStatement: - return child(cbNode, (node).label); + return visitNode(cbNode, (node).label); case SyntaxKind.ReturnStatement: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.WithStatement: - return child(cbNode, (node).expression) || - child(cbNode, (node).statement); + return visitNode(cbNode, (node).expression) || + visitNode(cbNode, (node).statement); case SyntaxKind.SwitchStatement: - return child(cbNode, (node).expression) || - children(cbNodes, (node).clauses); + return visitNode(cbNode, (node).expression) || + visitNodes(cbNodes, (node).clauses); case SyntaxKind.CaseClause: - return child(cbNode, (node).expression) || - children(cbNodes, (node).statements); + return visitNode(cbNode, (node).expression) || + visitNodes(cbNodes, (node).statements); case SyntaxKind.DefaultClause: - return children(cbNodes, (node).statements); + return visitNodes(cbNodes, (node).statements); case SyntaxKind.LabeledStatement: - return child(cbNode, (node).label) || - child(cbNode, (node).statement); + return visitNode(cbNode, (node).label) || + visitNode(cbNode, (node).statement); case SyntaxKind.ThrowStatement: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.TryStatement: - return child(cbNode, (node).tryBlock) || - child(cbNode, (node).catchClause) || - child(cbNode, (node).finallyBlock); + return visitNode(cbNode, (node).tryBlock) || + visitNode(cbNode, (node).catchClause) || + visitNode(cbNode, (node).finallyBlock); case SyntaxKind.CatchClause: - return child(cbNode, (node).name) || - child(cbNode, (node).type) || - child(cbNode, (node).block); + return visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).block); case SyntaxKind.ClassDeclaration: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).name) || - children(cbNodes, (node).typeParameters) || - children(cbNodes, (node).heritageClauses) || - children(cbNodes, (node).members); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNodes(cbNodes, (node).typeParameters) || + visitNodes(cbNodes, (node).heritageClauses) || + visitNodes(cbNodes, (node).members); case SyntaxKind.InterfaceDeclaration: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).name) || - children(cbNodes, (node).typeParameters) || - children(cbNodes, (node).heritageClauses) || - children(cbNodes, (node).members); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNodes(cbNodes, (node).typeParameters) || + visitNodes(cbNodes, (node).heritageClauses) || + visitNodes(cbNodes, (node).members); case SyntaxKind.TypeAliasDeclaration: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).name) || - child(cbNode, (node).type); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).type); case SyntaxKind.EnumDeclaration: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).name) || - children(cbNodes, (node).members); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNodes(cbNodes, (node).members); case SyntaxKind.EnumMember: - return child(cbNode, (node).name) || - child(cbNode, (node).initializer); + return visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).initializer); case SyntaxKind.ModuleDeclaration: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).name) || - child(cbNode, (node).body); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).body); case SyntaxKind.ImportDeclaration: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).name) || - child(cbNode, (node).moduleReference); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).moduleReference); case SyntaxKind.ExportAssignment: - return children(cbNodes, node.modifiers) || - child(cbNode, (node).exportName); + return visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, (node).exportName); case SyntaxKind.TemplateExpression: - return child(cbNode, (node).head) || children(cbNodes, (node).templateSpans); + return visitNode(cbNode, (node).head) || visitNodes(cbNodes, (node).templateSpans); case SyntaxKind.TemplateSpan: - return child(cbNode, (node).expression) || child(cbNode, (node).literal); + return visitNode(cbNode, (node).expression) || visitNode(cbNode, (node).literal); case SyntaxKind.ComputedPropertyName: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); case SyntaxKind.HeritageClause: - return children(cbNodes, (node).types); + return visitNodes(cbNodes, (node).types); case SyntaxKind.ExternalModuleReference: - return child(cbNode, (node).expression); + return visitNode(cbNode, (node).expression); } } From a8cf58939bb7aabb36ee6c43bf0d36ee33a2ff3c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 9 Jan 2015 06:52:24 -0800 Subject: [PATCH 42/93] Adding comment --- src/compiler/parser.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3fd2bbf4676..b70c4a7a1d5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -13,11 +13,15 @@ module ts { } function visitNode(cbNode: (node: Node) => T, node: Node): T { - return node ? cbNode(node) : void 0; + if (node) { + return cbNode(node); + } } function visitNodeArray(cbNodes: (nodes: Node[]) => T, nodes: Node[]) { - return nodes ? cbNodes(nodes) : void 0; + if (nodes) { + return cbNodes(nodes); + } } function visitEachNode(cbNode: (node: Node) => T, nodes: Node[]) { @@ -39,6 +43,9 @@ module ts { if (!node) { return; } + // The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray + // callback parameters, but that causes a closure allocation for each invocation with noticeable effects + // on performance. var visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { From cd246992ed4de56d700de735a2c823bb9278bea0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 9 Jan 2015 14:19:24 -0800 Subject: [PATCH 43/93] Clarified comment in test. --- .../parenthesizedContexualTyping2.errors.txt | 31 ++++++++++--------- .../parenthesizedContexualTyping2.js | 6 ++-- .../parenthesizedContexualTyping2.ts | 3 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt b/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt index c651110071d..e4a9f0df708 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt +++ b/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt @@ -1,25 +1,26 @@ -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(15,21): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(16,22): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(17,23): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(20,21): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(20,64): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,22): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,67): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,23): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,69): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(25,43): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(26,44): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(16,21): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(17,22): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(18,23): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,21): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,64): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,22): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,67): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(23,23): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(23,69): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(26,43): error TS2347: Untyped function calls may not accept type arguments. tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(27,44): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,46): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,114): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(31,33): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,44): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(29,46): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(29,114): error TS2347: Untyped function calls may not accept type arguments. +tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(32,33): error TS2347: Untyped function calls may not accept type arguments. ==== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts (15 errors) ==== // These tests ensure that in cases where it may *appear* that a value has a type, // they actually are properly being contextually typed. The way we test this is // that we invoke contextually typed arguments with type arguments. - // Since 'any' cannot be invoked with type arguments, we should get errors back. + // Since 'any' cannot be invoked with type arguments, we should get errors + // back if contextual typing is not taking effect. type FuncType = (x: (p: T) => T) => typeof x; diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.js b/tests/baselines/reference/parenthesizedContexualTyping2.js index 2ce2e35c906..d5e4e0ebe8f 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.js +++ b/tests/baselines/reference/parenthesizedContexualTyping2.js @@ -2,7 +2,8 @@ // These tests ensure that in cases where it may *appear* that a value has a type, // they actually are properly being contextually typed. The way we test this is // that we invoke contextually typed arguments with type arguments. -// Since 'any' cannot be invoked with type arguments, we should get errors back. +// Since 'any' cannot be invoked with type arguments, we should get errors +// back if contextual typing is not taking effect. type FuncType = (x: (p: T) => T) => typeof x; @@ -39,7 +40,8 @@ var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); // These tests ensure that in cases where it may *appear* that a value has a type, // they actually are properly being contextually typed. The way we test this is // that we invoke contextually typed arguments with type arguments. -// Since 'any' cannot be invoked with type arguments, we should get errors back. +// Since 'any' cannot be invoked with type arguments, we should get errors +// back if contextual typing is not taking effect. function fun() { var rest = []; for (var _i = 0; _i < arguments.length; _i++) { diff --git a/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts index 87f3dc6a580..15acbf3e134 100644 --- a/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts +++ b/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts @@ -1,7 +1,8 @@ // These tests ensure that in cases where it may *appear* that a value has a type, // they actually are properly being contextually typed. The way we test this is // that we invoke contextually typed arguments with type arguments. -// Since 'any' cannot be invoked with type arguments, we should get errors back. +// Since 'any' cannot be invoked with type arguments, we should get errors +// back if contextual typing is not taking effect. type FuncType = (x: (p: T) => T) => typeof x; From 22174a17c64319942f56da8d19ff97f3f14f8f54 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 9 Jan 2015 15:10:32 -0800 Subject: [PATCH 44/93] Contextually type parenthesized expressions. --- src/compiler/checker.ts | 4 + tests/baselines/reference/castTest.types | 24 +- ...lTypingWithFixedTypeParameters1.errors.txt | 12 +- ...alOrExpressionIsNotContextuallyTyped.types | 18 +- .../parenthesizedContexualTyping1.types | 224 +++++------ .../parenthesizedContexualTyping2.errors.txt | 84 ----- .../parenthesizedContexualTyping2.types | 350 ++++++++++++++++++ .../parenthesizedContexualTyping3.types | 78 ++-- tests/cases/fourslash/assertContextualType.ts | 2 +- tests/cases/fourslash/contextualTyping.ts | 26 +- 10 files changed, 550 insertions(+), 272 deletions(-) delete mode 100644 tests/baselines/reference/parenthesizedContexualTyping2.errors.txt create mode 100644 tests/baselines/reference/parenthesizedContexualTyping2.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 21633d97a3e..0cf6413370f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3337,6 +3337,8 @@ module ts { case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: return isContextSensitiveFunctionLikeDeclaration(node); + case SyntaxKind.ParenthesizedExpression: + return isContextSensitive((node).expression); } return false; @@ -5226,6 +5228,8 @@ module ts { case SyntaxKind.TemplateSpan: Debug.assert(parent.parent.kind === SyntaxKind.TemplateExpression); return getContextualTypeForSubstitutionExpression(parent.parent, node); + case SyntaxKind.ParenthesizedExpression: + return getContextualType(parent); } return undefined; } diff --git a/tests/baselines/reference/castTest.types b/tests/baselines/reference/castTest.types index 501ff5a3cbe..8250bec362d 100644 --- a/tests/baselines/reference/castTest.types +++ b/tests/baselines/reference/castTest.types @@ -65,8 +65,8 @@ var p_cast = ({ >p_cast : Point > ({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : Point >Point : Point ->({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : { x: number; y: number; add: (dx: any, dy: any) => Point; mult: (p: any) => any; } ->{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }} : { x: number; y: number; add: (dx: any, dy: any) => Point; mult: (p: any) => any; } +>({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; } +>{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }} : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; } x: 0, >x : number @@ -75,10 +75,10 @@ var p_cast = ({ >y : number add: function(dx, dy) { ->add : (dx: any, dy: any) => Point ->function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: any, dy: any) => Point ->dx : any ->dy : any +>add : (dx: number, dy: number) => Point +>function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: number, dy: number) => Point +>dx : number +>dy : number return new Point(this.x + dx, this.y + dy); >new Point(this.x + dx, this.y + dy) : Point @@ -87,19 +87,19 @@ var p_cast = ({ >this.x : any >this : any >x : any ->dx : any +>dx : number >this.y + dy : any >this.y : any >this : any >y : any ->dy : any +>dy : number }, mult: function(p) { return p; } ->mult : (p: any) => any ->function(p) { return p; } : (p: any) => any ->p : any ->p : any +>mult : (p: Point) => Point +>function(p) { return p; } : (p: Point) => Point +>p : Point +>p : Point }) diff --git a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt index 972b4bb9188..adfb1c68b7a 100644 --- a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt +++ b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt @@ -1,9 +1,17 @@ tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'. +tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'T'. +tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,32): error TS2339: Property 'foo' does not exist on type 'T'. -==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (1 errors) ==== +==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (3 errors) ==== var f10: (x: T, b: () => (a: T) => void, y: T) => T; f10('', () => a => a.foo, ''); // a is string ~~~ !!! error TS2339: Property 'foo' does not exist on type 'string'. - var r9 = f10('', () => (a => a.foo), 1); // error \ No newline at end of file + var r9 = f10('', () => (a => a.foo), 1); // error + ~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'T'. + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'T'. \ No newline at end of file diff --git a/tests/baselines/reference/logicalOrExpressionIsNotContextuallyTyped.types b/tests/baselines/reference/logicalOrExpressionIsNotContextuallyTyped.types index f450307758d..72fd6281ba9 100644 --- a/tests/baselines/reference/logicalOrExpressionIsNotContextuallyTyped.types +++ b/tests/baselines/reference/logicalOrExpressionIsNotContextuallyTyped.types @@ -11,14 +11,14 @@ var a: (a: string) => string; // bug 786110 var r = a || ((a) => a.toLowerCase()); ->r : (a: any) => any ->a || ((a) => a.toLowerCase()) : (a: any) => any +>r : (a: string) => string +>a || ((a) => a.toLowerCase()) : (a: string) => string >a : (a: string) => string ->((a) => a.toLowerCase()) : (a: any) => any ->(a) => a.toLowerCase() : (a: any) => any ->a : any ->a.toLowerCase() : any ->a.toLowerCase : any ->a : any ->toLowerCase : any +>((a) => a.toLowerCase()) : (a: string) => string +>(a) => a.toLowerCase() : (a: string) => string +>a : string +>a.toLowerCase() : string +>a.toLowerCase : () => string +>a : string +>toLowerCase : () => string diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index c8685206c47..60020fd8eb2 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -52,34 +52,34 @@ var a = fun(x => x, 10); >x : number var b = fun((x => x), 10); ->b : any ->fun((x => x), 10) : any +>b : number +>fun((x => x), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var c = fun(((x => x)), 10); ->c : any ->fun(((x => x)), 10) : any +>c : number +>fun(((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var d = fun((((x => x))), 10); ->d : any ->fun((((x => x))), 10) : any +>d : number +>fun((((x => x))), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(((x => x))) : (x: any) => any ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>(((x => x))) : (x: number) => number +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var e = fun(x => x, x => x, 10); >e : number @@ -93,106 +93,106 @@ var e = fun(x => x, x => x, 10); >x : number var f = fun((x => x), (x => x), 10); ->f : any ->fun((x => x), (x => x), 10) : any +>f : number +>fun((x => x), (x => x), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var g = fun(((x => x)), ((x => x)), 10); ->g : any ->fun(((x => x)), ((x => x)), 10) : any +>g : number +>fun(((x => x)), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var h = fun((((x => x))), ((x => x)), 10); ->h : any ->fun((((x => x))), ((x => x)), 10) : any +>h : number +>fun((((x => x))), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(((x => x))) : (x: any) => any ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>(((x => x))) : (x: number) => number +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number // Ternaries in parens var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >i : any >fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : any >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => x : x => undefined) : (x: any) => any ->Math.random() < 0.5 ? x => x : x => undefined : (x: any) => any +>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any +>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number >Math : Math >random : () => number ->x => x : (x: any) => any ->x : any ->x : any ->x => undefined : (x: any) => any ->x : any +>x => x : (x: number) => number +>x : number +>x : number +>x => undefined : (x: number) => any +>x : number >undefined : undefined var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >j : any >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : any >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: any) => any ->Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: any) => any +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number >Math : Math >random : () => number ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any ->(x => undefined) : (x: any) => any ->x => undefined : (x: any) => any ->x : any +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number +>(x => undefined) : (x: number) => any +>x => undefined : (x: number) => any +>x : number >undefined : undefined var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >k : any >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : any >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: any) => any ->Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: any) => any +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number >Math : Math >random : () => number ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any ->(x => undefined) : (x: any) => any ->x => undefined : (x: any) => any ->x : any +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number +>(x => undefined) : (x: number) => any +>x => undefined : (x: number) => any +>x : number >undefined : undefined >x => x : (x: any) => any >x : any @@ -202,29 +202,29 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >l : any >fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : any >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: any) => any ->(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: any) => any ->Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: any) => any +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number >Math : Math >random : () => number ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any ->((x => undefined)) : (x: any) => any ->(x => undefined) : (x: any) => any ->x => undefined : (x: any) => any ->x : any +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number +>((x => undefined)) : (x: number) => any +>(x => undefined) : (x: number) => any +>x => undefined : (x: number) => any +>x : number >undefined : undefined ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var lambda1: (x: number) => number = x => x; >lambda1 : (x: number) => number @@ -236,10 +236,10 @@ var lambda1: (x: number) => number = x => x; var lambda2: (x: number) => number = (x => x); >lambda2 : (x: number) => number >x : number ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number type ObjType = { x: (p: number) => string; y: (p: string) => number }; >ObjType : { x: (p: number) => string; y: (p: string) => number; } @@ -270,20 +270,20 @@ var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); >obj2 : { x: (p: number) => string; y: (p: string) => number; } >ObjType : { x: (p: number) => string; y: (p: string) => number; } ->({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: any) => any; y: (y: any) => any; } ->{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: any) => any; y: (y: any) => any; } ->x : (x: any) => any ->x => (x, undefined) : (x: any) => any ->x : any +>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; } +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } +>x : (x: number) => any +>x => (x, undefined) : (x: number) => any +>x : number >(x, undefined) : undefined >x, undefined : undefined ->x : any +>x : number >undefined : undefined ->y : (y: any) => any ->y => (y, undefined) : (y: any) => any ->y : any +>y : (y: string) => any +>y => (y, undefined) : (y: string) => any +>y : string >(y, undefined) : undefined >y, undefined : undefined ->y : any +>y : string >undefined : undefined diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt b/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt deleted file mode 100644 index e4a9f0df708..00000000000 --- a/tests/baselines/reference/parenthesizedContexualTyping2.errors.txt +++ /dev/null @@ -1,84 +0,0 @@ -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(16,21): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(17,22): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(18,23): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,21): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(21,64): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,22): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(22,67): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(23,23): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(23,69): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(26,43): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(27,44): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(28,44): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(29,46): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(29,114): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts(32,33): error TS2347: Untyped function calls may not accept type arguments. - - -==== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts (15 errors) ==== - // These tests ensure that in cases where it may *appear* that a value has a type, - // they actually are properly being contextually typed. The way we test this is - // that we invoke contextually typed arguments with type arguments. - // Since 'any' cannot be invoked with type arguments, we should get errors - // back if contextual typing is not taking effect. - - type FuncType = (x: (p: T) => T) => typeof x; - - function fun(f: FuncType, x: T): T; - function fun(f: FuncType, g: FuncType, x: T): T; - function fun(...rest: any[]): T { - return undefined; - } - - var a = fun(x => { x(undefined); return x; }, 10); - var b = fun((x => { x(undefined); return x; }), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - var c = fun(((x => { x(undefined); return x; })), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - var d = fun((((x => { x(undefined); return x; }))), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - - var e = fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10); - var f = fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - var g = fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - var h = fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - - // Ternaries in parens - var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - - var lambda1: FuncType = x => { x(undefined); return x; }; - var lambda2: FuncType = (x => { x(undefined); return x; }); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2347: Untyped function calls may not accept type arguments. - - type ObjType = { x: (p: number) => string; y: (p: string) => number }; - var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; - var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); \ No newline at end of file diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types new file mode 100644 index 00000000000..6824cc0f6e9 --- /dev/null +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -0,0 +1,350 @@ +=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts === +// These tests ensure that in cases where it may *appear* that a value has a type, +// they actually are properly being contextually typed. The way we test this is +// that we invoke contextually typed arguments with type arguments. +// Since 'any' cannot be invoked with type arguments, we should get errors +// back if contextual typing is not taking effect. + +type FuncType = (x: (p: T) => T) => typeof x; +>FuncType : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>T : T +>p : T +>T : T +>T : T +>x : (p: T) => T + +function fun(f: FuncType, x: T): T; +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>T : T +>f : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T +>x : T +>T : T +>T : T + +function fun(f: FuncType, g: FuncType, x: T): T; +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>T : T +>f : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T +>g : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T +>x : T +>T : T +>T : T + +function fun(...rest: any[]): T { +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>T : T +>rest : any[] +>T : T + + return undefined; +>undefined : undefined +} + +var a = fun(x => { x(undefined); return x; }, 10); +>a : number +>fun(x => { x(undefined); return x; }, 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var b = fun((x => { x(undefined); return x; }), 10); +>b : number +>fun((x => { x(undefined); return x; }), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var c = fun(((x => { x(undefined); return x; })), 10); +>c : number +>fun(((x => { x(undefined); return x; })), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var d = fun((((x => { x(undefined); return x; }))), 10); +>d : number +>fun((((x => { x(undefined); return x; }))), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(((x => { x(undefined); return x; }))) : (x: (p: T) => T) => (p: T) => T +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var e = fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10); +>e : number +>fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var f = fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10); +>f : number +>fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var g = fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10); +>g : number +>fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var h = fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10); +>h : number +>fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(((x => { x(undefined); return x; }))) : (x: (p: T) => T) => (p: T) => T +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +// Ternaries in parens +var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10); +>i : number +>fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>x => undefined : (x: (p: T) => T) => any +>x : (p: T) => T +>undefined : undefined + +var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10); +>j : number +>fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>(x => undefined) : (x: (p: T) => T) => any +>x => undefined : (x: (p: T) => T) => any +>x : (p: T) => T +>undefined : undefined + +var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); +>k : number +>fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>(x => undefined) : (x: (p: T) => T) => any +>x => undefined : (x: (p: T) => T) => any +>x : (p: T) => T +>undefined : undefined +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); +>l : number +>fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : number +>fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } +>((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T +>((x => undefined)) : (x: (p: T) => T) => any +>(x => undefined) : (x: (p: T) => T) => any +>x => undefined : (x: (p: T) => T) => any +>x : (p: T) => T +>undefined : undefined +>((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var lambda1: FuncType = x => { x(undefined); return x; }; +>lambda1 : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +var lambda2: FuncType = (x => { x(undefined); return x; }); +>lambda2 : (x: (p: T) => T) => (p: T) => T +>FuncType : (x: (p: T) => T) => (p: T) => T +>(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T +>x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T +>x : (p: T) => T +>x(undefined) : number +>x : (p: T) => T +>undefined : undefined +>x : (p: T) => T + +type ObjType = { x: (p: number) => string; y: (p: string) => number }; +>ObjType : { x: (p: number) => string; y: (p: string) => number; } +>x : (p: number) => string +>p : number +>y : (p: string) => number +>p : string + +var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; +>obj1 : { x: (p: number) => string; y: (p: string) => number; } +>ObjType : { x: (p: number) => string; y: (p: string) => number; } +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } +>x : (x: number) => any +>x => (x, undefined) : (x: number) => any +>x : number +>(x, undefined) : undefined +>x, undefined : undefined +>x : number +>undefined : undefined +>y : (y: string) => any +>y => (y, undefined) : (y: string) => any +>y : string +>(y, undefined) : undefined +>y, undefined : undefined +>y : string +>undefined : undefined + +var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); +>obj2 : { x: (p: number) => string; y: (p: string) => number; } +>ObjType : { x: (p: number) => string; y: (p: string) => number; } +>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; } +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } +>x : (x: number) => any +>x => (x, undefined) : (x: number) => any +>x : number +>(x, undefined) : undefined +>x, undefined : undefined +>x : number +>undefined : undefined +>y : (y: string) => any +>y => (y, undefined) : (y: string) => any +>y : string +>(y, undefined) : undefined +>y, undefined : undefined +>y : string +>undefined : undefined + diff --git a/tests/baselines/reference/parenthesizedContexualTyping3.types b/tests/baselines/reference/parenthesizedContexualTyping3.types index 6f9f24ef90b..26c0207e523 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping3.types +++ b/tests/baselines/reference/parenthesizedContexualTyping3.types @@ -62,21 +62,21 @@ var a = tempFun `${ x => x } ${ 10 }` >x : number var b = tempFun `${ (x => x) } ${ 10 }` ->b : any +>b : number >tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var c = tempFun `${ ((x => x)) } ${ 10 }` ->c : any +>c : number >tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var d = tempFun `${ x => x } ${ x => x } ${ 10 }` >d : number @@ -89,41 +89,41 @@ var d = tempFun `${ x => x } ${ x => x } ${ 10 }` >x : number var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }` ->e : any +>e : number >tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } ->x => x : (x: any) => any ->x : any ->x : any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>x => x : (x: number) => number +>x : number +>x : number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }` ->f : any +>f : number >tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } ->x => x : (x: any) => any ->x : any ->x : any ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>x => x : (x: number) => number +>x : number +>x : number +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }` ->g : any +>g : number >tempFun : { (tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; (tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any ->(((x => x))) : (x: any) => any ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number +>(((x => x))) : (x: number) => number +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }` >h : any diff --git a/tests/cases/fourslash/assertContextualType.ts b/tests/cases/fourslash/assertContextualType.ts index 36a59583825..7e057ce61d8 100644 --- a/tests/cases/fourslash/assertContextualType.ts +++ b/tests/cases/fourslash/assertContextualType.ts @@ -6,4 +6,4 @@ edit.insert(''); goTo.marker(); -verify.quickInfoIs('(parameter) bb: any'); \ No newline at end of file +verify.quickInfoIs('(parameter) bb: number'); \ No newline at end of file diff --git a/tests/cases/fourslash/contextualTyping.ts b/tests/cases/fourslash/contextualTyping.ts index 13fb4dc2450..c363302f7a1 100644 --- a/tests/cases/fourslash/contextualTyping.ts +++ b/tests/cases/fourslash/contextualTyping.ts @@ -212,9 +212,9 @@ verify.quickInfoIs("(parameter) i: number"); goTo.marker('7'); verify.quickInfoIs("(var) c3t1: (s: string) => string"); goTo.marker('8'); -verify.quickInfoIs("(parameter) s: any"); +verify.quickInfoIs("(parameter) s: string"); goTo.marker('9'); -verify.quickInfoIs("(parameter) s: any"); +verify.quickInfoIs("(parameter) s: string"); goTo.marker('10'); verify.quickInfoIs("(var) c3t2: IFoo"); goTo.marker('11'); @@ -254,11 +254,11 @@ verify.quickInfoIs("(property) foo: IFoo"); goTo.marker('29'); verify.quickInfoIs("(var) c3t13: IFoo"); goTo.marker('30'); -verify.quickInfoIs("(property) f: (i: any, s: any) => any"); +verify.quickInfoIs("(property) f: (i: number, s: string) => string"); goTo.marker('31'); -verify.quickInfoIs("(parameter) i: any"); +verify.quickInfoIs("(parameter) i: number"); goTo.marker('32'); -verify.quickInfoIs("(parameter) s: any"); +verify.quickInfoIs("(parameter) s: string"); goTo.marker('33'); verify.quickInfoIs("(var) c3t14: IFoo"); goTo.marker('34'); @@ -286,7 +286,7 @@ verify.quickInfoIs("(var) c7t2: IFoo[]"); goTo.marker('45'); verify.quickInfoIs("(property) t1: (s: string) => string"); goTo.marker('46'); -verify.quickInfoIs("(parameter) s: any"); +verify.quickInfoIs("(parameter) s: string"); goTo.marker('47'); verify.quickInfoIs("(property) t2: IFoo"); goTo.marker('48'); @@ -326,11 +326,11 @@ verify.quickInfoIs("(property) foo: IFoo"); goTo.marker('65'); verify.quickInfoIs("(property) t13: IFoo"); goTo.marker('66'); -verify.quickInfoIs("(property) f: (i: any, s: any) => any"); +verify.quickInfoIs("(property) f: (i: number, s: string) => string"); goTo.marker('67'); -verify.quickInfoIs("(parameter) i: any"); +verify.quickInfoIs("(parameter) i: number"); goTo.marker('68'); -verify.quickInfoIs("(parameter) s: any"); +verify.quickInfoIs("(parameter) s: string"); goTo.marker('69'); verify.quickInfoIs("(property) t14: IFoo"); goTo.marker('70'); @@ -346,7 +346,7 @@ verify.quickInfoIs("(parameter) n: number"); goTo.marker('75'); verify.quickInfoIs("(var) c12t1: (s: string) => string"); goTo.marker('76'); -verify.quickInfoIs("(parameter) s: any"); +verify.quickInfoIs("(parameter) s: string"); goTo.marker('77'); verify.quickInfoIs("(var) c12t2: IFoo"); goTo.marker('78'); @@ -386,11 +386,11 @@ verify.quickInfoIs("(property) foo: IFoo"); goTo.marker('95'); verify.quickInfoIs("(var) c12t13: IFoo"); goTo.marker('96'); -verify.quickInfoIs("(property) f: (i: any, s: any) => any"); +verify.quickInfoIs("(property) f: (i: number, s: string) => string"); goTo.marker('97'); -verify.quickInfoIs("(parameter) i: any"); +verify.quickInfoIs("(parameter) i: number"); goTo.marker('98'); -verify.quickInfoIs("(parameter) s: any"); +verify.quickInfoIs("(parameter) s: string"); goTo.marker('99'); verify.quickInfoIs("(var) c12t14: IFoo"); goTo.marker('100'); From 6783e35f89c54cbf8797511693d9775716742de6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sun, 11 Jan 2015 00:21:37 -0800 Subject: [PATCH 45/93] Removed probably-unnecessary statement from test. --- tests/cases/fourslash/assertContextualType.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/cases/fourslash/assertContextualType.ts b/tests/cases/fourslash/assertContextualType.ts index 7e057ce61d8..6ee8861ee8c 100644 --- a/tests/cases/fourslash/assertContextualType.ts +++ b/tests/cases/fourslash/assertContextualType.ts @@ -2,8 +2,5 @@ ////<(aa: number) =>void >(function myFn(b/**/b) { }); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker(); verify.quickInfoIs('(parameter) bb: number'); \ No newline at end of file From 47b8deb382085379c16450b5e9a9fc3d73ea5162 Mon Sep 17 00:00:00 2001 From: Lorant Pinter Date: Sun, 11 Jan 2015 11:14:06 +0100 Subject: [PATCH 46/93] Show --noImplicitAny as an option to throw errors, not warnings Fixes #1632 --- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/services/compiler/tsc.ts | 2 +- src/services/resources/diagnosticCode.generated.ts | 2 +- src/services/resources/diagnosticMessages.json | 2 +- src/services/syntax/SyntaxGenerator.d.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 9fe59b1ba27..fa31f25f7c3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -67,7 +67,7 @@ module ts { { name: "noImplicitAny", type: "boolean", - description: Diagnostics.Warn_on_expressions_and_declarations_with_an_implied_any_type, + description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noLib", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 99d8d0b72fb..f9d5dd518a9 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -419,7 +419,7 @@ module ts { Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, Corrupted_locale_file_0: { code: 6051, category: DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, - Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5bec5301721..371d5facdaf 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1772,7 +1772,7 @@ "category": "Error", "code": 6051 }, - "Warn on expressions and declarations with an implied 'any' type.": { + "Raise error on expressions and declarations with an implied 'any' type.": { "category": "Message", "code": 6052 }, diff --git a/src/services/compiler/tsc.ts b/src/services/compiler/tsc.ts index e77ea9467ca..acd4fb40e6a 100644 --- a/src/services/compiler/tsc.ts +++ b/src/services/compiler/tsc.ts @@ -413,7 +413,7 @@ module TypeScript { opts.flag('noImplicitAny', { usage: { - locCode: DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, + locCode: DiagnosticCode.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, args: null }, set: () => { diff --git a/src/services/resources/diagnosticCode.generated.ts b/src/services/resources/diagnosticCode.generated.ts index 03c4efea480..86509fdd63b 100644 --- a/src/services/resources/diagnosticCode.generated.ts +++ b/src/services/resources/diagnosticCode.generated.ts @@ -436,7 +436,7 @@ module TypeScript { This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.", Unknown_rule: "Unknown rule.", Invalid_line_number_0: "Invalid line number ({0})", - Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: "Raise error on expressions and declarations with an implied 'any' type.", Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", diff --git a/src/services/resources/diagnosticMessages.json b/src/services/resources/diagnosticMessages.json index 54ecbb75370..60a0bb48df9 100644 --- a/src/services/resources/diagnosticMessages.json +++ b/src/services/resources/diagnosticMessages.json @@ -1743,7 +1743,7 @@ "category": "Error", "code": 7003 }, - "Warn on expressions and declarations with an implied 'any' type.": { + "Raise error on expressions and declarations with an implied 'any' type.": { "category": "Message", "code": 7004 }, diff --git a/src/services/syntax/SyntaxGenerator.d.ts b/src/services/syntax/SyntaxGenerator.d.ts index 4a833f07587..d01d227b786 100644 --- a/src/services/syntax/SyntaxGenerator.d.ts +++ b/src/services/syntax/SyntaxGenerator.d.ts @@ -417,7 +417,7 @@ declare module TypeScript { This_version_of_the_Javascript_runtime_does_not_support_the_0_function: string; Unknown_rule: string; Invalid_line_number_0: string; - Warn_on_expressions_and_declarations_with_an_implied_any_type: string; + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: string; Variable_0_implicitly_has_an_any_type: string; Parameter_0_of_1_implicitly_has_an_any_type: string; Parameter_0_of_function_type_implicitly_has_an_any_type: string; From 12e55fb5f716b4816b6323e87d3a68e8451926ae Mon Sep 17 00:00:00 2001 From: steveluc Date: Sun, 11 Jan 2015 16:20:19 -0800 Subject: [PATCH 47/93] Added commandLineParser.ts to the generated node module, and added the type information for commandLineParser.ts to typescript_internal.d.ts. --- Jakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jakefile b/Jakefile index c1c408af0e9..15661debff6 100644 --- a/Jakefile +++ b/Jakefile @@ -58,6 +58,7 @@ var servicesSources = [ "checker.ts", "emitter.ts", "program.ts", + "commandLineParser.ts", "diagnosticInformationMap.generated.ts" ].map(function (f) { return path.join(compilerDirectory, f); @@ -102,6 +103,7 @@ var internalDefinitionsRoots = [ "compiler/core.d.ts", "compiler/sys.d.ts", "compiler/utilities.d.ts", + "compiler/commandLineParser.d.ts", "services/utilities.d.ts", ]; From 4aef3d60120aaee218fa90109aa3ccc39ba5d669 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Mon, 12 Jan 2015 05:37:58 +0000 Subject: [PATCH 48/93] Address code review comments from @JsonFreeman --- src/compiler/checker.ts | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2f16de1b1c1..c189310a05e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6110,10 +6110,10 @@ module ts { var result = candidates; var lastParent: Node; var lastSymbol: Symbol; - var cutoffPos: number = 0; - var pos: number; - var specializedPos: number = -1; - var splicePos: number; + var cutoffIndex: number = 0; + var index: number; + var specializedIndex: number = -1; + var spliceIndex: number; Debug.assert(!result.length); for (var i = 0; i < signatures.length; i++) { var signature = signatures[i]; @@ -6121,17 +6121,17 @@ module ts { var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { - pos++; + index++; } else { lastParent = parent; - pos = cutoffPos; + index = cutoffIndex; } } else { // current declaration belongs to a different symbol - // set cutoffPos so re-orderings in the future won't change result set from 0 to cutoffPos - pos = cutoffPos = result.length; + // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex + index = cutoffIndex = result.length; lastParent = parent; } lastSymbol = symbol; @@ -6139,20 +6139,18 @@ module ts { // specialized signatures always need to be placed before non-specialized signatures regardless // of the cutoff position; see GH#1133 if (signature.hasStringLiterals) { - splicePos = ++specializedPos; - // The cutoff position needs to be increased to account for the fact that we are adding things - // before the cutoff point. If the cutoff position is not incremented, merged interfaces will - // start adding their merged signatures at the wrong position - ++cutoffPos; + specializedIndex++; + spliceIndex = specializedIndex; + // The cutoff index always needs to be greater than or equal to the specialized signature index + // in order to prevent non-specialized signatures from being added before a specialized + // signature. + cutoffIndex++; } else { - splicePos = pos; + spliceIndex = index; } - for (var j = result.length; j > splicePos; j--) { - result[j] = result[j - 1]; - } - result[splicePos] = signature; + result.splice(spliceIndex, 0, signature); } } } From ecac4a519d18716c4a1fda53724d820df9fd0109 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 12 Jan 2015 10:58:21 -0800 Subject: [PATCH 49/93] disallow incorrect literal property names in indexed access for const enums --- src/compiler/checker.ts | 9 ++++++++- src/compiler/diagnosticInformationMap.generated.ts | 5 +++-- src/compiler/diagnosticMessages.json | 8 +++++++- .../reference/constEnumBadPropertyNames.errors.txt | 8 ++++++++ tests/cases/compiler/constEnumBadPropertyNames.ts | 2 ++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/constEnumBadPropertyNames.errors.txt create mode 100644 tests/cases/compiler/constEnumBadPropertyNames.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 843904dd018..40fd105c57f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5605,8 +5605,11 @@ module ts { return unknownType; } - if (isConstEnumObjectType(objectType) && node.argumentExpression && node.argumentExpression.kind !== SyntaxKind.StringLiteral) { + var isConstEnum = isConstEnumObjectType(objectType); + if (isConstEnum && + (!node.argumentExpression || node.argumentExpression.kind !== SyntaxKind.StringLiteral)) { error(node.argumentExpression, Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + return unknownType; } // TypeScript 1.0 spec (April 2014): 4.10 Property Access @@ -5627,6 +5630,10 @@ module ts { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } + else if (isConstEnum) { + error(node.argumentExpression, Diagnostics.Property_0_does_not_exist_on_const_enum_1, name, symbolToString(objectType.symbol)); + return unknownType; + } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f9d5dd518a9..f3ad6228a47 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -369,9 +369,10 @@ module ts { Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true }, const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'." }, + Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'.", isEarly: true }, const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, + Property_0_does_not_exist_on_const_enum_1: { code: 4088, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'.", isEarly: true }, The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, @@ -419,7 +420,7 @@ module ts { Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, Corrupted_locale_file_0: { code: 6051, category: DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 371d5facdaf..055c2067931 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1574,7 +1574,8 @@ }, "Index expression arguments in 'const' enums must be of type 'string'.": { "category": "Error", - "code": 4085 + "code": 4085, + "isEarly": true }, "'const' enum member initializer was evaluated to a non-finite value.": { "category": "Error", @@ -1584,6 +1585,11 @@ "category": "Error", "code": 4087 }, + "Property '{0}' does not exist on 'const' enum '{1}'.": { + "category": "Error", + "code": 4088, + "isEarly": true + }, "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 diff --git a/tests/baselines/reference/constEnumBadPropertyNames.errors.txt b/tests/baselines/reference/constEnumBadPropertyNames.errors.txt new file mode 100644 index 00000000000..7cccf86b1c8 --- /dev/null +++ b/tests/baselines/reference/constEnumBadPropertyNames.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS4088: Property 'B' does not exist on 'const' enum 'E'. + + +==== tests/cases/compiler/constEnumBadPropertyNames.ts (1 errors) ==== + const enum E { A } + var x = E["B"] + ~~~ +!!! error TS4088: Property 'B' does not exist on 'const' enum 'E'. \ No newline at end of file diff --git a/tests/cases/compiler/constEnumBadPropertyNames.ts b/tests/cases/compiler/constEnumBadPropertyNames.ts new file mode 100644 index 00000000000..89fc5d421ff --- /dev/null +++ b/tests/cases/compiler/constEnumBadPropertyNames.ts @@ -0,0 +1,2 @@ +const enum E { A } +var x = E["B"] \ No newline at end of file From c25f3eb9a358a3bc32ee3b2b320f5c861178a731 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 12 Jan 2015 11:31:54 -0800 Subject: [PATCH 50/93] addressed CR feedback --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- tests/baselines/reference/constEnumErrors.errors.txt | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 40fd105c57f..e632bb87eb1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5608,7 +5608,7 @@ module ts { var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && (!node.argumentExpression || node.argumentExpression.kind !== SyntaxKind.StringLiteral)) { - error(node.argumentExpression, Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + error(node.argumentExpression, Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f3ad6228a47..2a342fa17d2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -369,7 +369,7 @@ module ts { Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true }, const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'.", isEarly: true }, + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 4085, category: DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal.", isEarly: true }, const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, Property_0_does_not_exist_on_const_enum_1: { code: 4088, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 055c2067931..efb2bfe7e94 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1572,7 +1572,7 @@ "category": "Error", "code": 4084 }, - "Index expression arguments in 'const' enums must be of type 'string'.": { + "A const enum member can only be accessed using a string literal.": { "category": "Error", "code": 4085, "isEarly": true diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index 541f814af98..53fed12f382 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -3,8 +3,8 @@ tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier tests/cases/compiler/constEnumErrors.ts(12,9): error TS4083: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(14,9): error TS4083: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(15,10): error TS4083: In 'const' enum declarations member initializer must be constant expression. -tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'. -tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'. +tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: A const enum member can only be accessed using a string literal. +tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: A const enum member can only be accessed using a string literal. tests/cases/compiler/constEnumErrors.ts(26,9): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. tests/cases/compiler/constEnumErrors.ts(27,10): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. @@ -47,11 +47,11 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS4087: 'const' enum member var y0 = E2[1] ~ -!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'. +!!! error TS4085: A const enum member can only be accessed using a string literal. var name = "A"; var y1 = E2[name]; ~~~~ -!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'. +!!! error TS4085: A const enum member can only be accessed using a string literal. var x = E2; ~~ From e4701a66000e2cbb6300775d98e1afe583cef38b Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Mon, 12 Jan 2015 23:34:21 +0100 Subject: [PATCH 51/93] Remove unused timer.ts file --- src/services/core/timer.ts | 52 -------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 src/services/core/timer.ts diff --git a/src/services/core/timer.ts b/src/services/core/timer.ts deleted file mode 100644 index 7d6e3b0784e..00000000000 --- a/src/services/core/timer.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -var global: any = Function("return this").call(null); - -module TypeScript { - module Clock { - export var now: () => number; - export var resolution: number; - - declare module WScript { - export function InitializeProjection(): void; - } - - declare module TestUtilities { - export function QueryPerformanceCounter(): number; - export function QueryPerformanceFrequency(): number; - } - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - // Running in JSHost. - global['WScript'].InitializeProjection(); - - now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - resolution = TestUtilities.QueryPerformanceFrequency(); - } - else { - now = function () { - return Date.now(); - }; - - resolution = 1000; - } - } - - export class Timer { - public startTime: number; - public time = 0; - - public start() { - this.time = 0; - this.startTime = Clock.now(); - } - - public end() { - // Set time to MS. - this.time = (Clock.now() - this.startTime); - } - } -} \ No newline at end of file From 59e266de02979287c1b439277c0113f763483d36 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 12 Jan 2015 14:51:20 -0800 Subject: [PATCH 52/93] Improved handing of union types in type guards --- src/compiler/checker.ts | 14 +++++++--- .../reference/TypeGuardWithArrayUnion.js | 23 ++++++++++++++++ .../reference/TypeGuardWithArrayUnion.types | 26 +++++++++++++++++++ .../reference/typeGuardOfFormInstanceOf.types | 4 +-- ...typeGuardOfFormInstanceOfOnInterface.types | 4 +-- .../typeGuards/TypeGuardWithArrayUnion.ts | 9 +++++++ 6 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/TypeGuardWithArrayUnion.js create mode 100644 tests/baselines/reference/TypeGuardWithArrayUnion.types create mode 100644 tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 843904dd018..bdaf64d3a54 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4709,13 +4709,21 @@ module ts { if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } + // Target type is type of prototype property var prototypeProperty = getPropertyOfType(rightType, "prototype"); if (!prototypeProperty) { return type; } - var prototypeType = getTypeOfSymbol(prototypeProperty); - // Narrow to type of prototype property if it is a subtype of current type - return isTypeSubtypeOf(prototypeType, type) ? prototypeType : type; + var targetType = getTypeOfSymbol(prototypeProperty); + // Narrow to target type if it is a subtype of current type + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + // If current type is a union type, remove all constituents that aren't subtypes of target type + if (type.flags && TypeFlags.Union) { + return getUnionType(filter((type).types, t => isTypeSubtypeOf(t, targetType))); + } + return type; } // Narrow the given type based on the given expression having the assumed boolean value diff --git a/tests/baselines/reference/TypeGuardWithArrayUnion.js b/tests/baselines/reference/TypeGuardWithArrayUnion.js new file mode 100644 index 00000000000..cf98d2c2453 --- /dev/null +++ b/tests/baselines/reference/TypeGuardWithArrayUnion.js @@ -0,0 +1,23 @@ +//// [TypeGuardWithArrayUnion.ts] +class Message { + value: string; +} + +function saySize(message: Message | Message[]) { + if (message instanceof Array) { + return message.length; // Should have type Message[] here + } +} + + +//// [TypeGuardWithArrayUnion.js] +var Message = (function () { + function Message() { + } + return Message; +})(); +function saySize(message) { + if (message instanceof Array) { + return message.length; // Should have type Message[] here + } +} diff --git a/tests/baselines/reference/TypeGuardWithArrayUnion.types b/tests/baselines/reference/TypeGuardWithArrayUnion.types new file mode 100644 index 00000000000..557e305ef74 --- /dev/null +++ b/tests/baselines/reference/TypeGuardWithArrayUnion.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts === +class Message { +>Message : Message + + value: string; +>value : string +} + +function saySize(message: Message | Message[]) { +>saySize : (message: Message | Message[]) => number +>message : Message | Message[] +>Message : Message +>Message : Message + + if (message instanceof Array) { +>message instanceof Array : boolean +>message : Message | Message[] +>Array : ArrayConstructor + + return message.length; // Should have type Message[] here +>message.length : number +>message : Message[] +>length : number + } +} + diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOf.types b/tests/baselines/reference/typeGuardOfFormInstanceOf.types index fb44482c86e..891e8c1bea2 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOf.types +++ b/tests/baselines/reference/typeGuardOfFormInstanceOf.types @@ -124,9 +124,9 @@ var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1 >r2 : C2 | D1 >D1 : D1 >C2 : C2 ->c2Ord1 instanceof C1 && c2Ord1 : C2 | D1 +>c2Ord1 instanceof C1 && c2Ord1 : D1 >c2Ord1 instanceof C1 : boolean >c2Ord1 : C2 | D1 >C1 : typeof C1 ->c2Ord1 : C2 | D1 +>c2Ord1 : D1 diff --git a/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types b/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types index 7bf67da1500..fe23d6d303e 100644 --- a/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types +++ b/tests/baselines/reference/typeGuardOfFormInstanceOfOnInterface.types @@ -154,9 +154,9 @@ var r2: D1 | C2 = c2Ord1 instanceof c1 && c2Ord1; // C2 | D1 >r2 : C2 | D1 >D1 : D1 >C2 : C2 ->c2Ord1 instanceof c1 && c2Ord1 : C2 | D1 +>c2Ord1 instanceof c1 && c2Ord1 : D1 >c2Ord1 instanceof c1 : boolean >c2Ord1 : C2 | D1 >c1 : C1 ->c2Ord1 : C2 | D1 +>c2Ord1 : D1 diff --git a/tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts b/tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts new file mode 100644 index 00000000000..8884754b480 --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts @@ -0,0 +1,9 @@ +class Message { + value: string; +} + +function saySize(message: Message | Message[]) { + if (message instanceof Array) { + return message.length; // Should have type Message[] here + } +} From a99b9584848baeaac88f5e5b57ac45580146f784 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 13 Jan 2015 09:30:54 -0800 Subject: [PATCH 53/93] Manual port of fixe for #1593 from release-1.4 --- src/compiler/program.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b506a86786b..fc3cc0682d1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -185,7 +185,10 @@ module ts { } } else { - if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) { + if (options.allowNonTsExtensions && !findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = Diagnostics.File_0_not_found; + } + else if (!findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) { diagnostic = Diagnostics.File_0_not_found; filename += ".ts"; } From 39355985b1818b075f07238c0ba571dd24c9853e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 13 Jan 2015 09:39:10 -0800 Subject: [PATCH 54/93] Update LKG --- bin/tsc.js | 215 +++++++------ bin/typescript.d.ts | 4 +- bin/typescriptServices.d.ts | 4 +- bin/typescriptServices.js | 456 +++++++++++++++++++++------ bin/typescriptServices_internal.d.ts | 14 + bin/typescript_internal.d.ts | 14 + 6 files changed, 514 insertions(+), 193 deletions(-) diff --git a/bin/tsc.js b/bin/tsc.js index b547abd2469..070f5356189 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -212,6 +212,12 @@ var ts; return result; } ts.mapToArray = mapToArray; + function copyMap(source, target) { + for (var p in source) { + target[p] = source[p]; + } + } + ts.copyMap = copyMap; function arrayToMap(array, makeKey) { var result = {}; forEach(array, function (value) { @@ -1219,7 +1225,7 @@ var ts; Unsupported_locale_0: { code: 6049, category: 1 /* Error */, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: 1 /* Error */, key: "Unable to open file '{0}'." }, Corrupted_locale_file_0: { code: 6051, category: 1 /* Error */, key: "Corrupted locale file {0}." }, - Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: 1 /* Error */, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1 /* Error */, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2 /* Message */, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, @@ -2790,6 +2796,11 @@ var ts; return false; } ts.isExpression = isExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 /* Instantiated */ || (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + } + ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportDeclaration(node) { return node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind === 199 /* ExternalModuleReference */; } @@ -3180,34 +3191,37 @@ var ts; return new (getNodeConstructor(kind))(); } ts.createNode = createNode; - function forEachChild(node, cbNode, cbNodes) { - function child(node) { - if (node) { - return cbNode(node); - } + function visitNode(cbNode, node) { + if (node) { + return cbNode(node); } - function children(nodes) { - if (nodes) { - if (cbNodes) { - return cbNodes(nodes); - } - for (var i = 0, len = nodes.length; i < len; i++) { - var result = cbNode(nodes[i]); - if (result) { - return result; - } + } + function visitNodeArray(cbNodes, nodes) { + if (nodes) { + return cbNodes(nodes); + } + } + function visitEachNode(cbNode, nodes) { + if (nodes) { + for (var i = 0, len = nodes.length; i < len; i++) { + var result = cbNode(nodes[i]); + if (result) { + return result; } - return undefined; } } + } + function forEachChild(node, cbNode, cbNodeArray) { if (!node) { return; } + var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; switch (node.kind) { case 121 /* QualifiedName */: - return child(node.left) || child(node.right); + return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); case 123 /* TypeParameter */: - return child(node.name) || child(node.constraint) || child(node.expression); + return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); case 124 /* Parameter */: case 126 /* PropertyDeclaration */: case 125 /* PropertySignature */: @@ -3215,13 +3229,13 @@ var ts; case 205 /* ShorthandPropertyAssignment */: case 188 /* VariableDeclaration */: case 146 /* BindingElement */: - return children(node.modifiers) || child(node.propertyName) || child(node.dotDotDotToken) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); case 136 /* FunctionType */: case 137 /* ConstructorType */: case 132 /* CallSignature */: case 133 /* ConstructSignature */: case 134 /* IndexSignature */: - return children(node.modifiers) || children(node.typeParameters) || children(node.parameters) || child(node.type); + return visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); case 128 /* MethodDeclaration */: case 127 /* MethodSignature */: case 129 /* Constructor */: @@ -3230,127 +3244,127 @@ var ts; case 156 /* FunctionExpression */: case 190 /* FunctionDeclaration */: case 157 /* ArrowFunction */: - return children(node.modifiers) || child(node.asteriskToken) || child(node.name) || child(node.questionToken) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); case 135 /* TypeReference */: - return child(node.typeName) || children(node.typeArguments); + return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); case 138 /* TypeQuery */: - return child(node.exprName); + return visitNode(cbNode, node.exprName); case 139 /* TypeLiteral */: - return children(node.members); + return visitNodes(cbNodes, node.members); case 140 /* ArrayType */: - return child(node.elementType); + return visitNode(cbNode, node.elementType); case 141 /* TupleType */: - return children(node.elementTypes); + return visitNodes(cbNodes, node.elementTypes); case 142 /* UnionType */: - return children(node.types); + return visitNodes(cbNodes, node.types); case 143 /* ParenthesizedType */: - return child(node.type); + return visitNode(cbNode, node.type); case 144 /* ObjectBindingPattern */: case 145 /* ArrayBindingPattern */: - return children(node.elements); + return visitNodes(cbNodes, node.elements); case 147 /* ArrayLiteralExpression */: - return children(node.elements); + return visitNodes(cbNodes, node.elements); case 148 /* ObjectLiteralExpression */: - return children(node.properties); + return visitNodes(cbNodes, node.properties); case 149 /* PropertyAccessExpression */: - return child(node.expression) || child(node.name); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); case 150 /* ElementAccessExpression */: - return child(node.expression) || child(node.argumentExpression); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); case 151 /* CallExpression */: case 152 /* NewExpression */: - return child(node.expression) || children(node.typeArguments) || children(node.arguments); + return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); case 153 /* TaggedTemplateExpression */: - return child(node.tag) || child(node.template); + return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); case 154 /* TypeAssertionExpression */: - return child(node.type) || child(node.expression); + return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); case 155 /* ParenthesizedExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 158 /* DeleteExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 159 /* TypeOfExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 160 /* VoidExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 161 /* PrefixUnaryExpression */: - return child(node.operand); + return visitNode(cbNode, node.operand); case 166 /* YieldExpression */: - return child(node.asteriskToken) || child(node.expression); + return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); case 162 /* PostfixUnaryExpression */: - return child(node.operand); + return visitNode(cbNode, node.operand); case 163 /* BinaryExpression */: - return child(node.left) || child(node.right); + return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); case 164 /* ConditionalExpression */: - return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); + return visitNode(cbNode, node.condition) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.whenFalse); case 167 /* SpreadElementExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 170 /* Block */: case 196 /* ModuleBlock */: - return children(node.statements); + return visitNodes(cbNodes, node.statements); case 207 /* SourceFile */: - return children(node.statements) || child(node.endOfFileToken); + return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 171 /* VariableStatement */: - return children(node.modifiers) || child(node.declarationList); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); case 189 /* VariableDeclarationList */: - return children(node.declarations); + return visitNodes(cbNodes, node.declarations); case 173 /* ExpressionStatement */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 174 /* IfStatement */: - return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); case 175 /* DoStatement */: - return child(node.statement) || child(node.expression); + return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); case 176 /* WhileStatement */: - return child(node.expression) || child(node.statement); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 177 /* ForStatement */: - return child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); + return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.iterator) || visitNode(cbNode, node.statement); case 178 /* ForInStatement */: - return child(node.initializer) || child(node.expression) || child(node.statement); + return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 179 /* ContinueStatement */: case 180 /* BreakStatement */: - return child(node.label); + return visitNode(cbNode, node.label); case 181 /* ReturnStatement */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 182 /* WithStatement */: - return child(node.expression) || child(node.statement); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 183 /* SwitchStatement */: - return child(node.expression) || children(node.clauses); + return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.clauses); case 200 /* CaseClause */: - return child(node.expression) || children(node.statements); + return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 201 /* DefaultClause */: - return children(node.statements); + return visitNodes(cbNodes, node.statements); case 184 /* LabeledStatement */: - return child(node.label) || child(node.statement); + return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); case 185 /* ThrowStatement */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 186 /* TryStatement */: - return child(node.tryBlock) || child(node.catchClause) || child(node.finallyBlock); + return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 203 /* CatchClause */: - return child(node.name) || child(node.type) || child(node.block); + return visitNode(cbNode, node.name) || visitNode(cbNode, node.type) || visitNode(cbNode, node.block); case 191 /* ClassDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); case 192 /* InterfaceDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); case 193 /* TypeAliasDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.type); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); case 194 /* EnumDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.members); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); case 206 /* EnumMember */: - return child(node.name) || child(node.initializer); + return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); case 195 /* ModuleDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.body); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); case 197 /* ImportDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.moduleReference); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); case 198 /* ExportAssignment */: - return children(node.modifiers) || child(node.exportName); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportName); case 165 /* TemplateExpression */: - return child(node.head) || children(node.templateSpans); + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); case 169 /* TemplateSpan */: - return child(node.expression) || child(node.literal); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 122 /* ComputedPropertyName */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 202 /* HeritageClause */: - return children(node.types); + return visitNodes(cbNodes, node.types); case 199 /* ExternalModuleReference */: - return child(node.expression); + return visitNode(cbNode, node.expression); } } ts.forEachChild = forEachChild; @@ -7980,7 +7994,6 @@ var ts; case 134 /* IndexSignature */: case 124 /* Parameter */: case 196 /* ModuleBlock */: - case 123 /* TypeParameter */: case 136 /* FunctionType */: case 137 /* ConstructorType */: case 139 /* TypeLiteral */: @@ -7990,6 +8003,7 @@ var ts; case 142 /* UnionType */: case 143 /* ParenthesizedType */: return isDeclarationVisible(node.parent); + case 123 /* TypeParameter */: case 207 /* SourceFile */: return true; default: @@ -9745,9 +9759,7 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = result === -1 /* True */ || depth === 0 ? relation : maybeStack[depth - 1]; - for (var p in maybeCache) { - destinationCache[p] = maybeCache[p]; - } + ts.copyMap(maybeCache, destinationCache); } else { relation[id] = false; @@ -10566,7 +10578,7 @@ var ts; } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (node && symbol.flags & 3 /* Variable */ && type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + if (node && symbol.flags & 3 /* Variable */ && type.flags & (1 /* Any */ | 48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { loop: while (node.parent) { var child = node; node = node.parent; @@ -10655,7 +10667,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (!assumeTrue || expr.left.kind !== 64 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (type.flags & 1 /* Any */ || !assumeTrue || expr.left.kind !== 64 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -13789,7 +13801,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { + if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node) && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums)) { var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (classOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(classOrFunc)) { @@ -16894,19 +16906,30 @@ var ts; if (emitOuterParens) { write("("); } - emitLiteral(node.head); - ts.forEach(node.templateSpans, function (templateSpan) { + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0; i < node.templateSpans.length; i++) { + var templateSpan = node.templateSpans[i]; var needsParens = templateSpan.expression.kind !== 155 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; - write(" + "); + if (i > 0 || headEmitted) { + write(" + "); + } emitParenthesized(templateSpan.expression, needsParens); if (templateSpan.literal.text.length !== 0) { write(" + "); emitLiteral(templateSpan.literal); } - }); + } if (emitOuterParens) { write(")"); } + function shouldEmitTemplateHead() { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } function templateNeedsParens(template, parent) { switch (parent.kind) { case 151 /* CallExpression */: @@ -16930,6 +16953,7 @@ var ts; case 37 /* PercentToken */: return 1 /* GreaterThan */; case 33 /* PlusToken */: + case 34 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; @@ -18313,7 +18337,7 @@ var ts; } } function emitModuleDeclaration(node) { - var shouldEmit = ts.getModuleInstanceState(node) === 1 /* Instantiated */ || (ts.getModuleInstanceState(node) === 2 /* ConstEnumOnly */ && compilerOptions.preserveConstEnums); + var shouldEmit = ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums); if (!shouldEmit) { return emitPinnedOrTripleSlashComments(node); } @@ -19033,7 +19057,10 @@ var ts; } } else { - if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) { + if (options.allowNonTsExtensions && !findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = ts.Diagnostics.File_0_not_found; + } + else if (!findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; filename += ".ts"; } @@ -19268,7 +19295,7 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Warn_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type }, { name: "noLib", diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index bd7764c3f4b..592b73ba8d9 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -1028,8 +1028,6 @@ declare module "typescript" { } interface GenericType extends InterfaceType, TypeReference { instantiations: Map; - openReferenceTargets: GenericType[]; - openReferenceChecks: Map; } interface TupleType extends ObjectType { elementTypes: Type[]; @@ -1370,7 +1368,7 @@ declare module "typescript" { declare module "typescript" { function getNodeConstructor(kind: SyntaxKind): new () => Node; function createNode(kind: SyntaxKind): Node; - function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; + function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; function modifierToFlag(token: SyntaxKind): NodeFlags; function isEvalOrArgumentsIdentifier(node: Node): boolean; function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index c980d9c2d69..6fd1cda359a 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -1028,8 +1028,6 @@ declare module ts { } interface GenericType extends InterfaceType, TypeReference { instantiations: Map; - openReferenceTargets: GenericType[]; - openReferenceChecks: Map; } interface TupleType extends ObjectType { elementTypes: Type[]; @@ -1370,7 +1368,7 @@ declare module ts { declare module ts { function getNodeConstructor(kind: SyntaxKind): new () => Node; function createNode(kind: SyntaxKind): Node; - function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T; + function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; function modifierToFlag(token: SyntaxKind): NodeFlags; function isEvalOrArgumentsIdentifier(node: Node): boolean; function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 9506ab39dcf..c3725bdc367 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -763,6 +763,12 @@ var ts; return result; } ts.mapToArray = mapToArray; + function copyMap(source, target) { + for (var p in source) { + target[p] = source[p]; + } + } + ts.copyMap = copyMap; function arrayToMap(array, makeKey) { var result = {}; forEach(array, function (value) { @@ -1777,7 +1783,7 @@ var ts; Unsupported_locale_0: { code: 6049, category: 1 /* Error */, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: 1 /* Error */, key: "Unable to open file '{0}'." }, Corrupted_locale_file_0: { code: 6051, category: 1 /* Error */, key: "Corrupted locale file {0}." }, - Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: 1 /* Error */, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1 /* Error */, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2 /* Message */, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, @@ -3348,6 +3354,11 @@ var ts; return false; } ts.isExpression = isExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 /* Instantiated */ || (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + } + ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportDeclaration(node) { return node.kind === 197 /* ImportDeclaration */ && node.moduleReference.kind === 199 /* ExternalModuleReference */; } @@ -3738,34 +3749,37 @@ var ts; return new (getNodeConstructor(kind))(); } ts.createNode = createNode; - function forEachChild(node, cbNode, cbNodes) { - function child(node) { - if (node) { - return cbNode(node); - } + function visitNode(cbNode, node) { + if (node) { + return cbNode(node); } - function children(nodes) { - if (nodes) { - if (cbNodes) { - return cbNodes(nodes); - } - for (var i = 0, len = nodes.length; i < len; i++) { - var result = cbNode(nodes[i]); - if (result) { - return result; - } + } + function visitNodeArray(cbNodes, nodes) { + if (nodes) { + return cbNodes(nodes); + } + } + function visitEachNode(cbNode, nodes) { + if (nodes) { + for (var i = 0, len = nodes.length; i < len; i++) { + var result = cbNode(nodes[i]); + if (result) { + return result; } - return undefined; } } + } + function forEachChild(node, cbNode, cbNodeArray) { if (!node) { return; } + var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; switch (node.kind) { case 121 /* QualifiedName */: - return child(node.left) || child(node.right); + return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); case 123 /* TypeParameter */: - return child(node.name) || child(node.constraint) || child(node.expression); + return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); case 124 /* Parameter */: case 126 /* PropertyDeclaration */: case 125 /* PropertySignature */: @@ -3773,13 +3787,13 @@ var ts; case 205 /* ShorthandPropertyAssignment */: case 188 /* VariableDeclaration */: case 146 /* BindingElement */: - return children(node.modifiers) || child(node.propertyName) || child(node.dotDotDotToken) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); case 136 /* FunctionType */: case 137 /* ConstructorType */: case 132 /* CallSignature */: case 133 /* ConstructSignature */: case 134 /* IndexSignature */: - return children(node.modifiers) || children(node.typeParameters) || children(node.parameters) || child(node.type); + return visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); case 128 /* MethodDeclaration */: case 127 /* MethodSignature */: case 129 /* Constructor */: @@ -3788,127 +3802,127 @@ var ts; case 156 /* FunctionExpression */: case 190 /* FunctionDeclaration */: case 157 /* ArrowFunction */: - return children(node.modifiers) || child(node.asteriskToken) || child(node.name) || child(node.questionToken) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); case 135 /* TypeReference */: - return child(node.typeName) || children(node.typeArguments); + return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); case 138 /* TypeQuery */: - return child(node.exprName); + return visitNode(cbNode, node.exprName); case 139 /* TypeLiteral */: - return children(node.members); + return visitNodes(cbNodes, node.members); case 140 /* ArrayType */: - return child(node.elementType); + return visitNode(cbNode, node.elementType); case 141 /* TupleType */: - return children(node.elementTypes); + return visitNodes(cbNodes, node.elementTypes); case 142 /* UnionType */: - return children(node.types); + return visitNodes(cbNodes, node.types); case 143 /* ParenthesizedType */: - return child(node.type); + return visitNode(cbNode, node.type); case 144 /* ObjectBindingPattern */: case 145 /* ArrayBindingPattern */: - return children(node.elements); + return visitNodes(cbNodes, node.elements); case 147 /* ArrayLiteralExpression */: - return children(node.elements); + return visitNodes(cbNodes, node.elements); case 148 /* ObjectLiteralExpression */: - return children(node.properties); + return visitNodes(cbNodes, node.properties); case 149 /* PropertyAccessExpression */: - return child(node.expression) || child(node.name); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); case 150 /* ElementAccessExpression */: - return child(node.expression) || child(node.argumentExpression); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); case 151 /* CallExpression */: case 152 /* NewExpression */: - return child(node.expression) || children(node.typeArguments) || children(node.arguments); + return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); case 153 /* TaggedTemplateExpression */: - return child(node.tag) || child(node.template); + return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); case 154 /* TypeAssertionExpression */: - return child(node.type) || child(node.expression); + return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); case 155 /* ParenthesizedExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 158 /* DeleteExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 159 /* TypeOfExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 160 /* VoidExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 161 /* PrefixUnaryExpression */: - return child(node.operand); + return visitNode(cbNode, node.operand); case 166 /* YieldExpression */: - return child(node.asteriskToken) || child(node.expression); + return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); case 162 /* PostfixUnaryExpression */: - return child(node.operand); + return visitNode(cbNode, node.operand); case 163 /* BinaryExpression */: - return child(node.left) || child(node.right); + return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); case 164 /* ConditionalExpression */: - return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); + return visitNode(cbNode, node.condition) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.whenFalse); case 167 /* SpreadElementExpression */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 170 /* Block */: case 196 /* ModuleBlock */: - return children(node.statements); + return visitNodes(cbNodes, node.statements); case 207 /* SourceFile */: - return children(node.statements) || child(node.endOfFileToken); + return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 171 /* VariableStatement */: - return children(node.modifiers) || child(node.declarationList); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); case 189 /* VariableDeclarationList */: - return children(node.declarations); + return visitNodes(cbNodes, node.declarations); case 173 /* ExpressionStatement */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 174 /* IfStatement */: - return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); case 175 /* DoStatement */: - return child(node.statement) || child(node.expression); + return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); case 176 /* WhileStatement */: - return child(node.expression) || child(node.statement); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 177 /* ForStatement */: - return child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); + return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.iterator) || visitNode(cbNode, node.statement); case 178 /* ForInStatement */: - return child(node.initializer) || child(node.expression) || child(node.statement); + return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 179 /* ContinueStatement */: case 180 /* BreakStatement */: - return child(node.label); + return visitNode(cbNode, node.label); case 181 /* ReturnStatement */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 182 /* WithStatement */: - return child(node.expression) || child(node.statement); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 183 /* SwitchStatement */: - return child(node.expression) || children(node.clauses); + return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.clauses); case 200 /* CaseClause */: - return child(node.expression) || children(node.statements); + return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 201 /* DefaultClause */: - return children(node.statements); + return visitNodes(cbNodes, node.statements); case 184 /* LabeledStatement */: - return child(node.label) || child(node.statement); + return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); case 185 /* ThrowStatement */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 186 /* TryStatement */: - return child(node.tryBlock) || child(node.catchClause) || child(node.finallyBlock); + return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 203 /* CatchClause */: - return child(node.name) || child(node.type) || child(node.block); + return visitNode(cbNode, node.name) || visitNode(cbNode, node.type) || visitNode(cbNode, node.block); case 191 /* ClassDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); case 192 /* InterfaceDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); case 193 /* TypeAliasDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.type); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.type); case 194 /* EnumDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.members); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); case 206 /* EnumMember */: - return child(node.name) || child(node.initializer); + return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); case 195 /* ModuleDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.body); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); case 197 /* ImportDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.moduleReference); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); case 198 /* ExportAssignment */: - return children(node.modifiers) || child(node.exportName); + return visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportName); case 165 /* TemplateExpression */: - return child(node.head) || children(node.templateSpans); + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); case 169 /* TemplateSpan */: - return child(node.expression) || child(node.literal); + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 122 /* ComputedPropertyName */: - return child(node.expression); + return visitNode(cbNode, node.expression); case 202 /* HeritageClause */: - return children(node.types); + return visitNodes(cbNodes, node.types); case 199 /* ExternalModuleReference */: - return child(node.expression); + return visitNode(cbNode, node.expression); } } ts.forEachChild = forEachChild; @@ -8578,7 +8592,6 @@ var ts; case 134 /* IndexSignature */: case 124 /* Parameter */: case 196 /* ModuleBlock */: - case 123 /* TypeParameter */: case 136 /* FunctionType */: case 137 /* ConstructorType */: case 139 /* TypeLiteral */: @@ -8588,6 +8601,7 @@ var ts; case 142 /* UnionType */: case 143 /* ParenthesizedType */: return isDeclarationVisible(node.parent); + case 123 /* TypeParameter */: case 207 /* SourceFile */: return true; default: @@ -10343,9 +10357,7 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = result === -1 /* True */ || depth === 0 ? relation : maybeStack[depth - 1]; - for (var p in maybeCache) { - destinationCache[p] = maybeCache[p]; - } + ts.copyMap(maybeCache, destinationCache); } else { relation[id] = false; @@ -11164,7 +11176,7 @@ var ts; } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (node && symbol.flags & 3 /* Variable */ && type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + if (node && symbol.flags & 3 /* Variable */ && type.flags & (1 /* Any */ | 48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { loop: while (node.parent) { var child = node; node = node.parent; @@ -11253,7 +11265,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (!assumeTrue || expr.left.kind !== 64 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (type.flags & 1 /* Any */ || !assumeTrue || expr.left.kind !== 64 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -14387,7 +14399,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { + if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node) && ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums)) { var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (classOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(classOrFunc)) { @@ -17492,19 +17504,30 @@ var ts; if (emitOuterParens) { write("("); } - emitLiteral(node.head); - ts.forEach(node.templateSpans, function (templateSpan) { + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0; i < node.templateSpans.length; i++) { + var templateSpan = node.templateSpans[i]; var needsParens = templateSpan.expression.kind !== 155 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; - write(" + "); + if (i > 0 || headEmitted) { + write(" + "); + } emitParenthesized(templateSpan.expression, needsParens); if (templateSpan.literal.text.length !== 0) { write(" + "); emitLiteral(templateSpan.literal); } - }); + } if (emitOuterParens) { write(")"); } + function shouldEmitTemplateHead() { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } function templateNeedsParens(template, parent) { switch (parent.kind) { case 151 /* CallExpression */: @@ -17528,6 +17551,7 @@ var ts; case 37 /* PercentToken */: return 1 /* GreaterThan */; case 33 /* PlusToken */: + case 34 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; @@ -18911,7 +18935,7 @@ var ts; } } function emitModuleDeclaration(node) { - var shouldEmit = ts.getModuleInstanceState(node) === 1 /* Instantiated */ || (ts.getModuleInstanceState(node) === 2 /* ConstEnumOnly */ && compilerOptions.preserveConstEnums); + var shouldEmit = ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums); if (!shouldEmit) { return emitPinnedOrTripleSlashComments(node); } @@ -19631,7 +19655,10 @@ var ts; } } else { - if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) { + if (options.allowNonTsExtensions && !findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = ts.Diagnostics.File_0_not_found; + } + else if (!findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; filename += ".ts"; } @@ -19802,6 +19829,249 @@ var ts; ts.createProgram = createProgram; })(ts || (ts = {})); var ts; +(function (ts) { + ts.optionDeclarations = [ + { + name: "charset", + type: "string" + }, + { + name: "codepage", + type: "number" + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file + }, + { + name: "diagnostics", + type: "boolean" + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message + }, + { + name: "locale", + type: "string" + }, + { + name: "mapRoot", + type: "string", + description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "module", + shortName: "m", + type: { + "commonjs": 1 /* CommonJS */, + "amd": 2 /* AMD */ + }, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd, + paramType: ts.Diagnostics.KIND, + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_type_checking_errors_were_reported + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + }, + { + name: "noLib", + type: "boolean" + }, + { + name: "noLibCheck", + type: "boolean" + }, + { + name: "noResolve", + type: "boolean" + }, + { + name: "out", + type: "string", + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE + }, + { + name: "outDir", + type: "string", + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file + }, + { + name: "sourceRoot", + type: "string", + description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + }, + { + name: "target", + shortName: "t", + type: { "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES6 */ }, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, + paramType: ts.Diagnostics.VERSION, + error: ts.Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files + } + ]; + var shortOptionNames = {}; + var optionNameMap = {}; + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; + } + }); + function parseCommandLine(commandLine) { + var options = { + target: 0 /* ES3 */, + module: 0 /* None */ + }; + var filenames = []; + var errors = []; + parseStrings(commandLine); + return { + options: options, + filenames: filenames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i++]; + if (s.charCodeAt(0) === 64 /* at */) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45 /* minus */) { + s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); + if (ts.hasProperty(shortOptionNames, s)) { + s = shortOptionNames[s]; + } + if (ts.hasProperty(optionNameMap, s)) { + var opt = optionNameMap[s]; + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i++]); + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i++] || ""; + break; + default: + var map = opt.type; + var key = (args[i++] || "").toLowerCase(); + if (ts.hasProperty(map, key)) { + options[opt.name] = map[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + filenames.push(s); + } + } + } + function parseResponseFile(filename) { + var text = ts.sys.readFile(filename); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, filename)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34 /* doubleQuote */) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, filename)); + } + } + else { + while (text.charCodeAt(pos) > 32 /* space */) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; +})(ts || (ts = {})); +var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { diff --git a/bin/typescriptServices_internal.d.ts b/bin/typescriptServices_internal.d.ts index 7a19a0906a4..5731d6959de 100644 --- a/bin/typescriptServices_internal.d.ts +++ b/bin/typescriptServices_internal.d.ts @@ -48,6 +48,7 @@ declare module ts { function forEachKey(map: Map, callback: (key: string) => U): U; function lookUp(map: Map, key: string): T; function mapToArray(map: Map): T[]; + function copyMap(source: Map, target: Map): void; /** * Creates a map from the elements of an array. * @@ -142,6 +143,14 @@ declare module ts { interface StringSymbolWriter extends SymbolWriter { string(): string; } + interface EmitHost extends ScriptReferenceHost { + getSourceFiles(): SourceFile[]; + isEmitBlocked(sourceFile?: SourceFile): boolean; + getCommonSourceDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + } function getSingleLineStringWriter(): StringSymbolWriter; function releaseStringWriter(writer: StringSymbolWriter): void; function getFullWidth(node: Node): number; @@ -180,6 +189,7 @@ declare module ts { function getSuperContainer(node: Node): Node; function getInvokedExpression(node: CallLikeExpression): Expression; function isExpression(node: Node): boolean; + function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; function isExternalModuleImportDeclaration(node: Node): boolean; function getExternalModuleImportDeclarationExpression(node: Node): Expression; function isInternalModuleImportDeclaration(node: Node): boolean; @@ -231,6 +241,10 @@ declare module ts { */ function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; } +declare module ts { + var optionDeclarations: CommandLineOption[]; + function parseCommandLine(commandLine: string[]): ParsedCommandLine; +} declare module ts { interface ListItemInfo { listItemIndex: number; diff --git a/bin/typescript_internal.d.ts b/bin/typescript_internal.d.ts index 6a40dd36d1c..e9bff0d37f9 100644 --- a/bin/typescript_internal.d.ts +++ b/bin/typescript_internal.d.ts @@ -48,6 +48,7 @@ declare module "typescript" { function forEachKey(map: Map, callback: (key: string) => U): U; function lookUp(map: Map, key: string): T; function mapToArray(map: Map): T[]; + function copyMap(source: Map, target: Map): void; /** * Creates a map from the elements of an array. * @@ -142,6 +143,14 @@ declare module "typescript" { interface StringSymbolWriter extends SymbolWriter { string(): string; } + interface EmitHost extends ScriptReferenceHost { + getSourceFiles(): SourceFile[]; + isEmitBlocked(sourceFile?: SourceFile): boolean; + getCommonSourceDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + } function getSingleLineStringWriter(): StringSymbolWriter; function releaseStringWriter(writer: StringSymbolWriter): void; function getFullWidth(node: Node): number; @@ -180,6 +189,7 @@ declare module "typescript" { function getSuperContainer(node: Node): Node; function getInvokedExpression(node: CallLikeExpression): Expression; function isExpression(node: Node): boolean; + function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; function isExternalModuleImportDeclaration(node: Node): boolean; function getExternalModuleImportDeclarationExpression(node: Node): Expression; function isInternalModuleImportDeclaration(node: Node): boolean; @@ -231,6 +241,10 @@ declare module "typescript" { */ function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; } +declare module "typescript" { + var optionDeclarations: CommandLineOption[]; + function parseCommandLine(commandLine: string[]): ParsedCommandLine; +} declare module "typescript" { interface ListItemInfo { listItemIndex: number; From 150720bd70cd7a0d1ebf1347f37d97d57c0be7ee Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 13 Jan 2015 14:22:53 -0800 Subject: [PATCH 55/93] when formatting lists check if end list token still belongs to the parent node --- src/services/formatting/formatting.ts | 6 +++++- tests/cases/fourslash/formatEmptyParamList.ts | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/formatEmptyParamList.ts diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index b5edf776d58..13c423e9813 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -597,7 +597,11 @@ module ts.formatting { if (listEndToken !== SyntaxKind.Unknown) { if (formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === listEndToken) { + // consume the list end token only if it is still belong to the parent + // there might be the case when current token matches end token but does not considered as one + // function (x: function) <-- + // without this check close paren will be interpreted as list end token for function expression which is wrong + if (tokenInfo.token.kind === listEndToken && rangeContainsRange(parent, tokenInfo.token)) { // consume list end token consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); } diff --git a/tests/cases/fourslash/formatEmptyParamList.ts b/tests/cases/fourslash/formatEmptyParamList.ts new file mode 100644 index 00000000000..5b207581d61 --- /dev/null +++ b/tests/cases/fourslash/formatEmptyParamList.ts @@ -0,0 +1,5 @@ +/// +////function f( f: function){/*1*/ +goTo.marker("1"); +edit.insert("}"); +verify.currentLineContentIs("function f(f: function){ }") \ No newline at end of file From f2338016df8a1b49cca392c51519771b2a33f2b2 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 13 Jan 2015 14:37:55 -0800 Subject: [PATCH 56/93] save token when scanning binary\octal literals --- src/compiler/scanner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 427bc0012d6..2a0363f7f78 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1039,7 +1039,7 @@ module ts { value = 0; } tokenValue = "" + value; - return SyntaxKind.NumericLiteral; + return token = SyntaxKind.NumericLiteral; } else if (pos + 2 < len && (text.charCodeAt(pos + 1) === CharacterCodes.O || text.charCodeAt(pos + 1) === CharacterCodes.o)) { pos += 2; @@ -1049,7 +1049,7 @@ module ts { value = 0; } tokenValue = "" + value; - return SyntaxKind.NumericLiteral; + return token = SyntaxKind.NumericLiteral; } // Try to parse as an octal if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { From b434ee42a85700b1865fc43c180a97edbfecfb2e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2015 16:06:34 -0800 Subject: [PATCH 57/93] Added tests. --- ...estructuringPropertyParameters1.errors.txt | 68 +++++++++++++++++++ ...estructuringPropertyParameters2.errors.txt | 53 +++++++++++++++ .../destructuringPropertyParameters2.js | 58 ++++++++++++++++ ...estructuringPropertyParameters3.errors.txt | 53 +++++++++++++++ .../destructuringPropertyParameters3.js | 63 +++++++++++++++++ ...estructuringPropertyParameters4.errors.txt | 57 ++++++++++++++++ .../destructuringPropertyParameters4.js | 65 ++++++++++++++++++ ...estructuringPropertyParameters5.errors.txt | 51 ++++++++++++++ .../destructuringPropertyParameters1.ts | 29 ++++++++ .../destructuringPropertyParameters2.ts | 28 ++++++++ .../destructuringPropertyParameters3.ts | 31 +++++++++ .../destructuringPropertyParameters4.ts | 27 ++++++++ .../destructuringPropertyParameters5.ts | 12 ++++ 13 files changed, 595 insertions(+) create mode 100644 tests/baselines/reference/destructuringPropertyParameters1.errors.txt create mode 100644 tests/baselines/reference/destructuringPropertyParameters2.errors.txt create mode 100644 tests/baselines/reference/destructuringPropertyParameters2.js create mode 100644 tests/baselines/reference/destructuringPropertyParameters3.errors.txt create mode 100644 tests/baselines/reference/destructuringPropertyParameters3.js create mode 100644 tests/baselines/reference/destructuringPropertyParameters4.errors.txt create mode 100644 tests/baselines/reference/destructuringPropertyParameters4.js create mode 100644 tests/baselines/reference/destructuringPropertyParameters5.errors.txt create mode 100644 tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts create mode 100644 tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts create mode 100644 tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts create mode 100644 tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts create mode 100644 tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts diff --git a/tests/baselines/reference/destructuringPropertyParameters1.errors.txt b/tests/baselines/reference/destructuringPropertyParameters1.errors.txt new file mode 100644 index 00000000000..58625d2d115 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters1.errors.txt @@ -0,0 +1,68 @@ +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(16,24): error TS1005: ',' expected. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,52): error TS2339: Property 'z' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,26): error TS2339: Property 'x' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,35): error TS2339: Property 'y' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,43): error TS2339: Property 'y' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,52): error TS2339: Property 'z' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(27,10): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(28,6): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(28,23): error TS1005: ':' expected. + + +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts (12 errors) ==== + class C1 { + constructor(public [x, y, z]: string[]) { + } + } + + type TupleType1 = [string, number, boolean]; + + class C2 { + constructor(public [x, y, z]: TupleType1) { + } + } + + type ObjType1 = { x: number; y: string; z: boolean } + + class C3 { + constructor(public { x, y, z }: ObjType1) { + ~ +!!! error TS1005: ',' expected. + } + } + + var c1 = new C1([]); + c1 = new C1(["larry", "{curly}", "moe"]); + var useC1Properties = c1.x === c1.y && c1.y === c1.z; + ~ +!!! error TS2339: Property 'x' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'z' does not exist on type 'C1'. + + var c2 = new C2(["10", 10, !!10]); + var useC2Properties = c2.x === c2.y && c2.y === c2.z; + ~ +!!! error TS2339: Property 'x' does not exist on type 'C2'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C2'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C2'. + ~ +!!! error TS2339: Property 'z' does not exist on type 'C2'. + + var c3 = new C3({x: 0, y: "", z: false}); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c3 = new C3({x: 0, "y", z: true}); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~ +!!! error TS1005: ':' expected. + var useC3Properties = c3.x === c3.y && c3.y === c3.z; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringPropertyParameters2.errors.txt b/tests/baselines/reference/destructuringPropertyParameters2.errors.txt new file mode 100644 index 00000000000..75d873cf3d6 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters2.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. + + +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts (7 errors) ==== + class C1 { + constructor(private k: number, private [a, b, c]: [number, string, boolean]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + ~ +!!! error TS2339: Property 'b' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'C1'. + this.a = a || k; + ~ +!!! error TS2339: Property 'a' does not exist on type 'C1'. + } + } + + public getA() { + return this.a + ~ +!!! error TS2339: Property 'a' does not exist on type 'C1'. + } + + public getB() { + return this.b + ~ +!!! error TS2339: Property 'b' does not exist on type 'C1'. + } + + public getC() { + return this.c; + ~ +!!! error TS2339: Property 'c' does not exist on type 'C1'. + } + } + + var x = new C1(undefined, [0, undefined, ""]); + ~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. + var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; + + var y = new C1(10, [0, "", true]); + var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()]; + + var z = new C1(10, [undefined, "", null]); + var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringPropertyParameters2.js b/tests/baselines/reference/destructuringPropertyParameters2.js new file mode 100644 index 00000000000..026fe4896f8 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters2.js @@ -0,0 +1,58 @@ +//// [destructuringPropertyParameters2.ts] +class C1 { + constructor(private k: number, private [a, b, c]: [number, string, boolean]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + + public getA() { + return this.a + } + + public getB() { + return this.b + } + + public getC() { + return this.c; + } +} + +var x = new C1(undefined, [0, undefined, ""]); +var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; + +var y = new C1(10, [0, "", true]); +var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()]; + +var z = new C1(10, [undefined, "", null]); +var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; + + +//// [destructuringPropertyParameters2.js] +var C1 = (function () { + function C1(k, _a) { + var a = _a[0], b = _a[1], c = _a[2]; + this.k = k; + this.[a, b, c] = [a, b, c]; + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + C1.prototype.getA = function () { + return this.a; + }; + C1.prototype.getB = function () { + return this.b; + }; + C1.prototype.getC = function () { + return this.c; + }; + return C1; +})(); +var x = new C1(undefined, [0, undefined, ""]); +var _a = [x.getA(), x.getB(), x.getC()], x_a = _a[0], x_b = _a[1], x_c = _a[2]; +var y = new C1(10, [0, "", true]); +var _b = [y.getA(), y.getB(), y.getC()], y_a = _b[0], y_b = _b[1], y_c = _b[2]; +var z = new C1(10, [undefined, "", null]); +var _c = [z.getA(), z.getB(), z.getC()], z_a = _c[0], z_b = _c[1], z_c = _c[2]; diff --git a/tests/baselines/reference/destructuringPropertyParameters3.errors.txt b/tests/baselines/reference/destructuringPropertyParameters3.errors.txt new file mode 100644 index 00000000000..15cd0dbdebf --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters3.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. + + +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts (6 errors) ==== + class C1 { + constructor(private k: T, private [a, b, c]: [T,U,V]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + ~ +!!! error TS2339: Property 'b' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'C1'. + this.a = a || k; + ~ +!!! error TS2339: Property 'a' does not exist on type 'C1'. + } + } + + public getA() { + return this.a + ~ +!!! error TS2339: Property 'a' does not exist on type 'C1'. + } + + public getB() { + return this.b + ~ +!!! error TS2339: Property 'b' does not exist on type 'C1'. + } + + public getC() { + return this.c; + ~ +!!! error TS2339: Property 'c' does not exist on type 'C1'. + } + } + + var x = new C1(undefined, [0, true, ""]); + var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; + + var y = new C1(10, [0, true, true]); + var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()]; + + var z = new C1(10, [undefined, "", ""]); + var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; + + var w = new C1(10, [undefined, undefined, undefined]); + var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringPropertyParameters3.js b/tests/baselines/reference/destructuringPropertyParameters3.js new file mode 100644 index 00000000000..538f58d53f7 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters3.js @@ -0,0 +1,63 @@ +//// [destructuringPropertyParameters3.ts] +class C1 { + constructor(private k: T, private [a, b, c]: [T,U,V]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + + public getA() { + return this.a + } + + public getB() { + return this.b + } + + public getC() { + return this.c; + } +} + +var x = new C1(undefined, [0, true, ""]); +var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; + +var y = new C1(10, [0, true, true]); +var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()]; + +var z = new C1(10, [undefined, "", ""]); +var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; + +var w = new C1(10, [undefined, undefined, undefined]); +var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; + + +//// [destructuringPropertyParameters3.js] +var C1 = (function () { + function C1(k, _a) { + var a = _a[0], b = _a[1], c = _a[2]; + this.k = k; + this.[a, b, c] = [a, b, c]; + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + C1.prototype.getA = function () { + return this.a; + }; + C1.prototype.getB = function () { + return this.b; + }; + C1.prototype.getC = function () { + return this.c; + }; + return C1; +})(); +var x = new C1(undefined, [0, true, ""]); +var _a = [x.getA(), x.getB(), x.getC()], x_a = _a[0], x_b = _a[1], x_c = _a[2]; +var y = new C1(10, [0, true, true]); +var _b = [y.getA(), y.getB(), y.getC()], y_a = _b[0], y_b = _b[1], y_c = _b[2]; +var z = new C1(10, [undefined, "", ""]); +var _c = [z.getA(), z.getB(), z.getC()], z_a = _c[0], z_b = _c[1], z_c = _c[2]; +var w = new C1(10, [undefined, undefined, undefined]); +var _d = [z.getA(), z.getB(), z.getC()], z_a = _d[0], z_b = _d[1], z_c = _d[2]; diff --git a/tests/baselines/reference/destructuringPropertyParameters4.errors.txt b/tests/baselines/reference/destructuringPropertyParameters4.errors.txt new file mode 100644 index 00000000000..f8c9e899ebb --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters4.errors.txt @@ -0,0 +1,57 @@ +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(4,59): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(4,83): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(5,18): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(10,21): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(14,21): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(18,21): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,24): error TS2339: Property 'x' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,34): error TS2339: Property 'y' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,44): error TS2339: Property 'z' does not exist on type 'C2'. + + +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts (9 errors) ==== + + class C1 { + constructor(private k: T, protected [a, b, c]: [T,U,V]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + ~ +!!! error TS2339: Property 'b' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'c' does not exist on type 'C1'. + this.a = a || k; + ~ +!!! error TS2339: Property 'a' does not exist on type 'C1'. + } + } + + public getA() { + return this.a + ~ +!!! error TS2339: Property 'a' does not exist on type 'C1'. + } + + public getB() { + return this.b + ~ +!!! error TS2339: Property 'b' does not exist on type 'C1'. + } + + public getC() { + return this.c; + ~ +!!! error TS2339: Property 'c' does not exist on type 'C1'. + } + } + + class C2 extends C1 { + public doSomethingWithSuperProperties() { + return `${this.x} ${this.y} ${this.z}`; + ~ +!!! error TS2339: Property 'x' does not exist on type 'C2'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C2'. + ~ +!!! error TS2339: Property 'z' does not exist on type 'C2'. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringPropertyParameters4.js b/tests/baselines/reference/destructuringPropertyParameters4.js new file mode 100644 index 00000000000..02784ad5f82 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters4.js @@ -0,0 +1,65 @@ +//// [destructuringPropertyParameters4.ts] + +class C1 { + constructor(private k: T, protected [a, b, c]: [T,U,V]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + + public getA() { + return this.a + } + + public getB() { + return this.b + } + + public getC() { + return this.c; + } +} + +class C2 extends C1 { + public doSomethingWithSuperProperties() { + return `${this.x} ${this.y} ${this.z}`; + } +} + + +//// [destructuringPropertyParameters4.js] +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var C1 = (function () { + function C1(k, [a, b, c]) { + this.k = k; + this.[a, b, c] = [a, b, c]; + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + C1.prototype.getA = function () { + return this.a; + }; + C1.prototype.getB = function () { + return this.b; + }; + C1.prototype.getC = function () { + return this.c; + }; + return C1; +})(); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + C2.prototype.doSomethingWithSuperProperties = function () { + return `${this.x} ${this.y} ${this.z}`; + }; + return C2; +})(C1); diff --git a/tests/baselines/reference/destructuringPropertyParameters5.errors.txt b/tests/baselines/reference/destructuringPropertyParameters5.errors.txt new file mode 100644 index 00000000000..4531b82d647 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters5.errors.txt @@ -0,0 +1,51 @@ +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(5,27): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(5,31): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(5,35): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,29): error TS2339: Property 'x1' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,40): error TS2339: Property 'x2' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. + Types of property '0' are incompatible. + Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. + Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(11,56): error TS1005: ',' expected. + + +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts (10 errors) ==== + type ObjType1 = { x: number; y: string; z: boolean } + type TupleType1 = [ObjType1, number, string] + + class C1 { + constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) { + ~~ +!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature. + ~~ +!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature. + ~~ +!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature. + var foo: any = x1 || x2 || x3 || y || z; + var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z; + ~~ +!!! error TS2339: Property 'x1' does not exist on type 'C1'. + ~~ +!!! error TS2339: Property 'x2' does not exist on type 'C1'. + ~~ +!!! error TS2339: Property 'x3' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C1'. + ~ +!!! error TS2339: Property 'z' does not exist on type 'C1'. + } + } + + var a = new C1([{ x1: 10, x2: "", x3: true }, "", false); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. +!!! error TS2345: Types of property '0' are incompatible. +!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. +!!! error TS2345: Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. + ~ +!!! error TS1005: ',' expected. + var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts new file mode 100644 index 00000000000..8571db338e8 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts @@ -0,0 +1,29 @@ +class C1 { + constructor(public [x, y, z]: string[]) { + } +} + +type TupleType1 = [string, number, boolean]; + +class C2 { + constructor(public [x, y, z]: TupleType1) { + } +} + +type ObjType1 = { x: number; y: string; z: boolean } + +class C3 { + constructor(public { x, y, z }: ObjType1) { + } +} + +var c1 = new C1([]); +c1 = new C1(["larry", "{curly}", "moe"]); +var useC1Properties = c1.x === c1.y && c1.y === c1.z; + +var c2 = new C2(["10", 10, !!10]); +var useC2Properties = c2.x === c2.y && c2.y === c2.z; + +var c3 = new C3({x: 0, y: "", z: false}); +c3 = new C3({x: 0, "y", z: true}); +var useC3Properties = c3.x === c3.y && c3.y === c3.z; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts new file mode 100644 index 00000000000..b7f37809154 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts @@ -0,0 +1,28 @@ +class C1 { + constructor(private k: number, private [a, b, c]: [number, string, boolean]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + + public getA() { + return this.a + } + + public getB() { + return this.b + } + + public getC() { + return this.c; + } +} + +var x = new C1(undefined, [0, undefined, ""]); +var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; + +var y = new C1(10, [0, "", true]); +var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()]; + +var z = new C1(10, [undefined, "", null]); +var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts new file mode 100644 index 00000000000..6819d024e6a --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts @@ -0,0 +1,31 @@ +class C1 { + constructor(private k: T, private [a, b, c]: [T,U,V]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + + public getA() { + return this.a + } + + public getB() { + return this.b + } + + public getC() { + return this.c; + } +} + +var x = new C1(undefined, [0, true, ""]); +var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; + +var y = new C1(10, [0, true, true]); +var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()]; + +var z = new C1(10, [undefined, "", ""]); +var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; + +var w = new C1(10, [undefined, undefined, undefined]); +var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts new file mode 100644 index 00000000000..e8a494b2274 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts @@ -0,0 +1,27 @@ +// @target: es6 + +class C1 { + constructor(private k: T, protected [a, b, c]: [T,U,V]) { + if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { + this.a = a || k; + } + } + + public getA() { + return this.a + } + + public getB() { + return this.b + } + + public getC() { + return this.c; + } +} + +class C2 extends C1 { + public doSomethingWithSuperProperties() { + return `${this.x} ${this.y} ${this.z}`; + } +} diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts new file mode 100644 index 00000000000..94ec1fe27b5 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts @@ -0,0 +1,12 @@ +type ObjType1 = { x: number; y: string; z: boolean } +type TupleType1 = [ObjType1, number, string] + +class C1 { + constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) { + var foo: any = x1 || x2 || x3 || y || z; + var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z; + } +} + +var a = new C1([{ x1: 10, x2: "", x3: true }, "", false); +var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file From 372b0a4e15e988be403d267ca67ad658f1ca7225 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2015 16:24:23 -0800 Subject: [PATCH 58/93] Updated parser lookahead for modifiers to anticipate object literals. --- src/compiler/parser.ts | 5 +++- ...estructuringPropertyParameters1.errors.txt | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b70c4a7a1d5..5ae44e5ff39 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1395,7 +1395,10 @@ module ts { } function canFollowModifier(): boolean { - return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isLiteralPropertyName(); + return token === SyntaxKind.OpenBracketToken + || token === SyntaxKind.OpenBraceToken + || token === SyntaxKind.AsteriskToken + || isLiteralPropertyName(); } // True if positioned at the start of a list element diff --git a/tests/baselines/reference/destructuringPropertyParameters1.errors.txt b/tests/baselines/reference/destructuringPropertyParameters1.errors.txt index 58625d2d115..d4ed1e27cc0 100644 --- a/tests/baselines/reference/destructuringPropertyParameters1.errors.txt +++ b/tests/baselines/reference/destructuringPropertyParameters1.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(16,24): error TS1005: ',' expected. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'. @@ -7,12 +6,14 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25 tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,35): error TS2339: Property 'y' does not exist on type 'C2'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,43): error TS2339: Property 'y' does not exist on type 'C2'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,52): error TS2339: Property 'z' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(27,10): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(28,6): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(28,23): error TS1005: ':' expected. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,26): error TS2339: Property 'x' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,35): error TS2339: Property 'y' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,43): error TS2339: Property 'y' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,52): error TS2339: Property 'z' does not exist on type 'C3'. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts (12 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts (13 errors) ==== class C1 { constructor(public [x, y, z]: string[]) { } @@ -29,8 +30,6 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(28 class C3 { constructor(public { x, y, z }: ObjType1) { - ~ -!!! error TS1005: ',' expected. } } @@ -58,11 +57,15 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(28 !!! error TS2339: Property 'z' does not exist on type 'C2'. var c3 = new C3({x: 0, y: "", z: false}); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. c3 = new C3({x: 0, "y", z: true}); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. ~ !!! error TS1005: ':' expected. - var useC3Properties = c3.x === c3.y && c3.y === c3.z; \ No newline at end of file + var useC3Properties = c3.x === c3.y && c3.y === c3.z; + ~ +!!! error TS2339: Property 'x' does not exist on type 'C3'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C3'. + ~ +!!! error TS2339: Property 'y' does not exist on type 'C3'. + ~ +!!! error TS2339: Property 'z' does not exist on type 'C3'. \ No newline at end of file From e9f098bdfd73d3675c173ba69f955e0f99c25f7a Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Wed, 14 Jan 2015 01:34:17 +0100 Subject: [PATCH 59/93] Fix jake perftsc task Added ts module prefix andd depend on types.ts (for ts.Map) --- tests/perfsys.ts | 52 +++++++++++++++++++++++++----------------------- tests/perftsc.ts | 6 +++--- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/tests/perfsys.ts b/tests/perfsys.ts index d3f7ff2ab02..143d0d637d4 100644 --- a/tests/perfsys.ts +++ b/tests/perfsys.ts @@ -1,4 +1,6 @@ /// +/// + module perftest { interface IOLog { @@ -10,24 +12,24 @@ module perftest { getOut(): string; } - export var readFile = sys.readFile; - var writeFile = sys.writeFile; - export var write = sys.write; - var resolvePath = sys.resolvePath; - export var getExecutingFilePath = sys.getExecutingFilePath; - export var getCurrentDirectory = sys.getCurrentDirectory; - var exit = sys.exit; + export var readFile = ts.sys.readFile; + var writeFile = ts.sys.writeFile; + export var write = ts.sys.write; + var resolvePath = ts.sys.resolvePath; + export var getExecutingFilePath = ts.sys.getExecutingFilePath; + export var getCurrentDirectory = ts.sys.getCurrentDirectory; + var exit = ts.sys.exit; - var args = sys.args; + var args = ts.sys.args; // augment sys so first ts.executeCommandLine call will be finish silently - sys.write = (s: string) => { }; - sys.exit = (code: number) => { }; - sys.args = [] + ts.sys.write = (s: string) => { }; + ts.sys.exit = (code: number) => { }; + ts.sys.args = [] export function restoreSys() { - sys.args = args; - sys.write = write; + ts.sys.args = args; + ts.sys.write = write; } export function hasLogIOFlag() { @@ -45,7 +47,7 @@ module perftest { var resolvePathLog: ts.Map = {}; export function interceptIO() { - sys.resolvePath = (s) => { + ts.sys.resolvePath = (s) => { var result = resolvePath(s); resolvePathLog[s] = result; return result; @@ -68,21 +70,21 @@ module perftest { var files: ts.Map = {}; log.fileNames.forEach(f => { files[f] = readFile(f); }) - sys.createDirectory = (s: string) => { }; - sys.directoryExists = (s: string) => true; - sys.fileExists = (s: string) => true; + ts.sys.createDirectory = (s: string) => { }; + ts.sys.directoryExists = (s: string) => true; + ts.sys.fileExists = (s: string) => true; - var currentDirectory = sys.getCurrentDirectory(); - sys.getCurrentDirectory = () => currentDirectory; + var currentDirectory = ts.sys.getCurrentDirectory(); + ts.sys.getCurrentDirectory = () => currentDirectory; - var executingFilePath = sys.getExecutingFilePath(); - sys.getExecutingFilePath = () => executingFilePath; + var executingFilePath = ts.sys.getExecutingFilePath(); + ts.sys.getExecutingFilePath = () => executingFilePath; - sys.readFile = (s: string) => { + ts.sys.readFile = (s: string) => { return files[s]; } - sys.resolvePath = (s: string) => { + ts.sys.resolvePath = (s: string) => { var path = log.resolvePath[s]; if (!path) { throw new Error("Unexpected path '" + s + "'"); @@ -90,11 +92,11 @@ module perftest { return path } - sys.writeFile = (path: string, data: string) => { }; + ts.sys.writeFile = (path: string, data: string) => { }; var out: string = ""; - sys.write = (s: string) => { out += s; }; + ts.sys.write = (s: string) => { out += s; }; return { getOut: () => out, diff --git a/tests/perftsc.ts b/tests/perftsc.ts index e42a6710be4..e0189896a15 100644 --- a/tests/perftsc.ts +++ b/tests/perftsc.ts @@ -13,9 +13,9 @@ if (perftest.hasLogIOFlag()) { getDefaultLibFilename: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"), writeFile: (f: string, content: string) => { throw new Error("Unexpected operation: writeFile"); }, getCurrentDirectory: () => perftest.getCurrentDirectory(), - getCanonicalFileName: ts.getCanonicalFileName, - useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, - getNewLine: () => sys.newLine + getCanonicalFileName: (f: string) => ts.sys.useCaseSensitiveFileNames ? f : f.toLowerCase(), + useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, + getNewLine: () => ts.sys.newLine }; var commandLine = ts.parseCommandLine(perftest.getArgsWithoutLogIOFlag()); From e20b22c18bfcdfb838c09831ae391c9282106a3b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2015 16:46:41 -0800 Subject: [PATCH 60/93] Minor changes. --- src/compiler/checker.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7604c709fbc..8ddfb53d21f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7189,7 +7189,7 @@ module ts { checkVariableLikeDeclaration(node); var func = getContainingFunction(node); - if (node.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) { + if (node.flags & NodeFlags.AccessibilityModifier) { func = getContainingFunction(node); if (!(func.kind === SyntaxKind.Constructor && nodeIsPresent(func.body))) { error(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -7208,17 +7208,20 @@ module ts { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ConstructorType || + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ConstructorType || node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor || node.kind === SyntaxKind.ConstructSignature){ checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); + forEach(node.parameters, checkParameter); + if (node.type) { checkSourceElement(node.type); } + if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { From 2ce6c5635dc41fd1c098830071b65ca16cdaf5c5 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 13 Jan 2015 19:11:21 -0800 Subject: [PATCH 61/93] do not apply format on enter for the first line --- src/services/formatting/formatting.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 13c423e9813..787c6fe3f46 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -68,7 +68,9 @@ module ts.formatting { export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] { var line = sourceFile.getLineAndCharacterFromPosition(position).line; - Debug.assert(line >= 2); + if (line === 1) { + return []; + } // get the span for the previous\current line var span = { // get start position for the previous line From fdadd3c18e73c77a95670498087385ad836c7136 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 14 Jan 2015 11:30:58 -0800 Subject: [PATCH 62/93] Fix narrow type for instanceOf and add testcases --- src/compiler/checker.ts | 2 +- .../reference/typeGuardsWithInstanceOf.js | 18 +++++++++++ .../reference/typeGuardsWithInstanceOf.types | 31 +++++++++++++++++++ .../typeGuards/typeGuardsWithInstanceOf.ts | 8 +++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/typeGuardsWithInstanceOf.js create mode 100644 tests/baselines/reference/typeGuardsWithInstanceOf.types create mode 100644 tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 00990f0c8ac..ca3c0276406 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4720,7 +4720,7 @@ module ts { return targetType; } // If current type is a union type, remove all constituents that aren't subtypes of target type - if (type.flags && TypeFlags.Union) { + if (type.flags & TypeFlags.Union) { return getUnionType(filter((type).types, t => isTypeSubtypeOf(t, targetType))); } return type; diff --git a/tests/baselines/reference/typeGuardsWithInstanceOf.js b/tests/baselines/reference/typeGuardsWithInstanceOf.js new file mode 100644 index 00000000000..34af7037f0b --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithInstanceOf.js @@ -0,0 +1,18 @@ +//// [typeGuardsWithInstanceOf.ts] +interface I { global: string; } +var result: I; +var result2: I; + +if (!(result instanceof RegExp)) { + result = result2; +} else if (!result.global) { +} + +//// [typeGuardsWithInstanceOf.js] +var result; +var result2; +if (!(result instanceof RegExp)) { + result = result2; +} +else if (!result.global) { +} diff --git a/tests/baselines/reference/typeGuardsWithInstanceOf.types b/tests/baselines/reference/typeGuardsWithInstanceOf.types new file mode 100644 index 00000000000..0d7b477faed --- /dev/null +++ b/tests/baselines/reference/typeGuardsWithInstanceOf.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts === +interface I { global: string; } +>I : I +>global : string + +var result: I; +>result : I +>I : I + +var result2: I; +>result2 : I +>I : I + +if (!(result instanceof RegExp)) { +>!(result instanceof RegExp) : boolean +>(result instanceof RegExp) : boolean +>result instanceof RegExp : boolean +>result : I +>RegExp : RegExpConstructor + + result = result2; +>result = result2 : I +>result : I +>result2 : I + +} else if (!result.global) { +>!result.global : boolean +>result.global : string +>result : I +>global : string +} diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts new file mode 100644 index 00000000000..2750eb96ebf --- /dev/null +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts @@ -0,0 +1,8 @@ +interface I { global: string; } +var result: I; +var result2: I; + +if (!(result instanceof RegExp)) { + result = result2; +} else if (!result.global) { +} \ No newline at end of file From f58e6fc4a10762735fcebe603b9ceb65f1afa740 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2015 17:45:02 -0800 Subject: [PATCH 63/93] Fixed incorrect tests. --- ...estructuringPropertyParameters1.errors.txt | 41 +++++-------- .../destructuringPropertyParameters1.js | 61 +++++++++++++++++++ ...estructuringPropertyParameters4.errors.txt | 14 ++--- .../destructuringPropertyParameters4.js | 4 +- ...estructuringPropertyParameters5.errors.txt | 9 +-- .../destructuringPropertyParameters5.js | 26 ++++++++ .../destructuringPropertyParameters1.ts | 6 +- .../destructuringPropertyParameters4.ts | 2 +- .../destructuringPropertyParameters5.ts | 2 +- 9 files changed, 120 insertions(+), 45 deletions(-) create mode 100644 tests/baselines/reference/destructuringPropertyParameters1.js create mode 100644 tests/baselines/reference/destructuringPropertyParameters5.js diff --git a/tests/baselines/reference/destructuringPropertyParameters1.errors.txt b/tests/baselines/reference/destructuringPropertyParameters1.errors.txt index d4ed1e27cc0..87debfb17ae 100644 --- a/tests/baselines/reference/destructuringPropertyParameters1.errors.txt +++ b/tests/baselines/reference/destructuringPropertyParameters1.errors.txt @@ -2,18 +2,15 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22 tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,52): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,26): error TS2339: Property 'x' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,35): error TS2339: Property 'y' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,43): error TS2339: Property 'y' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,52): error TS2339: Property 'z' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(28,23): error TS1005: ':' expected. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,26): error TS2339: Property 'x' does not exist on type 'C3'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,35): error TS2339: Property 'y' does not exist on type 'C3'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,43): error TS2339: Property 'y' does not exist on type 'C3'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,52): error TS2339: Property 'z' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,30): error TS2339: Property 'x' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,36): error TS2339: Property 'y' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,42): error TS2339: Property 'z' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,30): error TS2339: Property 'x' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,36): error TS2339: Property 'y' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,42): error TS2339: Property 'z' does not exist on type 'C3'. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts (13 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts (10 errors) ==== class C1 { constructor(public [x, y, z]: string[]) { } @@ -46,26 +43,20 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29 !!! error TS2339: Property 'z' does not exist on type 'C1'. var c2 = new C2(["10", 10, !!10]); - var useC2Properties = c2.x === c2.y && c2.y === c2.z; - ~ + var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z]; + ~ !!! error TS2339: Property 'x' does not exist on type 'C2'. - ~ + ~ !!! error TS2339: Property 'y' does not exist on type 'C2'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'C2'. - ~ + ~ !!! error TS2339: Property 'z' does not exist on type 'C2'. var c3 = new C3({x: 0, y: "", z: false}); - c3 = new C3({x: 0, "y", z: true}); - ~ -!!! error TS1005: ':' expected. - var useC3Properties = c3.x === c3.y && c3.y === c3.z; - ~ + c3 = new C3({x: 0, "y": "y", z: true}); + var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z]; + ~ !!! error TS2339: Property 'x' does not exist on type 'C3'. - ~ + ~ !!! error TS2339: Property 'y' does not exist on type 'C3'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'C3'. - ~ + ~ !!! error TS2339: Property 'z' does not exist on type 'C3'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringPropertyParameters1.js b/tests/baselines/reference/destructuringPropertyParameters1.js new file mode 100644 index 00000000000..95f3bc9736f --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters1.js @@ -0,0 +1,61 @@ +//// [destructuringPropertyParameters1.ts] +class C1 { + constructor(public [x, y, z]: string[]) { + } +} + +type TupleType1 = [string, number, boolean]; + +class C2 { + constructor(public [x, y, z]: TupleType1) { + } +} + +type ObjType1 = { x: number; y: string; z: boolean } + +class C3 { + constructor(public { x, y, z }: ObjType1) { + } +} + +var c1 = new C1([]); +c1 = new C1(["larry", "{curly}", "moe"]); +var useC1Properties = c1.x === c1.y && c1.y === c1.z; + +var c2 = new C2(["10", 10, !!10]); +var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z]; + +var c3 = new C3({x: 0, y: "", z: false}); +c3 = new C3({x: 0, "y": "y", z: true}); +var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z]; + +//// [destructuringPropertyParameters1.js] +var C1 = (function () { + function C1(_a) { + var x = _a[0], y = _a[1], z = _a[2]; + this.[x, y, z] = [x, y, z]; + } + return C1; +})(); +var C2 = (function () { + function C2(_a) { + var x = _a[0], y = _a[1], z = _a[2]; + this.[x, y, z] = [x, y, z]; + } + return C2; +})(); +var C3 = (function () { + function C3(_a) { + var x = _a.x, y = _a.y, z = _a.z; + this.{ x, y, z } = { x, y, z }; + } + return C3; +})(); +var c1 = new C1([]); +c1 = new C1(["larry", "{curly}", "moe"]); +var useC1Properties = c1.x === c1.y && c1.y === c1.z; +var c2 = new C2(["10", 10, !!10]); +var _a = [c2.x, c2.y, c2.z], c2_x = _a[0], c2_y = _a[1], c2_z = _a[2]; +var c3 = new C3({ x: 0, y: "", z: false }); +c3 = new C3({ x: 0, "y": "y", z: true }); +var _b = [c3.x, c3.y, c3.z], c3_x = _b[0], c3_y = _b[1], c3_z = _b[2]; diff --git a/tests/baselines/reference/destructuringPropertyParameters4.errors.txt b/tests/baselines/reference/destructuringPropertyParameters4.errors.txt index f8c9e899ebb..a83fec307af 100644 --- a/tests/baselines/reference/destructuringPropertyParameters4.errors.txt +++ b/tests/baselines/reference/destructuringPropertyParameters4.errors.txt @@ -4,9 +4,9 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(5, tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(10,21): error TS2339: Property 'a' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(14,21): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(18,21): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,24): error TS2339: Property 'x' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,34): error TS2339: Property 'y' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,44): error TS2339: Property 'z' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,24): error TS2339: Property 'a' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,34): error TS2339: Property 'b' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,44): error TS2339: Property 'c' does not exist on type 'C2'. ==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts (9 errors) ==== @@ -45,13 +45,13 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24 class C2 extends C1 { public doSomethingWithSuperProperties() { - return `${this.x} ${this.y} ${this.z}`; + return `${this.a} ${this.b} ${this.c}`; ~ -!!! error TS2339: Property 'x' does not exist on type 'C2'. +!!! error TS2339: Property 'a' does not exist on type 'C2'. ~ -!!! error TS2339: Property 'y' does not exist on type 'C2'. +!!! error TS2339: Property 'b' does not exist on type 'C2'. ~ -!!! error TS2339: Property 'z' does not exist on type 'C2'. +!!! error TS2339: Property 'c' does not exist on type 'C2'. } } \ No newline at end of file diff --git a/tests/baselines/reference/destructuringPropertyParameters4.js b/tests/baselines/reference/destructuringPropertyParameters4.js index 02784ad5f82..4aa796a4f37 100644 --- a/tests/baselines/reference/destructuringPropertyParameters4.js +++ b/tests/baselines/reference/destructuringPropertyParameters4.js @@ -22,7 +22,7 @@ class C1 { class C2 extends C1 { public doSomethingWithSuperProperties() { - return `${this.x} ${this.y} ${this.z}`; + return `${this.a} ${this.b} ${this.c}`; } } @@ -59,7 +59,7 @@ var C2 = (function (_super) { _super.apply(this, arguments); } C2.prototype.doSomethingWithSuperProperties = function () { - return `${this.x} ${this.y} ${this.z}`; + return `${this.a} ${this.b} ${this.c}`; }; return C2; })(C1); diff --git a/tests/baselines/reference/destructuringPropertyParameters5.errors.txt b/tests/baselines/reference/destructuringPropertyParameters5.errors.txt index 4531b82d647..cdb9bc15476 100644 --- a/tests/baselines/reference/destructuringPropertyParameters5.errors.txt +++ b/tests/baselines/reference/destructuringPropertyParameters5.errors.txt @@ -10,10 +10,9 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(11 Types of property '0' are incompatible. Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(11,56): error TS1005: ',' expected. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts (10 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts (9 errors) ==== type ObjType1 = { x: number; y: string; z: boolean } type TupleType1 = [ObjType1, number, string] @@ -40,12 +39,10 @@ tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(11 } } - var a = new C1([{ x1: 10, x2: "", x3: true }, "", false); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. !!! error TS2345: Types of property '0' are incompatible. !!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. !!! error TS2345: Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. - ~ -!!! error TS1005: ',' expected. var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringPropertyParameters5.js b/tests/baselines/reference/destructuringPropertyParameters5.js new file mode 100644 index 00000000000..16f551a24b7 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyParameters5.js @@ -0,0 +1,26 @@ +//// [destructuringPropertyParameters5.ts] +type ObjType1 = { x: number; y: string; z: boolean } +type TupleType1 = [ObjType1, number, string] + +class C1 { + constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) { + var foo: any = x1 || x2 || x3 || y || z; + var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z; + } +} + +var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); +var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; + +//// [destructuringPropertyParameters5.js] +var C1 = (function () { + function C1(_a) { + var _b = _a[0], x1 = _b.x1, x2 = _b.x2, x3 = _b.x3, y = _a[1], z = _a[2]; + this.[{ x1, x2, x3 }, y, z] = [{ x1, x2, x3 }, y, z]; + var foo = x1 || x2 || x3 || y || z; + var bar = this.x1 || this.x2 || this.x3 || this.y || this.z; + } + return C1; +})(); +var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); +var _a = [a.x1, a.x2, a.x3, a.y, a.z], a_x1 = _a[0], a_x2 = _a[1], a_x3 = _a[2], a_y = _a[3], a_z = _a[4]; diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts index 8571db338e8..ba73adc9fde 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts @@ -22,8 +22,8 @@ c1 = new C1(["larry", "{curly}", "moe"]); var useC1Properties = c1.x === c1.y && c1.y === c1.z; var c2 = new C2(["10", 10, !!10]); -var useC2Properties = c2.x === c2.y && c2.y === c2.z; +var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z]; var c3 = new C3({x: 0, y: "", z: false}); -c3 = new C3({x: 0, "y", z: true}); -var useC3Properties = c3.x === c3.y && c3.y === c3.z; \ No newline at end of file +c3 = new C3({x: 0, "y": "y", z: true}); +var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts index e8a494b2274..7a83e5f4d4b 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts @@ -22,6 +22,6 @@ class C1 { class C2 extends C1 { public doSomethingWithSuperProperties() { - return `${this.x} ${this.y} ${this.z}`; + return `${this.a} ${this.b} ${this.c}`; } } diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts index 94ec1fe27b5..02f9b780ad9 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts @@ -8,5 +8,5 @@ class C1 { } } -var a = new C1([{ x1: 10, x2: "", x3: true }, "", false); +var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file From 61e2eb6b8913882834862872a1ed1875bafacf73 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 14 Jan 2015 14:20:32 -0800 Subject: [PATCH 64/93] Renamed tests. --- ...tructuringParameterProperties1.errors.txt} | 22 +++++++++---------- ...s => destructuringParameterProperties1.js} | 4 ++-- ...tructuringParameterProperties2.errors.txt} | 16 +++++++------- ...s => destructuringParameterProperties2.js} | 4 ++-- ...tructuringParameterProperties3.errors.txt} | 14 ++++++------ ...s => destructuringParameterProperties3.js} | 4 ++-- ...tructuringParameterProperties4.errors.txt} | 20 ++++++++--------- ...s => destructuringParameterProperties4.js} | 4 ++-- ...tructuringParameterProperties5.errors.txt} | 20 ++++++++--------- ...s => destructuringParameterProperties5.js} | 4 ++-- ...s => destructuringParameterProperties1.ts} | 0 ...s => destructuringParameterProperties2.ts} | 0 ...s => destructuringParameterProperties3.ts} | 0 ...s => destructuringParameterProperties4.ts} | 0 ...s => destructuringParameterProperties5.ts} | 0 15 files changed, 56 insertions(+), 56 deletions(-) rename tests/baselines/reference/{destructuringPropertyParameters1.errors.txt => destructuringParameterProperties1.errors.txt} (52%) rename tests/baselines/reference/{destructuringPropertyParameters1.js => destructuringParameterProperties1.js} (92%) rename tests/baselines/reference/{destructuringPropertyParameters2.errors.txt => destructuringParameterProperties2.errors.txt} (57%) rename tests/baselines/reference/{destructuringPropertyParameters2.js => destructuringParameterProperties2.js} (93%) rename tests/baselines/reference/{destructuringPropertyParameters3.errors.txt => destructuringParameterProperties3.errors.txt} (61%) rename tests/baselines/reference/{destructuringPropertyParameters3.js => destructuringParameterProperties3.js} (93%) rename tests/baselines/reference/{destructuringPropertyParameters4.errors.txt => destructuringParameterProperties4.errors.txt} (54%) rename tests/baselines/reference/{destructuringPropertyParameters4.js => destructuringParameterProperties4.js} (92%) rename tests/baselines/reference/{destructuringPropertyParameters5.errors.txt => destructuringParameterProperties5.errors.txt} (57%) rename tests/baselines/reference/{destructuringPropertyParameters5.js => destructuringParameterProperties5.js} (89%) rename tests/cases/conformance/es6/destructuring/{destructuringPropertyParameters1.ts => destructuringParameterProperties1.ts} (100%) rename tests/cases/conformance/es6/destructuring/{destructuringPropertyParameters2.ts => destructuringParameterProperties2.ts} (100%) rename tests/cases/conformance/es6/destructuring/{destructuringPropertyParameters3.ts => destructuringParameterProperties3.ts} (100%) rename tests/cases/conformance/es6/destructuring/{destructuringPropertyParameters4.ts => destructuringParameterProperties4.ts} (100%) rename tests/cases/conformance/es6/destructuring/{destructuringPropertyParameters5.ts => destructuringParameterProperties5.ts} (100%) diff --git a/tests/baselines/reference/destructuringPropertyParameters1.errors.txt b/tests/baselines/reference/destructuringParameterProperties1.errors.txt similarity index 52% rename from tests/baselines/reference/destructuringPropertyParameters1.errors.txt rename to tests/baselines/reference/destructuringParameterProperties1.errors.txt index 87debfb17ae..c3a9cfc2924 100644 --- a/tests/baselines/reference/destructuringPropertyParameters1.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties1.errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(22,52): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,30): error TS2339: Property 'x' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,36): error TS2339: Property 'y' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(25,42): error TS2339: Property 'z' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,30): error TS2339: Property 'x' does not exist on type 'C3'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,36): error TS2339: Property 'y' does not exist on type 'C3'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts(29,42): error TS2339: Property 'z' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,52): error TS2339: Property 'z' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,30): error TS2339: Property 'x' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,36): error TS2339: Property 'y' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,42): error TS2339: Property 'z' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,30): error TS2339: Property 'x' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,36): error TS2339: Property 'y' does not exist on type 'C3'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,42): error TS2339: Property 'z' does not exist on type 'C3'. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts (10 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts (10 errors) ==== class C1 { constructor(public [x, y, z]: string[]) { } diff --git a/tests/baselines/reference/destructuringPropertyParameters1.js b/tests/baselines/reference/destructuringParameterProperties1.js similarity index 92% rename from tests/baselines/reference/destructuringPropertyParameters1.js rename to tests/baselines/reference/destructuringParameterProperties1.js index 95f3bc9736f..cc16cc78de5 100644 --- a/tests/baselines/reference/destructuringPropertyParameters1.js +++ b/tests/baselines/reference/destructuringParameterProperties1.js @@ -1,4 +1,4 @@ -//// [destructuringPropertyParameters1.ts] +//// [destructuringParameterProperties1.ts] class C1 { constructor(public [x, y, z]: string[]) { } @@ -29,7 +29,7 @@ var c3 = new C3({x: 0, y: "", z: false}); c3 = new C3({x: 0, "y": "y", z: true}); var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z]; -//// [destructuringPropertyParameters1.js] +//// [destructuringParameterProperties1.js] var C1 = (function () { function C1(_a) { var x = _a[0], y = _a[1], z = _a[2]; diff --git a/tests/baselines/reference/destructuringPropertyParameters2.errors.txt b/tests/baselines/reference/destructuringParameterProperties2.errors.txt similarity index 57% rename from tests/baselines/reference/destructuringPropertyParameters2.errors.txt rename to tests/baselines/reference/destructuringParameterProperties2.errors.txt index 75d873cf3d6..3b424f8ae97 100644 --- a/tests/baselines/reference/destructuringPropertyParameters2.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties2.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts (7 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (7 errors) ==== class C1 { constructor(private k: number, private [a, b, c]: [number, string, boolean]) { if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { diff --git a/tests/baselines/reference/destructuringPropertyParameters2.js b/tests/baselines/reference/destructuringParameterProperties2.js similarity index 93% rename from tests/baselines/reference/destructuringPropertyParameters2.js rename to tests/baselines/reference/destructuringParameterProperties2.js index 026fe4896f8..27e190af62f 100644 --- a/tests/baselines/reference/destructuringPropertyParameters2.js +++ b/tests/baselines/reference/destructuringParameterProperties2.js @@ -1,4 +1,4 @@ -//// [destructuringPropertyParameters2.ts] +//// [destructuringParameterProperties2.ts] class C1 { constructor(private k: number, private [a, b, c]: [number, string, boolean]) { if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { @@ -29,7 +29,7 @@ var z = new C1(10, [undefined, "", null]); var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; -//// [destructuringPropertyParameters2.js] +//// [destructuringParameterProperties2.js] var C1 = (function () { function C1(k, _a) { var a = _a[0], b = _a[1], c = _a[2]; diff --git a/tests/baselines/reference/destructuringPropertyParameters3.errors.txt b/tests/baselines/reference/destructuringParameterProperties3.errors.txt similarity index 61% rename from tests/baselines/reference/destructuringPropertyParameters3.errors.txt rename to tests/baselines/reference/destructuringParameterProperties3.errors.txt index 15cd0dbdebf..44c18d32cc1 100644 --- a/tests/baselines/reference/destructuringPropertyParameters3.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties3.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts (6 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts (6 errors) ==== class C1 { constructor(private k: T, private [a, b, c]: [T,U,V]) { if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { diff --git a/tests/baselines/reference/destructuringPropertyParameters3.js b/tests/baselines/reference/destructuringParameterProperties3.js similarity index 93% rename from tests/baselines/reference/destructuringPropertyParameters3.js rename to tests/baselines/reference/destructuringParameterProperties3.js index 538f58d53f7..fe9e69d7e5b 100644 --- a/tests/baselines/reference/destructuringPropertyParameters3.js +++ b/tests/baselines/reference/destructuringParameterProperties3.js @@ -1,4 +1,4 @@ -//// [destructuringPropertyParameters3.ts] +//// [destructuringParameterProperties3.ts] class C1 { constructor(private k: T, private [a, b, c]: [T,U,V]) { if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { @@ -32,7 +32,7 @@ var w = new C1(10, [undefined, undefined, undefined]); var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()]; -//// [destructuringPropertyParameters3.js] +//// [destructuringParameterProperties3.js] var C1 = (function () { function C1(k, _a) { var a = _a[0], b = _a[1], c = _a[2]; diff --git a/tests/baselines/reference/destructuringPropertyParameters4.errors.txt b/tests/baselines/reference/destructuringParameterProperties4.errors.txt similarity index 54% rename from tests/baselines/reference/destructuringPropertyParameters4.errors.txt rename to tests/baselines/reference/destructuringParameterProperties4.errors.txt index a83fec307af..9d8fdb9d933 100644 --- a/tests/baselines/reference/destructuringPropertyParameters4.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties4.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(4,59): error TS2339: Property 'b' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(4,83): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(5,18): error TS2339: Property 'a' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(10,21): error TS2339: Property 'a' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(14,21): error TS2339: Property 'b' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(18,21): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,24): error TS2339: Property 'a' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,34): error TS2339: Property 'b' does not exist on type 'C2'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts(24,44): error TS2339: Property 'c' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,59): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,83): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(5,18): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(10,21): error TS2339: Property 'a' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(14,21): error TS2339: Property 'b' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(18,21): error TS2339: Property 'c' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,24): error TS2339: Property 'a' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,34): error TS2339: Property 'b' does not exist on type 'C2'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,44): error TS2339: Property 'c' does not exist on type 'C2'. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts (9 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts (9 errors) ==== class C1 { constructor(private k: T, protected [a, b, c]: [T,U,V]) { diff --git a/tests/baselines/reference/destructuringPropertyParameters4.js b/tests/baselines/reference/destructuringParameterProperties4.js similarity index 92% rename from tests/baselines/reference/destructuringPropertyParameters4.js rename to tests/baselines/reference/destructuringParameterProperties4.js index 4aa796a4f37..6da6f53a4fe 100644 --- a/tests/baselines/reference/destructuringPropertyParameters4.js +++ b/tests/baselines/reference/destructuringParameterProperties4.js @@ -1,4 +1,4 @@ -//// [destructuringPropertyParameters4.ts] +//// [destructuringParameterProperties4.ts] class C1 { constructor(private k: T, protected [a, b, c]: [T,U,V]) { @@ -27,7 +27,7 @@ class C2 extends C1 { } -//// [destructuringPropertyParameters4.js] +//// [destructuringParameterProperties4.js] var __extends = this.__extends || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } diff --git a/tests/baselines/reference/destructuringPropertyParameters5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt similarity index 57% rename from tests/baselines/reference/destructuringPropertyParameters5.errors.txt rename to tests/baselines/reference/destructuringParameterProperties5.errors.txt index cdb9bc15476..00839fff662 100644 --- a/tests/baselines/reference/destructuringPropertyParameters5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -1,18 +1,18 @@ -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(5,27): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(5,31): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(5,35): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,29): error TS2339: Property 'x1' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,40): error TS2339: Property 'x2' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,27): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,31): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,35): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,29): error TS2339: Property 'x1' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,40): error TS2339: Property 'x2' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. Types of property '0' are incompatible. Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. -==== tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts (9 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (9 errors) ==== type ObjType1 = { x: number; y: string; z: boolean } type TupleType1 = [ObjType1, number, string] diff --git a/tests/baselines/reference/destructuringPropertyParameters5.js b/tests/baselines/reference/destructuringParameterProperties5.js similarity index 89% rename from tests/baselines/reference/destructuringPropertyParameters5.js rename to tests/baselines/reference/destructuringParameterProperties5.js index 16f551a24b7..d9b1710ae89 100644 --- a/tests/baselines/reference/destructuringPropertyParameters5.js +++ b/tests/baselines/reference/destructuringParameterProperties5.js @@ -1,4 +1,4 @@ -//// [destructuringPropertyParameters5.ts] +//// [destructuringParameterProperties5.ts] type ObjType1 = { x: number; y: string; z: boolean } type TupleType1 = [ObjType1, number, string] @@ -12,7 +12,7 @@ class C1 { var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; -//// [destructuringPropertyParameters5.js] +//// [destructuringParameterProperties5.js] var C1 = (function () { function C1(_a) { var _b = _a[0], x1 = _b.x1, x2 = _b.x2, x3 = _b.x3, y = _a[1], z = _a[2]; diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts similarity index 100% rename from tests/cases/conformance/es6/destructuring/destructuringPropertyParameters1.ts rename to tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts similarity index 100% rename from tests/cases/conformance/es6/destructuring/destructuringPropertyParameters2.ts rename to tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts similarity index 100% rename from tests/cases/conformance/es6/destructuring/destructuringPropertyParameters3.ts rename to tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts similarity index 100% rename from tests/cases/conformance/es6/destructuring/destructuringPropertyParameters4.ts rename to tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts diff --git a/tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts similarity index 100% rename from tests/cases/conformance/es6/destructuring/destructuringPropertyParameters5.ts rename to tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts From e19ebc6d3ea63a33beb70a59c698ba2a152c3d73 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 14 Jan 2015 15:30:17 -0800 Subject: [PATCH 65/93] Disallow binding patterns in parameter properties. --- src/compiler/checker.ts | 3 +++ src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 8 ++++++-- .../destructuringParameterProperties1.errors.txt | 11 ++++++++++- .../destructuringParameterProperties2.errors.txt | 5 ++++- .../destructuringParameterProperties3.errors.txt | 5 ++++- .../destructuringParameterProperties4.errors.txt | 5 ++++- .../destructuringParameterProperties5.errors.txt | 5 ++++- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8ddfb53d21f..06c4ca9190f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10172,6 +10172,9 @@ module ts { else if (node.kind === SyntaxKind.InterfaceDeclaration && flags & NodeFlags.Ambient) { return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } + else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.AccessibilityModifier) && isBindingPattern((node).name)) { + return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); + } } function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 2a342fa17d2..80e1505569d 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -146,6 +146,7 @@ module ts { Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, A_rest_element_cannot_have_an_initializer: { code: 1186, category: DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, + A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index efb2bfe7e94..704e3ada25f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -224,7 +224,7 @@ "A 'declare' modifier cannot be used with an import declaration.": { "category": "Error", "code": 1079, - "isEarly": true + "isEarly": true }, "Invalid 'reference' directive syntax.": { "category": "Error", @@ -659,7 +659,7 @@ "An implementation cannot be declared in ambient contexts.": { "category": "Error", "code": 1184, - "isEarly": true + "isEarly": true }, "Modifiers cannot appear here.": { "category": "Error", @@ -673,6 +673,10 @@ "category": "Error", "code": 1186 }, + "A parameter property may not be a binding pattern.": { + "category": "Error", + "code": 1187 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/tests/baselines/reference/destructuringParameterProperties1.errors.txt b/tests/baselines/reference/destructuringParameterProperties1.errors.txt index c3a9cfc2924..b8f3a22b4c5 100644 --- a/tests/baselines/reference/destructuringParameterProperties1.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties1.errors.txt @@ -1,3 +1,6 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2,17): error TS1187: A parameter property may not be a binding pattern. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(9,17): error TS1187: A parameter property may not be a binding pattern. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(16,17): error TS1187: A parameter property may not be a binding pattern. tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'. @@ -10,9 +13,11 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2 tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,42): error TS2339: Property 'z' does not exist on type 'C3'. -==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts (10 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts (13 errors) ==== class C1 { constructor(public [x, y, z]: string[]) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. } } @@ -20,6 +25,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2 class C2 { constructor(public [x, y, z]: TupleType1) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. } } @@ -27,6 +34,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2 class C3 { constructor(public { x, y, z }: ObjType1) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. } } diff --git a/tests/baselines/reference/destructuringParameterProperties2.errors.txt b/tests/baselines/reference/destructuringParameterProperties2.errors.txt index 3b424f8ae97..61c0e61611a 100644 --- a/tests/baselines/reference/destructuringParameterProperties2.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties2.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2,36): error TS1187: A parameter property may not be a binding pattern. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. @@ -7,9 +8,11 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(1 tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. -==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (7 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ==== class C1 { constructor(private k: number, private [a, b, c]: [number, string, boolean]) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { ~ !!! error TS2339: Property 'b' does not exist on type 'C1'. diff --git a/tests/baselines/reference/destructuringParameterProperties3.errors.txt b/tests/baselines/reference/destructuringParameterProperties3.errors.txt index 44c18d32cc1..73d7dab2a38 100644 --- a/tests/baselines/reference/destructuringParameterProperties3.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties3.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(2,31): error TS1187: A parameter property may not be a binding pattern. tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'. @@ -6,9 +7,11 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(1 tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. -==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts (6 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts (7 errors) ==== class C1 { constructor(private k: T, private [a, b, c]: [T,U,V]) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { ~ !!! error TS2339: Property 'b' does not exist on type 'C1'. diff --git a/tests/baselines/reference/destructuringParameterProperties4.errors.txt b/tests/baselines/reference/destructuringParameterProperties4.errors.txt index 9d8fdb9d933..04f6f82b5df 100644 --- a/tests/baselines/reference/destructuringParameterProperties4.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties4.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(3,31): error TS1187: A parameter property may not be a binding pattern. tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,59): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,83): error TS2339: Property 'c' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(5,18): error TS2339: Property 'a' does not exist on type 'C1'. @@ -9,10 +10,12 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(2 tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,44): error TS2339: Property 'c' does not exist on type 'C2'. -==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts (9 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts (10 errors) ==== class C1 { constructor(private k: T, protected [a, b, c]: [T,U,V]) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { ~ !!! error TS2339: Property 'b' does not exist on type 'C1'. diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index 00839fff662..dca02a9a84e 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,17): error TS1187: A parameter property may not be a binding pattern. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,27): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,31): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,35): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature. @@ -12,12 +13,14 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'. -==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (9 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ==== type ObjType1 = { x: number; y: string; z: boolean } type TupleType1 = [ObjType1, number, string] class C1 { constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1187: A parameter property may not be a binding pattern. ~~ !!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature. ~~ From 6e8957da34d8ea9f100137825cfa13ba0d58c2c6 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 14 Jan 2015 16:28:10 -0800 Subject: [PATCH 66/93] Pass information of rwc's currentDirectory to the compiler host in the Harness --- src/harness/harness.ts | 28 +++++++++++++++++++--------- src/harness/rwcRunner.ts | 12 +++++++++--- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ba84a3c9ffd..ecae4ee47a4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -810,7 +810,9 @@ module Harness { export function createCompilerHost(inputFiles: { unitName: string; content: string; }[], writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void, scriptTarget: ts.ScriptTarget, - useCaseSensitiveFileNames: boolean): ts.CompilerHost { + useCaseSensitiveFileNames: boolean, + // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host + currentDirectory?: string): ts.CompilerHost { // Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames function getCanonicalFileName(fileName: string): string { @@ -818,6 +820,8 @@ module Harness { } var filemap: { [filename: string]: ts.SourceFile; } = {}; + var getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory; + // Register input files function register(file: { unitName: string; content: string; }) { if (file.content !== undefined) { @@ -828,11 +832,15 @@ module Harness { inputFiles.forEach(register); return { - getCurrentDirectory: ts.sys.getCurrentDirectory, + getCurrentDirectory, getSourceFile: (fn, languageVersion) => { if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) { return filemap[getCanonicalFileName(fn)]; } + else if (currentDirectory) { + var canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory)); + return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined; + } else if (fn === fourslashFilename) { var tsFn = 'tests/cases/fourslash/' + fourslashFilename; fourslashSourceFile = fourslashSourceFile || ts.createSourceFile(tsFn, Harness.IO.readFile(tsFn), scriptTarget); @@ -909,7 +917,9 @@ module Harness { otherFiles: { unitName: string; content: string }[], onComplete: (result: CompilerResult, program: ts.Program) => void, settingsCallback?: (settings: ts.CompilerOptions) => void, - options?: ts.CompilerOptions) { + options?: ts.CompilerOptions, + // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file + currentDirectory?: string) { options = options || { noResolve: false }; options.target = options.target || ts.ScriptTarget.ES3; @@ -1063,8 +1073,7 @@ module Harness { var programFiles = inputFiles.map(file => file.unitName); var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(otherFiles), (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), - options.target, - useCaseSensitiveFileNames)); + options.target, useCaseSensitiveFileNames, currentDirectory)); var checker = program.getTypeChecker(/*produceDiagnostics*/ true); @@ -1095,7 +1104,9 @@ module Harness { otherFiles: { unitName: string; content: string; }[], result: CompilerResult, settingsCallback?: (settings: ts.CompilerOptions) => void, - options?: ts.CompilerOptions) { + options?: ts.CompilerOptions, + // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file + currentDirectory?: string) { if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) { throw new Error('There were no errors and declFiles generated did not match number of js files generated'); } @@ -1108,9 +1119,8 @@ module Harness { ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles)); ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles)); - this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { - declResult = compileResult; - }, settingsCallback, options); + this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; }, + settingsCallback, options, currentDirectory); return { declInputFiles, declOtherFiles, declResult }; } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 085f66f1a3e..5cf9023a7c5 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -28,6 +28,7 @@ module RWC { var compilerOptions: ts.CompilerOptions; var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' }; var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; + var currentDirectory: string; after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. @@ -45,6 +46,7 @@ module RWC { var opts: ts.ParsedCommandLine; var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); + currentDirectory = ioLog.currentDirectory; runWithIOLog(ioLog, () => { opts = ts.parseCommandLine(ioLog.arguments); assert.equal(opts.errors.length, 0); @@ -52,7 +54,6 @@ module RWC { runWithIOLog(ioLog, () => { harnessCompiler.reset(); - // Load the files ts.forEach(opts.filenames, fileName => { inputFiles.push(getHarnessCompilerInputUnit(fileName)); @@ -81,7 +82,11 @@ module RWC { // Emit the results compilerOptions = harnessCompiler.compileFiles(inputFiles, otherFiles, compileResult => { compilerResult = compileResult; - }, /*settingsCallback*/ undefined, opts.options); + }, + /*settingsCallback*/ undefined, opts.options, + // Since all Rwc json file specified current directory in its json file, we need to pass this information to compilerHost + // so that when the host is asked for current directory, it should give the value from json rather than from process + currentDirectory); }); function getHarnessCompilerInputUnit(fileName: string) { @@ -145,7 +150,8 @@ module RWC { it('has the expected errors in generated declaration files', () => { if (compilerOptions.declaration && !compilerResult.errors.length) { Harness.Baseline.runBaseline('has the expected errors in generated declaration files', baseName + '.dts.errors.txt', () => { - var declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions); + var declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, + /*settingscallback*/ undefined, compilerOptions, currentDirectory); if (declFileCompilationResult.declResult.errors.length === 0) { return null; } From dafe7c8958bee8cfae4e9b7b264336fa7f1178eb Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 14 Jan 2015 17:02:31 -0800 Subject: [PATCH 67/93] Added tests. --- .../optionalBindingParameters1.errors.txt | 14 +++++++++++++ .../reference/optionalBindingParameters1.js | 16 +++++++++++++++ .../optionalBindingParameters2.errors.txt | 18 +++++++++++++++++ .../reference/optionalBindingParameters2.js | 16 +++++++++++++++ ...alBindingParametersInOverloads1.errors.txt | 15 ++++++++++++++ .../optionalBindingParametersInOverloads1.js | 20 +++++++++++++++++++ ...alBindingParametersInOverloads2.errors.txt | 19 ++++++++++++++++++ .../optionalBindingParametersInOverloads2.js | 20 +++++++++++++++++++ .../optionalBindingParameters1.ts | 8 ++++++++ .../optionalBindingParameters2.ts | 8 ++++++++ .../optionalBindingParametersInOverloads1.ts | 9 +++++++++ .../optionalBindingParametersInOverloads2.ts | 9 +++++++++ 12 files changed, 172 insertions(+) create mode 100644 tests/baselines/reference/optionalBindingParameters1.errors.txt create mode 100644 tests/baselines/reference/optionalBindingParameters1.js create mode 100644 tests/baselines/reference/optionalBindingParameters2.errors.txt create mode 100644 tests/baselines/reference/optionalBindingParameters2.js create mode 100644 tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt create mode 100644 tests/baselines/reference/optionalBindingParametersInOverloads1.js create mode 100644 tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt create mode 100644 tests/baselines/reference/optionalBindingParametersInOverloads2.js create mode 100644 tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts create mode 100644 tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts create mode 100644 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts create mode 100644 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt new file mode 100644 index 00000000000..dbc0f9a44e9 --- /dev/null +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. + + +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (1 errors) ==== + + function foo([x,y,z]?: [string, number, boolean]) { + + } + + foo(["", 0, false]); + + foo([false, 0, ""]); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParameters1.js b/tests/baselines/reference/optionalBindingParameters1.js new file mode 100644 index 00000000000..536cb1e567a --- /dev/null +++ b/tests/baselines/reference/optionalBindingParameters1.js @@ -0,0 +1,16 @@ +//// [optionalBindingParameters1.ts] + +function foo([x,y,z]?: [string, number, boolean]) { + +} + +foo(["", 0, false]); + +foo([false, 0, ""]); + +//// [optionalBindingParameters1.js] +function foo(_a) { + var x = _a[0], y = _a[1], z = _a[2]; +} +foo(["", 0, false]); +foo([false, 0, ""]); diff --git a/tests/baselines/reference/optionalBindingParameters2.errors.txt b/tests/baselines/reference/optionalBindingParameters2.errors.txt new file mode 100644 index 00000000000..b906bc6a231 --- /dev/null +++ b/tests/baselines/reference/optionalBindingParameters2.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. + Types of property 'x' are incompatible. + Type 'boolean' is not assignable to type 'string'. + + +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (1 errors) ==== + + function foo({ x, y, z }?: { x: string; y: number; z: boolean }) { + + } + + foo({ x: "", y: 0, z: false }); + + foo({ x: false, y: 0, z: "" }); + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. +!!! error TS2345: Types of property 'x' are incompatible. +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParameters2.js b/tests/baselines/reference/optionalBindingParameters2.js new file mode 100644 index 00000000000..04e1138561a --- /dev/null +++ b/tests/baselines/reference/optionalBindingParameters2.js @@ -0,0 +1,16 @@ +//// [optionalBindingParameters2.ts] + +function foo({ x, y, z }?: { x: string; y: number; z: boolean }) { + +} + +foo({ x: "", y: 0, z: false }); + +foo({ x: false, y: 0, z: "" }); + +//// [optionalBindingParameters2.js] +function foo(_a) { + var x = _a.x, y = _a.y, z = _a.z; +} +foo({ x: "", y: 0, z: false }); +foo({ x: false, y: 0, z: "" }); diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt new file mode 100644 index 00000000000..5999ec514b0 --- /dev/null +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(9,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. + + +==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (1 errors) ==== + + function foo([x, y, z] ?: [string, number, boolean]); + function foo(...rest: any[]) { + + } + + foo(["", 0, false]); + + foo([false, 0, ""]); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.js b/tests/baselines/reference/optionalBindingParametersInOverloads1.js new file mode 100644 index 00000000000..3658efa72c6 --- /dev/null +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.js @@ -0,0 +1,20 @@ +//// [optionalBindingParametersInOverloads1.ts] + +function foo([x, y, z] ?: [string, number, boolean]); +function foo(...rest: any[]) { + +} + +foo(["", 0, false]); + +foo([false, 0, ""]); + +//// [optionalBindingParametersInOverloads1.js] +function foo() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +} +foo(["", 0, false]); +foo([false, 0, ""]); diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt new file mode 100644 index 00000000000..765fd5e3de6 --- /dev/null +++ b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(9,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. + Types of property 'x' are incompatible. + Type 'boolean' is not assignable to type 'string'. + + +==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (1 errors) ==== + + function foo({ x, y, z }?: { x: string; y: number; z: boolean }); + function foo(...rest: any[]) { + + } + + foo({ x: "", y: 0, z: false }); + + foo({ x: false, y: 0, z: "" }); + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. +!!! error TS2345: Types of property 'x' are incompatible. +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads2.js b/tests/baselines/reference/optionalBindingParametersInOverloads2.js new file mode 100644 index 00000000000..1ddfdae4f07 --- /dev/null +++ b/tests/baselines/reference/optionalBindingParametersInOverloads2.js @@ -0,0 +1,20 @@ +//// [optionalBindingParametersInOverloads2.ts] + +function foo({ x, y, z }?: { x: string; y: number; z: boolean }); +function foo(...rest: any[]) { + +} + +foo({ x: "", y: 0, z: false }); + +foo({ x: false, y: 0, z: "" }); + +//// [optionalBindingParametersInOverloads2.js] +function foo() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +} +foo({ x: "", y: 0, z: false }); +foo({ x: false, y: 0, z: "" }); diff --git a/tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts b/tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts new file mode 100644 index 00000000000..5bdcb49e5d9 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts @@ -0,0 +1,8 @@ + +function foo([x,y,z]?: [string, number, boolean]) { + +} + +foo(["", 0, false]); + +foo([false, 0, ""]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts b/tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts new file mode 100644 index 00000000000..12338aeb445 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts @@ -0,0 +1,8 @@ + +function foo({ x, y, z }?: { x: string; y: number; z: boolean }) { + +} + +foo({ x: "", y: 0, z: false }); + +foo({ x: false, y: 0, z: "" }); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts b/tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts new file mode 100644 index 00000000000..82aa49d346a --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts @@ -0,0 +1,9 @@ + +function foo([x, y, z] ?: [string, number, boolean]); +function foo(...rest: any[]) { + +} + +foo(["", 0, false]); + +foo([false, 0, ""]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts b/tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts new file mode 100644 index 00000000000..bbe763b3008 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts @@ -0,0 +1,9 @@ + +function foo({ x, y, z }?: { x: string; y: number; z: boolean }); +function foo(...rest: any[]) { + +} + +foo({ x: "", y: 0, z: false }); + +foo({ x: false, y: 0, z: "" }); \ No newline at end of file From 75a1a8a493675f4e0744ebddb52d0e50fd185001 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 14 Jan 2015 17:25:37 -0800 Subject: [PATCH 68/93] Disallow optional destructured parameters in implementation signatures. --- src/compiler/checker.ts | 3 +++ src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 8 ++++++-- .../reference/optionalBindingParameters1.errors.txt | 5 ++++- .../reference/optionalBindingParameters2.errors.txt | 5 ++++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8e23fb2050d..781718f7299 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7212,6 +7212,9 @@ module ts { error(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } + if (node.questionToken && isBindingPattern(node.name) && func.body) { + error(node, Diagnostics.A_binding_pattern_parameter_may_not_be_optional_in_an_implementation_signature); + } if (node.dotDotDotToken) { if (!isArrayType(getTypeOfSymbol(node.symbol))) { error(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 2a342fa17d2..5f404d51c23 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -297,6 +297,7 @@ module ts { Type_0_has_no_property_1: { code: 2460, category: DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, + A_binding_pattern_parameter_may_not_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter may not be optional in an implementation signature." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index efb2bfe7e94..aa0af6ff743 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -224,7 +224,7 @@ "A 'declare' modifier cannot be used with an import declaration.": { "category": "Error", "code": 1079, - "isEarly": true + "isEarly": true }, "Invalid 'reference' directive syntax.": { "category": "Error", @@ -659,7 +659,7 @@ "An implementation cannot be declared in ambient contexts.": { "category": "Error", "code": 1184, - "isEarly": true + "isEarly": true }, "Modifiers cannot appear here.": { "category": "Error", @@ -1282,6 +1282,10 @@ "category": "Error", "code": 2462 }, + "A binding pattern parameter may not be optional in an implementation signature.": { + "category": "Error", + "code": 2463 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt index dbc0f9a44e9..51cc9d7817f 100644 --- a/tests/baselines/reference/optionalBindingParameters1.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -1,9 +1,12 @@ +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(2,14): error TS2463: A binding pattern parameter may not be optional in an implementation signature. tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (1 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (2 errors) ==== function foo([x,y,z]?: [string, number, boolean]) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter may not be optional in an implementation signature. } diff --git a/tests/baselines/reference/optionalBindingParameters2.errors.txt b/tests/baselines/reference/optionalBindingParameters2.errors.txt index b906bc6a231..56a0a339cc7 100644 --- a/tests/baselines/reference/optionalBindingParameters2.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters2.errors.txt @@ -1,11 +1,14 @@ +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(2,14): error TS2463: A binding pattern parameter may not be optional in an implementation signature. tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. Types of property 'x' are incompatible. Type 'boolean' is not assignable to type 'string'. -==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (1 errors) ==== +==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (2 errors) ==== function foo({ x, y, z }?: { x: string; y: number; z: boolean }) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter may not be optional in an implementation signature. } From ffbdf46f254e18f73fefa704bdea2e1dc97f4676 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 15 Jan 2015 09:56:43 -0800 Subject: [PATCH 69/93] Address code review --- src/harness/rwcRunner.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 5cf9023a7c5..b506cdd66b6 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -39,6 +39,7 @@ module RWC { compilerOptions = undefined; baselineOpts = undefined; baseName = undefined; + currentDirectory = undefined; }); it('can compile', () => { From f9f95ba6149d437d955fbe523ccef13583736d0b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 15 Jan 2015 13:22:23 -0800 Subject: [PATCH 70/93] Support for tsconfig.json files in command-line compiler --- src/compiler/commandLineParser.ts | 108 ++++++++++++++++-- src/compiler/core.ts | 15 ++- .../diagnosticInformationMap.generated.ts | 2 + src/compiler/diagnosticMessages.json | 8 ++ src/compiler/program.ts | 9 +- src/compiler/sys.ts | 63 ++++++++++ src/compiler/tsc.ts | 71 ++++++++++-- src/compiler/types.ts | 9 +- 8 files changed, 258 insertions(+), 27 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index fa31f25f7c3..22e6919319d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -33,6 +33,10 @@ module ts { type: "boolean", description: Diagnostics.Print_this_message, }, + { + name: "listFiles", + type: "boolean", + }, { name: "locale", type: "string", @@ -40,6 +44,7 @@ module ts { { name: "mapRoot", type: "string", + isFilePath: true, description: Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, paramType: Diagnostics.LOCATION, }, @@ -90,6 +95,7 @@ module ts { { name: "outDir", type: "string", + isFilePath: true, description: Diagnostics.Redirect_output_structure_to_the_directory, paramType: Diagnostics.DIRECTORY, }, @@ -98,6 +104,14 @@ module ts { type: "boolean", description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: Diagnostics.Compile_the_project_in_the_given_directory, + paramType: Diagnostics.DIRECTORY + }, { name: "removeComments", type: "boolean", @@ -111,6 +125,7 @@ module ts { { name: "sourceRoot", type: "string", + isFilePath: true, description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: Diagnostics.LOCATION, }, @@ -141,17 +156,6 @@ module ts { } ]; - var shortOptionNames: Map = {}; - var optionNameMap: Map = {}; - - forEach(optionDeclarations, option => { - optionNameMap[option.name.toLowerCase()] = option; - - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - export function parseCommandLine(commandLine: string[]): ParsedCommandLine { // Set default compiler option values var options: CompilerOptions = { @@ -160,7 +164,15 @@ module ts { }; var filenames: string[] = []; var errors: Diagnostic[] = []; + var shortOptionNames: Map = {}; + var optionNameMap: Map = {}; + forEach(optionDeclarations, option => { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; + } + }); parseStrings(commandLine); return { options, @@ -256,4 +268,78 @@ module ts { parseStrings(args); } } + + export function readConfigFile(filename: string): any { + try { + var text = sys.readFile(filename); + return /\S/.test(text) ? JSON.parse(text) : {}; + } + catch (e) { + } + } + + export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine { + var errors: Diagnostic[] = []; + + return { + options: getCompilerOptions(), + filenames: getFiles(), + errors + }; + + function getCompilerOptions(): CompilerOptions { + var options: CompilerOptions = {}; + var optionNameMap: Map = {}; + forEach(optionDeclarations, option => { + optionNameMap[option.name] = option; + }); + var jsonOptions = json["compilerOptions"]; + if (jsonOptions) { + for (var id in jsonOptions) { + if (hasProperty(optionNameMap, id)) { + var opt = optionNameMap[id]; + var optType = opt.type; + var value = jsonOptions[id]; + var expectedType = typeof optType === "string" ? optType : "string"; + if (typeof value === expectedType) { + if (typeof optType !== "string") { + var key = value.toLowerCase(); + if (hasProperty(optType, key)) { + value = optType[key]; + } + else { + errors.push(createCompilerDiagnostic(opt.error)); + value = 0; + } + } + if (opt.isFilePath) { + value = normalizePath(combinePaths(basePath, value)); + } + options[opt.name] = value; + } + else { + errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType)); + } + } + else { + errors.push(createCompilerDiagnostic(Diagnostics.Unknown_compiler_option_0, id)); + } + } + } + return options; + } + + function getFiles(): string[] { + var references: string[] = json["references"] instanceof Array ? json["references"] : [] + var files = map(references, s => combinePaths(basePath, s)); + var sysFiles = sys.readDirectory(basePath, ".ts"); + for (var i = 0; i < sysFiles.length; i++) { + var name = sysFiles[i]; + if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { + files.push(name); + } + } + return files; + } + } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 2e5a471bb27..4a710c035ba 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -178,6 +178,19 @@ module ts { return result; } + export function extend(first: Map, second: Map): Map { + var result: Map = {}; + for (var id in first) { + result[id] = first[id]; + } + for (var id in second) { + if (!hasProperty(result, id)) { + result[id] = second[id]; + } + } + return result; + } + export function forEachValue(map: Map, callback: (value: T) => U): U { var result: U; for (var id in map) { @@ -568,7 +581,7 @@ module ts { export function combinePaths(path1: string, path2: string) { if (!(path1 && path1.length)) return path2; if (!(path2 && path2.length)) return path1; - if (path2.charAt(0) === directorySeparator) return path2; + if (getRootLength(path2) !== 0) return path2; if (path1.charAt(path1.length - 1) === directorySeparator) return path1 + path2; return path1 + directorySeparator + path2; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 2a342fa17d2..6a9b86399df 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -378,6 +378,7 @@ module ts { Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." }, Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, + Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." }, Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." }, @@ -397,6 +398,7 @@ module ts { Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." }, + Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." }, Syntax_Colon_0: { code: 6023, category: DiagnosticCategory.Message, key: "Syntax: {0}" }, options: { code: 6024, category: DiagnosticCategory.Message, key: "options" }, file: { code: 6025, category: DiagnosticCategory.Message, key: "file" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index efb2bfe7e94..00ac39bd0ec 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1610,6 +1610,10 @@ "category": "Error", "code": 5023 }, + "Compiler option '{0}' requires a value of type {1}.": { + "category": "Error", + "code": 5024 + }, "Could not write file '{0}': {1}": { "category": "Error", "code": 5033 @@ -1686,6 +1690,10 @@ "category": "Message", "code": 6019 }, + "Compile the project in the given directory.": { + "category": "Message", + "code": 6020 + }, "Syntax: {0}": { "category": "Message", "code": 6023 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index fc3cc0682d1..5af676aa575 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -81,6 +81,11 @@ module ts { var seenNoDefaultLib = options.noLib; var commonSourceDirectory: string; + //options = extend(options, { + // module: ModuleKind.None, + // target: ScriptTarget.ES3 + //}); + forEach(rootNames, name => processRootFile(name, false)); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFilename(options), true); @@ -146,7 +151,9 @@ module ts { function invokeEmitter(targetSourceFile?: SourceFile) { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(); return emitFiles(resolver, getEmitHost(), targetSourceFile); - } function getSourceFile(filename: string) { + } + + function getSourceFile(filename: string) { filename = host.getCanonicalFileName(filename); return hasProperty(filesByName, filename) ? filesByName[filename] : undefined; } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 27a8c305c4b..eba766162f7 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -14,6 +14,7 @@ module ts { createDirectory(directoryName: string): void; getExecutingFilePath(): string; getCurrentDirectory(): string; + readDirectory(path: string, extension?: string): string[]; getMemoryUsage? (): number; exit(exitCode?: number): void; } @@ -28,6 +29,13 @@ module ts { declare var global: any; declare var __filename: string; + declare class Enumerator { + public atEnd(): boolean; + public moveNext(): boolean; + public item(): any; + constructor(o: any); + } + export var sys: System = (function () { function getWScriptSystem(): System { @@ -100,6 +108,34 @@ module ts { } } + function getNames(collection: any): string[] { + var result: string[] = []; + for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { + result.push(e.item().Name); + } + return result.sort(); + } + + function readDirectory(path: string, extension?: string): string[] { + var result: string[] = []; + visitDirectory(path); + return result; + function visitDirectory(path: string) { + var folder = fso.GetFolder(path || "."); + var files = getNames(folder.files); + for (var i = 0; i < files.length; i++) { + var name = files[i]; + if (!extension || fileExtensionIs(name, extension)) { + result.push(combinePaths(path, name)); + } + } + var subfolders = getNames(folder.subfolders); + for (var i = 0; i < subfolders.length; i++) { + visitDirectory(combinePaths(path, subfolders[i])); + } + } + } + return { args, newLine: "\r\n", @@ -129,6 +165,7 @@ module ts { getCurrentDirectory() { return new ActiveXObject("WScript.Shell").CurrentDirectory; }, + readDirectory, exit(exitCode?: number): void { try { WScript.Quit(exitCode); @@ -185,6 +222,31 @@ module ts { _fs.writeFileSync(fileName, data, "utf8"); } + function readDirectory(path: string, extension?: string): string[] { + var result: string[] = []; + visitDirectory(path); + return result; + function visitDirectory(path: string) { + var files = _fs.readdirSync(path || ".").sort(); + var directories: string[] = []; + for (var i = 0; i < files.length; i++) { + var name = combinePaths(path, files[i]); + var stat = _fs.statSync(name); + if (stat.isFile()) { + if (!extension || fileExtensionIs(name, extension)) { + result.push(name); + } + } + else if (stat.isDirectory()) { + directories.push(name); + } + } + for (var i = 0; i < directories.length; i++) { + visitDirectory(directories[i]); + } + } + } + return { args: process.argv.slice(2), newLine: _os.EOL, @@ -231,6 +293,7 @@ module ts { getCurrentDirectory() { return process.cwd(); }, + readDirectory, getMemoryUsage() { if (global.gc) { global.gc(); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 9d038920693..13a1a8830d5 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -126,9 +126,28 @@ module ts { reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); } + function findConfigFile(): string { + var searchPath = sys.getCurrentDirectory(); + var filename = "tsconfig.json"; + while (true) { + if (sys.fileExists(filename)) { + return filename; + } + var parentPath = getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + filename = "../" + filename; + } + return undefined; + } + export function executeCommandLine(args: string[]): void { var commandLine = parseCommandLine(args); var compilerOptions = commandLine.options; + var filenames = commandLine.filenames; + var configFilename: string; if (compilerOptions.locale) { if (typeof JSON === "undefined") { @@ -157,12 +176,37 @@ module ts { return sys.exit(EmitReturnStatus.Succeeded); } - if (commandLine.filenames.length === 0) { + if (compilerOptions.project) { + configFilename = normalizePath(combinePaths(compilerOptions.project, "tsconfig.json")); + } + else if (filenames.length === 0) { + configFilename = findConfigFile(); + } + + if (commandLine.filenames.length === 0 && !configFilename) { printVersion(); printHelp(); return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } + if (configFilename) { + var configObject = readConfigFile(configFilename); + if (!configObject) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFilename)); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + } + + var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFilename)); + + if (configParseResult.errors.length > 0) { + reportDiagnostics(configParseResult.errors); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + } + + compilerOptions = extend(compilerOptions, configParseResult.options); + filenames = configParseResult.filenames; + } + var defaultCompilerHost = createCompilerHost(compilerOptions); if (compilerOptions.watch) { @@ -170,11 +214,10 @@ module ts { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } - - watchProgram(commandLine, defaultCompilerHost); + watchProgram(filenames, compilerOptions, defaultCompilerHost); } else { - var result = compile(commandLine, defaultCompilerHost).exitStatus + var result = compile(filenames, compilerOptions, defaultCompilerHost).exitStatus return sys.exit(result); } } @@ -185,12 +228,12 @@ module ts { * 250ms and then perform a recompilation. The reasoning is that in some cases, an editor can * save all files at once, and we'd like to just perform a single recompilation. */ - function watchProgram(commandLine: ParsedCommandLine, compilerHost: CompilerHost): void { + function watchProgram(filenames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost): void { var watchers: Map = {}; var updatedFiles: Map = {}; // Compile the program the first time and watch all given/referenced files. - var program = compile(commandLine, compilerHost).program; + var program = compile(filenames, compilerOptions, compilerHost).program; reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); addWatchers(program); return; @@ -257,7 +300,7 @@ module ts { return compilerHost.getSourceFile(fileName, languageVersion, onError); }; - program = compile(commandLine, newCompilerHost).program; + program = compile(filenames, compilerOptions, newCompilerHost).program; reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); addWatchers(program); } @@ -267,10 +310,9 @@ module ts { } } - function compile(commandLine: ParsedCommandLine, compilerHost: CompilerHost) { + function compile(filenames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) { var parseStart = new Date().getTime(); - var compilerOptions = commandLine.options; - var program = createProgram(commandLine.filenames, compilerOptions, compilerHost); + var program = createProgram(filenames, compilerOptions, compilerHost); var bindStart = new Date().getTime(); var errors: Diagnostic[] = program.getDiagnostics(); @@ -303,7 +345,14 @@ module ts { } reportDiagnostics(errors); - if (commandLine.options.diagnostics) { + + if (compilerOptions.listFiles) { + forEach(program.getSourceFiles(), file => { + sys.write(file.filename + sys.newLine); + }); + } + + if (compilerOptions.diagnostics) { var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; reportCountStatistic("Files", program.getSourceFiles().length); reportCountStatistic("Lines", countLines(program)); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9ebab8dc220..b8c842641d7 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1448,6 +1448,7 @@ module ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + listFiles?: boolean; locale?: string; mapRoot?: string; module?: ModuleKind; @@ -1461,6 +1462,7 @@ module ts { out?: string; outDir?: string; preserveConstEnums?: boolean; + project?: string; removeComments?: boolean; sourceMap?: boolean; sourceRoot?: string; @@ -1501,10 +1503,11 @@ module ts { export interface CommandLineOption { name: string; type: string | Map; // "string", "number", "boolean", or an object literal mapping named values to actual values - shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'. + isFilePath?: boolean; // True if option value is a path or filename + shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does - paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter. - error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'. + paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter + error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type' } export const enum CharacterCodes { From 65452aa0114efe610466ff8da29caf5dd9e8ffe4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 15 Jan 2015 15:57:08 -0800 Subject: [PATCH 71/93] Hardening compiler to accept empty CompilerOptions object --- src/compiler/checker.ts | 8 ++++---- src/compiler/commandLineParser.ts | 6 +----- src/compiler/emitter.ts | 22 +++++++++++----------- src/compiler/program.ts | 7 +------ src/compiler/scanner.ts | 12 ++++++------ 5 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7604c709fbc..274a7980ff1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6340,7 +6340,7 @@ module ts { function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { // Grammar checking - if (compilerOptions.target < ScriptTarget.ES6) { + if (!(compilerOptions.target >= ScriptTarget.ES6)) { grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); } @@ -10401,7 +10401,7 @@ module ts { return; var computedPropertyName = node; - if (compilerOptions.target < ScriptTarget.ES6) { + if (!(compilerOptions.target >= ScriptTarget.ES6)) { grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } else if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (computedPropertyName.expression).operator === SyntaxKind.CommaToken) { @@ -10501,7 +10501,7 @@ module ts { function checkGrammarAccessor(accessor: MethodDeclaration): boolean { var kind = accessor.kind; - if (compilerOptions.target < ScriptTarget.ES5) { + if (!(compilerOptions.target >= ScriptTarget.ES5)) { return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } else if (isInAmbientContext(accessor)) { @@ -10706,7 +10706,7 @@ module ts { return grammarErrorAtPos(getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty); } - if (compilerOptions.target < ScriptTarget.ES6) { + if (!(compilerOptions.target >= ScriptTarget.ES6)) { if (isLet(declarationList)) { return grammarErrorOnFirstToken(declarationList, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 22e6919319d..75d18458903 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -157,11 +157,7 @@ module ts { ]; export function parseCommandLine(commandLine: string[]): ParsedCommandLine { - // Set default compiler option values - var options: CompilerOptions = { - target: ScriptTarget.ES3, - module: ModuleKind.None - }; + var options: CompilerOptions = {}; var filenames: string[] = []; var errors: Diagnostic[] = []; var shortOptionNames: Map = {}; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d82e577971d..abef385c76c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2021,14 +2021,14 @@ module ts { } function emitLiteral(node: LiteralExpression) { - var text = compilerOptions.target < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : + var text = !(compilerOptions.target >= ScriptTarget.ES6) && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : node.parent ? getSourceTextOfNodeFromSourceFile(currentSourceFile, node) : node.text; if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } // For version below ES6, emit binary integer literal and octal integer literal in canonical form - else if (compilerOptions.target < ScriptTarget.ES6 && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) { + else if (!(compilerOptions.target >= ScriptTarget.ES6) && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) { write(node.text); } else { @@ -2150,7 +2150,7 @@ module ts { // // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. - Debug.assert(compilerOptions.target <= ScriptTarget.ES5); + Debug.assert(!(compilerOptions.target >= ScriptTarget.ES6)); switch (expression.kind) { case SyntaxKind.BinaryExpression: switch ((expression).operator) { @@ -2405,7 +2405,7 @@ module ts { } emitLeadingComments(node); emit(node.name); - if (compilerOptions.target < ScriptTarget.ES6) { + if (!(compilerOptions.target >= ScriptTarget.ES6)) { write(": function "); } emitSignatureAndBody(node); @@ -2431,7 +2431,7 @@ module ts { // export var obj = { y }; // } // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (compilerOptions.target < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) { + if (!(compilerOptions.target >= ScriptTarget.ES6) || resolver.getExpressionNamePrefix(node.name)) { // Emit identifier as an identifier write(": "); // Even though this is stored as identifier treat it as an expression @@ -2605,7 +2605,7 @@ module ts { function emitBinaryExpression(node: BinaryExpression) { - if (compilerOptions.target < ScriptTarget.ES6 && node.operator === SyntaxKind.EqualsToken && + if (!(compilerOptions.target >= ScriptTarget.ES6) && node.operator === SyntaxKind.EqualsToken && (node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) { emitDestructuring(node); } @@ -3101,7 +3101,7 @@ module ts { function emitVariableDeclaration(node: VariableDeclaration) { emitLeadingComments(node); if (isBindingPattern(node.name)) { - if (compilerOptions.target < ScriptTarget.ES6) { + if (!(compilerOptions.target >= ScriptTarget.ES6)) { emitDestructuring(node); } else { @@ -3136,7 +3136,7 @@ module ts { function emitParameter(node: ParameterDeclaration) { emitLeadingComments(node); - if (compilerOptions.target < ScriptTarget.ES6) { + if (!(compilerOptions.target >= ScriptTarget.ES6)) { if (isBindingPattern(node.name)) { var name = createTempVariable(node); if (!tempParameters) { @@ -3160,7 +3160,7 @@ module ts { } function emitDefaultValueAssignments(node: FunctionLikeDeclaration) { - if (compilerOptions.target < ScriptTarget.ES6) { + if (!(compilerOptions.target >= ScriptTarget.ES6)) { var tempIndex = 0; forEach(node.parameters, p => { if (isBindingPattern(p.name)) { @@ -3190,7 +3190,7 @@ module ts { } function emitRestParameter(node: FunctionLikeDeclaration) { - if (compilerOptions.target < ScriptTarget.ES6 && hasRestParameters(node)) { + if (!(compilerOptions.target >= ScriptTarget.ES6) && hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; var tempName = createTempVariable(node, /*forLoopVariable*/ true).text; @@ -3269,7 +3269,7 @@ module ts { write("("); if (node) { var parameters = node.parameters; - var omitCount = compilerOptions.target < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0; + var omitCount = !(compilerOptions.target >= ScriptTarget.ES6) && hasRestParameters(node) ? 1 : 0; emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5af676aa575..06e63635232 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -81,11 +81,6 @@ module ts { var seenNoDefaultLib = options.noLib; var commonSourceDirectory: string; - //options = extend(options, { - // module: ModuleKind.None, - // target: ScriptTarget.ES3 - //}); - forEach(rootNames, name => processRootFile(name, false)); if (!seenNoDefaultLib) { processRootFile(host.getDefaultLibFilename(options), true); @@ -347,7 +342,7 @@ module ts { } var firstExternalModule = forEach(files, f => isExternalModule(f) ? f : undefined); - if (firstExternalModule && options.module === ModuleKind.None) { + if (firstExternalModule && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator); var errorStart = skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 427bc0012d6..5d800be0275 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -224,15 +224,15 @@ module ts { } function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) { - return languageVersion === ScriptTarget.ES3 ? - lookupInUnicodeMap(code, unicodeES3IdentifierStart) : - lookupInUnicodeMap(code, unicodeES5IdentifierStart); + return languageVersion >= ScriptTarget.ES5 ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } function isUnicodeIdentifierPart(code: number, languageVersion: ScriptTarget) { - return languageVersion === ScriptTarget.ES3 ? - lookupInUnicodeMap(code, unicodeES3IdentifierPart) : - lookupInUnicodeMap(code, unicodeES5IdentifierPart); + return languageVersion >= ScriptTarget.ES5 ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source: Map): string[] { From 50b0cb98cce557f44f92a9970a5beeae648bea0c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 15 Jan 2015 15:57:48 -0800 Subject: [PATCH 72/93] Adding missing @module to several fourslash tests --- tests/cases/fourslash/getEmitOutputSingleFile2.ts | 1 + tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts | 1 + tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts | 1 + tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts | 2 ++ tests/cases/fourslash/underscoreTyping1.ts | 2 ++ 5 files changed, 7 insertions(+) diff --git a/tests/cases/fourslash/getEmitOutputSingleFile2.ts b/tests/cases/fourslash/getEmitOutputSingleFile2.ts index bcb1012a6ea..8bf4f7f4af7 100644 --- a/tests/cases/fourslash/getEmitOutputSingleFile2.ts +++ b/tests/cases/fourslash/getEmitOutputSingleFile2.ts @@ -1,6 +1,7 @@ /// // @BaselineFile: getEmitOutputSingleFile2.baseline +// @module: CommonJS // @declaration: true // @out: declSingleFile.js // @outDir: tests/cases/fourslash/ diff --git a/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts b/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts index f80fa777296..ac68611246b 100644 --- a/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts +++ b/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts @@ -1,6 +1,7 @@ /// // @BaselineFile: getEmitOutputWithDeclarationFile2.baseline +// @module: CommonJS // @Filename: decl.d.ts // @emitThisFile: true diff --git a/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts b/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts index fbd086d191d..6345c464213 100644 --- a/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts +++ b/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts @@ -1,5 +1,6 @@ /// +// @module: CommonJS // @declaration: true //// interface privateInterface {} //// export class Bar implements /*1*/privateInterface/*2*/{ } diff --git a/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts b/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts index 57a490fb31c..dc351a21f2c 100644 --- a/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts +++ b/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts @@ -1,5 +1,7 @@ /// +// @module: CommonJS + //// interface privateInterface {} //// export class Bar implements /*1*/privateInterface/*2*/{ } diff --git a/tests/cases/fourslash/underscoreTyping1.ts b/tests/cases/fourslash/underscoreTyping1.ts index d4556e07f74..fddafe5e88e 100644 --- a/tests/cases/fourslash/underscoreTyping1.ts +++ b/tests/cases/fourslash/underscoreTyping1.ts @@ -1,4 +1,6 @@ /// + +// @module: CommonJS //// interface Dictionary { //// [x: string]: T; From 2a11222050ddbc0e9902476d9b1d3eb3885970fb Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 15 Jan 2015 16:29:50 -0800 Subject: [PATCH 73/93] 'may not' -> 'cannot' --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../baselines/reference/optionalBindingParameters1.errors.txt | 4 ++-- .../baselines/reference/optionalBindingParameters2.errors.txt | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 781718f7299..e3fbff9dc4e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7213,7 +7213,7 @@ module ts { } } if (node.questionToken && isBindingPattern(node.name) && func.body) { - error(node, Diagnostics.A_binding_pattern_parameter_may_not_be_optional_in_an_implementation_signature); + error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.dotDotDotToken) { if (!isArrayType(getTypeOfSymbol(node.symbol))) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 5f404d51c23..a04338de49a 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -297,7 +297,7 @@ module ts { Type_0_has_no_property_1: { code: 2460, category: DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_may_not_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter may not be optional in an implementation signature." }, + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index aa0af6ff743..43f671713e9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1282,7 +1282,7 @@ "category": "Error", "code": 2462 }, - "A binding pattern parameter may not be optional in an implementation signature.": { + "A binding pattern parameter cannot be optional in an implementation signature.": { "category": "Error", "code": 2463 }, diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt index 51cc9d7817f..a2961fb9651 100644 --- a/tests/baselines/reference/optionalBindingParameters1.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(2,14): error TS2463: A binding pattern parameter may not be optional in an implementation signature. +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. @@ -6,7 +6,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): er function foo([x,y,z]?: [string, number, boolean]) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2463: A binding pattern parameter may not be optional in an implementation signature. +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. } diff --git a/tests/baselines/reference/optionalBindingParameters2.errors.txt b/tests/baselines/reference/optionalBindingParameters2.errors.txt index 56a0a339cc7..e67687722d0 100644 --- a/tests/baselines/reference/optionalBindingParameters2.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(2,14): error TS2463: A binding pattern parameter may not be optional in an implementation signature. +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. Types of property 'x' are incompatible. Type 'boolean' is not assignable to type 'string'. @@ -8,7 +8,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): er function foo({ x, y, z }?: { x: string; y: number; z: boolean }) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2463: A binding pattern parameter may not be optional in an implementation signature. +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. } From 960d92f9b66717583fe77edffd0ac19f2c996df2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 15 Jan 2015 17:12:45 -0800 Subject: [PATCH 74/93] Default to all files only when none are specified in tsconfig.json --- src/compiler/commandLineParser.ts | 20 ++++++++++++------- .../diagnosticInformationMap.generated.ts | 9 +++++---- src/compiler/diagnosticMessages.json | 12 +++++++---- src/compiler/tsc.ts | 8 ++++++-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 75d18458903..23bbba5c6ca 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -326,13 +326,19 @@ module ts { } function getFiles(): string[] { - var references: string[] = json["references"] instanceof Array ? json["references"] : [] - var files = map(references, s => combinePaths(basePath, s)); - var sysFiles = sys.readDirectory(basePath, ".ts"); - for (var i = 0; i < sysFiles.length; i++) { - var name = sysFiles[i]; - if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { - files.push(name); + var files: string[] = []; + if (hasProperty(json, "files")) { + if (json["files"] instanceof Array) { + var files = map(json["files"], s => combinePaths(basePath, s)); + } + } + else { + var sysFiles = sys.readDirectory(basePath, ".ts"); + for (var i = 0; i < sysFiles.length; i++) { + var name = sysFiles[i]; + if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { + files.push(name); + } } } return files; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 6a9b86399df..a3c28c42a49 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -380,10 +380,11 @@ module ts { Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option noEmit cannot be specified with option out or outDir." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option noEmit cannot be specified with option declaration." }, + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." }, + Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, + Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 00ac39bd0ec..896af943d9f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1618,22 +1618,26 @@ "category": "Error", "code": 5033 }, - "Option mapRoot cannot be specified without specifying sourcemap option.": { + "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option.": { "category": "Error", "code": 5038 }, - "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option.": { "category": "Error", "code": 5039 }, - "Option noEmit cannot be specified with option out or outDir.": { + "Option 'noEmit' cannot be specified with option 'out' or 'outDir'.": { "category": "Error", "code": 5040 }, - "Option noEmit cannot be specified with option declaration.": { + "Option 'noEmit' cannot be specified with option 'declaration'.": { "category": "Error", "code": 5041 }, + "Option 'project' cannot be mixed with source files on a command line.": { + "category": "Error", + "code": 5042 + }, "Concatenate and emit output to single file.": { "category": "Message", "code": 6001 diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 13a1a8830d5..7fc57c8cf46 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -127,7 +127,7 @@ module ts { } function findConfigFile(): string { - var searchPath = sys.getCurrentDirectory(); + var searchPath = normalizePath(sys.getCurrentDirectory()); var filename = "tsconfig.json"; while (true) { if (sys.fileExists(filename)) { @@ -178,12 +178,16 @@ module ts { if (compilerOptions.project) { configFilename = normalizePath(combinePaths(compilerOptions.project, "tsconfig.json")); + if (filenames.length !== 0) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + } } else if (filenames.length === 0) { configFilename = findConfigFile(); } - if (commandLine.filenames.length === 0 && !configFilename) { + if (filenames.length === 0 && !configFilename) { printVersion(); printHelp(); return sys.exit(EmitReturnStatus.CompilerOptionsErrors); From ee6f2faabbff0c0ecffc1cfefca1a60b10082783 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 15 Jan 2015 17:19:22 -0800 Subject: [PATCH 75/93] Accepting baselines for corrected error messages --- .../amd/mapRootSourceRootWithNoSourceMapOption.errors.txt | 8 ++++---- .../mapRootSourceRootWithNoSourceMapOption.errors.txt | 8 ++++---- .../amd/mapRootWithNoSourceMapOption.errors.txt | 4 ++-- .../node/mapRootWithNoSourceMapOption.errors.txt | 4 ++-- .../amd/sourceRootWithNoSourceMapOption.errors.txt | 4 ++-- .../node/sourceRootWithNoSourceMapOption.errors.txt | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt index 4f41f7523d7..0d3528b6dc3 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. -error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. -!!! error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt index 4f41f7523d7..0d3528b6dc3 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. -error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. -!!! error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt index de6de5ecfc6..01a3526196c 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt index de6de5ecfc6..01a3526196c 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5038: Option mapRoot cannot be specified without specifying sourcemap option. +!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourcemap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt index 93a57bb27f5..b7abc0c2d52 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt index 93a57bb27f5..b7abc0c2d52 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. +error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. -!!! error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option. +!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { From c342b58b23aa735cfc08cc6798635c11259d271a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 15 Jan 2015 18:18:19 -0800 Subject: [PATCH 76/93] Adding reference to core.ts in sys.ts --- src/compiler/sys.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index eba766162f7..8d7b1104ff5 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,3 +1,4 @@ +/// module ts { export interface System { From bce15cb368437d9b38c33770d7f41db7ccd56efd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 16 Jan 2015 07:15:31 -0800 Subject: [PATCH 77/93] Fixing negated language version checks --- src/compiler/checker.ts | 18 ++++++++++-------- src/compiler/emitter.ts | 32 +++++++++++++++++--------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 274a7980ff1..7b78e19c5ef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16,6 +16,8 @@ module ts { var emptySymbols: SymbolTable = {}; var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || ScriptTarget.ES3; + var emitResolver = createResolver(); var checker: TypeChecker = { @@ -6340,7 +6342,7 @@ module ts { function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { // Grammar checking - if (!(compilerOptions.target >= ScriptTarget.ES6)) { + if (languageVersion < ScriptTarget.ES6) { grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); } @@ -10032,7 +10034,7 @@ module ts { globalRegExpType = getGlobalType("RegExp"); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. - globalTemplateStringsArrayType = compilerOptions.target >= ScriptTarget.ES6 + globalTemplateStringsArrayType = languageVersion >= ScriptTarget.ES6 ? getGlobalType("TemplateStringsArray") : unknownType; anyArrayType = createArrayType(anyType); @@ -10401,7 +10403,7 @@ module ts { return; var computedPropertyName = node; - if (!(compilerOptions.target >= ScriptTarget.ES6)) { + if (languageVersion < ScriptTarget.ES6) { grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } else if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (computedPropertyName.expression).operator === SyntaxKind.CommaToken) { @@ -10501,7 +10503,7 @@ module ts { function checkGrammarAccessor(accessor: MethodDeclaration): boolean { var kind = accessor.kind; - if (!(compilerOptions.target >= ScriptTarget.ES5)) { + if (languageVersion < ScriptTarget.ES5) { return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } else if (isInAmbientContext(accessor)) { @@ -10706,7 +10708,7 @@ module ts { return grammarErrorAtPos(getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty); } - if (!(compilerOptions.target >= ScriptTarget.ES6)) { + if (languageVersion < ScriptTarget.ES6) { if (isLet(declarationList)) { return grammarErrorOnFirstToken(declarationList, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } @@ -10808,7 +10810,7 @@ module ts { function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { - var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text); + var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceFile.text); var start = scanToken(scanner, node.pos); diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); return true; @@ -10950,7 +10952,7 @@ module ts { if (node.parserContextFlags & ParserContextFlags.StrictMode) { return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); } - else if (compilerOptions.target >= ScriptTarget.ES5) { + else if (languageVersion >= ScriptTarget.ES5) { return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -10959,7 +10961,7 @@ module ts { function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { - var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text); + var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceFile.text); scanToken(scanner, node.pos); diagnostics.push(createFileDiagnostic(sourceFile, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); return true; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index abef385c76c..25cb7a8b2ee 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -339,6 +339,7 @@ module ts { function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || ScriptTarget.ES3; var write: (s: string) => void; var writeLine: () => void; @@ -1473,6 +1474,7 @@ module ts { export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile?: SourceFile): EmitResult { // var program = resolver.getProgram(); var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || ScriptTarget.ES3; var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined; var diagnostics: Diagnostic[] = []; var newLine = host.getNewLine(); @@ -2021,14 +2023,14 @@ module ts { } function emitLiteral(node: LiteralExpression) { - var text = !(compilerOptions.target >= ScriptTarget.ES6) && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : + var text = languageVersion < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : node.parent ? getSourceTextOfNodeFromSourceFile(currentSourceFile, node) : node.text; if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } // For version below ES6, emit binary integer literal and octal integer literal in canonical form - else if (!(compilerOptions.target >= ScriptTarget.ES6) && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) { + else if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) { write(node.text); } else { @@ -2043,7 +2045,7 @@ module ts { function emitTemplateExpression(node: TemplateExpression): void { // In ES6 mode and above, we can simply emit each portion of a template in order, but in // ES3 & ES5 we must convert the template expression into a series of string concatenations. - if (compilerOptions.target >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES6) { forEachChild(node, emit); return; } @@ -2150,7 +2152,7 @@ module ts { // // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. - Debug.assert(!(compilerOptions.target >= ScriptTarget.ES6)); + Debug.assert(languageVersion < ScriptTarget.ES6); switch (expression.kind) { case SyntaxKind.BinaryExpression: switch ((expression).operator) { @@ -2335,7 +2337,7 @@ module ts { write("[]"); return; } - if (compilerOptions.target >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES6) { write("["); emitList(elements, 0, elements.length, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, /*trailingComma*/ elements.hasTrailingComma); @@ -2385,7 +2387,7 @@ module ts { write(" "); } emitList(properties, 0, properties.length, /*multiLine*/ multiLine, - /*trailingComma*/ properties.hasTrailingComma && compilerOptions.target >= ScriptTarget.ES5); + /*trailingComma*/ properties.hasTrailingComma && languageVersion >= ScriptTarget.ES5); if (!multiLine) { write(" "); } @@ -2405,7 +2407,7 @@ module ts { } emitLeadingComments(node); emit(node.name); - if (!(compilerOptions.target >= ScriptTarget.ES6)) { + if (languageVersion < ScriptTarget.ES6) { write(": function "); } emitSignatureAndBody(node); @@ -2431,7 +2433,7 @@ module ts { // export var obj = { y }; // } // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version - if (!(compilerOptions.target >= ScriptTarget.ES6) || resolver.getExpressionNamePrefix(node.name)) { + if (languageVersion < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) { // Emit identifier as an identifier write(": "); // Even though this is stored as identifier treat it as an expression @@ -2513,7 +2515,7 @@ module ts { } function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { - Debug.assert(compilerOptions.target >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode."); + Debug.assert(languageVersion >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode."); emit(node.tag); write(" "); emit(node.template); @@ -2605,7 +2607,7 @@ module ts { function emitBinaryExpression(node: BinaryExpression) { - if (!(compilerOptions.target >= ScriptTarget.ES6) && node.operator === SyntaxKind.EqualsToken && + if (languageVersion < ScriptTarget.ES6 && node.operator === SyntaxKind.EqualsToken && (node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) { emitDestructuring(node); } @@ -3101,7 +3103,7 @@ module ts { function emitVariableDeclaration(node: VariableDeclaration) { emitLeadingComments(node); if (isBindingPattern(node.name)) { - if (!(compilerOptions.target >= ScriptTarget.ES6)) { + if (languageVersion < ScriptTarget.ES6) { emitDestructuring(node); } else { @@ -3136,7 +3138,7 @@ module ts { function emitParameter(node: ParameterDeclaration) { emitLeadingComments(node); - if (!(compilerOptions.target >= ScriptTarget.ES6)) { + if (languageVersion < ScriptTarget.ES6) { if (isBindingPattern(node.name)) { var name = createTempVariable(node); if (!tempParameters) { @@ -3160,7 +3162,7 @@ module ts { } function emitDefaultValueAssignments(node: FunctionLikeDeclaration) { - if (!(compilerOptions.target >= ScriptTarget.ES6)) { + if (languageVersion < ScriptTarget.ES6) { var tempIndex = 0; forEach(node.parameters, p => { if (isBindingPattern(p.name)) { @@ -3190,7 +3192,7 @@ module ts { } function emitRestParameter(node: FunctionLikeDeclaration) { - if (!(compilerOptions.target >= ScriptTarget.ES6) && hasRestParameters(node)) { + if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; var tempName = createTempVariable(node, /*forLoopVariable*/ true).text; @@ -3269,7 +3271,7 @@ module ts { write("("); if (node) { var parameters = node.parameters; - var omitCount = !(compilerOptions.target >= ScriptTarget.ES6) && hasRestParameters(node) ? 1 : 0; + var omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0; emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); From ca9cd9af2b27b90d9ff5649da64068d468d8faec Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 16 Jan 2015 14:33:51 -0800 Subject: [PATCH 78/93] Change sys to ts.sys in instrumenter --- src/harness/instrumenter.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/harness/instrumenter.ts b/src/harness/instrumenter.ts index 61f6a8f2ec3..1c9b9af78d2 100644 --- a/src/harness/instrumenter.ts +++ b/src/harness/instrumenter.ts @@ -3,11 +3,11 @@ var fs: any = require('fs'); var path: any = require('path'); function instrumentForRecording(fn: string, tscPath: string) { - instrument(tscPath, 'sys = Playback.wrapSystem(sys); sys.startRecord("' + fn + '");', 'sys.endRecord();'); + instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startRecord("' + fn + '");', 'ts.sys.endRecord();'); } function instrumentForReplay(logFilename: string, tscPath: string) { - instrument(tscPath, 'sys = Playback.wrapSystem(sys); sys.startReplay("' + logFilename + '");'); + instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startReplay("' + logFilename + '");'); } function instrument(tscPath: string, prepareCode: string, cleanupCode: string = '') { @@ -27,8 +27,12 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode: string = fs.readFile(path.resolve(path.dirname(tscPath) + '/loggedIO.js'), 'utf-8', (err: any, loggerContent: string) => { if (err) throw err; - var invocationLine = 'ts.executeCommandLine(sys.args);'; + var invocationLine = 'ts.executeCommandLine(ts.sys.args);'; var index1 = tscContent.indexOf(invocationLine); + if (index1 < 0) { + throw new Error("Could not find " + invocationLine); + } + var index2 = index1 + invocationLine.length; var newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + '\r\n'; fs.writeFile(tscPath, newContent); From af61e6424ae5b19279b3f257f7357ea3b4b7ed71 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 18 Jan 2015 17:40:05 -0800 Subject: [PATCH 79/93] Watch for changes to tsconfig.json in -watch mode --- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/tsc.ts | 225 +++++++++--------- 3 files changed, 108 insertions(+), 121 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a3c28c42a49..8683867a4a3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -407,7 +407,7 @@ module ts { Options_Colon: { code: 6027, category: DiagnosticCategory.Message, key: "Options:" }, Version_0: { code: 6029, category: DiagnosticCategory.Message, key: "Version {0}" }, Insert_command_line_options_and_files_from_a_file: { code: 6030, category: DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, - File_change_detected_Compiling: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Compiling..." }, + File_change_detected_Starting_incremental_compilation: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, KIND: { code: 6034, category: DiagnosticCategory.Message, key: "KIND" }, FILE: { code: 6035, category: DiagnosticCategory.Message, key: "FILE" }, VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 896af943d9f..abdb37d2c85 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1726,7 +1726,7 @@ "category": "Message", "code": 6030 }, - "File change detected. Compiling...": { + "File change detected. Starting incremental compilation...": { "category": "Message", "code": 6032 }, diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 7fc57c8cf46..9a537426f68 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -145,16 +145,22 @@ module ts { export function executeCommandLine(args: string[]): void { var commandLine = parseCommandLine(args); - var compilerOptions = commandLine.options; - var filenames = commandLine.filenames; - var configFilename: string; + var existingSourceFiles: SourceFile[]; // Reusable SourceFile objects from last compilation + var existingFilesByName: Map; // SourceFile object lookup + var configFilename: string; // Configuration file name (if any) + var rootFilenames: string[]; // Root filenames for compilation + var compilerOptions: CompilerOptions; // Compiler options for compilation + var compilerHost: CompilerHost; // Compiler host + var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host + var fileWatchers: FileWatcher[]; // Active file watchers + var changedFiles: Map; // Map of files for which change notification was received + var timerStarted: boolean; // Flag for 0.25s timer - if (compilerOptions.locale) { + if (commandLine.options.locale) { if (typeof JSON === "undefined") { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); return sys.exit(1); } - validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); } @@ -165,152 +171,133 @@ module ts { return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } - if (compilerOptions.version) { + if (commandLine.options.version) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version)); return sys.exit(EmitReturnStatus.Succeeded); } - if (compilerOptions.help) { + if (commandLine.options.help) { printVersion(); printHelp(); return sys.exit(EmitReturnStatus.Succeeded); } - if (compilerOptions.project) { - configFilename = normalizePath(combinePaths(compilerOptions.project, "tsconfig.json")); - if (filenames.length !== 0) { + if (commandLine.options.project) { + configFilename = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json")); + if (commandLine.filenames.length !== 0) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } } - else if (filenames.length === 0) { + else if (commandLine.filenames.length === 0) { configFilename = findConfigFile(); } - if (filenames.length === 0 && !configFilename) { + if (commandLine.filenames.length === 0 && !configFilename) { printVersion(); printHelp(); return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } - if (configFilename) { - var configObject = readConfigFile(configFilename); - if (!configObject) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFilename)); - return sys.exit(EmitReturnStatus.CompilerOptionsErrors); - } - - var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFilename)); - - if (configParseResult.errors.length > 0) { - reportDiagnostics(configParseResult.errors); - return sys.exit(EmitReturnStatus.CompilerOptionsErrors); - } - - compilerOptions = extend(compilerOptions, configParseResult.options); - filenames = configParseResult.filenames; + if (commandLine.options.watch && !sys.watchFile) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } - var defaultCompilerHost = createCompilerHost(compilerOptions); - - if (compilerOptions.watch) { - if (!sys.watchFile) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); - return sys.exit(EmitReturnStatus.CompilerOptionsErrors); - } - watchProgram(filenames, compilerOptions, defaultCompilerHost); - } - else { - var result = compile(filenames, compilerOptions, defaultCompilerHost).exitStatus - return sys.exit(result); - } - } + performCompilation(); - /** - * Compiles the program once, and then watches all given and referenced files for changes. - * Upon detecting a file change, watchProgram will queue up file modification events for the next - * 250ms and then perform a recompilation. The reasoning is that in some cases, an editor can - * save all files at once, and we'd like to just perform a single recompilation. - */ - function watchProgram(filenames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost): void { - var watchers: Map = {}; - var updatedFiles: Map = {}; + // Invoked to perform initial compilation or re-compilation in watch mode + function performCompilation() { - // Compile the program the first time and watch all given/referenced files. - var program = compile(filenames, compilerOptions, compilerHost).program; - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); - addWatchers(program); - return; - - function addWatchers(program: Program) { - forEach(program.getSourceFiles(), f => { - var filename = getCanonicalName(f.filename); - watchers[filename] = sys.watchFile(filename, fileUpdated); - }); - } - - function removeWatchers(program: Program) { - forEach(program.getSourceFiles(), f => { - var filename = getCanonicalName(f.filename); - if (hasProperty(watchers, filename)) { - watchers[filename].close(); + if (!existingSourceFiles) { + if (configFilename) { + var configObject = readConfigFile(configFilename); + if (!configObject) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFilename)); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + } + var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFilename)); + if (configParseResult.errors.length > 0) { + reportDiagnostics(configParseResult.errors); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + } + rootFilenames = configParseResult.filenames; + compilerOptions = extend(commandLine.options, configParseResult.options); } - }); - - watchers = {}; - } - - // Fired off whenever a file is changed. - function fileUpdated(filename: string) { - var firstNotification = isEmpty(updatedFiles); - updatedFiles[getCanonicalName(filename)] = true; - - // Only start this off when the first file change comes in, - // so that we can batch up all further changes. - if (firstNotification) { - setTimeout(() => { - var changedFiles = updatedFiles; - updatedFiles = {}; - - recompile(changedFiles); - }, 250); - } - } - - function recompile(changedFiles: Map) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Compiling)); - // Remove all the watchers, as we may not be watching every file - // specified since the last compilation cycle. - removeWatchers(program); - - // Reuse source files from the last compilation so long as they weren't changed. - var oldSourceFiles = arrayToMap( - filter(program.getSourceFiles(), file => !hasProperty(changedFiles, getCanonicalName(file.filename))), - file => getCanonicalName(file.filename)); - - // We create a new compiler host for this compilation cycle. - // This new host is effectively the same except that 'getSourceFile' - // will try to reuse the SourceFiles from the last compilation cycle - // so long as they were not modified. - var newCompilerHost = clone(compilerHost); - newCompilerHost.getSourceFile = (fileName, languageVersion, onError) => { - fileName = getCanonicalName(fileName); - - var sourceFile = lookUp(oldSourceFiles, fileName); - if (sourceFile) { - return sourceFile; + else { + rootFilenames = commandLine.filenames; + compilerOptions = commandLine.options; } + compilerHost = createCompilerHost(compilerOptions); + hostGetSourceFile = compilerHost.getSourceFile; + compilerHost.getSourceFile = getSourceFile; + } + else { + // We have reusable SourceFile objects from the previous compilation + existingFilesByName = arrayToMap(existingSourceFiles, f => compilerHost.getCanonicalFileName(f.filename)); + } - return compilerHost.getSourceFile(fileName, languageVersion, onError); - }; + var compileResult = compile(rootFilenames, compilerOptions, compilerHost); + + if (!commandLine.options.watch) { + return sys.exit(compileResult.exitStatus); + } + + existingSourceFiles = compileResult.program.getSourceFiles(); + existingFilesByName = undefined; + fileWatchers = map(existingSourceFiles, f => sys.watchFile(f.filename, sourceFileChanged)); + if (configFilename) { + fileWatchers.push(sys.watchFile(configFilename, configFileChanged)); + } + changedFiles = {}; + timerStarted = false; - program = compile(filenames, compilerOptions, newCompilerHost).program; reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); - addWatchers(program); } - function getCanonicalName(fileName: string) { - return compilerHost.getCanonicalFileName(fileName); + function getSourceFile(filename: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) { + // Return existing SourceFile object if one is available + if (existingFilesByName) { + var canonicalName = compilerHost.getCanonicalFileName(filename); + if (hasProperty(existingFilesByName, canonicalName)) { + return existingFilesByName[canonicalName]; + } + } + // Use default host function + return hostGetSourceFile(filename, languageVersion, onError); + } + + function sourceFileChanged(filename: string) { + startTimer(); + changedFiles[filename] = true; + } + + function configFileChanged(filename: string) { + startTimer(); + existingSourceFiles = undefined; + } + + // Upon detecting a file change, queue up file modification events for the next 250ms and then + // perform a recompilation. The reasoning is that in some cases an editor can save all files at once, + // and we'd like to just perform a single recompilation. + function startTimer() { + if (!timerStarted) { + timerStarted = true; + setTimeout(recompile, 250); + } + } + + function recompile() { + forEach(fileWatchers, watcher => { + watcher.close(); + }); + if (existingSourceFiles) { + existingSourceFiles = filter(existingSourceFiles, f => !hasProperty(changedFiles, f.filename)); + } + fileWatchers = undefined; + changedFiles = undefined; + reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); + performCompilation(); } } From d736014f3504a381c6de89f014065f78c1e13582 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Tue, 13 Jan 2015 01:33:03 +0000 Subject: [PATCH 80/93] Expose optional getNewLine for language service hosts Fixes #1653. --- src/services/services.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1618fb6e276..84e5e7fefa5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -852,6 +852,7 @@ module ts { // export interface LanguageServiceHost extends Logger { getCompilationSettings(): CompilerOptions; + getNewLine?(): string; getScriptFileNames(): string[]; getScriptVersion(fileName: string): string; getScriptIsOpen(fileName: string): boolean; @@ -1962,7 +1963,9 @@ module ts { getCancellationToken: () => cancellationToken, getCanonicalFileName: (filename) => useCaseSensitivefilenames ? filename : filename.toLowerCase(), useCaseSensitiveFileNames: () => useCaseSensitivefilenames, - getNewLine: () => "\r\n", + getNewLine: () => { + return host.getNewLine ? host.getNewLine() : "\r\n"; + }, getDefaultLibFilename: (options): string => { return host.getDefaultLibFilename(options); }, From 9c802e7bd352c3e1bfd3a6e5275798bce5044a72 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 19 Jan 2015 14:45:23 -0800 Subject: [PATCH 81/93] Modifying logic to watch files at all times in -watch mode --- src/compiler/tsc.ts | 116 ++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 41 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 9a537426f68..370d1357ccb 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -4,6 +4,11 @@ module ts { var version = "1.4.0.0"; + export interface SourceFile { + fileWatcher: FileWatcher; + fileChanged: boolean; + } + /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. @@ -145,16 +150,14 @@ module ts { export function executeCommandLine(args: string[]): void { var commandLine = parseCommandLine(args); - var existingSourceFiles: SourceFile[]; // Reusable SourceFile objects from last compilation - var existingFilesByName: Map; // SourceFile object lookup var configFilename: string; // Configuration file name (if any) + var configFileWatcher: FileWatcher; // Configuration file watcher + var cachedSourceFiles: Map; // Cached SourceFile objects var rootFilenames: string[]; // Root filenames for compilation var compilerOptions: CompilerOptions; // Compiler options for compilation var compilerHost: CompilerHost; // Compiler host var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host - var fileWatchers: FileWatcher[]; // Active file watchers - var changedFiles: Map; // Map of files for which change notification was received - var timerStarted: boolean; // Flag for 0.25s timer + var timerHandle: number; // Handle for 0.25s wait timer if (commandLine.options.locale) { if (typeof JSON === "undefined") { @@ -199,9 +202,14 @@ module ts { return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } - if (commandLine.options.watch && !sys.watchFile) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); - return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + if (commandLine.options.watch) { + if (!sys.watchFile) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + } + if (configFilename) { + configFileWatcher = sys.watchFile(configFilename, configFileChanged); + } } performCompilation(); @@ -209,7 +217,7 @@ module ts { // Invoked to perform initial compilation or re-compilation in watch mode function performCompilation() { - if (!existingSourceFiles) { + if (!cachedSourceFiles) { if (configFilename) { var configObject = readConfigFile(configFilename); if (!configObject) { @@ -232,10 +240,6 @@ module ts { hostGetSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = getSourceFile; } - else { - // We have reusable SourceFile objects from the previous compilation - existingFilesByName = arrayToMap(existingSourceFiles, f => compilerHost.getCanonicalFileName(f.filename)); - } var compileResult = compile(rootFilenames, compilerOptions, compilerHost); @@ -243,59 +247,89 @@ module ts { return sys.exit(compileResult.exitStatus); } - existingSourceFiles = compileResult.program.getSourceFiles(); - existingFilesByName = undefined; - fileWatchers = map(existingSourceFiles, f => sys.watchFile(f.filename, sourceFileChanged)); - if (configFilename) { - fileWatchers.push(sys.watchFile(configFilename, configFileChanged)); - } - changedFiles = {}; - timerStarted = false; - + updateSourceFileCache(compileResult.program.getSourceFiles()); reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(filename: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) { // Return existing SourceFile object if one is available - if (existingFilesByName) { + if (cachedSourceFiles) { var canonicalName = compilerHost.getCanonicalFileName(filename); - if (hasProperty(existingFilesByName, canonicalName)) { - return existingFilesByName[canonicalName]; + if (hasProperty(cachedSourceFiles, canonicalName)) { + return cachedSourceFiles[canonicalName]; } } // Use default host function - return hostGetSourceFile(filename, languageVersion, onError); + var sourceFile = hostGetSourceFile(filename, languageVersion, onError); + // Cache the source file in -watch mode + if (commandLine.options.watch) { + cacheSourceFile(sourceFile); + } + return sourceFile; + } + + function cacheSourceFile(sourceFile: SourceFile) { + cachedSourceFiles = cachedSourceFiles || {}; + cachedSourceFiles[compilerHost.getCanonicalFileName(sourceFile.filename)] = sourceFile; + sourceFile.fileWatcher = sys.watchFile(sourceFile.filename, sourceFileChanged); + } + + function forgetSourceFile(sourceFile: SourceFile) { + if (sourceFile.fileWatcher) { + sourceFile.fileWatcher.close(); + sourceFile.fileWatcher = undefined; + delete cachedSourceFiles[sourceFile.filename]; + } + } + + function updateSourceFileCache(keepSourceFiles: SourceFile[]) { + for (var filename in cachedSourceFiles) { + var sourceFile = cachedSourceFiles[filename]; + if (sourceFile) { + if (!contains(keepSourceFiles, sourceFile)) { + forgetSourceFile(sourceFile); + } + } + } + } + + function clearSourceFileCache() { + if (cachedSourceFiles) { + for (var filename in cachedSourceFiles) { + var sourceFile = cachedSourceFiles[filename]; + if (sourceFile) { + forgetSourceFile(sourceFile); + } + } + } + cachedSourceFiles = undefined; } function sourceFileChanged(filename: string) { - startTimer(); - changedFiles[filename] = true; + var sourceFile = cachedSourceFiles[filename]; + if (sourceFile) { + forgetSourceFile(sourceFile); + startTimer(); + } } - function configFileChanged(filename: string) { + function configFileChanged() { + clearSourceFileCache(); startTimer(); - existingSourceFiles = undefined; } // Upon detecting a file change, queue up file modification events for the next 250ms and then // perform a recompilation. The reasoning is that in some cases an editor can save all files at once, // and we'd like to just perform a single recompilation. function startTimer() { - if (!timerStarted) { - timerStarted = true; - setTimeout(recompile, 250); + if (timerHandle) { + clearTimeout(timerHandle); } + timerHandle = setTimeout(recompile, 250); } function recompile() { - forEach(fileWatchers, watcher => { - watcher.close(); - }); - if (existingSourceFiles) { - existingSourceFiles = filter(existingSourceFiles, f => !hasProperty(changedFiles, f.filename)); - } - fileWatchers = undefined; - changedFiles = undefined; + timerHandle = undefined; reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); performCompilation(); } From 562244ec41fcf455daf841864c46191e3ff32eb0 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 19 Jan 2015 14:58:34 -0800 Subject: [PATCH 82/93] Fix unicode comparision and counting error for test262 --- src/harness/harness.ts | 12 +++++++++--- tests/webhost/webtsc.ts | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ecae4ee47a4..dc273949ab4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -22,6 +22,7 @@ declare var require: any; declare var process: any; +declare var Buffer: any; // this will work in the browser via browserify var _chai: typeof chai = require('chai'); @@ -1207,7 +1208,6 @@ module Harness { export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) { diagnostics.sort(compareDiagnostics); - var outputLines: string[] = []; // Count up all the errors we find so we don't miss any var totalErrorsReported = 0; @@ -1298,8 +1298,13 @@ module Harness { return diagnostic.filename && isLibraryFile(diagnostic.filename); }); + var test262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { + // Count an error generated from tests262-harness folder.This should only apply for test262 + return diagnostic.filename.indexOf("test262-harness") >= 0; + }); + // Verify we didn't miss any errors in total - assert.equal(totalErrorsReported + numLibraryDiagnostics, diagnostics.length, 'total number of errors'); + assert.equal(totalErrorsReported + numLibraryDiagnostics + test262HarnessDiagnostics, diagnostics.length, 'total number of errors'); return minimalDiagnosticsToString(diagnostics) + ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n'); @@ -1642,7 +1647,8 @@ module Harness { } function writeComparison(expected: string, actual: string, relativeFilename: string, actualFilename: string, descriptionForDescribe: string) { - if (expected != actual) { + var encoded_actual = (new Buffer(actual)).toString('utf8') + if (expected != encoded_actual) { // Overwrite & issue error var errMsg = 'The baseline file ' + relativeFilename + ' has changed'; throw new Error(errMsg); diff --git a/tests/webhost/webtsc.ts b/tests/webhost/webtsc.ts index c88d2e8f512..ad3c06c8565 100644 --- a/tests/webhost/webtsc.ts +++ b/tests/webhost/webtsc.ts @@ -4,8 +4,12 @@ module TypeScript.WebTsc { declare var RealActiveXObject: { new (s: string): any }; - function getWScriptSystem(): System { + function getWScriptSystem() { var fso = new RealActiveXObject("Scripting.FileSystemObject"); + + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2 /*text*/; + var args: string[] = []; for (var i = 0; i < WScript.Arguments.length; i++) { args[i] = WScript.Arguments.Item(i); @@ -19,17 +23,35 @@ module TypeScript.WebTsc { writeErr(s: string): void { WScript.StdErr.Write(s); }, - readFile(fileName: string): string { + readFile(fileName: string, encoding?: string): string { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); try { - var f = fso.OpenTextFile(fileName, 1); - var s: string = f.ReadAll(); - // TODO: Properly handle byte order marks - if (s.length >= 3 && s.charCodeAt(0) === 0xEF && s.charCodeAt(1) === 0xBB && s.charCodeAt(2) === 0xBF) s = s.slice(3); - f.Close(); + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + // Load file and read the first two bytes into a string with no interpretation + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + // Position must be at 0 before encoding can be changed + fileStream.Position = 0; + // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + // ReadText method always strips byte order mark from resulting string + return fileStream.ReadText(); } catch (e) { + throw e; + } + finally { + fileStream.Close(); } - return s; }, writeFile(fileName: string, data: string): boolean { var f = fso.CreateTextFile(fileName, true); From c727efd323996593b85836304877e6a20e7fe821 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 19 Jan 2015 14:58:34 -0800 Subject: [PATCH 83/93] Fix unicode comparision and counting error for test262 --- src/harness/harness.ts | 12 +++++++++--- tests/webhost/webtsc.ts | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ecae4ee47a4..fbe1124b375 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -22,6 +22,7 @@ declare var require: any; declare var process: any; +declare var Buffer: any; // this will work in the browser via browserify var _chai: typeof chai = require('chai'); @@ -1207,7 +1208,6 @@ module Harness { export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) { diagnostics.sort(compareDiagnostics); - var outputLines: string[] = []; // Count up all the errors we find so we don't miss any var totalErrorsReported = 0; @@ -1298,8 +1298,13 @@ module Harness { return diagnostic.filename && isLibraryFile(diagnostic.filename); }); + var test262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { + // Count an error generated from tests262-harness folder.This should only apply for test262 + return diagnostic.filename && diagnostic.filename.indexOf("test262-harness") >= 0; + }); + // Verify we didn't miss any errors in total - assert.equal(totalErrorsReported + numLibraryDiagnostics, diagnostics.length, 'total number of errors'); + assert.equal(totalErrorsReported + numLibraryDiagnostics + test262HarnessDiagnostics, diagnostics.length, 'total number of errors'); return minimalDiagnosticsToString(diagnostics) + ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n'); @@ -1642,7 +1647,8 @@ module Harness { } function writeComparison(expected: string, actual: string, relativeFilename: string, actualFilename: string, descriptionForDescribe: string) { - if (expected != actual) { + var encoded_actual = (new Buffer(actual)).toString('utf8') + if (expected != encoded_actual) { // Overwrite & issue error var errMsg = 'The baseline file ' + relativeFilename + ' has changed'; throw new Error(errMsg); diff --git a/tests/webhost/webtsc.ts b/tests/webhost/webtsc.ts index c88d2e8f512..ad3c06c8565 100644 --- a/tests/webhost/webtsc.ts +++ b/tests/webhost/webtsc.ts @@ -4,8 +4,12 @@ module TypeScript.WebTsc { declare var RealActiveXObject: { new (s: string): any }; - function getWScriptSystem(): System { + function getWScriptSystem() { var fso = new RealActiveXObject("Scripting.FileSystemObject"); + + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2 /*text*/; + var args: string[] = []; for (var i = 0; i < WScript.Arguments.length; i++) { args[i] = WScript.Arguments.Item(i); @@ -19,17 +23,35 @@ module TypeScript.WebTsc { writeErr(s: string): void { WScript.StdErr.Write(s); }, - readFile(fileName: string): string { + readFile(fileName: string, encoding?: string): string { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); try { - var f = fso.OpenTextFile(fileName, 1); - var s: string = f.ReadAll(); - // TODO: Properly handle byte order marks - if (s.length >= 3 && s.charCodeAt(0) === 0xEF && s.charCodeAt(1) === 0xBB && s.charCodeAt(2) === 0xBF) s = s.slice(3); - f.Close(); + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + // Load file and read the first two bytes into a string with no interpretation + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + // Position must be at 0 before encoding can be changed + fileStream.Position = 0; + // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + // ReadText method always strips byte order mark from resulting string + return fileStream.ReadText(); } catch (e) { + throw e; + } + finally { + fileStream.Close(); } - return s; }, writeFile(fileName: string, data: string): boolean { var f = fso.CreateTextFile(fileName, true); From 1aa67b7fc42f5a7329656c980682ddc0ee9e8073 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 19 Jan 2015 16:41:33 -0800 Subject: [PATCH 84/93] Adding comments and a missing undefined check --- src/compiler/tsc.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 370d1357ccb..d74474142cb 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -6,7 +6,6 @@ module ts { export interface SourceFile { fileWatcher: FileWatcher; - fileChanged: boolean; } /** @@ -262,18 +261,20 @@ module ts { // Use default host function var sourceFile = hostGetSourceFile(filename, languageVersion, onError); // Cache the source file in -watch mode - if (commandLine.options.watch) { + if (sourceFile && commandLine.options.watch) { cacheSourceFile(sourceFile); } return sourceFile; } + // Cache the given source file and watch for changes function cacheSourceFile(sourceFile: SourceFile) { cachedSourceFiles = cachedSourceFiles || {}; cachedSourceFiles[compilerHost.getCanonicalFileName(sourceFile.filename)] = sourceFile; sourceFile.fileWatcher = sys.watchFile(sourceFile.filename, sourceFileChanged); } + // Remove the given source file from the cache function forgetSourceFile(sourceFile: SourceFile) { if (sourceFile.fileWatcher) { sourceFile.fileWatcher.close(); @@ -282,6 +283,7 @@ module ts { } } + // Update the cache to contain only source files in the given list function updateSourceFileCache(keepSourceFiles: SourceFile[]) { for (var filename in cachedSourceFiles) { var sourceFile = cachedSourceFiles[filename]; @@ -293,6 +295,7 @@ module ts { } } + // Remove all source files from the cache function clearSourceFileCache() { if (cachedSourceFiles) { for (var filename in cachedSourceFiles) { @@ -305,6 +308,7 @@ module ts { cachedSourceFiles = undefined; } + // If a source file changes, remove that file from the cache and start the recompilation timer function sourceFileChanged(filename: string) { var sourceFile = cachedSourceFiles[filename]; if (sourceFile) { @@ -313,14 +317,14 @@ module ts { } } + // If the configuration file changes, clear the cache and start the recompilation timer function configFileChanged() { clearSourceFileCache(); startTimer(); } - // Upon detecting a file change, queue up file modification events for the next 250ms and then - // perform a recompilation. The reasoning is that in some cases an editor can save all files at once, - // and we'd like to just perform a single recompilation. + // Upon detecting a file change, wait for the 250ms and then perform a recompilation. The reasoning is that + // in some cases an editor can save all files at once, and we'd like to just perform a single recompilation. function startTimer() { if (timerHandle) { clearTimeout(timerHandle); From 25e52a3975bfb7774323931bc1b5b7b438622dfa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 20 Jan 2015 09:58:25 -0800 Subject: [PATCH 85/93] Ignore symbolic links when enumerating directories --- src/compiler/sys.ts | 2 +- src/compiler/tsc.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 8d7b1104ff5..5f10a747d42 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -232,7 +232,7 @@ module ts { var directories: string[] = []; for (var i = 0; i < files.length; i++) { var name = combinePaths(path, files[i]); - var stat = _fs.statSync(name); + var stat = _fs.lstatSync(name); if (stat.isFile()) { if (!extension || fileExtensionIs(name, extension)) { result.push(name); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index d74474142cb..037df11664c 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -323,8 +323,9 @@ module ts { startTimer(); } - // Upon detecting a file change, wait for the 250ms and then perform a recompilation. The reasoning is that - // in some cases an editor can save all files at once, and we'd like to just perform a single recompilation. + // Upon detecting a file change, wait for 250ms and then perform a recompilation. This gives batch + // operations (such as saving all modified files in an editor) a chance to complete before we kick + // off a new compilation. function startTimer() { if (timerHandle) { clearTimeout(timerHandle); From fbbc30f1dfd42ec50132ceff14490255d21b6eca Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 20 Jan 2015 12:44:28 -0800 Subject: [PATCH 86/93] Address code review --- src/harness/harness.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index fbe1124b375..bb11d680dfe 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -22,7 +22,8 @@ declare var require: any; declare var process: any; -declare var Buffer: any; +//declare var Buffer: any; +var Buffer = require('buffer').Buffer; // this will work in the browser via browserify var _chai: typeof chai = require('chai'); @@ -1298,13 +1299,13 @@ module Harness { return diagnostic.filename && isLibraryFile(diagnostic.filename); }); - var test262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { + var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { // Count an error generated from tests262-harness folder.This should only apply for test262 return diagnostic.filename && diagnostic.filename.indexOf("test262-harness") >= 0; }); // Verify we didn't miss any errors in total - assert.equal(totalErrorsReported + numLibraryDiagnostics + test262HarnessDiagnostics, diagnostics.length, 'total number of errors'); + assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, 'total number of errors'); return minimalDiagnosticsToString(diagnostics) + ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n'); From aa5e65a4e20041c6b0418c621b09d7b2891f250a Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 20 Jan 2015 13:57:07 -0800 Subject: [PATCH 87/93] Remove old commit --- src/harness/harness.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index bb11d680dfe..df73e52a605 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -22,7 +22,6 @@ declare var require: any; declare var process: any; -//declare var Buffer: any; var Buffer = require('buffer').Buffer; // this will work in the browser via browserify From a6d374ee21359c9001f4de161929df1d90058060 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 20 Jan 2015 14:07:01 -0800 Subject: [PATCH 88/93] fixed smart indentation\formatting in template literals --- src/services/formatting/formatting.ts | 14 ++++++++++++-- src/services/formatting/smartIndenter.ts | 13 +++++++++---- tests/cases/fourslash/formatTemplateLiteral.ts | 7 +++++++ .../fourslash/smartIndentTemplateLiterals.ts | 17 +++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/formatTemplateLiteral.ts create mode 100644 tests/cases/fourslash/smartIndentTemplateLiterals.ts diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 787c6fe3f46..cab7547557c 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -243,8 +243,18 @@ module ts.formatting { } var precedingToken = findPrecedingToken(originalRange.pos, sourceFile); - // no preceding token found - start from the beginning of enclosing node - return precedingToken ? precedingToken.end : enclosingNode.pos; + if (!precedingToken) { + // no preceding token found - start from the beginning of enclosing node + return enclosingNode.pos; + } + + // preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal) + // start from the beginning of enclosingNode to handle the entire 'originalRange' + if (precedingToken.end >= originalRange.pos) { + return enclosingNode.pos; + } + + return precedingToken.end; } /* diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index ce240a95168..3aa97fe6ae6 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -12,10 +12,15 @@ module ts.formatting { return 0; } - // no indentation in string \regex literals - if ((precedingToken.kind === SyntaxKind.StringLiteral || precedingToken.kind === SyntaxKind.RegularExpressionLiteral) && - precedingToken.getStart(sourceFile) <= position && - precedingToken.end > position) { + // no indentation in string \regex\template literals + var precedingTokenIsLiteral = + precedingToken.kind === SyntaxKind.StringLiteral || + precedingToken.kind === SyntaxKind.RegularExpressionLiteral || + precedingToken.kind === SyntaxKind.NoSubstitutionTemplateLiteral || + precedingToken.kind === SyntaxKind.TemplateHead || + precedingToken.kind === SyntaxKind.TemplateMiddle || + precedingToken.kind === SyntaxKind.TemplateTail; + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } diff --git a/tests/cases/fourslash/formatTemplateLiteral.ts b/tests/cases/fourslash/formatTemplateLiteral.ts new file mode 100644 index 00000000000..b20eb4053f3 --- /dev/null +++ b/tests/cases/fourslash/formatTemplateLiteral.ts @@ -0,0 +1,7 @@ +/// +////var x = `sadasdasdasdasfegsfd +/////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `; + +goTo.marker("1"); +edit.insert("\r\n"); // edit will trigger formatting - should succeeed + diff --git a/tests/cases/fourslash/smartIndentTemplateLiterals.ts b/tests/cases/fourslash/smartIndentTemplateLiterals.ts new file mode 100644 index 00000000000..679978a515c --- /dev/null +++ b/tests/cases/fourslash/smartIndentTemplateLiterals.ts @@ -0,0 +1,17 @@ +/// +////var x0 = `sadasdasdasdas/*1*/fegsfdrasdesgeryt35t35y35 e4 ergt er 35t 3535 `; +////var x1 = `sadasdasdasdas/*2*/fegsfdr${0}asdesgeryt35t35y35 e4 ergt er 35t 3535 `; +////var x2 = `sadasdasdasdasfegsfdra${0}sdesge/*3*/ryt35t35y35 e4 ergt er 35t 3535 `; +////var x3 = `sadasdasdasdasfegsfdra${0}sdesge/*4*/ryt35${1}t35y35 e4 ergt er 35t 3535 `; +////var x2 = `sadasdasdasdasfegsfdra${0}sdesge${1}sf/*5*/ryt35t35y35 e4 ergt er 35t 3535 `; + +function verifyIndentation(marker: string): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(0); +} +verifyIndentation("1"); +verifyIndentation("2"); +verifyIndentation("3"); +verifyIndentation("4"); +verifyIndentation("5"); From 8497667f33164943b6fca032bb8216af978a1f3c Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 20 Jan 2015 14:44:24 -0800 Subject: [PATCH 89/93] drop trailing trivia prior to rescanning it --- src/services/formatting/formattingScanner.ts | 3 +++ tests/cases/fourslash/formatTemplateLiteral.ts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 7ddfecc17f2..e9485158aba 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -187,6 +187,9 @@ module ts.formatting { } // consume trailing trivia + if (trailingTrivia) { + trailingTrivia = undefined; + } while(scanner.getStartPos() < endPos) { currentToken = scanner.scan(); if (!isTrivia(currentToken)) { diff --git a/tests/cases/fourslash/formatTemplateLiteral.ts b/tests/cases/fourslash/formatTemplateLiteral.ts index b20eb4053f3..a1f5ef963da 100644 --- a/tests/cases/fourslash/formatTemplateLiteral.ts +++ b/tests/cases/fourslash/formatTemplateLiteral.ts @@ -1,7 +1,13 @@ /// ////var x = `sadasdasdasdasfegsfd /////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `; +////var y = `1${2}/*2*/3`; + goTo.marker("1"); edit.insert("\r\n"); // edit will trigger formatting - should succeeed +goTo.marker("2"); +edit.insert("\r\n"); +verify.indentationIs(0); +verify.currentLineContentIs("3`;") \ No newline at end of file From fbfec8a07d911a8293c84e13b9b992617e0d43bc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 20 Jan 2015 14:53:22 -0800 Subject: [PATCH 90/93] Simplified cache logic + better error message when JSON not supported --- src/compiler/tsc.ts | 97 ++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 58 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 037df11664c..ee5dc5104ff 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -130,6 +130,10 @@ module ts { reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); } + function isJSONSupported() { + return typeof JSON === "object" && typeof JSON.parse === "function"; + } + function findConfigFile(): string { var searchPath = normalizePath(sys.getCurrentDirectory()); var filename = "tsconfig.json"; @@ -151,7 +155,7 @@ module ts { var commandLine = parseCommandLine(args); var configFilename: string; // Configuration file name (if any) var configFileWatcher: FileWatcher; // Configuration file watcher - var cachedSourceFiles: Map; // Cached SourceFile objects + var cachedProgram: Program; // Program cached from last compilation var rootFilenames: string[]; // Root filenames for compilation var compilerOptions: CompilerOptions; // Compiler options for compilation var compilerHost: CompilerHost; // Compiler host @@ -159,9 +163,9 @@ module ts { var timerHandle: number; // Handle for 0.25s wait timer if (commandLine.options.locale) { - if (typeof JSON === "undefined") { + if (!isJSONSupported()) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); - return sys.exit(1); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); } @@ -185,13 +189,17 @@ module ts { } if (commandLine.options.project) { + if (!isJSONSupported()) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); + return sys.exit(EmitReturnStatus.CompilerOptionsErrors); + } configFilename = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json")); if (commandLine.filenames.length !== 0) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); return sys.exit(EmitReturnStatus.CompilerOptionsErrors); } } - else if (commandLine.filenames.length === 0) { + else if (commandLine.filenames.length === 0 && isJSONSupported()) { configFilename = findConfigFile(); } @@ -216,7 +224,7 @@ module ts { // Invoked to perform initial compilation or re-compilation in watch mode function performCompilation() { - if (!cachedSourceFiles) { + if (!cachedProgram) { if (configFilename) { var configObject = readConfigFile(configFilename); if (!configObject) { @@ -246,80 +254,53 @@ module ts { return sys.exit(compileResult.exitStatus); } - updateSourceFileCache(compileResult.program.getSourceFiles()); + setCachedProgram(compileResult.program); reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(filename: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) { // Return existing SourceFile object if one is available - if (cachedSourceFiles) { - var canonicalName = compilerHost.getCanonicalFileName(filename); - if (hasProperty(cachedSourceFiles, canonicalName)) { - return cachedSourceFiles[canonicalName]; + if (cachedProgram) { + var sourceFile = cachedProgram.getSourceFile(filename); + // A modified source file has no watcher and should not be reused + if (sourceFile && sourceFile.fileWatcher) { + return sourceFile; } } // Use default host function var sourceFile = hostGetSourceFile(filename, languageVersion, onError); - // Cache the source file in -watch mode if (sourceFile && commandLine.options.watch) { - cacheSourceFile(sourceFile); + // Attach a file watcher + sourceFile.fileWatcher = sys.watchFile(sourceFile.filename, () => sourceFileChanged(sourceFile)); } return sourceFile; } - // Cache the given source file and watch for changes - function cacheSourceFile(sourceFile: SourceFile) { - cachedSourceFiles = cachedSourceFiles || {}; - cachedSourceFiles[compilerHost.getCanonicalFileName(sourceFile.filename)] = sourceFile; - sourceFile.fileWatcher = sys.watchFile(sourceFile.filename, sourceFileChanged); - } - - // Remove the given source file from the cache - function forgetSourceFile(sourceFile: SourceFile) { - if (sourceFile.fileWatcher) { - sourceFile.fileWatcher.close(); - sourceFile.fileWatcher = undefined; - delete cachedSourceFiles[sourceFile.filename]; - } - } - - // Update the cache to contain only source files in the given list - function updateSourceFileCache(keepSourceFiles: SourceFile[]) { - for (var filename in cachedSourceFiles) { - var sourceFile = cachedSourceFiles[filename]; - if (sourceFile) { - if (!contains(keepSourceFiles, sourceFile)) { - forgetSourceFile(sourceFile); + // Change cached program to the given program + function setCachedProgram(program: Program) { + if (cachedProgram) { + var newSourceFiles = program ? program.getSourceFiles() : undefined; + forEach(cachedProgram.getSourceFiles(), sourceFile => { + if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) { + if (sourceFile.fileWatcher) { + sourceFile.fileWatcher.close(); + sourceFile.fileWatcher = undefined; + } } - } + }); } + cachedProgram = program; } - // Remove all source files from the cache - function clearSourceFileCache() { - if (cachedSourceFiles) { - for (var filename in cachedSourceFiles) { - var sourceFile = cachedSourceFiles[filename]; - if (sourceFile) { - forgetSourceFile(sourceFile); - } - } - } - cachedSourceFiles = undefined; + // If a source file changes, mark it as unwatched and start the recompilation timer + function sourceFileChanged(sourceFile: SourceFile) { + sourceFile.fileWatcher = undefined; + startTimer(); } - // If a source file changes, remove that file from the cache and start the recompilation timer - function sourceFileChanged(filename: string) { - var sourceFile = cachedSourceFiles[filename]; - if (sourceFile) { - forgetSourceFile(sourceFile); - startTimer(); - } - } - - // If the configuration file changes, clear the cache and start the recompilation timer + // If the configuration file changes, forget cached program and start the recompilation timer function configFileChanged() { - clearSourceFileCache(); + setCachedProgram(undefined); startTimer(); } From 45e700e515e6a58545bbf074d417560c2478fdb2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 20 Jan 2015 16:28:57 -0800 Subject: [PATCH 91/93] Adding src/compiler/tsconfig.json and src/services/tsconfig.json --- src/compiler/tsconfig.json | 25 ++++++++++++++++++++ src/services/tsconfig.json | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/compiler/tsconfig.json create mode 100644 src/services/tsconfig.json diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json new file mode 100644 index 00000000000..fd541a8ca80 --- /dev/null +++ b/src/compiler/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": true, + "removeComments": true, + "preserveConstEnums": true, + "out": "../../built/local/tsc.js", + "sourceMap": true + }, + "files": [ + "core.ts", + "sys.ts", + "types.ts", + "scanner.ts", + "parser.ts", + "utilities.ts", + "binder.ts", + "checker.ts", + "emitter.ts", + "program.ts", + "commandLineParser.ts", + "tsc.ts", + "diagnosticInformationMap.generated.ts" + ] +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json new file mode 100644 index 00000000000..296e65965d5 --- /dev/null +++ b/src/services/tsconfig.json @@ -0,0 +1,47 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": true, + "removeComments": true, + "preserveConstEnums": true, + "out": "../../built/local/typescriptServices.js", + "sourceMap": true + }, + "files": [ + "../compiler/core.ts", + "../compiler/sys.ts", + "../compiler/types.ts", + "../compiler/scanner.ts", + "../compiler/parser.ts", + "../compiler/utilities.ts", + "../compiler/binder.ts", + "../compiler/checker.ts", + "../compiler/emitter.ts", + "../compiler/program.ts", + "../compiler/commandLineParser.ts", + "../compiler/diagnosticInformationMap.generated.ts", + "breakpoints.ts", + "navigationBar.ts", + "outliningElementsCollector.ts", + "services.ts", + "shims.ts", + "signatureHelp.ts", + "utilities.ts", + "formatting/formatting.ts", + "formatting/formattingContext.ts", + "formatting/formattingRequestKind.ts", + "formatting/formattingScanner.ts", + "formatting/references.ts", + "formatting/rule.ts", + "formatting/ruleAction.ts", + "formatting/ruleDescriptor.ts", + "formatting/ruleFlag.ts", + "formatting/ruleOperation.ts", + "formatting/ruleOperationContext.ts", + "formatting/rules.ts", + "formatting/rulesMap.ts", + "formatting/rulesProvider.ts", + "formatting/smartIndenter.ts", + "formatting/tokenRange.ts" + ] +} From e8e2356afaa00b3fbd4cd18c18692f46f63bee46 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 20 Jan 2015 12:24:13 -0800 Subject: [PATCH 92/93] Fixes the emit of comment when comment ends on last line This fixes regression from 5a7500ca5e62d7e6c7863cf42d156e8bcdc3017c with addition of eof token Handles #1714 --- src/compiler/emitter.ts | 3 +- .../reference/baseIndexSignatureResolution.js | 25 +-------------- .../commentEmitWithCommentOnLastLine.js | 11 +++++++ .../commentEmitWithCommentOnLastLine.types | 7 ++++ tests/baselines/reference/concatError.js | 32 +------------------ ...sivelySpecializedConstructorDeclaration.js | 30 +---------------- .../commentEmitWithCommentOnLastLine.ts | 4 +++ 7 files changed, 27 insertions(+), 85 deletions(-) create mode 100644 tests/baselines/reference/commentEmitWithCommentOnLastLine.js create mode 100644 tests/baselines/reference/commentEmitWithCommentOnLastLine.types create mode 100644 tests/cases/compiler/commentEmitWithCommentOnLastLine.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 25cb7a8b2ee..dafd03717a6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -170,9 +170,10 @@ module ts { function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos); + var lastLine = currentSourceFile.getLineStarts().length; var firstCommentLineIndent: number; for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1); + var nextLineStart = currentLine === lastLine ? (comment.end + 1) : currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1); if (pos !== comment.pos) { // If we are not emitting first line, we need to write the spaces to adjust the alignment diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 4c2d63bf2c9..4720e92b969 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -55,27 +55,4 @@ interface B extends A { } var b: B = null; var z: Derived = b.foo(); -class Base { private a: string; } -class Derived extends Base { private b: string; } - -// Note - commmenting "extends Foo" prevents the error -interface Foo { - [i: number]: Base; -} -interface FooOf extends Foo { - [i: number]: TBase; -} -var x: FooOf = null; -var y: Derived = x[0]; - -/* -// Note - the equivalent for normal interface methods works fine: -interface A { - foo(): Base; -} -interface B extends A { - foo(): TBase; -} -var b: B = null; -var z: Derived = b.foo(); - +*/ diff --git a/tests/baselines/reference/commentEmitWithCommentOnLastLine.js b/tests/baselines/reference/commentEmitWithCommentOnLastLine.js new file mode 100644 index 00000000000..ffd4addb264 --- /dev/null +++ b/tests/baselines/reference/commentEmitWithCommentOnLastLine.js @@ -0,0 +1,11 @@ +//// [commentEmitWithCommentOnLastLine.ts] +var x: any; +/* +var bar; +*/ + +//// [commentEmitWithCommentOnLastLine.js] +var x; +/* +var bar; +*/ diff --git a/tests/baselines/reference/commentEmitWithCommentOnLastLine.types b/tests/baselines/reference/commentEmitWithCommentOnLastLine.types new file mode 100644 index 00000000000..d59c42d3795 --- /dev/null +++ b/tests/baselines/reference/commentEmitWithCommentOnLastLine.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/commentEmitWithCommentOnLastLine.ts === +var x: any; +>x : any + +/* +var bar; +*/ diff --git a/tests/baselines/reference/concatError.js b/tests/baselines/reference/concatError.js index 04c0a16b836..dee3d8a30e3 100644 --- a/tests/baselines/reference/concatError.js +++ b/tests/baselines/reference/concatError.js @@ -57,34 +57,4 @@ var c: C; var cc: C>; c = c.m(cc); -var n1: number[]; -/* -interface Array { - concat(...items: T[][]): T[]; // Note: This overload needs to be picked for arrays of arrays, even though both are applicable - concat(...items: T[]): T[]; -} -*/ -var fa: number[]; - -fa = fa.concat([0]); -fa = fa.concat(0); - - - - - -/* - - - - -declare class C { - public m(p1: C>): C; - //public p: T; -} - -var c: C; -var cc: C>; - -c = c.m(cc); - +*/ diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js index dd8028b086a..c0abe985dbc 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js @@ -74,32 +74,4 @@ declare module MsPortal.Controls.Base.ItemList { class ViewModel extends ItemValue { } } -module MsPortal.Controls.Base.ItemList { - - export interface Interface { - // Removing this line fixes the constructor of ItemValue - options: ViewModel; - } - - export class ItemValue { - constructor(value: T) { - } - } - - export class ViewModel extends ItemValue { - } -} - -// Generates: -/* -declare module MsPortal.Controls.Base.ItemList { - interface Interface { - options: ViewModel; - } - class ItemValue { - constructor(value: T); - } - class ViewModel extends ItemValue { - } -} - +*/ diff --git a/tests/cases/compiler/commentEmitWithCommentOnLastLine.ts b/tests/cases/compiler/commentEmitWithCommentOnLastLine.ts new file mode 100644 index 00000000000..d148fbda6fa --- /dev/null +++ b/tests/cases/compiler/commentEmitWithCommentOnLastLine.ts @@ -0,0 +1,4 @@ +var x: any; +/* +var bar; +*/ \ No newline at end of file From 8f3609048d8c2a0f0de3c53a7ab3f7dd7a6aa777 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 20 Jan 2015 20:09:16 -0800 Subject: [PATCH 93/93] Update the assert for valid line number when getting character position --- src/compiler/scanner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 8cbd2a905f0..4aef773004b 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -279,7 +279,7 @@ module ts { } export function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number { - Debug.assert(line > 0); + Debug.assert(line > 0 && line <= lineStarts.length ); return lineStarts[line - 1] + character - 1; }