From 525aea3cf9e233a06425e1a95848cb43e9055a87 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Fri, 28 Aug 2015 23:00:58 +0900 Subject: [PATCH 001/103] add rules and indents to named export/import --- src/services/formatting/formatting.ts | 1 + src/services/formatting/rules.ts | 43 ++++++------------- src/services/formatting/smartIndenter.ts | 6 +++ .../fourslash/formatNamedExportImport.ts | 28 ++++++++++++ 4 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 tests/cases/fourslash/formatNamedExportImport.ts diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 66cdbd53750..f1388eb8995 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -484,6 +484,7 @@ namespace ts.formatting { case SyntaxKind.CloseParenToken: case SyntaxKind.ElseKeyword: case SyntaxKind.WhileKeyword: + case SyntaxKind.FromKeyword: case SyntaxKind.AtToken: return indentation; default: diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index f609edb0501..99090dd0a0e 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -213,25 +213,15 @@ namespace ts.formatting { public NoSpaceBetweenYieldKeywordAndStar: Rule; public SpaceBetweenYieldOrYieldStarAndOperand: Rule; - // Async-await + // Async functions public SpaceBetweenAsyncAndFunctionKeyword: Rule; - public NoSpaceBetweenAsyncAndFunctionKeyword: Rule; - public SpaceAfterAwaitKeyword: Rule; - public NoSpaceAfterAwaitKeyword: Rule; - - // Type alias declaration - public SpaceAfterTypeKeyword: Rule; - public NoSpaceAfterTypeKeyword: Rule; // Tagged template string public SpaceBetweenTagAndTemplateString: Rule; - public NoSpaceBetweenTagAndTemplateString: Rule; // Union type public SpaceBeforeBar: Rule; - public NoSpaceBeforeBar: Rule; public SpaceAfterBar: Rule; - public NoSpaceAfterBar: Rule; constructor() { /// @@ -313,7 +303,7 @@ namespace ts.formatting { this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space)); this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete)); this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); @@ -346,8 +336,13 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([ + SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, + SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, + SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, + SyntaxKind.TypeKeyword, SyntaxKind.AsKeyword, SyntaxKind.FromKeyword + ]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.AsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space)); @@ -382,23 +377,13 @@ namespace ts.formatting { // Async-await this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - - // Type alias declaration - this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // template string this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // union type this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // These rules are higher in priority than user-configurable rules. @@ -427,11 +412,9 @@ namespace ts.formatting { this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, - this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, - this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, - this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, - this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, + this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.SpaceAfterBar, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, @@ -623,6 +606,8 @@ namespace ts.formatting { case SyntaxKind.CaseBlock: case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.ModuleBlock: + case SyntaxKind.NamedExports: + case SyntaxKind.NamedImports: return true; } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index ebbf09e9feb..3049e66fd00 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -440,6 +440,12 @@ namespace ts.formatting { case SyntaxKind.ParenthesizedType: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.AwaitExpression: + case SyntaxKind.NamedExports: + case SyntaxKind.ExportDeclaration: + case SyntaxKind.NamedImports: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ExportSpecifier: + //case SyntaxKind.ImportSpecifier: return true; } return false; diff --git a/tests/cases/fourslash/formatNamedExportImport.ts b/tests/cases/fourslash/formatNamedExportImport.ts new file mode 100644 index 00000000000..29e58160cc1 --- /dev/null +++ b/tests/cases/fourslash/formatNamedExportImport.ts @@ -0,0 +1,28 @@ +/// +////var x = `sadasdasdasdasfegsfd +/////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `; +////var y = `1${2}/*2*/3`; +////let z= `foo`/*3*/ +////let w= `bar${3}`/*4*/ +////String.raw +//// `template`/*5*/ + + +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`;") + +goTo.marker("3"); +edit.insert(";"); +verify.currentLineContentIs("let z = `foo`;"); +goTo.marker("4"); +edit.insert(";"); +verify.currentLineContentIs("let w = `bar${3}`;"); + +goTo.marker("5"); +edit.insert(";"); +verify.currentLineContentIs(" `template`;"); \ No newline at end of file From 9d867b70e3e09d54c073933ce54c0309d32e7ec9 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Sun, 30 Aug 2015 15:02:15 +0900 Subject: [PATCH 002/103] pseudo-block indentation --- src/services/formatting/formatting.ts | 14 ++++++++++++++ src/services/formatting/smartIndenter.ts | 9 +++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index f1388eb8995..adaaed40d79 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -403,6 +403,20 @@ namespace ts.formatting { indentation = parentDynamicIndentation.getIndentation(); } } + else if (node.kind === SyntaxKind.NamedExports || node.kind === SyntaxKind.ImportClause) { + let blockParent = node.kind === SyntaxKind.ImportClause ? + (node).namedBindings : node; + + let children = (blockParent).getChildren(sourceFile); + // Detect named export/import pseudo-block + if (children[0] && children[0].kind === SyntaxKind.OpenBraceToken && + children[2] && children[2].kind === SyntaxKind.CloseBraceToken) { + indentation = parentDynamicIndentation.getIndentation(); + } + else { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); + } + } else { if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { indentation = parentDynamicIndentation.getIndentation(); diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 3049e66fd00..57d527d943f 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -440,12 +440,11 @@ namespace ts.formatting { case SyntaxKind.ParenthesizedType: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.AwaitExpression: - case SyntaxKind.NamedExports: - case SyntaxKind.ExportDeclaration: - case SyntaxKind.NamedImports: case SyntaxKind.ImportDeclaration: + case SyntaxKind.NamedExports: + case SyntaxKind.NamedImports: case SyntaxKind.ExportSpecifier: - //case SyntaxKind.ImportSpecifier: + case SyntaxKind.ImportSpecifier: return true; } return false; @@ -470,6 +469,8 @@ namespace ts.formatting { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: return child !== SyntaxKind.Block; + case SyntaxKind.ExportDeclaration: + return child !== SyntaxKind.NamedExports; default: return false; } From 66924a371842f13bcfd54f0313352313886b89dd Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 20:01:39 +0900 Subject: [PATCH 003/103] format open brace in export/import decl --- src/services/formatting/rules.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 99090dd0a0e..62a91f3e3c8 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -262,7 +262,7 @@ namespace ts.formatting { this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia]); + this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ExportKeyword, SyntaxKind.ImportKeyword]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a control flow construct @@ -606,8 +606,6 @@ namespace ts.formatting { case SyntaxKind.CaseBlock: case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.ModuleBlock: - case SyntaxKind.NamedExports: - case SyntaxKind.NamedImports: return true; } @@ -652,6 +650,10 @@ namespace ts.formatting { case SyntaxKind.EnumDeclaration: case SyntaxKind.TypeLiteral: case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ExportDeclaration: + case SyntaxKind.NamedExports: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.NamedImports: return true; } From f0ed672eb1d2058605a2ca732cf6e790471081ef Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 20:02:48 +0900 Subject: [PATCH 004/103] disable indentation when in brace shell This pattern can also be used to format JSX end tag. --- src/services/formatting/formatting.ts | 15 ++------------- src/services/formatting/smartIndenter.ts | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index adaaed40d79..3773412bace 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -403,19 +403,8 @@ namespace ts.formatting { indentation = parentDynamicIndentation.getIndentation(); } } - else if (node.kind === SyntaxKind.NamedExports || node.kind === SyntaxKind.ImportClause) { - let blockParent = node.kind === SyntaxKind.ImportClause ? - (node).namedBindings : node; - - let children = (blockParent).getChildren(sourceFile); - // Detect named export/import pseudo-block - if (children[0] && children[0].kind === SyntaxKind.OpenBraceToken && - children[2] && children[2].kind === SyntaxKind.CloseBraceToken) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } + else if (SmartIndenter.isIndentationPrevented(node)) { + indentation = parentDynamicIndentation.getIndentation(); } else { if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 57d527d943f..ebcbfbb1394 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -133,7 +133,9 @@ namespace ts.formatting { } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line - if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) { + if (shouldIndentChildNode(parent.kind, current.kind) && + !isIndentationPrevented(current) && !parentAndChildShareLine) { + indentationDelta += options.IndentSize; } @@ -475,5 +477,23 @@ namespace ts.formatting { return false; } } + + function hasBraceShell(node: Node) { + let children = node.getChildren(); + let last = children.length - 1; + // Check if node looks like a block + return children[0] && children[0].kind === SyntaxKind.OpenBraceToken && + children[last] && children[last].kind === SyntaxKind.CloseBraceToken; + } + + export function isIndentationPrevented(node: TextRangeWithKind) { + switch (node.kind) { + case SyntaxKind.NamedExports: + return hasBraceShell(node); + case SyntaxKind.ImportClause: + return hasBraceShell((node).namedBindings); + } + return false; + } } } \ No newline at end of file From 80089f7e3aad1e3a107b08f32aa602d7a29fd0ec Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 3 Sep 2015 20:03:05 +0900 Subject: [PATCH 005/103] add tests --- .../fourslash/formatNamedExportImport.ts | 87 ++++++++++++++----- 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/tests/cases/fourslash/formatNamedExportImport.ts b/tests/cases/fourslash/formatNamedExportImport.ts index 29e58160cc1..2e22c54ae3b 100644 --- a/tests/cases/fourslash/formatNamedExportImport.ts +++ b/tests/cases/fourslash/formatNamedExportImport.ts @@ -1,28 +1,71 @@ /// -////var x = `sadasdasdasdasfegsfd -/////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `; -////var y = `1${2}/*2*/3`; -////let z= `foo`/*3*/ -////let w= `bar${3}`/*4*/ -////String.raw -//// `template`/*5*/ +/////*selectionStart*/ +////export { x, y as yy, z } from "foo"/*export1*/ +////export{x, y as yy, z}from"bar"/*export2*/ +//// +////export +/////*exportOpenBrace*/{x,/*exportSpecifier1*/ +////y as yy, z/*exportSpecifier2*/ }/*exportCloseBrace*/ +//// from/*fromKeywordAutoformat*/ +/////*fromKeywordIndent*/ +////"foo"/*exportDir*/ +//// +////import {x, y as yy, z}from "baz"/*import1*/ +//// +////import/*importOpenBrace*/{x,/*importSpecifier1*/ +////y +////as yy,/*importSpecifier2*/ +////z}/*importCloseBrace*/ +////from "wow"/*importDir*/ +/////*selectionEnd*/ +//// +////export/*formatOnEnter*/{/*formatOnEnterOpenBrace*/ +/////*differentLineIndent*/x/*differentLineAutoformat*/ +////} from "abc" -goTo.marker("1"); -edit.insert("\r\n"); // edit will trigger formatting - should succeeed +format.selection("selectionStart", "selectionEnd"); -goTo.marker("2"); -edit.insert("\r\n"); -verify.indentationIs(0); -verify.currentLineContentIs("3`;") +goTo.marker("export1"); +verify.currentLineContentIs('export { x, y as yy, z } from "foo"'); +goTo.marker("export2"); +verify.currentLineContentIs('export { x, y as yy, z } from "bar"'); -goTo.marker("3"); -edit.insert(";"); -verify.currentLineContentIs("let z = `foo`;"); -goTo.marker("4"); -edit.insert(";"); -verify.currentLineContentIs("let w = `bar${3}`;"); +goTo.marker("exportOpenBrace"); +verify.currentLineContentIs("export {"); +goTo.marker("exportSpecifier1"); +verify.currentLineContentIs(" x,"); +goTo.marker("exportSpecifier2"); +verify.currentLineContentIs(" y as yy, z"); +goTo.marker("exportCloseBrace"); +verify.currentLineContentIs("}"); +goTo.marker("fromKeywordAutoformat"); +verify.currentLineContentIs("from"); +goTo.marker("fromKeywordIndent"); +verify.indentationIs(4); +goTo.marker("exportDir"); +verify.currentLineContentIs(' "foo"'); -goTo.marker("5"); -edit.insert(";"); -verify.currentLineContentIs(" `template`;"); \ No newline at end of file +goTo.marker("import1"); +verify.currentLineContentIs('import { x, y as yy, z } from "baz"'); + +goTo.marker("importOpenBrace"); +verify.currentLineContentIs("import {"); +goTo.marker("importSpecifier1"); +verify.currentLineContentIs(" x,"); +goTo.marker("importSpecifier2"); +verify.currentLineContentIs(" as yy,"); +goTo.marker("importCloseBrace"); +verify.currentLineContentIs("}"); +goTo.marker("importDir"); +verify.currentLineContentIs('from "wow"'); + +goTo.marker("formatOnEnter"); +edit.insertLine(''); +goTo.marker("formatOnEnterOpenBrace"); +verify.currentLineContentIs("{"); +goTo.marker("differentLineIndent"); +verify.indentationIs(4); +edit.insertLine(''); +goTo.marker("differentLineAutoformat"); +verify.currentLineContentIs(" x"); \ No newline at end of file From 40f3fcf575d808bd7b006c5f9a58e8520997a1dd Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Sat, 5 Sep 2015 11:43:08 +0900 Subject: [PATCH 006/103] remove hasBraceShell and add namedBindings check --- src/services/formatting/smartIndenter.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index d8bc8fc3b98..a95d756f356 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -478,20 +478,13 @@ namespace ts.formatting { } } - function hasBraceShell(node: Node) { - let children = node.getChildren(); - let last = children.length - 1; - // Check if node looks like a block - return children[0] && children[0].kind === SyntaxKind.OpenBraceToken && - children[last] && children[last].kind === SyntaxKind.CloseBraceToken; - } - export function isIndentationPrevented(node: TextRangeWithKind) { switch (node.kind) { case SyntaxKind.NamedExports: - return hasBraceShell(node); + return true; + // Allow indentation only when namedBindings is NamespaceImport. case SyntaxKind.ImportClause: - return hasBraceShell((node).namedBindings); + return (node).namedBindings.kind === SyntaxKind.NamedImports; } return false; } From 0fc9e7e313412e1a77c260a0823a03e4609360a2 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Sun, 6 Sep 2015 16:02:38 +0900 Subject: [PATCH 007/103] simplified code flow --- src/services/formatting/formatting.ts | 11 ++++------- src/services/formatting/smartIndenter.ts | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 3773412bace..d8ca7f03d96 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -403,16 +403,13 @@ namespace ts.formatting { indentation = parentDynamicIndentation.getIndentation(); } } - else if (SmartIndenter.isIndentationPrevented(node)) { + else if (SmartIndenter.isIndentationPrevented(node) || + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { + indentation = parentDynamicIndentation.getIndentation(); } else { - if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index a95d756f356..86ee0f5f363 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -482,7 +482,7 @@ namespace ts.formatting { switch (node.kind) { case SyntaxKind.NamedExports: return true; - // Allow indentation only when namedBindings is NamespaceImport. + // NamedImports has its own braces as Block does case SyntaxKind.ImportClause: return (node).namedBindings.kind === SyntaxKind.NamedImports; } From 9ca46b8e0de4f691deac7952dfe7b1f6f4c8698f Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 01:58:42 +0900 Subject: [PATCH 008/103] Move housekeeping part to new PR #4711 --- src/services/formatting/rules.ts | 34 ++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 5ba1fd8d9c7..273a104a6b8 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -213,15 +213,25 @@ namespace ts.formatting { public NoSpaceBetweenYieldKeywordAndStar: Rule; public SpaceBetweenYieldOrYieldStarAndOperand: Rule; - // Async functions + // Async-await public SpaceBetweenAsyncAndFunctionKeyword: Rule; + public NoSpaceBetweenAsyncAndFunctionKeyword: Rule; + public SpaceAfterAwaitKeyword: Rule; + public NoSpaceAfterAwaitKeyword: Rule; + + // Type alias declaration + public SpaceAfterTypeKeyword: Rule; + public NoSpaceAfterTypeKeyword: Rule; // Tagged template string public SpaceBetweenTagAndTemplateString: Rule; + public NoSpaceBetweenTagAndTemplateString: Rule; // Type operation public SpaceBeforeBar: Rule; + public NoSpaceBeforeBar: Rule; public SpaceAfterBar: Rule; + public NoSpaceAfterBar: Rule; public SpaceBeforeAmpersand: Rule; public SpaceAfterAmpersand: Rule; @@ -305,7 +315,7 @@ namespace ts.formatting { this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space)); this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete)); this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); @@ -342,7 +352,7 @@ namespace ts.formatting { SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, - SyntaxKind.TypeKeyword, SyntaxKind.AsKeyword, SyntaxKind.FromKeyword + SyntaxKind.AsKeyword, SyntaxKind.FromKeyword ]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.AsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); @@ -379,13 +389,23 @@ namespace ts.formatting { // Async-await this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + + // Type alias declaration + this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // template string this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // type operation this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); @@ -415,9 +435,11 @@ namespace ts.formatting { this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndFunctionKeyword, - this.SpaceBetweenTagAndTemplateString, - this.SpaceBeforeBar, this.SpaceAfterBar, + this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword, + this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword, + this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar, this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand, // TypeScript-specific rules From feae0f711ab45203a2fc1822b2dec3bbb39cdc1c Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 02:18:26 +0900 Subject: [PATCH 009/103] Consider export/import specifier as binary op context --- src/services/formatting/rules.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 273a104a6b8..c4c72f3e6f0 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -348,13 +348,8 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([ - SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, - SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, - SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, - SyntaxKind.AsKeyword, SyntaxKind.FromKeyword - ]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.AsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.FromKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space)); @@ -543,6 +538,8 @@ namespace ts.formatting { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.AsExpression: + case SyntaxKind.ExportSpecifier: + case SyntaxKind.ImportSpecifier: case SyntaxKind.TypePredicate: return true; From ad010ea8ee240054cf2beedf5e50e760eab43b21 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 02:31:27 +0900 Subject: [PATCH 010/103] Add some comments to isIndentationPrevented --- src/services/formatting/smartIndenter.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 86ee0f5f363..05aa867113d 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -478,12 +478,15 @@ namespace ts.formatting { } } + /** + * Function returns true if a node should not get additional indentation in its parent node. + */ export function isIndentationPrevented(node: TextRangeWithKind) { switch (node.kind) { case SyntaxKind.NamedExports: return true; - // NamedImports has its own braces as Block does case SyntaxKind.ImportClause: + // NamedImports has its own braces as Block does return (node).namedBindings.kind === SyntaxKind.NamedImports; } return false; From b65cfe13da06a3073168fd9d90100b6564145b6a Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 06:32:43 +0900 Subject: [PATCH 011/103] update isCompletedNode --- src/services/utilities.ts | 6 ++++++ tests/cases/fourslash/formatNamedExportImport.ts | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 8b77dcb953b..c413cedd5d1 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -79,6 +79,8 @@ namespace ts { case SyntaxKind.Block: case SyntaxKind.ModuleBlock: case SyntaxKind.CaseBlock: + case SyntaxKind.NamedImports: + case SyntaxKind.NamedExports: return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile); case SyntaxKind.CatchClause: return isCompletedNode((n).block, sourceFile); @@ -181,6 +183,10 @@ namespace ts { case SyntaxKind.TemplateSpan: return nodeIsPresent((n).literal); + case SyntaxKind.ExportDeclaration: + case SyntaxKind.ImportDeclaration: + return nodeIsPresent((n).moduleSpecifier); + case SyntaxKind.PrefixUnaryExpression: return isCompletedNode((n).operand, sourceFile); case SyntaxKind.BinaryExpression: diff --git a/tests/cases/fourslash/formatNamedExportImport.ts b/tests/cases/fourslash/formatNamedExportImport.ts index 2e22c54ae3b..18f2f19577a 100644 --- a/tests/cases/fourslash/formatNamedExportImport.ts +++ b/tests/cases/fourslash/formatNamedExportImport.ts @@ -23,6 +23,10 @@ ////export/*formatOnEnter*/{/*formatOnEnterOpenBrace*/ /////*differentLineIndent*/x/*differentLineAutoformat*/ ////} from "abc" +//// +////export { +/////*incompleteExportDeclIndent*/ +/////*incompleteExportDeclIndent2*/ format.selection("selectionStart", "selectionEnd"); @@ -68,4 +72,10 @@ goTo.marker("differentLineIndent"); verify.indentationIs(4); edit.insertLine(''); goTo.marker("differentLineAutoformat"); -verify.currentLineContentIs(" x"); \ No newline at end of file +verify.currentLineContentIs(" x"); + +goTo.marker("incompleteExportDeclIndent") +verify.indentationIs(4); +edit.insert("} from"); +goTo.marker("incompleteExportDeclIndent2"); +verify.indentationIs(4); \ No newline at end of file From 886e4d22593d6cead584997f33a02d99d8bae88b Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Sep 2015 14:36:13 +0900 Subject: [PATCH 012/103] rename isIndentationPrevented --- src/services/formatting/formatting.ts | 2 +- src/services/formatting/smartIndenter.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index d8ca7f03d96..4f21f3ae2a7 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -403,7 +403,7 @@ namespace ts.formatting { indentation = parentDynamicIndentation.getIndentation(); } } - else if (SmartIndenter.isIndentationPrevented(node) || + else if (SmartIndenter.shouldInheritParentIndentation(node) || SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { indentation = parentDynamicIndentation.getIndentation(); diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 05aa867113d..aabd9af2544 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -134,7 +134,7 @@ namespace ts.formatting { // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line if (shouldIndentChildNode(parent.kind, current.kind) && - !isIndentationPrevented(current) && !parentAndChildShareLine) { + !shouldInheritParentIndentation(current) && !parentAndChildShareLine) { indentationDelta += options.IndentSize; } @@ -481,7 +481,7 @@ namespace ts.formatting { /** * Function returns true if a node should not get additional indentation in its parent node. */ - export function isIndentationPrevented(node: TextRangeWithKind) { + export function shouldInheritParentIndentation(node: TextRangeWithKind) { switch (node.kind) { case SyntaxKind.NamedExports: return true; From 1110b902dc88cf93cac92e3a0aa4dffb3e72c311 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Fri, 11 Sep 2015 13:43:35 +0900 Subject: [PATCH 013/103] nodeWillIndentChild --- src/services/formatting/formatting.ts | 31 +++++----------- src/services/formatting/smartIndenter.ts | 46 ++++++++++++------------ 2 files changed, 30 insertions(+), 47 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 4f21f3ae2a7..a47d5c85712 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -282,19 +282,19 @@ namespace ts.formatting { */ function getOwnOrInheritedDelta(n: Node, options: FormatCodeOptions, sourceFile: SourceFile): number { let previousLine = Constants.Unknown; - let childKind = SyntaxKind.Unknown; + let child: Node = null; while (n) { let line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; if (previousLine !== Constants.Unknown && line !== previousLine) { break; } - if (SmartIndenter.shouldIndentChildNode(n.kind, childKind)) { + if (SmartIndenter.shouldIndentChildNode(n, child)) { return options.IndentSize; } previousLine = line; - childKind = n.kind; + child = n; n = n.parent; } return 0; @@ -386,24 +386,9 @@ namespace ts.formatting { effectiveParentStartLine: number): Indentation { let indentation = inheritedIndentation; - if (indentation === Constants.Unknown) { - if (isSomeBlock(node.kind)) { - // blocks should be indented in - // - other blocks - // - source file - // - switch\default clauses - if (isSomeBlock(parent.kind) || - parent.kind === SyntaxKind.SourceFile || - parent.kind === SyntaxKind.CaseClause || - parent.kind === SyntaxKind.DefaultClause) { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } - else { - indentation = parentDynamicIndentation.getIndentation(); - } - } - else if (SmartIndenter.shouldInheritParentIndentation(node) || + if (indentation === Constants.Unknown) { + if (SmartIndenter.shouldInheritParentIndentation(parent, node) || SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { indentation = parentDynamicIndentation.getIndentation(); @@ -413,7 +398,7 @@ namespace ts.formatting { } } - var delta = SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown) ? options.IndentSize : 0; + var delta = SmartIndenter.shouldIndentChildNode(node, null) ? options.IndentSize : 0; if (effectiveParentStartLine === startLine) { // if node is located on the same line with the parent @@ -495,7 +480,7 @@ namespace ts.formatting { getIndentation: () => indentation, getDelta: () => delta, recomputeIndentation: lineAdded => { - if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) { + if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent, node)) { if (lineAdded) { indentation += options.IndentSize; } @@ -503,7 +488,7 @@ namespace ts.formatting { indentation -= options.IndentSize; } - if (SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown)) { + if (SmartIndenter.shouldIndentChildNode(node, null)) { delta = options.IndentSize; } else { diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index aabd9af2544..e30c83151a7 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -48,7 +48,7 @@ namespace ts.formatting { let indentationDelta: number; while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : SyntaxKind.Unknown)) { + if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { @@ -133,9 +133,7 @@ namespace ts.formatting { } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line - if (shouldIndentChildNode(parent.kind, current.kind) && - !shouldInheritParentIndentation(current) && !parentAndChildShareLine) { - + if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { indentationDelta += options.IndentSize; } @@ -442,7 +440,6 @@ namespace ts.formatting { case SyntaxKind.ParenthesizedType: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.AwaitExpression: - case SyntaxKind.ImportDeclaration: case SyntaxKind.NamedExports: case SyntaxKind.NamedImports: case SyntaxKind.ExportSpecifier: @@ -451,12 +448,10 @@ namespace ts.formatting { } return false; } - - export function shouldIndentChildNode(parent: SyntaxKind, child: SyntaxKind): boolean { - if (nodeContentIsAlwaysIndented(parent)) { - return true; - } - switch (parent) { + + function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) { + let childKind = child ? child.kind : SyntaxKind.Unknown; + switch (parent.kind) { case SyntaxKind.DoStatement: case SyntaxKind.WhileStatement: case SyntaxKind.ForInStatement: @@ -470,26 +465,29 @@ namespace ts.formatting { case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - return child !== SyntaxKind.Block; + return childKind !== SyntaxKind.Block; case SyntaxKind.ExportDeclaration: - return child !== SyntaxKind.NamedExports; - default: - return false; + return childKind !== SyntaxKind.NamedExports; + case SyntaxKind.ImportDeclaration: + return childKind !== SyntaxKind.ImportClause || + (child).namedBindings.kind !== SyntaxKind.NamedImports; } + // No explicit rule for selected nodes, so result will follow the default value argument. + return indentByDefault; } + export function shouldIndentChildNode(parent: TextRangeWithKind, child: TextRangeWithKind): boolean { + if (nodeContentIsAlwaysIndented(parent.kind)) { + return true; + } + return nodeWillIndentChild(parent, child, false); + } + /** * Function returns true if a node should not get additional indentation in its parent node. */ - export function shouldInheritParentIndentation(node: TextRangeWithKind) { - switch (node.kind) { - case SyntaxKind.NamedExports: - return true; - case SyntaxKind.ImportClause: - // NamedImports has its own braces as Block does - return (node).namedBindings.kind === SyntaxKind.NamedImports; - } - return false; + export function shouldInheritParentIndentation(parent: TextRangeWithKind, child: TextRangeWithKind) { + return !nodeWillIndentChild(parent, child, true); } } } \ No newline at end of file From 70cb7582047bb7a73e4d9c4e81f90e6c093730bf Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Fri, 11 Sep 2015 14:26:10 +0900 Subject: [PATCH 014/103] making comment more specific --- src/services/formatting/smartIndenter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 982a6dc5394..2720ae0b6d3 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -485,7 +485,7 @@ namespace ts.formatting { } /** - * Function returns true if a node should not get additional indentation in its parent node. + * Function returns true if existing node content indentation should be suppressed for a specific child */ export function shouldInheritParentIndentation(parent: TextRangeWithKind, child: TextRangeWithKind) { return !nodeWillIndentChild(parent, child, true); From 76d799cf0da6303910d284793c25a02c3e761482 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Dec 2015 00:34:48 +0900 Subject: [PATCH 015/103] crlf --- src/services/formatting/rules.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index ca7f633545a..191868039ac 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -335,9 +335,9 @@ namespace ts.formatting { // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword, SyntaxKind.FromKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); - this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + // Add a space around certain TypeScript keywords + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword, SyntaxKind.FromKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space)); From d90a66ca2338b502f5be6ee72b3f663118a1ee76 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Thu, 10 Dec 2015 01:32:07 +0900 Subject: [PATCH 016/103] crlf 2 --- src/services/formatting/formatting.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 4453bd299fc..ab0867bdd69 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -281,8 +281,8 @@ namespace ts.formatting { * to the initial indentation. */ function getOwnOrInheritedDelta(n: Node, options: FormatCodeOptions, sourceFile: SourceFile): number { - let previousLine = Constants.Unknown; - let child: Node; + let previousLine = Constants.Unknown; + let child: Node; while (n) { let line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; if (previousLine !== Constants.Unknown && line !== previousLine) { @@ -385,8 +385,8 @@ namespace ts.formatting { parentDynamicIndentation: DynamicIndentation, effectiveParentStartLine: number): Indentation { - let indentation = inheritedIndentation; - var delta = SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0; + let indentation = inheritedIndentation; + var delta = SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0; if (effectiveParentStartLine === startLine) { // if node is located on the same line with the parent @@ -485,8 +485,8 @@ namespace ts.formatting { else { indentation -= options.IndentSize; } - - if (SmartIndenter.shouldIndentChildNode(node)) { + + if (SmartIndenter.shouldIndentChildNode(node)) { delta = options.IndentSize; } else { From dfb0dcde0e2a5b4db9bd426dd8f49f34a947f3d0 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sat, 13 Feb 2016 07:48:25 -0800 Subject: [PATCH 017/103] Load JS from node_modules --- src/compiler/commandLineParser.ts | 5 ++ src/compiler/diagnosticMessages.json | 4 ++ src/compiler/program.ts | 68 ++++++++++++++++++++-------- src/compiler/types.ts | 3 ++ src/compiler/utilities.ts | 10 ++-- 5 files changed, 67 insertions(+), 23 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 86d073f7d49..9a4a96f373a 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -326,6 +326,11 @@ namespace ts { name: "noImplicitUseStrict", type: "boolean", description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files } ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 25b86e67d34..d7b56746802 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2576,6 +2576,10 @@ "category": "Message", "code": 6112 }, + "The maximum dependency depth to search under node_modules and load JavaScript files": { + "category": "Message", + "code": 6113 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7a2e65ed33b..08d7a553b55 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -9,10 +9,10 @@ namespace ts { /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ + export const version = "1.9.0"; const emptyArray: any[] = []; - - export const version = "1.9.0"; + const startsWithDotSlashOrDotDotSlash = /^(\.\/|\.\.\/)/; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { let fileName = "tsconfig.json"; @@ -79,9 +79,7 @@ namespace ts { return false; } - const i = moduleName.lastIndexOf("./", 1); - const startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === CharacterCodes.dot); - return !startsWithDotSlashOrDotDotSlash; + return !startsWithDotSlashOrDotDotSlash.test(moduleName); } interface ModuleResolutionState { @@ -448,11 +446,11 @@ namespace ts { trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath); } - let jsonContent: { typings?: string }; + let jsonContent: { typings?: string; main?: string }; try { const jsonText = state.host.readFile(packageJsonPath); - jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined }; + jsonContent = jsonText ? <{ typings?: string; main?: string }>JSON.parse(jsonText) : { typings: undefined, main: undefined }; } catch (e) { // gracefully handle if readFile fails or returns not JSON @@ -465,7 +463,7 @@ namespace ts { if (state.traceEnabled) { trace(state.host, Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile); } - const result = loadModuleFromFile(typingsFile, extensions, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typingsFile), state.host), state); + const result = loadModuleFromFile(typingsFile, /* don't add extension */ [""], failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typingsFile), state.host), state); if (result) { return result; } @@ -479,6 +477,15 @@ namespace ts { trace(state.host, Diagnostics.package_json_does_not_have_typings_field); } } + // TODO (billti): tracing as per above + if (typeof jsonContent.main === "string") { + // If 'main' points to 'foo.js', we still want to try and load 'foo.d.ts' and 'foo.ts' first (and only 'foo.js' if 'allowJs' is set). + const mainFile = normalizePath(combinePaths(candidate, removeFileExtension(jsonContent.main))); + const result = loadModuleFromFile(mainFile, extensions, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(mainFile), state.host), state); + if (result) { + return result; + } + } } else { if (state.traceEnabled) { @@ -499,12 +506,13 @@ namespace ts { const nodeModulesFolder = combinePaths(directory, "node_modules"); const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); - // Load only typescript files irrespective of allowJs option if loading from node modules - let result = loadModuleFromFile(candidate, supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + + const supportedExtensions = getSupportedExtensions(state.compilerOptions); + let result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { return result; } - result = loadNodeModuleFromDirectory(supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { return result; } @@ -1397,7 +1405,7 @@ namespace ts { } // Get source file from normalized fileName - function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { + function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number, isFileFromNodeSearch?: boolean): SourceFile { if (filesByName.contains(path)) { const file = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -1406,6 +1414,13 @@ namespace ts { reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd); } + // If this was a file found by a node_modules search, set the nodeModuleSearchDistance to parent distance + 1. + if (isFileFromNodeSearch) { + const newDistance = (refFile && refFile.nodeModuleSearchDistance) === undefined ? 1 : refFile.nodeModuleSearchDistance + 1; + // If already set on the file, don't overwrite if it was already found closer (which may be '0' if added as a root file) + file.nodeModuleSearchDistance = (typeof file.nodeModuleSearchDistance === "number") ? Math.min(file.nodeModuleSearchDistance, newDistance) : newDistance; + } + return file; } @@ -1424,6 +1439,12 @@ namespace ts { if (file) { file.path = path; + // Default to same distance as parent. Add one if found by a search. + file.nodeModuleSearchDistance = (refFile && refFile.nodeModuleSearchDistance) || 0; + if (isFileFromNodeSearch) { + file.nodeModuleSearchDistance++; + } + if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case const existingFile = filesByNameIgnoreCase.get(path); @@ -1468,11 +1489,13 @@ namespace ts { } function processImportedModules(file: SourceFile, basePath: string) { + const maxJsNodeModuleSearchDistance = options.maxNodeModuleJsDepth || 0; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = {}; const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); + file.nodeModuleSearchDistance = file.nodeModuleSearchDistance || 0; for (let i = 0; i < moduleNames.length; i++) { const resolution = resolutions[i]; setResolvedModule(file, moduleNames[i], resolution); @@ -1480,16 +1503,23 @@ namespace ts { // - resolution was successful // - noResolve is falsy // - module name come from the list fo imports - const shouldAddFile = resolution && - !options.noResolve && - i < file.imports.length; + // - it's not a top level JavaScript module that exceeded the search max + const exceedsJsSearchDepth = resolution && resolution.isExternalLibraryImport && + hasJavaScriptFileExtension(resolution.resolvedFileName) && + file.nodeModuleSearchDistance >= maxJsNodeModuleSearchDistance; + const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !exceedsJsSearchDepth; if (shouldAddFile) { - const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + const importedFile = findSourceFile(resolution.resolvedFileName, + toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), + /*isDefaultLib*/ false, + file, + skipTrivia(file.text, file.imports[i].pos), + file.imports[i].end, + resolution.isExternalLibraryImport); - if (importedFile && resolution.isExternalLibraryImport) { - // Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files, - // this check is ok. Otherwise this would be never true for javascript file + // TODO (billti): Should we check here if a JavaScript file is a CommonJS file, or doesn't have /// references? + if (importedFile && resolution.isExternalLibraryImport && !hasJavaScriptFileExtension(importedFile.fileName)) { if (!isExternalModule(importedFile) && importedFile.statements.length) { const start = getTokenPosOfNode(file.imports[i], file); fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6b9f49cac01..b414ad50aab 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1536,6 +1536,8 @@ namespace ts { /* @internal */ externalModuleIndicator: Node; // The first node that causes this file to be a CommonJS module /* @internal */ commonJsModuleIndicator: Node; + // The number of times node_modules was searched to locate the package containing this file + /* @internal */ nodeModuleSearchDistance?: number; /* @internal */ identifiers: Map; /* @internal */ nodeCount: number; @@ -2419,6 +2421,7 @@ namespace ts { traceModuleResolution?: boolean; allowSyntheticDefaultImports?: boolean; allowJs?: boolean; + maxNodeModuleJsDepth?: number; noImplicitUseStrict?: boolean; /* @internal */ stripInternal?: boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5494db5fbd6..7a443073688 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2035,7 +2035,8 @@ namespace ts { else { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; for (const sourceFile of sourceFiles) { - if (!isDeclarationFile(sourceFile)) { + // Don't emit if source file is a declaration file, or was found by a search under 'node_modules' + if (!isDeclarationFile(sourceFile) && !sourceFile.nodeModuleSearchDistance) { onSingleFileEmit(host, sourceFile); } } @@ -2069,9 +2070,10 @@ namespace ts { function onBundledEmit(host: EmitHost) { // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified const bundledSources = filter(host.getSourceFiles(), - sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file - (!isExternalModule(sourceFile) || // non module file - (getEmitModuleKind(options) && isExternalModule(sourceFile)))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted + sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file + !sourceFile.nodeModuleSearchDistance && // Not loaded from searching under node_modules + (!isExternalModule(sourceFile) || // non module file + (getEmitModuleKind(options) && isExternalModule(sourceFile)))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted if (bundledSources.length) { const jsFilePath = options.outFile || options.out; const emitFileNames: EmitFileNames = { From 6126f7b493d1ebae5ff74332591c8d92bc39d0d9 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sat, 13 Feb 2016 16:31:53 -0800 Subject: [PATCH 018/103] Added tests --- tests/cases/fourslash/importJsNodeModule1.ts | 18 ++++++++++++ tests/cases/fourslash/importJsNodeModule2.ts | 23 +++++++++++++++ tests/cases/fourslash/importJsNodeModule3.ts | 31 ++++++++++++++++++++ tests/cases/fourslash/importJsNodeModule4.ts | 20 +++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 tests/cases/fourslash/importJsNodeModule1.ts create mode 100644 tests/cases/fourslash/importJsNodeModule2.ts create mode 100644 tests/cases/fourslash/importJsNodeModule3.ts create mode 100644 tests/cases/fourslash/importJsNodeModule4.ts diff --git a/tests/cases/fourslash/importJsNodeModule1.ts b/tests/cases/fourslash/importJsNodeModule1.ts new file mode 100644 index 00000000000..2c4b6352cb0 --- /dev/null +++ b/tests/cases/fourslash/importJsNodeModule1.ts @@ -0,0 +1,18 @@ +/// + +// @allowJs: true +// @Filename: node_modules/myMod/index.js +//// module.exports = { n: 3, s: 'foo', b: true }; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/importJsNodeModule2.ts b/tests/cases/fourslash/importJsNodeModule2.ts new file mode 100644 index 00000000000..c8b7c479ddf --- /dev/null +++ b/tests/cases/fourslash/importJsNodeModule2.ts @@ -0,0 +1,23 @@ +/// + +// @allowJs: true + +// @Filename: node_modules/myMod/package.json +//// {"main": "entry.js"} + + +// @Filename: node_modules/myMod/entry.js +//// module.exports = { n: 3, s: 'foo', b: true }; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/importJsNodeModule3.ts b/tests/cases/fourslash/importJsNodeModule3.ts new file mode 100644 index 00000000000..a48150a4218 --- /dev/null +++ b/tests/cases/fourslash/importJsNodeModule3.ts @@ -0,0 +1,31 @@ +/// + +// @allowJs: true + +// @Filename: node_modules/myMod/index.js +//// exports.n = 3; +//// exports.s = 'foo'; +//// exports.b = true; + +// @Filename: node_modules/anotherMod/index.js +//// exports.x = 3; +//// exports.y = 'foo'; +//// exports.z = true; + +// @Filename: consumer.js +//// import * as x from 'myMod'; +//// import {y,z} from 'anotherMod'; +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); + +edit.backspace(4); +edit.insert('y.'); +verify.completionListContains("toUpperCase", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/importJsNodeModule4.ts b/tests/cases/fourslash/importJsNodeModule4.ts new file mode 100644 index 00000000000..b4bdc7ce9f7 --- /dev/null +++ b/tests/cases/fourslash/importJsNodeModule4.ts @@ -0,0 +1,20 @@ +/// + +// @allowJs: true + +// @Filename: node_modules/myMod/index.js +//// module.exports = { n: 3, s: 'foo', b: true }; + +// @Filename: consumer.js +//// import * as x from 'myMod'; +//// x/**/; + +goTo.file('consumer.js'); +goTo.marker(); +edit.insert('.'); +// TODO: Bug: Fix ES6 import of assignments to module.exports +// verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +// verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +// verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +// edit.insert('n.'); +// verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); From e2df645b1631201a704ac92a073a607095158215 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sat, 13 Feb 2016 16:47:15 -0800 Subject: [PATCH 019/103] Updated tests --- tests/baselines/reference/nodeResolution6.js | 2 -- tests/baselines/reference/nodeResolution8.js | 2 -- .../reference/pathMappingBasedModuleResolution5_node.js | 3 --- tests/cases/fourslash/importJsNodeModule3.ts | 9 ++++++++- tests/cases/unittests/moduleResolution.ts | 3 +++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/nodeResolution6.js b/tests/baselines/reference/nodeResolution6.js index 58a9b907250..196e8ae57cf 100644 --- a/tests/baselines/reference/nodeResolution6.js +++ b/tests/baselines/reference/nodeResolution6.js @@ -13,7 +13,5 @@ export declare var y; import y = require("a"); -//// [ref.js] -var x = 1; //// [b.js] "use strict"; diff --git a/tests/baselines/reference/nodeResolution8.js b/tests/baselines/reference/nodeResolution8.js index 36b53eec553..1d90399ff70 100644 --- a/tests/baselines/reference/nodeResolution8.js +++ b/tests/baselines/reference/nodeResolution8.js @@ -12,7 +12,5 @@ export declare var y; //// [b.ts] import y = require("a"); -//// [ref.js] -var x = 1; //// [b.js] "use strict"; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js index 1958800f918..e4440299cc7 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js @@ -31,9 +31,6 @@ exports.x = 1; //// [file2.js] "use strict"; exports.y = 1; -//// [file4.js] -"use strict"; -exports.z1 = 1; //// [file1.js] "use strict"; var file1_1 = require("folder2/file1"); diff --git a/tests/cases/fourslash/importJsNodeModule3.ts b/tests/cases/fourslash/importJsNodeModule3.ts index a48150a4218..b790d351a1f 100644 --- a/tests/cases/fourslash/importJsNodeModule3.ts +++ b/tests/cases/fourslash/importJsNodeModule3.ts @@ -10,7 +10,11 @@ // @Filename: node_modules/anotherMod/index.js //// exports.x = 3; //// exports.y = 'foo'; -//// exports.z = true; +//// /** +//// * @param {(number | boolean)} a The first param +//// * @param {Array} b The second param +//// */ +//// exports.z = function(a,b){ return "test"; }; // @Filename: consumer.js //// import * as x from 'myMod'; @@ -29,3 +33,6 @@ verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documenta edit.backspace(4); edit.insert('y.'); verify.completionListContains("toUpperCase", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +edit.backspace(2); +edit.insert('z('); +verify.currentSignatureHelpIs("z(a: number | boolean, b: string[]): string"); diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index 1173f579f2c..b1caed2d62a 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -179,6 +179,9 @@ module ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", + "/c/d.ts", + "/c/d.tsx", + "/c/d.d.ts", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); From 294862c15e66e7533d78fe83342d99d1b4d3d63f Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 19 Feb 2016 15:58:00 +0900 Subject: [PATCH 020/103] indent 'from' again --- src/services/formatting/formatting.ts | 1 - tests/cases/fourslash/formatNamedExportImport.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 08390788245..53a8c2b4307 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -477,7 +477,6 @@ namespace ts.formatting { case SyntaxKind.CloseParenToken: case SyntaxKind.ElseKeyword: case SyntaxKind.WhileKeyword: - case SyntaxKind.FromKeyword: case SyntaxKind.AtToken: return indentation; default: diff --git a/tests/cases/fourslash/formatNamedExportImport.ts b/tests/cases/fourslash/formatNamedExportImport.ts index 18f2f19577a..efc91111b2d 100644 --- a/tests/cases/fourslash/formatNamedExportImport.ts +++ b/tests/cases/fourslash/formatNamedExportImport.ts @@ -44,7 +44,7 @@ verify.currentLineContentIs(" y as yy, z"); goTo.marker("exportCloseBrace"); verify.currentLineContentIs("}"); goTo.marker("fromKeywordAutoformat"); -verify.currentLineContentIs("from"); +verify.currentLineContentIs(" from"); goTo.marker("fromKeywordIndent"); verify.indentationIs(4); goTo.marker("exportDir"); @@ -62,7 +62,7 @@ verify.currentLineContentIs(" as yy,"); goTo.marker("importCloseBrace"); verify.currentLineContentIs("}"); goTo.marker("importDir"); -verify.currentLineContentIs('from "wow"'); +verify.currentLineContentIs(' from "wow"'); goTo.marker("formatOnEnter"); edit.insertLine(''); From ac541948c95b778e0da6945d2cec86bb9fba557d Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 23 May 2016 17:06:48 -0700 Subject: [PATCH 021/103] Fixed diagnostic message wording --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/program.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index efc90dbdc48..9d8e7c7afda 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2756,7 +2756,7 @@ "category": "Message", "code": 6131 }, - "No types specified in 'package.json' and is 'allowJs' set. Returning package 'main' value of '{0}' for module": { + "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'": { "category": "Message", "code": 6132 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 68ea6e71e41..49762cf22b4 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -180,7 +180,7 @@ namespace ts { // Use the main module for inferring types if no types package specified and the allowJs is set if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { if (state.traceEnabled) { - trace(state.host, Diagnostics.No_types_specified_in_package_json_and_is_allowJs_set_Returning_package_main_value_of_0_for_module, jsonContent.main); + trace(state.host, Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); } const mainFilePath = normalizePath(combinePaths(baseDirectory, jsonContent.main)); return mainFilePath; From dd31bf93e73f8c0b4eb41c031cec15fe87409acd Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 23 May 2016 17:25:10 -0700 Subject: [PATCH 022/103] Updated test --- tests/cases/unittests/moduleResolution.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index c33d4a6ff0a..29fde331892 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -179,9 +179,6 @@ module ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", - "/c/d.ts", - "/c/d.tsx", - "/c/d.d.ts", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); From 073f16e35956d96f773d81d9d9bca919cc5e150e Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 23 May 2016 17:28:41 -0700 Subject: [PATCH 023/103] Fixed whitespace --- src/compiler/diagnosticMessages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index eaffbe0364d..94b73cfe51e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2759,7 +2759,7 @@ "Resolving real path for '{0}', result '{1}'": { "category": "Message", "code": 6130 - }, + }, "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'.": { "category": "Error", "code": 6131 From a826892de18d6a86324e7f75a34446b255718e2a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 14 Jun 2016 13:23:08 -0700 Subject: [PATCH 024/103] Unions/intersections of readonly props are readonly --- src/compiler/checker.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a2fe0065983..fe63d0c1c3b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11975,6 +11975,10 @@ namespace ts { // Variables declared with 'const' // Get accessors without matching set accessors // Enum members + // Unions and intersections of the above + if (symbol.flags & SymbolFlags.SyntheticProperty) { + return forEach(symbol.declarations, decl => isReadonlySymbol(getSymbolOfNode(decl))); + } return symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 || symbol.flags & SymbolFlags.Variable && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 || symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) || From 931839c84294d7ec9618fd506098ce019d3c4904 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 14 Jun 2016 13:23:53 -0700 Subject: [PATCH 025/103] Test readonly intersection and union properties --- .../intersectionTypeReadonly.errors.txt | 44 ++++++++++++++++++ .../reference/intersectionTypeReadonly.js | 39 ++++++++++++++++ .../reference/unionTypeReadonly.errors.txt | 45 +++++++++++++++++++ .../baselines/reference/unionTypeReadonly.js | 40 +++++++++++++++++ .../intersection/intersectionTypeReadonly.ts | 25 +++++++++++ .../types/union/unionTypeReadonly.ts | 26 +++++++++++ 6 files changed, 219 insertions(+) create mode 100644 tests/baselines/reference/intersectionTypeReadonly.errors.txt create mode 100644 tests/baselines/reference/intersectionTypeReadonly.js create mode 100644 tests/baselines/reference/unionTypeReadonly.errors.txt create mode 100644 tests/baselines/reference/unionTypeReadonly.js create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts create mode 100644 tests/cases/conformance/types/union/unionTypeReadonly.ts diff --git a/tests/baselines/reference/intersectionTypeReadonly.errors.txt b/tests/baselines/reference/intersectionTypeReadonly.errors.txt new file mode 100644 index 00000000000..d9e22fd2223 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeReadonly.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(21,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(23,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(25,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + + +==== tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts (5 errors) ==== + interface Base { + readonly value: number; + } + interface Identical { + readonly value: number; + } + interface Mutable { + value: number; + } + interface DifferentType { + readonly value: string; + } + interface DifferentName { + readonly other: number; + } + let base: Base; + base.value = 12 // error, lhs can't be a readonly property + ~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let identical: Base & Identical; + identical.value = 12; // error, lhs can't be a readonly property + ~~~~~~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let mutable: Base & Mutable; + mutable.value = 12; // error, lhs can't be a readonly property + ~~~~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let differentType: Base & DifferentType; + differentType.value = 12; // error, lhs can't be a readonly property + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let differentName: Base & DifferentName; + differentName.value = 12; // error, property 'value' doesn't exist + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionTypeReadonly.js b/tests/baselines/reference/intersectionTypeReadonly.js new file mode 100644 index 00000000000..7399125bbb1 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeReadonly.js @@ -0,0 +1,39 @@ +//// [intersectionTypeReadonly.ts] +interface Base { + readonly value: number; +} +interface Identical { + readonly value: number; +} +interface Mutable { + value: number; +} +interface DifferentType { + readonly value: string; +} +interface DifferentName { + readonly other: number; +} +let base: Base; +base.value = 12 // error, lhs can't be a readonly property +let identical: Base & Identical; +identical.value = 12; // error, lhs can't be a readonly property +let mutable: Base & Mutable; +mutable.value = 12; // error, lhs can't be a readonly property +let differentType: Base & DifferentType; +differentType.value = 12; // error, lhs can't be a readonly property +let differentName: Base & DifferentName; +differentName.value = 12; // error, property 'value' doesn't exist + + +//// [intersectionTypeReadonly.js] +var base; +base.value = 12; // error, lhs can't be a readonly property +var identical; +identical.value = 12; // error, lhs can't be a readonly property +var mutable; +mutable.value = 12; // error, lhs can't be a readonly property +var differentType; +differentType.value = 12; // error, lhs can't be a readonly property +var differentName; +differentName.value = 12; // error, property 'value' doesn't exist diff --git a/tests/baselines/reference/unionTypeReadonly.errors.txt b/tests/baselines/reference/unionTypeReadonly.errors.txt new file mode 100644 index 00000000000..0875b2b5af3 --- /dev/null +++ b/tests/baselines/reference/unionTypeReadonly.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/types/union/unionTypeReadonly.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/union/unionTypeReadonly.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/union/unionTypeReadonly.ts(21,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/union/unionTypeReadonly.ts(23,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. +tests/cases/conformance/types/union/unionTypeReadonly.ts(25,15): error TS2339: Property 'value' does not exist on type 'Base | DifferentName'. + + +==== tests/cases/conformance/types/union/unionTypeReadonly.ts (5 errors) ==== + interface Base { + readonly value: number; + } + interface Identical { + readonly value: number; + } + interface Mutable { + value: number; + } + interface DifferentType { + readonly value: string; + } + interface DifferentName { + readonly other: number; + } + let base: Base; + base.value = 12 // error, lhs can't be a readonly property + ~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let identical: Base | Identical; + identical.value = 12; // error, lhs can't be a readonly property + ~~~~~~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let mutable: Base | Mutable; + mutable.value = 12; // error, lhs can't be a readonly property + ~~~~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let differentType: Base | DifferentType; + differentType.value = 12; // error, lhs can't be a readonly property + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. + let differentName: Base | DifferentName; + differentName.value = 12; // error, property 'value' doesn't exist + ~~~~~ +!!! error TS2339: Property 'value' does not exist on type 'Base | DifferentName'. + + \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeReadonly.js b/tests/baselines/reference/unionTypeReadonly.js new file mode 100644 index 00000000000..cdc893c91d9 --- /dev/null +++ b/tests/baselines/reference/unionTypeReadonly.js @@ -0,0 +1,40 @@ +//// [unionTypeReadonly.ts] +interface Base { + readonly value: number; +} +interface Identical { + readonly value: number; +} +interface Mutable { + value: number; +} +interface DifferentType { + readonly value: string; +} +interface DifferentName { + readonly other: number; +} +let base: Base; +base.value = 12 // error, lhs can't be a readonly property +let identical: Base | Identical; +identical.value = 12; // error, lhs can't be a readonly property +let mutable: Base | Mutable; +mutable.value = 12; // error, lhs can't be a readonly property +let differentType: Base | DifferentType; +differentType.value = 12; // error, lhs can't be a readonly property +let differentName: Base | DifferentName; +differentName.value = 12; // error, property 'value' doesn't exist + + + +//// [unionTypeReadonly.js] +var base; +base.value = 12; // error, lhs can't be a readonly property +var identical; +identical.value = 12; // error, lhs can't be a readonly property +var mutable; +mutable.value = 12; // error, lhs can't be a readonly property +var differentType; +differentType.value = 12; // error, lhs can't be a readonly property +var differentName; +differentName.value = 12; // error, property 'value' doesn't exist diff --git a/tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts b/tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts new file mode 100644 index 00000000000..e659c6f6f56 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts @@ -0,0 +1,25 @@ +interface Base { + readonly value: number; +} +interface Identical { + readonly value: number; +} +interface Mutable { + value: number; +} +interface DifferentType { + readonly value: string; +} +interface DifferentName { + readonly other: number; +} +let base: Base; +base.value = 12 // error, lhs can't be a readonly property +let identical: Base & Identical; +identical.value = 12; // error, lhs can't be a readonly property +let mutable: Base & Mutable; +mutable.value = 12; // error, lhs can't be a readonly property +let differentType: Base & DifferentType; +differentType.value = 12; // error, lhs can't be a readonly property +let differentName: Base & DifferentName; +differentName.value = 12; // error, property 'value' doesn't exist diff --git a/tests/cases/conformance/types/union/unionTypeReadonly.ts b/tests/cases/conformance/types/union/unionTypeReadonly.ts new file mode 100644 index 00000000000..89cf1cbfd37 --- /dev/null +++ b/tests/cases/conformance/types/union/unionTypeReadonly.ts @@ -0,0 +1,26 @@ +interface Base { + readonly value: number; +} +interface Identical { + readonly value: number; +} +interface Mutable { + value: number; +} +interface DifferentType { + readonly value: string; +} +interface DifferentName { + readonly other: number; +} +let base: Base; +base.value = 12 // error, lhs can't be a readonly property +let identical: Base | Identical; +identical.value = 12; // error, lhs can't be a readonly property +let mutable: Base | Mutable; +mutable.value = 12; // error, lhs can't be a readonly property +let differentType: Base | DifferentType; +differentType.value = 12; // error, lhs can't be a readonly property +let differentName: Base | DifferentName; +differentName.value = 12; // error, property 'value' doesn't exist + From cc8d193d4a2cae6883e701120a5050454d7064ed Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 14 Jun 2016 16:14:59 -0700 Subject: [PATCH 026/103] Calculate readonly? on union/intersection creation --- src/compiler/checker.ts | 13 ++++++++----- src/compiler/types.ts | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fe63d0c1c3b..2831a591fbc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4197,6 +4197,7 @@ namespace ts { let props: Symbol[]; // Flags we want to propagate to the result if they exist in all source symbols let commonFlags = (containingType.flags & TypeFlags.Intersection) ? SymbolFlags.Optional : SymbolFlags.None; + let isReadonly = false; for (const current of types) { const type = getApparentType(current); if (type !== unknownType) { @@ -4209,6 +4210,9 @@ namespace ts { else if (!contains(props, prop)) { props.push(prop); } + if (isReadonlySymbol(prop)) { + isReadonly = true; + } } else if (containingType.flags & TypeFlags.Union) { // A union type requires the property to be present in all constituent types @@ -4238,6 +4242,7 @@ namespace ts { name); result.containingType = containingType; result.declarations = declarations; + result.isReadonly = isReadonly; result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } @@ -11975,11 +11980,9 @@ namespace ts { // Variables declared with 'const' // Get accessors without matching set accessors // Enum members - // Unions and intersections of the above - if (symbol.flags & SymbolFlags.SyntheticProperty) { - return forEach(symbol.declarations, decl => isReadonlySymbol(getSymbolOfNode(decl))); - } - return symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 || + // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) + return symbol.isReadonly || + symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 || symbol.flags & SymbolFlags.Variable && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 || symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) || (symbol.flags & SymbolFlags.EnumMember) !== 0; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index db34bb7c6e8..7487d1db258 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2104,6 +2104,7 @@ namespace ts { members?: SymbolTable; // Class, interface or literal instance members exports?: SymbolTable; // Module exports globalExports?: SymbolTable; // Conditional global UMD exports + /* @internal */ isReadonly?: boolean; // readonly? (set only for intersections and unions) /* @internal */ id?: number; // Unique id (used to look up SymbolLinks) /* @internal */ mergeId?: number; // Merge id (used to look up merged symbol) /* @internal */ parent?: Symbol; // Parent symbol From 218a5ba0bb9fd78ea9b06f21323199bad7ba77ec Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Fri, 17 Jun 2016 13:02:15 -0700 Subject: [PATCH 027/103] Adding base indentation for script block formatting and smart indent --- src/harness/fourslash.ts | 1 + src/server/editorServices.ts | 1 + src/server/protocol.d.ts | 5 ++++- src/server/session.ts | 1 + src/services/formatting/smartIndenter.ts | 18 +++++++++++------- src/services/services.ts | 3 ++- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 695e19b4667..5aa31780092 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -310,6 +310,7 @@ namespace FourSlash { } this.formatCodeOptions = { + BaseIndentSize: 0, IndentSize: 4, TabSize: 4, NewLineCharacter: Harness.IO.newLine(), diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 5c1fe354d18..a7f11ac2757 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1389,6 +1389,7 @@ namespace ts.server { static getDefaultFormatCodeOptions(host: ServerHost): ts.FormatCodeOptions { return ts.clone({ + BaseIndentSize: 0, IndentSize: 4, TabSize: 4, NewLineCharacter: host.newLine || "\n", diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index b62d89ae520..bf1bef75db1 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -434,6 +434,9 @@ declare namespace ts.server.protocol { /** Number of spaces to indent during formatting. Default value is 4. */ indentSize?: number; + /** Number of additional spaces to indent during formatting to preserve base indentation (ex. script block indentation). Default value is 0. */ + baseIndentSize?: number; + /** The new line character to be used. Default value is the OS line delimiter. */ newLineCharacter?: string; @@ -474,7 +477,7 @@ declare namespace ts.server.protocol { placeOpenBraceOnNewLineForControlBlocks?: boolean; /** Index operator */ - [key: string]: string | number | boolean; + [key: string]: string | number | boolean | undefined; } /** diff --git a/src/server/session.ts b/src/server/session.ts index 2964dc66505..f4cb542f5c3 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -674,6 +674,7 @@ namespace ts.server { if (lineText.search("\\S") < 0) { // TODO: get these options from host const editorOptions: ts.EditorOptions = { + BaseIndentSize: formatOptions.BaseIndentSize, IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: formatOptions.NewLineCharacter, diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 23a1d937869..1de7a7cb74c 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -10,24 +10,24 @@ namespace ts.formatting { export function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number { if (position > sourceFile.text.length) { - return 0; // past EOF + return getBaseIndentation(options); // past EOF } // no indentation when the indent style is set to none, // so we can return fast if (options.IndentStyle === IndentStyle.None) { - return 0; + return getBaseIndentation(options); } const precedingToken = findPrecedingToken(position, sourceFile); if (!precedingToken) { - return 0; + return getBaseIndentation(options); } // no indentation in string \regex\template literals const precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return 0; + return getBaseIndentation(options); } const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -96,13 +96,17 @@ namespace ts.formatting { } if (!current) { - // no parent was found - return 0 to be indented on the level of SourceFile - return 0; + // no parent was found - return the base indentation of the SourceFile + return getBaseIndentation(options); } return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } + function getBaseIndentation(options: EditorOptions) { + return options.BaseIndentSize || 0; + } + export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number { const start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); @@ -162,7 +166,7 @@ namespace ts.formatting { parent = current.parent; } - return indentationDelta; + return indentationDelta + getBaseIndentation(options); } diff --git a/src/services/services.ts b/src/services/services.ts index 68fd95f1441..84f4216cb16 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1244,6 +1244,7 @@ namespace ts { } export interface EditorOptions { + BaseIndentSize?: number; IndentSize: number; TabSize: number; NewLineCharacter: string; @@ -1268,7 +1269,7 @@ namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string; + [s: string]: boolean | number | string | undefined; } export interface DefinitionInfo { From 369253bbc419db2db106c2250382a25fb2046115 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Tue, 21 Jun 2016 11:46:49 -0700 Subject: [PATCH 028/103] Fix case when a document contains multiple script blocks with different base indentations. Use the base indent size if it is greater that the indentation of the inherited predecessor --- src/services/formatting/formatting.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index ef8fddcfb3a..50295de3e1a 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -394,6 +394,11 @@ namespace ts.formatting { const startLinePosition = getLineStartPositionForPosition(startPos, sourceFile); const column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); if (startLine !== parentStartLine || startPos === column) { + // Use the base indent size if it is greater than + // the indentation of the inherited predecessor. + if (options.BaseIndentSize > column) { + return options.BaseIndentSize; + } return column; } } From 07bfbab6ffa819dff5fa845888e516b8adc669cf Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 21 Jun 2016 13:42:02 -0700 Subject: [PATCH 029/103] Changed implementation to use closure --- src/compiler/program.ts | 66 ++++++++++++++++----------------------- src/compiler/types.ts | 2 -- src/compiler/utilities.ts | 12 +++---- 3 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 2917660fcc6..567eae7b9a8 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1066,6 +1066,16 @@ namespace ts { let resolvedTypeReferenceDirectives: Map = {}; let fileProcessingDiagnostics = createDiagnosticCollection(); + // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules. + // This works as imported modules are discovered recursively in a depth first manner, specifically: + // - For each root file, findSourceFile is called. + // - This calls processImportedModules for each module imported in the source file. + // - This calls resolveModuleNames, and then calls findSourceFile for each resolved module. + // As all these operations happen - and are nested - within the createProgram call, they close over the below variables. + // The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses. + const maxNodeModulesJsDepth = options.maxNodeModuleJsDepth || 2; + let currentNodeModulesJsDepth = 0; + const start = new Date().getTime(); host = host || createCompilerHost(options); @@ -1869,7 +1879,7 @@ namespace ts { } // Get source file from normalized fileName - function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number, isFileFromNodeSearch?: boolean): SourceFile { + function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { if (filesByName.contains(path)) { const file = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -1878,12 +1888,6 @@ namespace ts { reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd); } - // If this was a file found by a node_modules search, set the nodeModuleSearchDistance to parent distance + 1. - if (isFileFromNodeSearch) { - const newDistance = (refFile && refFile.nodeModuleSearchDistance) === undefined ? 1 : refFile.nodeModuleSearchDistance + 1; - // If already set on the file, don't overwrite if it was already found closer (which may be '0' if added as a root file) - file.nodeModuleSearchDistance = (typeof file.nodeModuleSearchDistance === "number") ? Math.min(file.nodeModuleSearchDistance, newDistance) : newDistance; - } return file; } @@ -1902,12 +1906,6 @@ namespace ts { if (file) { file.path = path; - // Default to same distance as parent. Add one if found by a search. - file.nodeModuleSearchDistance = (refFile && refFile.nodeModuleSearchDistance) || 0; - if (isFileFromNodeSearch) { - file.nodeModuleSearchDistance++; - } - if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case const existingFile = filesByNameIgnoreCase.get(path); @@ -2020,13 +2018,11 @@ namespace ts { } function processImportedModules(file: SourceFile, basePath: string) { - const maxJsNodeModuleSearchDistance = options.maxNodeModuleJsDepth || 0; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = {}; const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); - file.nodeModuleSearchDistance = file.nodeModuleSearchDistance || 0; for (let i = 0; i < moduleNames.length; i++) { const resolution = resolutions[i]; setResolvedModule(file, moduleNames[i], resolution); @@ -2035,32 +2031,24 @@ namespace ts { // - noResolve is falsy // - module name comes from the list of imports // - it's not a top level JavaScript module that exceeded the search max - const exceedsJsSearchDepth = resolution && resolution.isExternalLibraryImport && - hasJavaScriptFileExtension(resolution.resolvedFileName) && - file.nodeModuleSearchDistance >= maxJsNodeModuleSearchDistance; - const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !exceedsJsSearchDepth; + let isJsFileUnderNodeModules = resolution && resolution.isExternalLibraryImport && + hasJavaScriptFileExtension(resolution.resolvedFileName); + if (isJsFileUnderNodeModules) { + currentNodeModulesJsDepth++; + } + const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && + !(isJsFileUnderNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth); if (shouldAddFile) { -// const importedFile = findSourceFile(resolution.resolvedFileName, -// toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), -// /*isDefaultLib*/ false, /*isReference*/ false, -// file, -// skipTrivia(file.text, file.imports[i].pos), -// file.imports[i].end, -// resolution.isExternalLibraryImport); -// -// // TODO (billti): Should we check here if a JavaScript file is a CommonJS file, or doesn't have /// references? -// if (importedFile && resolution.isExternalLibraryImport && !hasJavaScriptFileExtension(importedFile.fileName)) { -// if (!isExternalModule(importedFile) && importedFile.statements.length) { -// const start = getTokenPosOfNode(file.imports[i], file); -// fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); -// } -// else if (importedFile.referencedFiles.length) { -// const firstRef = importedFile.referencedFiles[0]; -// fileProcessingDiagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); -// } -// } - findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, + toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), + /*isDefaultLib*/ false, /*isReference*/ false, + file, + skipTrivia(file.text, file.imports[i].pos), + file.imports[i].end); + } + if (isJsFileUnderNodeModules) { + currentNodeModulesJsDepth--; } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7e9ba86fa32..bd123177a33 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1642,8 +1642,6 @@ namespace ts { /* @internal */ externalModuleIndicator: Node; // The first node that causes this file to be a CommonJS module /* @internal */ commonJsModuleIndicator: Node; - // The number of times node_modules was searched to locate the package containing this file - /* @internal */ nodeModuleSearchDistance?: number; /* @internal */ identifiers: Map; /* @internal */ nodeCount: number; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4c435640316..d01678ac767 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2275,8 +2275,8 @@ namespace ts { else { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; for (const sourceFile of sourceFiles) { - // Don't emit if source file is a declaration file, or was found by a search under 'node_modules' - if (!isDeclarationFile(sourceFile) && !sourceFile.nodeModuleSearchDistance) { + // Don't emit if source file is a declaration file, or TODO: was found by a search under 'node_modules' + if (!isDeclarationFile(sourceFile)) { onSingleFileEmit(host, sourceFile); } } @@ -2310,10 +2310,10 @@ namespace ts { function onBundledEmit(host: EmitHost) { // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified const bundledSources = filter(host.getSourceFiles(), - sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file - !sourceFile.nodeModuleSearchDistance && // Not loaded from searching under node_modules - (!isExternalModule(sourceFile) || // non module file - (getEmitModuleKind(options) && isExternalModule(sourceFile)))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted + // TODO: Don't emit from source resolved by searching under node_modules + sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file + (!isExternalModule(sourceFile) || // non module file + !!getEmitModuleKind(options))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted if (bundledSources.length) { const jsFilePath = options.outFile || options.out; const emitFileNames: EmitFileNames = { From d01d5b1cb25212407fe78e93fab8e804aefe9f75 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 21 Jun 2016 13:51:31 -0700 Subject: [PATCH 030/103] Updated tests --- tests/baselines/reference/nodeResolution6.js | 2 ++ tests/baselines/reference/nodeResolution8.js | 2 ++ .../pathMappingBasedModuleResolution5_node.js | 3 +++ tests/cases/fourslash/importJsNodeModule4.ts | 11 +++++------ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/nodeResolution6.js b/tests/baselines/reference/nodeResolution6.js index 196e8ae57cf..58a9b907250 100644 --- a/tests/baselines/reference/nodeResolution6.js +++ b/tests/baselines/reference/nodeResolution6.js @@ -13,5 +13,7 @@ export declare var y; import y = require("a"); +//// [ref.js] +var x = 1; //// [b.js] "use strict"; diff --git a/tests/baselines/reference/nodeResolution8.js b/tests/baselines/reference/nodeResolution8.js index 1d90399ff70..36b53eec553 100644 --- a/tests/baselines/reference/nodeResolution8.js +++ b/tests/baselines/reference/nodeResolution8.js @@ -12,5 +12,7 @@ export declare var y; //// [b.ts] import y = require("a"); +//// [ref.js] +var x = 1; //// [b.js] "use strict"; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js index e4440299cc7..1958800f918 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js @@ -31,6 +31,9 @@ exports.x = 1; //// [file2.js] "use strict"; exports.y = 1; +//// [file4.js] +"use strict"; +exports.z1 = 1; //// [file1.js] "use strict"; var file1_1 = require("folder2/file1"); diff --git a/tests/cases/fourslash/importJsNodeModule4.ts b/tests/cases/fourslash/importJsNodeModule4.ts index b4bdc7ce9f7..917bea35842 100644 --- a/tests/cases/fourslash/importJsNodeModule4.ts +++ b/tests/cases/fourslash/importJsNodeModule4.ts @@ -12,9 +12,8 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -// TODO: Bug: Fix ES6 import of assignments to module.exports -// verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -// verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -// verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -// edit.insert('n.'); -// verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +edit.insert('n.'); +verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); From 8ff2c1ad4f02579cd15eb32fc6aaf72cddaec869 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 21 Jun 2016 14:00:42 -0700 Subject: [PATCH 031/103] Fixed linting error --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 567eae7b9a8..ecddd721211 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2031,7 +2031,7 @@ namespace ts { // - noResolve is falsy // - module name comes from the list of imports // - it's not a top level JavaScript module that exceeded the search max - let isJsFileUnderNodeModules = resolution && resolution.isExternalLibraryImport && + const isJsFileUnderNodeModules = resolution && resolution.isExternalLibraryImport && hasJavaScriptFileExtension(resolution.resolvedFileName); if (isJsFileUnderNodeModules) { currentNodeModulesJsDepth++; From e5ddcfed075c2d1bf3eddcb2772fa5c87d92a7ef Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 23 Jun 2016 16:44:16 -0700 Subject: [PATCH 032/103] Allow space in exec cmds --- Gulpfile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 2e6081bea4a..08dc48dde9d 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -69,7 +69,7 @@ function exec(cmd: string, args: string[], complete: () => void = (() => {}), er console.log(`${cmd} ${args.join(" ")}`); // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition const subshellFlag = isWin ? "/c" : "-c"; - const command = isWin ? [cmd, ...args] : [`${cmd} ${args.join(" ")}`]; + const command = isWin ? [cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd, ...args] : [`${cmd} ${args.join(" ")}`]; const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true } as any); ex.on("exit", (code) => code === 0 ? complete() : error(/*e*/ undefined, code)); ex.on("error", error); From 6346fc1168f34f8f0b268d1bd822c796c5c20951 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 23 Jun 2016 17:36:59 -0700 Subject: [PATCH 033/103] Fix typo --- src/harness/fourslash.ts | 8 +++--- src/harness/harnessLanguageService.ts | 4 +-- src/server/client.ts | 2 +- src/services/services.ts | 6 ++-- src/services/shims.ts | 8 +++--- .../commentBraceCompletionPosition.ts | 6 ++-- tests/cases/fourslash/fourslash.ts | 2 +- .../fourslash/jsxBraceCompletionPosition.ts | 28 +++++++++---------- .../stringBraceCompletionPosition.ts | 6 ++-- .../stringTemplateBraceCompletionPosition.ts | 8 +++--- .../fourslash/validBraceCompletionPosition.ts | 10 +++---- 11 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 695e19b4667..6cd1c305911 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1895,7 +1895,7 @@ namespace FourSlash { }); } - public verifyBraceCompletionAtPostion(negative: boolean, openingBrace: string) { + public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { const openBraceMap: ts.Map = { "(": ts.CharacterCodes.openParen, @@ -1915,7 +1915,7 @@ namespace FourSlash { const position = this.currentCaretPosition; - const validBraceCompletion = this.languageService.isValidBraceCompletionAtPostion(this.activeFile.fileName, position, charCode); + const validBraceCompletion = this.languageService.isValidBraceCompletionAtPosition(this.activeFile.fileName, position, charCode); if (!negative && !validBraceCompletion) { this.raiseError(`${position} is not a valid brace completion position for ${openingBrace}`); @@ -2919,8 +2919,8 @@ namespace FourSlashInterface { this.state.verifyDefinitionsName(this.negative, name, containerName); } - public isValidBraceCompletionAtPostion(openingBrace: string) { - this.state.verifyBraceCompletionAtPostion(this.negative, openingBrace); + public isValidBraceCompletionAtPosition(openingBrace: string) { + this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace); } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8567a9109de..b40cbde73e7 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -450,8 +450,8 @@ namespace Harness.LanguageService { getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion { return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position)); } - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { - return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace)); + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { + return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } getEmitOutput(fileName: string): ts.EmitOutput { return unwrapJSONCallResult(this.shim.getEmitOutput(fileName)); diff --git a/src/server/client.ts b/src/server/client.ts index 09cfa2ac739..f04dbd8dc02 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -588,7 +588,7 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { throw new Error("Not Implemented Yet."); } diff --git a/src/services/services.ts b/src/services/services.ts index fd72fd40eee..2b35749d592 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1147,7 +1147,7 @@ namespace ts { getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; getEmitOutput(fileName: string): EmitOutput; @@ -7769,7 +7769,7 @@ namespace ts { return { newText: result, caretOffset: preamble.length }; } - function isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { + function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too // expensive to do during typing scenarios @@ -8137,7 +8137,7 @@ namespace ts { getFormattingEditsForDocument, getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, - isValidBraceCompletionAtPostion, + isValidBraceCompletionAtPosition, getEmitOutput, getNonBoundSourceFile, getProgram diff --git a/src/services/shims.ts b/src/services/shims.ts index ac74ee09750..e0f7cc6dc76 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -228,7 +228,7 @@ namespace ts { * at the current position. * E.g. we don't want brace completion inside string-literals, comments, etc. */ - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; getEmitOutput(fileName: string): string; } @@ -773,10 +773,10 @@ namespace ts { ); } - public isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string { + public isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string { return this.forwardJSONCall( - `isValidBraceCompletionAtPostion('${fileName}', ${position}, ${openingBrace})`, - () => this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace) + `isValidBraceCompletionAtPosition('${fileName}', ${position}, ${openingBrace})`, + () => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace) ); } diff --git a/tests/cases/fourslash/commentBraceCompletionPosition.ts b/tests/cases/fourslash/commentBraceCompletionPosition.ts index 23b8240dcaf..b92c49d3a14 100644 --- a/tests/cases/fourslash/commentBraceCompletionPosition.ts +++ b/tests/cases/fourslash/commentBraceCompletionPosition.ts @@ -14,10 +14,10 @@ //// } goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); \ No newline at end of file +verify.not.isValidBraceCompletionAtPosition('('); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index dd8a61ac458..ede322481e6 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -134,7 +134,7 @@ declare namespace FourSlashInterface { typeDefinitionCountIs(expectedCount: number): void; definitionLocationExists(): void; verifyDefinitionsName(name: string, containerName: string): void; - isValidBraceCompletionAtPostion(openingBrace?: string): void; + isValidBraceCompletionAtPosition(openingBrace?: string): void; } class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; diff --git a/tests/cases/fourslash/jsxBraceCompletionPosition.ts b/tests/cases/fourslash/jsxBraceCompletionPosition.ts index c1c331435ce..91ee96cc5b7 100644 --- a/tests/cases/fourslash/jsxBraceCompletionPosition.ts +++ b/tests/cases/fourslash/jsxBraceCompletionPosition.ts @@ -19,29 +19,29 @@ //// goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.not.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.not.isValidBraceCompletionAtPosition('{'); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('4'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('5'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('6'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('7'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); \ No newline at end of file +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); \ No newline at end of file diff --git a/tests/cases/fourslash/stringBraceCompletionPosition.ts b/tests/cases/fourslash/stringBraceCompletionPosition.ts index 09a9a86b0f1..5df80e2c676 100644 --- a/tests/cases/fourslash/stringBraceCompletionPosition.ts +++ b/tests/cases/fourslash/stringBraceCompletionPosition.ts @@ -6,11 +6,11 @@ //// /*3*/"; goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); diff --git a/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts b/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts index 33bcd4d0625..73c945e932c 100644 --- a/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts +++ b/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts @@ -4,13 +4,13 @@ //// var y = `hello /*2*/world, ${100}how /*3*/are you{ 200 } to/*4*/day!?` goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('4'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); diff --git a/tests/cases/fourslash/validBraceCompletionPosition.ts b/tests/cases/fourslash/validBraceCompletionPosition.ts index 57c30c27c21..1d281be705d 100644 --- a/tests/cases/fourslash/validBraceCompletionPosition.ts +++ b/tests/cases/fourslash/validBraceCompletionPosition.ts @@ -8,16 +8,16 @@ //// var x = /*5*/{ a:true } goTo.marker('1'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('4'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('5'); -verify.isValidBraceCompletionAtPostion('('); \ No newline at end of file +verify.isValidBraceCompletionAtPosition('('); \ No newline at end of file From 034c41822ea35bc0086780b400349060358c8fc9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 24 Jun 2016 11:01:16 -0700 Subject: [PATCH 034/103] extract expression into function --- Gulpfile.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 08dc48dde9d..74113b4b0c7 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -69,12 +69,15 @@ function exec(cmd: string, args: string[], complete: () => void = (() => {}), er console.log(`${cmd} ${args.join(" ")}`); // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition const subshellFlag = isWin ? "/c" : "-c"; - const command = isWin ? [cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd, ...args] : [`${cmd} ${args.join(" ")}`]; + const command = isWin ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`]; const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true } as any); ex.on("exit", (code) => code === 0 ? complete() : error(/*e*/ undefined, code)); ex.on("error", error); } +function possiblyQuote(cmd: string) { + return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd; +} let useDebugMode = true; let host = cmdLineOptions["host"]; From 8c503207be8d54a828cb8209d6620362c87f79ef Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Fri, 24 Jun 2016 13:16:58 -0700 Subject: [PATCH 035/103] Add fourslash tests & address CR comments --- src/harness/fourslash.ts | 15 +- src/services/formatting/formatting.ts | 6 +- src/services/formatting/smartIndenter.ts | 6 +- tests/cases/fourslash/formatWithBaseIndent.ts | 264 ++++++++++++++++++ tests/cases/fourslash/fourslash.ts | 5 +- .../fourslash/indentationWithBaseIndent.ts | 211 ++++++++++++++ 6 files changed, 491 insertions(+), 16 deletions(-) create mode 100644 tests/cases/fourslash/formatWithBaseIndent.ts create mode 100644 tests/cases/fourslash/indentationWithBaseIndent.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5aa31780092..a529b50219a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1663,24 +1663,25 @@ namespace FourSlash { } } - private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle): number { + private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle, baseIndentSize: number): number { const formatOptions = ts.clone(this.formatCodeOptions); formatOptions.IndentStyle = indentStyle; + formatOptions.BaseIndentSize = baseIndentSize; return this.languageService.getIndentationAtPosition(fileName, position, formatOptions); } - public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) { - const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle); + public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) { + const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle, baseIndentSize); const lineCol = this.getLineColStringAtPosition(this.currentCaretPosition); if (actual !== numberOfSpaces) { this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`); } } - public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) { - const actual = this.getIndentation(fileName, position, indentStyle); + public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) { + const actual = this.getIndentation(fileName, position, indentStyle, baseIndentSize); const lineCol = this.getLineColStringAtPosition(position); if (actual !== numberOfSpaces) { this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`); @@ -2938,8 +2939,8 @@ namespace FourSlashInterface { this.state.verifyIndentationAtCurrentPosition(numberOfSpaces); } - public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = ts.IndentStyle.Smart) { - this.state.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle); + public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) { + this.state.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle, baseIndentSize); } public textAtCaretIs(text: string) { diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 50295de3e1a..5dae6393b99 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -396,10 +396,8 @@ namespace ts.formatting { if (startLine !== parentStartLine || startPos === column) { // Use the base indent size if it is greater than // the indentation of the inherited predecessor. - if (options.BaseIndentSize > column) { - return options.BaseIndentSize; - } - return column; + const baseIndentSize = SmartIndenter.getBaseIndentation(options); + return baseIndentSize > column ? baseIndentSize : column; } } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 1de7a7cb74c..d25182c73df 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -16,7 +16,7 @@ namespace ts.formatting { // no indentation when the indent style is set to none, // so we can return fast if (options.IndentStyle === IndentStyle.None) { - return getBaseIndentation(options); + return 0; } const precedingToken = findPrecedingToken(position, sourceFile); @@ -27,7 +27,7 @@ namespace ts.formatting { // no indentation in string \regex\template literals const precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return getBaseIndentation(options); + return 0; } const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -103,7 +103,7 @@ namespace ts.formatting { return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } - function getBaseIndentation(options: EditorOptions) { + export function getBaseIndentation(options: EditorOptions) { return options.BaseIndentSize || 0; } diff --git a/tests/cases/fourslash/formatWithBaseIndent.ts b/tests/cases/fourslash/formatWithBaseIndent.ts new file mode 100644 index 00000000000..660131996c9 --- /dev/null +++ b/tests/cases/fourslash/formatWithBaseIndent.ts @@ -0,0 +1,264 @@ +/// + +//// +/////*1*/ module classes { +/////*2*/ class Bar { +//// +/////*3*/ constructor() { +/////*4*/ } +//// +/////*5*/private foo: string = ""; +//// +/////*6*/ private f() { +/////*7*/ var a: any[] = [[1, 2], [3, 4], 5]; +/////*8*/ return ((1 + 1)); +/////*9*/ } +//// +/////*10*/ private f2() { +/////*11*/ if (true) { } { }; +/////*12*/ } +/////*13*/ } +/////*14*/ } +//// +//// +/////*15*/ module interfaces { +/////*16*/ interface Foo { +//// +/////*17*/ x: number; +//// +/////*18*/ foo(): number; +/////*19*/ } +/////*20*/ } +//// +//// +/////*21*/ module nestedModules { +/////*22*/ module Foo2 { +/////*23*/ function f() { +/////*24*/ } +/////*25*/ var x: number; +/////*26*/} +/////*27*/ } +//// +//// +/////*28*/ module Enums { +/////*29*/ enum Foo3 { +/////*30*/ val1 , +/////*31*/ val2, +/////*32*/ } +/////*33*/ } +//// +//// +/////*34*/ function controlStatements() { +/////*35*/ for (var i = 0; i < 10; i++) { +/////*36*/ } +//// +/////*37*/ for (var e in foo.bar) { +/////*38*/ } +//// +/////*39*/with (foo.bar) { +/////*40*/ } +//// +/////*41*/ while (false) { +/////*42*/ } +//// +/////*43*/ do { +/////*44*/ } while (false); +//// +/////*45*/ switch (foo.bar) { +/////*46*/ } +//// +/////*47*/ switch (foo.bar) { +/////*48*/ case 1: +/////*49*/ break; +/////*50*/ default: +/////*51*/ break; +/////*52*/ } +/////*53*/ } +//// +//// +/////*54*/ function tryCatch() { +/////*55*/try { +/////*56*/} +/////*57*/catch (err) { +/////*58*/ } +/////*59*/ } +//// +//// +/////*60*/ function tryFinally() { +/////*61*/ try { +/////*62*/ } +/////*63*/ finally { +/////*64*/ } +/////*65*/ } +//// +//// +/////*66*/ function tryCatchFinally() { +/////*67*/ try { +/////*68*/ } +/////*69*/ catch (err) { +/////*70*/ } +/////*71*/ finally { +/////*72*/ } +/////*73*/ } +//// +//// +/////*74*/ class indentBeforeCurly +/////*75*/ { +/////*76*/ } +//// +//// +/////*77*/ function argumentsListIndentation(bar, +/////*78*/ blah, +/////*79*/ ); +//// +//// +/////*80*/ function blockIndentAfterIndentedParameter1(bar, +/////*81*/ blah) { +/////*82*/ } +//// +//// +/////*83*/ function blockIndentAfterIndentedParameter2(bar, +/////*84*/ blah) { +/////*85*/ if (foo) { +/////*86*/ } +/////*87*/} +//// +/////*88*/ var templateLiterals = `abcdefghi +/////*89*/jklmnop +/////*90*/qrstuvwxyz`; + +var originalOptions = format.copyFormatOptions(); +var copy = format.copyFormatOptions(); +copy.BaseIndentSize = 10; +copy.IndentSize = 4; + +format.setFormatOptions(copy); +format.document(); + +verify.currentFileContentIs(` + module classes { + class Bar { + + constructor() { + } + + private foo: string = ""; + + private f() { + var a: any[] = [[1, 2], [3, 4], 5]; + return ((1 + 1)); + } + + private f2() { + if (true) { } { }; + } + } + } + + + module interfaces { + interface Foo { + + x: number; + + foo(): number; + } + } + + + module nestedModules { + module Foo2 { + function f() { + } + var x: number; + } + } + + + module Enums { + enum Foo3 { + val1, + val2, + } + } + + + function controlStatements() { + for (var i = 0; i < 10; i++) { + } + + for (var e in foo.bar) { + } + + with (foo.bar) { + } + + while (false) { + } + + do { + } while (false); + + switch (foo.bar) { + } + + switch (foo.bar) { + case 1: + break; + default: + break; + } + } + + + function tryCatch() { + try { + } + catch (err) { + } + } + + + function tryFinally() { + try { + } + finally { + } + } + + + function tryCatchFinally() { + try { + } + catch (err) { + } + finally { + } + } + + + class indentBeforeCurly { + } + + + function argumentsListIndentation(bar, + blah, + ); + + + function blockIndentAfterIndentedParameter1(bar, + blah) { + } + + + function blockIndentAfterIndentedParameter2(bar, + blah) { + if (foo) { + } + } + + var templateLiterals = \`abcdefghi +jklmnop +qrstuvwxyz\`;`); + +format.setFormatOptions(originalOptions); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index dd8a61ac458..861d68f803d 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -68,6 +68,7 @@ declare namespace FourSlashInterface { data?: any; } interface EditorOptions { + BaseIndentSize?: number, IndentSize: number; TabSize: number; NewLineCharacter: string; @@ -84,7 +85,7 @@ declare namespace FourSlashInterface { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string; + [s: string]: boolean | number | string | undefined; } interface Range { fileName: string; @@ -140,7 +141,7 @@ declare namespace FourSlashInterface { assertHasRanges(ranges: Range[]): void; caretAtMarker(markerName?: string): void; indentationIs(numberOfSpaces: number): void; - indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle): void; + indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle, baseIndentSize?: number): void; textAtCaretIs(text: string): void; /** * Compiles the current file and evaluates 'expr' in a context containing diff --git a/tests/cases/fourslash/indentationWithBaseIndent.ts b/tests/cases/fourslash/indentationWithBaseIndent.ts new file mode 100644 index 00000000000..53ee01c9a3c --- /dev/null +++ b/tests/cases/fourslash/indentationWithBaseIndent.ts @@ -0,0 +1,211 @@ +/// + +//// +////{| "indent": 10 , "baseIndentSize": 10 |} +//// module classes { +////{| "indent": 14 , "baseIndentSize": 10 |} +//// class Bar { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// +//// constructor() { +////{| "indent": 22, "baseIndentSize": 10 |} +//// } +//// +//// private foo: string = ""; +////{| "indent": 18, "baseIndentSize": 10 |} +//// +//// private f() { +//// var a: any[] = [[1, 2], [3, 4], 5]; +////{| "indent": 22, "baseIndentSize": 10 |} +//// return ((1 + 1)); +//// } +//// +////{| "indent": 18, "baseIndentSize": 10 |} +//// private f2() { +//// if (true) { } { }; +//// } +//// } +//// } +//// +//// +//// module interfaces { +////{| "indent": 14 , "baseIndentSize": 10 |} +//// interface Foo { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// +//// x: number; +////{| "indent": 18 , "baseIndentSize": 10 |} +//// +//// foo(): number; +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +//// } +//// +//// +//// module nestedModules { +//// module Foo2 { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// function f() { +//// } +////{| "indent": 18 , "baseIndentSize": 10 |} +//// var x: number; +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +//// } +//// +//// +//// module Enums { +//// enum Foo3 { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// val1, +////{| "indent": 18 , "baseIndentSize": 10 |} +//// val2, +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////{| "indent": 14 , "baseIndentSize": 10 |} +//// } +//// +//// +//// function controlStatements() { +//// for (var i = 0; i < 10; i++) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +//// +//// for (var e in foo.bar) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +//// +//// with (foo.bar) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +//// +//// while (false) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +//// +//// do { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } while (false); +//// +//// switch (foo.bar) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +//// +//// switch (foo.bar) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// case 1: +////{| "indent": 22 , "baseIndentSize": 10 |} +//// break; +//// default: +////{| "indent": 22 , "baseIndentSize": 10 |} +//// break; +//// } +//// } +//// +//// +//// function tryCatch() { +////{| "indent": 14 , "baseIndentSize": 10 |} +//// try { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////{| "indent": 14 , "baseIndentSize": 10 |} +//// catch (err) { +////{| "indent": 18, "baseIndentSize": 10 |} +//// } +////{| "indent": 14, "baseIndentSize": 10 |} +//// } +//// +//// +//// function tryFinally() { +////{| "indent": 14 , "baseIndentSize": 10 |} +//// try { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////{| "indent": 14 , "baseIndentSize": 10 |} +//// finally { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////{| "indent": 14 , "baseIndentSize": 10 |} +//// } +//// +//// +//// function tryCatchFinally() { +////{| "indent": 14 , "baseIndentSize": 10 |} +//// try { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////{| "indent": 14 , "baseIndentSize": 10 |} +//// catch (err) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////{| "indent": 14 , "baseIndentSize": 10 |} +//// finally { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////{| "indent": 14 , "baseIndentSize": 10 |} +//// } +//// +//// +//// class indentBeforeCurly +////{| "indent": 10 , "baseIndentSize": 10 |} +////{| "indent": 10 , "baseIndentSize": 10 |} +//// { +////{| "indent": 14 , "baseIndentSize": 10 |} +//// } +////{| "indent": 10 , "baseIndentSize": 10 |} +//// +//// +//// function argumentsListIndentation(bar, +//// blah, +//// {| "indent": 14 , "baseIndentSize": 10 |} +//// ); +//// +//// +//// function blockIndentAfterIndentedParameter1(bar, +//// blah) { +////{| "indent": 14 , "baseIndentSize": 10 |} +//// } +//// +//// +//// function blockIndentAfterIndentedParameter2(bar, +//// blah) { +//// if (foo) { +////{| "indent": 18 , "baseIndentSize": 10 |} +//// } +////} +////{| "indent": 10 , "baseIndentSize": 10 |} +//// +//// var templateLiterals = `abcdefghi +////{| "indent": 0 , "baseIndentSize": 10 |} +////jklmnop +////{| "indent": 0 , "baseIndentSize": 10 |} +////qrstuvwxyz`; +////{| "indent": 10 , "baseIndentSize": 10 |} +//// +//// +//// module changeBaseIndentSizeInSameFile { +////{| "indent": 21 , "baseIndentSize": 17 |} +//// interface Foo { +////{| "indent": 25 , "baseIndentSize": 17 |} +//// +//// x: number; +////{| "indent": 25 , "baseIndentSize": 10 |} +//// +//// foo(): number; +////{| "indent": 25 , "baseIndentSize": 10 |} +//// } +////{| "indent": 21 , "baseIndentSize": 10 |} +//// } +////{| "indent": 17 , "baseIndentSize": 17 |} +//// +//// +////// Note: Do not add more tests at the end of this file, as +////// the purpose of this test is to verify smart indent +////// works for unterminated function arguments at the end of a file. +//// function unterminatedListIndentation(a, +////{| "indent": 14 , "baseIndentSize": 10 |} + +debugger; +test.markers().forEach(marker => { + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, ts.IndentStyle.Smart, marker.data.baseIndentSize); +}); From db0d8e094b92aa7314e905b261844b5fbf0b593d Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 24 Jun 2016 14:15:44 -0700 Subject: [PATCH 036/103] Fix 8549: Using variable as Jsx tagname (#9337) * Parse JSXElement's name as property access instead of just entity name. So when one accesses property of the class through this, checker will check correctly * wip - just resolve to any type for now * Resolve string type to anytype and look up property in intrinsicElementsType of Jsx * Add tests and update baselines * Remove unneccessary comment * wip-address PR * Address PR * Add tets and update baselines * Fix linting error --- src/compiler/checker.ts | 28 ++++++++++++- src/compiler/emitter.ts | 2 +- src/compiler/parser.ts | 36 ++++++++++------ src/compiler/types.ts | 6 ++- .../baselines/reference/tsxDynamicTagName1.js | 8 ++++ .../reference/tsxDynamicTagName1.symbols | 9 ++++ .../reference/tsxDynamicTagName1.types | 11 +++++ .../reference/tsxDynamicTagName2.errors.txt | 19 +++++++++ .../baselines/reference/tsxDynamicTagName2.js | 15 +++++++ .../reference/tsxDynamicTagName3.errors.txt | 16 +++++++ .../baselines/reference/tsxDynamicTagName3.js | 15 +++++++ .../baselines/reference/tsxDynamicTagName4.js | 16 +++++++ .../reference/tsxDynamicTagName4.symbols | 26 ++++++++++++ .../reference/tsxDynamicTagName4.types | 28 +++++++++++++ .../baselines/reference/tsxDynamicTagName5.js | 41 ++++++++++++++++++ .../reference/tsxDynamicTagName5.symbols | 34 +++++++++++++++ .../reference/tsxDynamicTagName5.types | 38 +++++++++++++++++ .../baselines/reference/tsxDynamicTagName6.js | 15 +++++++ .../reference/tsxDynamicTagName6.symbols | 26 ++++++++++++ .../reference/tsxDynamicTagName6.types | 29 +++++++++++++ .../reference/tsxDynamicTagName7.errors.txt | 23 ++++++++++ .../baselines/reference/tsxDynamicTagName7.js | 42 +++++++++++++++++++ .../baselines/reference/tsxDynamicTagName8.js | 41 ++++++++++++++++++ .../reference/tsxDynamicTagName8.symbols | 37 ++++++++++++++++ .../reference/tsxDynamicTagName8.types | 41 ++++++++++++++++++ .../baselines/reference/tsxDynamicTagName9.js | 41 ++++++++++++++++++ .../reference/tsxDynamicTagName9.symbols | 37 ++++++++++++++++ .../reference/tsxDynamicTagName9.types | 41 ++++++++++++++++++ .../tsxUnionTypeComponent2.errors.txt | 4 +- .../reference/tsxUnionTypeComponent2.js | 6 +-- .../conformance/jsx/tsxDynamicTagName1.tsx | 4 ++ .../conformance/jsx/tsxDynamicTagName2.tsx | 11 +++++ .../conformance/jsx/tsxDynamicTagName3.tsx | 11 +++++ .../conformance/jsx/tsxDynamicTagName4.tsx | 12 ++++++ .../conformance/jsx/tsxDynamicTagName5.tsx | 19 +++++++++ .../conformance/jsx/tsxDynamicTagName6.tsx | 11 +++++ .../conformance/jsx/tsxDynamicTagName7.tsx | 19 +++++++++ .../conformance/jsx/tsxDynamicTagName8.tsx | 19 +++++++++ .../conformance/jsx/tsxDynamicTagName9.tsx | 19 +++++++++ .../jsx/tsxUnionTypeComponent2.tsx | 4 +- 40 files changed, 836 insertions(+), 24 deletions(-) create mode 100644 tests/baselines/reference/tsxDynamicTagName1.js create mode 100644 tests/baselines/reference/tsxDynamicTagName1.symbols create mode 100644 tests/baselines/reference/tsxDynamicTagName1.types create mode 100644 tests/baselines/reference/tsxDynamicTagName2.errors.txt create mode 100644 tests/baselines/reference/tsxDynamicTagName2.js create mode 100644 tests/baselines/reference/tsxDynamicTagName3.errors.txt create mode 100644 tests/baselines/reference/tsxDynamicTagName3.js create mode 100644 tests/baselines/reference/tsxDynamicTagName4.js create mode 100644 tests/baselines/reference/tsxDynamicTagName4.symbols create mode 100644 tests/baselines/reference/tsxDynamicTagName4.types create mode 100644 tests/baselines/reference/tsxDynamicTagName5.js create mode 100644 tests/baselines/reference/tsxDynamicTagName5.symbols create mode 100644 tests/baselines/reference/tsxDynamicTagName5.types create mode 100644 tests/baselines/reference/tsxDynamicTagName6.js create mode 100644 tests/baselines/reference/tsxDynamicTagName6.symbols create mode 100644 tests/baselines/reference/tsxDynamicTagName6.types create mode 100644 tests/baselines/reference/tsxDynamicTagName7.errors.txt create mode 100644 tests/baselines/reference/tsxDynamicTagName7.js create mode 100644 tests/baselines/reference/tsxDynamicTagName8.js create mode 100644 tests/baselines/reference/tsxDynamicTagName8.symbols create mode 100644 tests/baselines/reference/tsxDynamicTagName8.types create mode 100644 tests/baselines/reference/tsxDynamicTagName9.js create mode 100644 tests/baselines/reference/tsxDynamicTagName9.symbols create mode 100644 tests/baselines/reference/tsxDynamicTagName9.types create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName1.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName2.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName3.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName4.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName5.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName6.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName7.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName8.tsx create mode 100644 tests/cases/conformance/jsx/tsxDynamicTagName9.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0ca0fd907fb..34d73f9f721 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9657,8 +9657,9 @@ namespace ts { /** * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ - function isJsxIntrinsicIdentifier(tagName: Identifier | QualifiedName) { - if (tagName.kind === SyntaxKind.QualifiedName) { + function isJsxIntrinsicIdentifier(tagName: JsxTagNameExpression) { + // TODO (yuisu): comment + if (tagName.kind === SyntaxKind.PropertyAccessExpression || tagName.kind === SyntaxKind.ThisKeyword) { return false; } else { @@ -9854,6 +9855,29 @@ namespace ts { })); } + // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type + if (elemType.flags & TypeFlags.String) { + return anyType; + } + else if (elemType.flags & TypeFlags.StringLiteral) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); + if (intrinsicElementsType !== unknownType) { + const stringLiteralTypeName = (elemType).text; + const intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + const indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String); + if (indexSignatureType) { + return indexSignatureType; + } + error(node, Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } + // Get the element instance type (the result of newing or invoking this tag) const elemInstanceType = getJsxElementInstanceType(node, elemType); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f33bad264fd..46cab8f92f0 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1219,7 +1219,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function jsxEmitReact(node: JsxElement | JsxSelfClosingElement) { /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names - function emitTagName(name: Identifier | QualifiedName) { + function emitTagName(name: LeftHandSideExpression) { if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((name).text)) { write('"'); emit(name); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c245f9ba462..9f02e8c2926 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3576,7 +3576,7 @@ namespace ts { return finishNode(node); } - function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean { + function tagNamesAreEquivalent(lhs: JsxTagNameExpression, rhs: JsxTagNameExpression): boolean { if (lhs.kind !== rhs.kind) { return false; } @@ -3585,8 +3585,15 @@ namespace ts { return (lhs).text === (rhs).text; } - return (lhs).right.text === (rhs).right.text && - tagNamesAreEquivalent((lhs).left, (rhs).left); + if (lhs.kind === SyntaxKind.ThisKeyword) { + return true; + } + + // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only + // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression + // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element + return (lhs).name.text === (rhs).name.text && + tagNamesAreEquivalent((lhs).expression as JsxTagNameExpression, (rhs).expression as JsxTagNameExpression); } @@ -3654,7 +3661,7 @@ namespace ts { Debug.fail("Unknown JSX child kind " + token); } - function parseJsxChildren(openingTagName: EntityName): NodeArray { + function parseJsxChildren(openingTagName: LeftHandSideExpression): NodeArray { const result = >[]; result.pos = scanner.getStartPos(); const saveParsingContext = parsingContext; @@ -3717,17 +3724,22 @@ namespace ts { return finishNode(node); } - function parseJsxElementName(): EntityName { + function parseJsxElementName(): JsxTagNameExpression { scanJsxIdentifier(); - let elementName: EntityName = parseIdentifierName(); + // JsxElement can have name in the form of + // propertyAccessExpression + // primaryExpression in the form of an identifier and "this" keyword + // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword + // We only want to consider "this" as a primaryExpression + let expression: JsxTagNameExpression = token === SyntaxKind.ThisKeyword ? + parseTokenNode() : parseIdentifierName(); while (parseOptional(SyntaxKind.DotToken)) { - scanJsxIdentifier(); - const node: QualifiedName = createNode(SyntaxKind.QualifiedName, elementName.pos); // !!! - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); + const propertyAccess: PropertyAccessExpression = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + expression = finishNode(propertyAccess); } - return elementName; + return expression; } function parseJsxExpression(inExpressionContext: boolean): JsxExpression { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index cac04172a5c..2baae322a27 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1042,11 +1042,13 @@ namespace ts { closingElement: JsxClosingElement; } + export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + /// The opening element of a ... JsxElement // @kind(SyntaxKind.JsxOpeningElement) export interface JsxOpeningElement extends Expression { _openingElementBrand?: any; - tagName: EntityName; + tagName: JsxTagNameExpression; attributes: NodeArray; } @@ -1073,7 +1075,7 @@ namespace ts { // @kind(SyntaxKind.JsxClosingElement) export interface JsxClosingElement extends Node { - tagName: EntityName; + tagName: JsxTagNameExpression; } // @kind(SyntaxKind.JsxExpression) diff --git a/tests/baselines/reference/tsxDynamicTagName1.js b/tests/baselines/reference/tsxDynamicTagName1.js new file mode 100644 index 00000000000..e77d126dd83 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName1.js @@ -0,0 +1,8 @@ +//// [tsxDynamicTagName1.tsx] + +var CustomTag = "h1"; + Hello World // No error + +//// [tsxDynamicTagName1.jsx] +var CustomTag = "h1"; + Hello World ; // No error diff --git a/tests/baselines/reference/tsxDynamicTagName1.symbols b/tests/baselines/reference/tsxDynamicTagName1.symbols new file mode 100644 index 00000000000..c3ba6440e48 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsx/tsxDynamicTagName1.tsx === + +var CustomTag = "h1"; +>CustomTag : Symbol(CustomTag, Decl(tsxDynamicTagName1.tsx, 1, 3)) + + Hello World // No error +>CustomTag : Symbol(CustomTag, Decl(tsxDynamicTagName1.tsx, 1, 3)) +>CustomTag : Symbol(CustomTag, Decl(tsxDynamicTagName1.tsx, 1, 3)) + diff --git a/tests/baselines/reference/tsxDynamicTagName1.types b/tests/baselines/reference/tsxDynamicTagName1.types new file mode 100644 index 00000000000..005afcf6adb --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName1.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsx/tsxDynamicTagName1.tsx === + +var CustomTag = "h1"; +>CustomTag : string +>"h1" : string + + Hello World // No error +> Hello World : any +>CustomTag : string +>CustomTag : string + diff --git a/tests/baselines/reference/tsxDynamicTagName2.errors.txt b/tests/baselines/reference/tsxDynamicTagName2.errors.txt new file mode 100644 index 00000000000..008a013e379 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName2.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/jsx/tsxDynamicTagName2.tsx(10,1): error TS2339: Property 'customTag' does not exist on type 'JSX.IntrinsicElements'. +tests/cases/conformance/jsx/tsxDynamicTagName2.tsx(10,25): error TS2339: Property 'customTag' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxDynamicTagName2.tsx (2 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } + } + + var customTag = "h1"; + Hello World // This should be an error. The lower-case is look up as an intrinsic element name + ~~~~~~~~~~~ +!!! error TS2339: Property 'customTag' does not exist on type 'JSX.IntrinsicElements'. + ~~~~~~~~~~~~ +!!! error TS2339: Property 'customTag' does not exist on type 'JSX.IntrinsicElements'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxDynamicTagName2.js b/tests/baselines/reference/tsxDynamicTagName2.js new file mode 100644 index 00000000000..7fb7bb1a965 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName2.js @@ -0,0 +1,15 @@ +//// [tsxDynamicTagName2.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +var customTag = "h1"; + Hello World // This should be an error. The lower-case is look up as an intrinsic element name + +//// [tsxDynamicTagName2.jsx] +var customTag = "h1"; + Hello World ; // This should be an error. The lower-case is look up as an intrinsic element name diff --git a/tests/baselines/reference/tsxDynamicTagName3.errors.txt b/tests/baselines/reference/tsxDynamicTagName3.errors.txt new file mode 100644 index 00000000000..40c10c63f53 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName3.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/jsx/tsxDynamicTagName3.tsx(10,1): error TS2339: Property 'h1' does not exist on type 'JSX.IntrinsicElements'. + + +==== tests/cases/conformance/jsx/tsxDynamicTagName3.tsx (1 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } + } + + var CustomTag: "h1" = "h1"; + Hello World // This should be an error. we will try look up string literal type in JSX.IntrinsicElements + ~~~~~~~~~~~ +!!! error TS2339: Property 'h1' does not exist on type 'JSX.IntrinsicElements'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxDynamicTagName3.js b/tests/baselines/reference/tsxDynamicTagName3.js new file mode 100644 index 00000000000..63c2a0a398b --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName3.js @@ -0,0 +1,15 @@ +//// [tsxDynamicTagName3.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +var CustomTag: "h1" = "h1"; + Hello World // This should be an error. we will try look up string literal type in JSX.IntrinsicElements + +//// [tsxDynamicTagName3.jsx] +var CustomTag = "h1"; + Hello World ; // This should be an error. we will try look up string literal type in JSX.IntrinsicElements diff --git a/tests/baselines/reference/tsxDynamicTagName4.js b/tests/baselines/reference/tsxDynamicTagName4.js new file mode 100644 index 00000000000..e708273237d --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName4.js @@ -0,0 +1,16 @@ +//// [tsxDynamicTagName4.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + h1: any + } +} + +var CustomTag: "h1" = "h1"; + Hello World + +//// [tsxDynamicTagName4.jsx] +var CustomTag = "h1"; + Hello World ; diff --git a/tests/baselines/reference/tsxDynamicTagName4.symbols b/tests/baselines/reference/tsxDynamicTagName4.symbols new file mode 100644 index 00000000000..3f0fe57ce1f --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName4.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsx/tsxDynamicTagName4.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxDynamicTagName4.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxDynamicTagName4.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxDynamicTagName4.tsx, 2, 22)) + + div: any +>div : Symbol(IntrinsicElements.div, Decl(tsxDynamicTagName4.tsx, 3, 30)) + + h1: any +>h1 : Symbol(IntrinsicElements.h1, Decl(tsxDynamicTagName4.tsx, 4, 10)) + } +} + +var CustomTag: "h1" = "h1"; +>CustomTag : Symbol(CustomTag, Decl(tsxDynamicTagName4.tsx, 9, 3)) + + Hello World +>CustomTag : Symbol(CustomTag, Decl(tsxDynamicTagName4.tsx, 9, 3)) +>CustomTag : Symbol(CustomTag, Decl(tsxDynamicTagName4.tsx, 9, 3)) + diff --git a/tests/baselines/reference/tsxDynamicTagName4.types b/tests/baselines/reference/tsxDynamicTagName4.types new file mode 100644 index 00000000000..3a9a34f2898 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName4.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsx/tsxDynamicTagName4.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + div: any +>div : any + + h1: any +>h1 : any + } +} + +var CustomTag: "h1" = "h1"; +>CustomTag : "h1" +>"h1" : "h1" + + Hello World +> Hello World : JSX.Element +>CustomTag : "h1" +>CustomTag : "h1" + diff --git a/tests/baselines/reference/tsxDynamicTagName5.js b/tests/baselines/reference/tsxDynamicTagName5.js new file mode 100644 index 00000000000..03c9627c2c1 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName5.js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/jsx/tsxDynamicTagName5.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + class Component { } +} + +//// [app.tsx] +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: string = 'div'; + + render() { + return ( + + ); + } +} + +//// [app.jsx] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +var Text = (function (_super) { + __extends(Text, _super); + function Text() { + _super.apply(this, arguments); + this._tagName = 'div'; + } + Text.prototype.render = function () { + return (); + }; + return Text; +}(React.Component)); +exports.Text = Text; diff --git a/tests/baselines/reference/tsxDynamicTagName5.symbols b/tests/baselines/reference/tsxDynamicTagName5.symbols new file mode 100644 index 00000000000..9abac5521c9 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName5.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Symbol(Component, Decl(react.d.ts, 1, 24)) +>T : Symbol(T, Decl(react.d.ts, 2, 17)) +>U : Symbol(U, Decl(react.d.ts, 2, 19)) +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : Symbol(React, Decl(app.tsx, 0, 6)) + +export class Text extends React.Component<{}, {}> { +>Text : Symbol(Text, Decl(app.tsx, 0, 31)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) +>React : Symbol(React, Decl(app.tsx, 0, 6)) +>Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) + + _tagName: string = 'div'; +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) + + render() { +>render : Symbol(Text.render, Decl(app.tsx, 3, 27)) + + return ( + +>this._tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) +>this : Symbol(Text, Decl(app.tsx, 0, 31)) +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) + + ); + } +} diff --git a/tests/baselines/reference/tsxDynamicTagName5.types b/tests/baselines/reference/tsxDynamicTagName5.types new file mode 100644 index 00000000000..ac4ee31141a --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName5.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Component +>T : T +>U : U +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : typeof React + +export class Text extends React.Component<{}, {}> { +>Text : Text +>React.Component : React.Component<{}, {}> +>React : typeof React +>Component : typeof React.Component + + _tagName: string = 'div'; +>_tagName : string +>'div' : string + + render() { +>render : () => any + + return ( +>( ) : any + + +> : any +>this._tagName : string +>this : this +>_tagName : string + + ); + } +} diff --git a/tests/baselines/reference/tsxDynamicTagName6.js b/tests/baselines/reference/tsxDynamicTagName6.js new file mode 100644 index 00000000000..a7ec12b50b7 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName6.js @@ -0,0 +1,15 @@ +//// [tsxDynamicTagName6.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +const t = {tag:'h1'} +const foo = // No error + +//// [tsxDynamicTagName6.jsx] +var t = { tag: 'h1' }; +var foo = ; // No error diff --git a/tests/baselines/reference/tsxDynamicTagName6.symbols b/tests/baselines/reference/tsxDynamicTagName6.symbols new file mode 100644 index 00000000000..f1afd91eacb --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName6.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsx/tsxDynamicTagName6.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxDynamicTagName6.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxDynamicTagName6.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxDynamicTagName6.tsx, 2, 22)) + + div: any +>div : Symbol(IntrinsicElements.div, Decl(tsxDynamicTagName6.tsx, 3, 30)) + } +} + +const t = {tag:'h1'} +>t : Symbol(t, Decl(tsxDynamicTagName6.tsx, 8, 5)) +>tag : Symbol(tag, Decl(tsxDynamicTagName6.tsx, 8, 11)) + +const foo = // No error +>foo : Symbol(foo, Decl(tsxDynamicTagName6.tsx, 9, 5)) +>t.tag : Symbol(tag, Decl(tsxDynamicTagName6.tsx, 8, 11)) +>t : Symbol(t, Decl(tsxDynamicTagName6.tsx, 8, 5)) +>tag : Symbol(tag, Decl(tsxDynamicTagName6.tsx, 8, 11)) + diff --git a/tests/baselines/reference/tsxDynamicTagName6.types b/tests/baselines/reference/tsxDynamicTagName6.types new file mode 100644 index 00000000000..5dadf6fe825 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName6.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsx/tsxDynamicTagName6.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + div: any +>div : any + } +} + +const t = {tag:'h1'} +>t : { tag: string; } +>{tag:'h1'} : { tag: string; } +>tag : string +>'h1' : string + +const foo = // No error +>foo : JSX.Element +> : JSX.Element +>t.tag : string +>t : { tag: string; } +>tag : string + diff --git a/tests/baselines/reference/tsxDynamicTagName7.errors.txt b/tests/baselines/reference/tsxDynamicTagName7.errors.txt new file mode 100644 index 00000000000..19f9bed3c27 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName7.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/jsx/app.tsx(8,8): error TS2604: JSX element type 'this' does not have any construct or call signatures. + + +==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== + + declare module 'react' { + class Component { } + } + +==== tests/cases/conformance/jsx/app.tsx (1 errors) ==== + import * as React from 'react'; + + export class Text extends React.Component<{}, {}> { + _tagName: string = 'div'; + + render() { + return ( + // this should be an error + ~~~~ +!!! error TS2604: JSX element type 'this' does not have any construct or call signatures. + ); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/tsxDynamicTagName7.js b/tests/baselines/reference/tsxDynamicTagName7.js new file mode 100644 index 00000000000..f8dffbfad7e --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName7.js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/jsx/tsxDynamicTagName7.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + class Component { } +} + +//// [app.tsx] +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: string = 'div'; + + render() { + return ( + // this should be an error + ); + } +} + +//// [app.jsx] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +var Text = (function (_super) { + __extends(Text, _super); + function Text() { + _super.apply(this, arguments); + this._tagName = 'div'; + } + Text.prototype.render = function () { + return ( // this should be an error + ); + }; + return Text; +}(React.Component)); +exports.Text = Text; diff --git a/tests/baselines/reference/tsxDynamicTagName8.js b/tests/baselines/reference/tsxDynamicTagName8.js new file mode 100644 index 00000000000..36d551b0ce7 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName8.js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/jsx/tsxDynamicTagName8.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + class Component { } +} + +//// [app.tsx] +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: string = 'div'; + + render() { + return ( + Hello world + ); + } +} + +//// [app.jsx] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +var Text = (function (_super) { + __extends(Text, _super); + function Text() { + _super.apply(this, arguments); + this._tagName = 'div'; + } + Text.prototype.render = function () { + return ( Hello world ); + }; + return Text; +}(React.Component)); +exports.Text = Text; diff --git a/tests/baselines/reference/tsxDynamicTagName8.symbols b/tests/baselines/reference/tsxDynamicTagName8.symbols new file mode 100644 index 00000000000..87a71e740de --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName8.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Symbol(Component, Decl(react.d.ts, 1, 24)) +>T : Symbol(T, Decl(react.d.ts, 2, 17)) +>U : Symbol(U, Decl(react.d.ts, 2, 19)) +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : Symbol(React, Decl(app.tsx, 0, 6)) + +export class Text extends React.Component<{}, {}> { +>Text : Symbol(Text, Decl(app.tsx, 0, 31)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) +>React : Symbol(React, Decl(app.tsx, 0, 6)) +>Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) + + _tagName: string = 'div'; +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) + + render() { +>render : Symbol(Text.render, Decl(app.tsx, 3, 27)) + + return ( + Hello world +>this._tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) +>this : Symbol(Text, Decl(app.tsx, 0, 31)) +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) +>this._tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) +>this : Symbol(Text, Decl(app.tsx, 0, 31)) +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) + + ); + } +} diff --git a/tests/baselines/reference/tsxDynamicTagName8.types b/tests/baselines/reference/tsxDynamicTagName8.types new file mode 100644 index 00000000000..154e7e33fe0 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName8.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Component +>T : T +>U : U +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : typeof React + +export class Text extends React.Component<{}, {}> { +>Text : Text +>React.Component : React.Component<{}, {}> +>React : typeof React +>Component : typeof React.Component + + _tagName: string = 'div'; +>_tagName : string +>'div' : string + + render() { +>render : () => any + + return ( +>( Hello world ) : any + + Hello world +> Hello world : any +>this._tagName : string +>this : this +>_tagName : string +>this._tagName : string +>this : this +>_tagName : string + + ); + } +} diff --git a/tests/baselines/reference/tsxDynamicTagName9.js b/tests/baselines/reference/tsxDynamicTagName9.js new file mode 100644 index 00000000000..78abc446e3f --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName9.js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/jsx/tsxDynamicTagName9.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + class Component { } +} + +//// [app.tsx] +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: "div" = 'div'; + + render() { + return ( + Hello world + ); + } +} + +//// [app.jsx] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var React = require('react'); +var Text = (function (_super) { + __extends(Text, _super); + function Text() { + _super.apply(this, arguments); + this._tagName = 'div'; + } + Text.prototype.render = function () { + return ( Hello world ); + }; + return Text; +}(React.Component)); +exports.Text = Text; diff --git a/tests/baselines/reference/tsxDynamicTagName9.symbols b/tests/baselines/reference/tsxDynamicTagName9.symbols new file mode 100644 index 00000000000..436e1205751 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName9.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Symbol(Component, Decl(react.d.ts, 1, 24)) +>T : Symbol(T, Decl(react.d.ts, 2, 17)) +>U : Symbol(U, Decl(react.d.ts, 2, 19)) +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : Symbol(React, Decl(app.tsx, 0, 6)) + +export class Text extends React.Component<{}, {}> { +>Text : Symbol(Text, Decl(app.tsx, 0, 31)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) +>React : Symbol(React, Decl(app.tsx, 0, 6)) +>Component : Symbol(React.Component, Decl(react.d.ts, 1, 24)) + + _tagName: "div" = 'div'; +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) + + render() { +>render : Symbol(Text.render, Decl(app.tsx, 3, 26)) + + return ( + Hello world +>this._tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) +>this : Symbol(Text, Decl(app.tsx, 0, 31)) +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) +>this._tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) +>this : Symbol(Text, Decl(app.tsx, 0, 31)) +>_tagName : Symbol(Text._tagName, Decl(app.tsx, 2, 51)) + + ); + } +} diff --git a/tests/baselines/reference/tsxDynamicTagName9.types b/tests/baselines/reference/tsxDynamicTagName9.types new file mode 100644 index 00000000000..e500d3f0ab1 --- /dev/null +++ b/tests/baselines/reference/tsxDynamicTagName9.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + class Component { } +>Component : Component +>T : T +>U : U +} + +=== tests/cases/conformance/jsx/app.tsx === +import * as React from 'react'; +>React : typeof React + +export class Text extends React.Component<{}, {}> { +>Text : Text +>React.Component : React.Component<{}, {}> +>React : typeof React +>Component : typeof React.Component + + _tagName: "div" = 'div'; +>_tagName : "div" +>'div' : "div" + + render() { +>render : () => any + + return ( +>( Hello world ) : any + + Hello world +> Hello world : any +>this._tagName : "div" +>this : this +>_tagName : "div" +>this._tagName : "div" +>this : this +>_tagName : "div" + + ); + } +} diff --git a/tests/baselines/reference/tsxUnionTypeComponent2.errors.txt b/tests/baselines/reference/tsxUnionTypeComponent2.errors.txt index e5a5c77da4c..a43c45ec59e 100644 --- a/tests/baselines/reference/tsxUnionTypeComponent2.errors.txt +++ b/tests/baselines/reference/tsxUnionTypeComponent2.errors.txt @@ -5,9 +5,9 @@ tests/cases/conformance/jsx/file.tsx(8,2): error TS2604: JSX element type 'X' do import React = require('react'); - type Invalid1 = React.ComponentClass | string; + type Invalid1 = React.ComponentClass | number; - const X: Invalid1 = "Should fail to construct"; + const X: Invalid1 = 1; ; ~ diff --git a/tests/baselines/reference/tsxUnionTypeComponent2.js b/tests/baselines/reference/tsxUnionTypeComponent2.js index 18e86eb8b4c..b88816f285a 100644 --- a/tests/baselines/reference/tsxUnionTypeComponent2.js +++ b/tests/baselines/reference/tsxUnionTypeComponent2.js @@ -2,9 +2,9 @@ import React = require('react'); -type Invalid1 = React.ComponentClass | string; +type Invalid1 = React.ComponentClass | number; -const X: Invalid1 = "Should fail to construct"; +const X: Invalid1 = 1; ; @@ -14,5 +14,5 @@ const X: Invalid1 = "Should fail to construct"; //// [file.js] "use strict"; var React = require('react'); -var X = "Should fail to construct"; +var X = 1; React.createElement(X, null); diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName1.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName1.tsx new file mode 100644 index 00000000000..1a54b55f94e --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName1.tsx @@ -0,0 +1,4 @@ +// @jsx: preserve + +var CustomTag = "h1"; + Hello World // No error \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName2.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName2.tsx new file mode 100644 index 00000000000..0d5810bbd9a --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName2.tsx @@ -0,0 +1,11 @@ +// @jsx: preserve + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +var customTag = "h1"; + Hello World // This should be an error. The lower-case is look up as an intrinsic element name \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName3.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName3.tsx new file mode 100644 index 00000000000..09e05800ca5 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName3.tsx @@ -0,0 +1,11 @@ +// @jsx: preserve + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +var CustomTag: "h1" = "h1"; + Hello World // This should be an error. we will try look up string literal type in JSX.IntrinsicElements \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName4.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName4.tsx new file mode 100644 index 00000000000..18ea11a6647 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName4.tsx @@ -0,0 +1,12 @@ +// @jsx: preserve + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + h1: any + } +} + +var CustomTag: "h1" = "h1"; + Hello World \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName5.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName5.tsx new file mode 100644 index 00000000000..b8e98cc1103 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName5.tsx @@ -0,0 +1,19 @@ +// @jsx: preserve + +//@filename: react.d.ts +declare module 'react' { + class Component { } +} + +//@filename: app.tsx +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: string = 'div'; + + render() { + return ( + + ); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName6.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName6.tsx new file mode 100644 index 00000000000..7657f7a82b3 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName6.tsx @@ -0,0 +1,11 @@ +// @jsx: preserve + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any + } +} + +const t = {tag:'h1'} +const foo = // No error \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName7.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName7.tsx new file mode 100644 index 00000000000..52ff5f4ec24 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName7.tsx @@ -0,0 +1,19 @@ +// @jsx: preserve + +//@filename: react.d.ts +declare module 'react' { + class Component { } +} + +//@filename: app.tsx +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: string = 'div'; + + render() { + return ( + // this should be an error + ); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName8.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName8.tsx new file mode 100644 index 00000000000..ee3bfaa0dfa --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName8.tsx @@ -0,0 +1,19 @@ +// @jsx: preserve + +//@filename: react.d.ts +declare module 'react' { + class Component { } +} + +//@filename: app.tsx +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: string = 'div'; + + render() { + return ( + Hello world + ); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxDynamicTagName9.tsx b/tests/cases/conformance/jsx/tsxDynamicTagName9.tsx new file mode 100644 index 00000000000..397fbdcd837 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxDynamicTagName9.tsx @@ -0,0 +1,19 @@ +// @jsx: preserve + +//@filename: react.d.ts +declare module 'react' { + class Component { } +} + +//@filename: app.tsx +import * as React from 'react'; + +export class Text extends React.Component<{}, {}> { + _tagName: "div" = 'div'; + + render() { + return ( + Hello world + ); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxUnionTypeComponent2.tsx b/tests/cases/conformance/jsx/tsxUnionTypeComponent2.tsx index 39807219661..dbd14f6c27f 100644 --- a/tests/cases/conformance/jsx/tsxUnionTypeComponent2.tsx +++ b/tests/cases/conformance/jsx/tsxUnionTypeComponent2.tsx @@ -5,9 +5,9 @@ import React = require('react'); -type Invalid1 = React.ComponentClass | string; +type Invalid1 = React.ComponentClass | number; -const X: Invalid1 = "Should fail to construct"; +const X: Invalid1 = 1; ; From a0a96667ed75653ad9d4373a272602a697e0566d Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 24 Jun 2016 15:38:39 -0700 Subject: [PATCH 037/103] Unused identifiers compiler code (#9200) * Code changes to update references of the Identifiers * Added code for handling function, method and coonstructor level local variables and parameters * Rebased with origin master * Code changes to handle unused private variables, private methods and typed parameters * Code changes to handle namespace level elements * Code changes to handle unimplemented interfaces * Code to optimize the d.ts check * Correct Code change to handle the parameters for methods inside interfaces * Fix for lint error * Remove Trailing whitespace * Code changes to handle interface implementations * Changes to display the error position correctly * Compiler Test Cases * Adding condition to ignore constructor parameters * Removing unnecessary tests * Additional changes for compiler code * Additional changes to handle constructor scenario * Fixing the consolidated case * Changed logic to search for private instead of public * Response to PR Comments * Changed the error code in test cases as result of merge with master * Adding the missing file * Adding the missing file II * Response to PR comments * Code changes for checking unused imports * Test Cases for Unused Imports * Response to PR comments * Code change specific to position of Import Declaration * Code change for handling the position for unused import * New scenarios for handling parameters in lambda function, type parameters in methods, etc. * Additional scenarios based on PR comments * Removing a redundant check * Added ambient check to imports and typeparatmeter reporting * Added one more scenario to handle type parameters * Added new scenario for TypeParameter on Interface * Refactoring the code * Added scenario to handle private class elements declared in constructor. * Minor change to erro reporting --- src/compiler/checker.ts | 130 +++++++++++- src/compiler/commandLineParser.ts | 10 + src/compiler/diagnosticMessages.json | 12 ++ src/compiler/types.ts | 3 + src/compiler/utilities.ts | 2 +- .../unusedClassesinModule1.errors.txt | 13 ++ .../reference/unusedClassesinModule1.js | 20 ++ .../unusedClassesinNamespace1.errors.txt | 12 ++ .../reference/unusedClassesinNamespace1.js | 17 ++ .../unusedClassesinNamespace2.errors.txt | 16 ++ .../reference/unusedClassesinNamespace2.js | 27 +++ .../reference/unusedClassesinNamespace3.js | 30 +++ .../unusedClassesinNamespace3.symbols | 19 ++ .../reference/unusedClassesinNamespace3.types | 20 ++ .../unusedClassesinNamespace4.errors.txt | 20 ++ .../reference/unusedClassesinNamespace4.js | 43 ++++ .../unusedClassesinNamespace5.errors.txt | 20 ++ .../reference/unusedClassesinNamespace5.js | 36 ++++ .../unusedFunctionsinNamespaces1.errors.txt | 11 ++ .../reference/unusedFunctionsinNamespaces1.js | 13 ++ .../unusedFunctionsinNamespaces2.errors.txt | 11 ++ .../reference/unusedFunctionsinNamespaces2.js | 13 ++ .../unusedFunctionsinNamespaces3.errors.txt | 14 ++ .../reference/unusedFunctionsinNamespaces3.js | 13 ++ .../unusedFunctionsinNamespaces4.errors.txt | 15 ++ .../reference/unusedFunctionsinNamespaces4.js | 20 ++ .../unusedFunctionsinNamespaces5.errors.txt | 26 +++ .../reference/unusedFunctionsinNamespaces5.js | 33 ++++ .../unusedFunctionsinNamespaces6.errors.txt | 25 +++ .../reference/unusedFunctionsinNamespaces6.js | 36 ++++ .../reference/unusedGetterInClass.js | 23 +++ .../reference/unusedGetterInClass.symbols | 17 ++ .../reference/unusedGetterInClass.types | 17 ++ .../unusedIdentifiersConsolidated1.errors.txt | 153 ++++++++++++++ .../unusedIdentifiersConsolidated1.js | 187 ++++++++++++++++++ .../reference/unusedImports1.errors.txt | 13 ++ tests/baselines/reference/unusedImports1.js | 21 ++ .../reference/unusedImports10.errors.txt | 17 ++ tests/baselines/reference/unusedImports10.js | 25 +++ .../reference/unusedImports2.errors.txt | 21 ++ tests/baselines/reference/unusedImports2.js | 36 ++++ .../reference/unusedImports3.errors.txt | 24 +++ tests/baselines/reference/unusedImports3.js | 42 ++++ .../reference/unusedImports4.errors.txt | 25 +++ tests/baselines/reference/unusedImports4.js | 44 +++++ .../reference/unusedImports5.errors.txt | 25 +++ tests/baselines/reference/unusedImports5.js | 44 +++++ .../reference/unusedImports6.errors.txt | 25 +++ tests/baselines/reference/unusedImports6.js | 41 ++++ .../reference/unusedImports7.errors.txt | 23 +++ tests/baselines/reference/unusedImports7.js | 39 ++++ .../reference/unusedImports8.errors.txt | 25 +++ tests/baselines/reference/unusedImports8.js | 44 +++++ .../reference/unusedImports9.errors.txt | 21 ++ tests/baselines/reference/unusedImports9.js | 36 ++++ .../unusedInterfaceinNamespace1.errors.txt | 12 ++ .../reference/unusedInterfaceinNamespace1.js | 9 + .../unusedInterfaceinNamespace2.errors.txt | 16 ++ .../reference/unusedInterfaceinNamespace2.js | 13 ++ .../unusedInterfaceinNamespace3.errors.txt | 20 ++ .../reference/unusedInterfaceinNamespace3.js | 17 ++ .../reference/unusedInterfaceinNamespace4.js | 30 +++ .../unusedInterfaceinNamespace4.symbols | 27 +++ .../unusedInterfaceinNamespace4.types | 27 +++ .../reference/unusedInterfaceinNamespace5.js | 36 ++++ .../unusedInterfaceinNamespace5.symbols | 36 ++++ .../unusedInterfaceinNamespace5.types | 36 ++++ .../unusedLocalsInMethod1.errors.txt | 12 ++ .../reference/unusedLocalsInMethod1.js | 17 ++ .../unusedLocalsInMethod2.errors.txt | 13 ++ .../reference/unusedLocalsInMethod2.js | 19 ++ .../unusedLocalsInMethod3.errors.txt | 13 ++ .../reference/unusedLocalsInMethod3.js | 19 ++ ...ationWithinFunctionDeclaration1.errors.txt | 26 +++ ...onDeclarationWithinFunctionDeclaration1.js | 18 ++ ...ationWithinFunctionDeclaration2.errors.txt | 35 ++++ ...onDeclarationWithinFunctionDeclaration2.js | 24 +++ ...rationWithinFunctionExpression1.errors.txt | 26 +++ ...ionDeclarationWithinFunctionExpression1.js | 18 ++ ...rationWithinFunctionExpression2.errors.txt | 35 ++++ ...ionDeclarationWithinFunctionExpression2.js | 24 +++ ...ssionWithinFunctionDeclaration1.errors.txt | 26 +++ ...ionExpressionWithinFunctionDeclaration1.js | 18 ++ ...ssionWithinFunctionDeclaration2.errors.txt | 35 ++++ ...ionExpressionWithinFunctionDeclaration2.js | 24 +++ ...essionWithinFunctionExpression1.errors.txt | 26 +++ ...tionExpressionWithinFunctionExpression1.js | 18 ++ ...essionWithinFunctionExpression2.errors.txt | 35 ++++ ...tionExpressionWithinFunctionExpression2.js | 24 +++ .../unusedLocalsinConstructor1.errors.txt | 12 ++ .../reference/unusedLocalsinConstructor1.js | 15 ++ .../unusedLocalsinConstructor2.errors.txt | 14 ++ .../reference/unusedLocalsinConstructor2.js | 19 ++ .../reference/unusedMethodsInInterface.js | 8 + .../unusedMethodsInInterface.symbols | 13 ++ .../reference/unusedMethodsInInterface.types | 13 ++ .../reference/unusedModuleInModule.errors.txt | 10 + .../reference/unusedModuleInModule.js | 7 + ...dMultipleParameter1InContructor.errors.txt | 16 ++ .../unusedMultipleParameter1InContructor.js | 17 ++ ...eParameter1InFunctionExpression.errors.txt | 14 ++ ...dMultipleParameter1InFunctionExpression.js | 12 ++ ...dMultipleParameter2InContructor.errors.txt | 19 ++ .../unusedMultipleParameter2InContructor.js | 17 ++ ...eParameter2InFunctionExpression.errors.txt | 17 ++ ...dMultipleParameter2InFunctionExpression.js | 12 ++ ...arameters1InFunctionDeclaration.errors.txt | 14 ++ ...ultipleParameters1InFunctionDeclaration.js | 12 ++ ...eParameters1InMethodDeclaration.errors.txt | 16 ++ ...dMultipleParameters1InMethodDeclaration.js | 19 ++ ...arameters2InFunctionDeclaration.errors.txt | 17 ++ ...ultipleParameters2InFunctionDeclaration.js | 12 ++ ...eParameters2InMethodDeclaration.errors.txt | 19 ++ ...dMultipleParameters2InMethodDeclaration.js | 19 ++ .../unusedNamespaceInModule.errors.txt | 11 ++ .../reference/unusedNamespaceInModule.js | 8 + .../unusedNamespaceInNamespace.errors.txt | 11 ++ .../reference/unusedNamespaceInNamespace.js | 8 + .../unusedParameterInCatchClause.errors.txt | 10 + .../reference/unusedParameterInCatchClause.js | 11 ++ .../reference/unusedParameterUsedInTypeOf.js | 10 + .../unusedParameterUsedInTypeOf.symbols | 11 ++ .../unusedParameterUsedInTypeOf.types | 12 ++ .../unusedParametersInLambda1.errors.txt | 13 ++ .../reference/unusedParametersInLambda1.js | 19 ++ .../unusedParametersInLambda2.errors.txt | 14 ++ .../reference/unusedParametersInLambda2.js | 21 ++ .../unusedParametersinConstructor1.errors.txt | 11 ++ .../unusedParametersinConstructor1.js | 13 ++ .../unusedParametersinConstructor2.errors.txt | 12 ++ .../unusedParametersinConstructor2.js | 15 ++ .../unusedParametersinConstructor3.errors.txt | 15 ++ .../unusedParametersinConstructor3.js | 15 ++ .../unusedPrivateMethodInClass1.errors.txt | 13 ++ .../reference/unusedPrivateMethodInClass1.js | 19 ++ .../unusedPrivateMethodInClass2.errors.txt | 21 ++ .../reference/unusedPrivateMethodInClass2.js | 28 +++ .../unusedPrivateMethodInClass3.errors.txt | 26 +++ .../reference/unusedPrivateMethodInClass3.js | 37 ++++ .../unusedPrivateMethodInClass4.errors.txt | 24 +++ .../reference/unusedPrivateMethodInClass4.js | 39 ++++ .../unusedPrivateVariableInClass1.errors.txt | 10 + .../unusedPrivateVariableInClass1.js | 12 ++ .../unusedPrivateVariableInClass2.errors.txt | 14 ++ .../unusedPrivateVariableInClass2.js | 13 ++ .../unusedPrivateVariableInClass3.errors.txt | 15 ++ .../unusedPrivateVariableInClass3.js | 14 ++ .../unusedPrivateVariableInClass4.errors.txt | 16 ++ .../unusedPrivateVariableInClass4.js | 21 ++ .../unusedPrivateVariableInClass5.errors.txt | 16 ++ .../unusedPrivateVariableInClass5.js | 19 ++ .../reference/unusedSetterInClass.js | 23 +++ .../reference/unusedSetterInClass.symbols | 19 ++ .../reference/unusedSetterInClass.types | 20 ++ ...usedSingleParameterInContructor.errors.txt | 15 ++ .../unusedSingleParameterInContructor.js | 15 ++ ...eParameterInFunctionDeclaration.errors.txt | 13 ++ ...sedSingleParameterInFunctionDeclaration.js | 10 + ...leParameterInFunctionExpression.errors.txt | 13 ++ ...usedSingleParameterInFunctionExpression.js | 10 + ...gleParameterInMethodDeclaration.errors.txt | 15 ++ ...nusedSingleParameterInMethodDeclaration.js | 17 ++ .../unusedTypeParameterInFunction1.errors.txt | 10 + .../unusedTypeParameterInFunction1.js | 9 + .../unusedTypeParameterInFunction2.errors.txt | 11 ++ .../unusedTypeParameterInFunction2.js | 12 ++ .../unusedTypeParameterInFunction3.errors.txt | 13 ++ .../unusedTypeParameterInFunction3.js | 16 ++ .../unusedTypeParameterInFunction4.errors.txt | 13 ++ .../unusedTypeParameterInFunction4.js | 16 ++ ...unusedTypeParameterInInterface1.errors.txt | 10 + .../unusedTypeParameterInInterface1.js | 7 + ...unusedTypeParameterInInterface2.errors.txt | 11 ++ .../unusedTypeParameterInInterface2.js | 8 + .../unusedTypeParameterInLambda1.errors.txt | 14 ++ .../reference/unusedTypeParameterInLambda1.js | 20 ++ .../unusedTypeParameterInLambda2.errors.txt | 15 ++ .../reference/unusedTypeParameterInLambda2.js | 23 +++ .../unusedTypeParameterInLambda3.errors.txt | 12 ++ .../reference/unusedTypeParameterInLambda3.js | 15 ++ .../unusedTypeParameterInMethod1.errors.txt | 15 ++ .../reference/unusedTypeParameterInMethod1.js | 23 +++ .../unusedTypeParameterInMethod2.errors.txt | 15 ++ .../reference/unusedTypeParameterInMethod2.js | 23 +++ .../unusedTypeParameterInMethod3.errors.txt | 15 ++ .../reference/unusedTypeParameterInMethod3.js | 23 +++ .../unusedTypeParameterInMethod4.errors.txt | 12 ++ .../reference/unusedTypeParameterInMethod4.js | 16 ++ .../unusedTypeParameterInMethod5.errors.txt | 12 ++ .../reference/unusedTypeParameterInMethod5.js | 16 ++ .../unusedTypeParameters1.errors.txt | 10 + .../reference/unusedTypeParameters1.js | 12 ++ .../unusedTypeParameters2.errors.txt | 14 ++ .../reference/unusedTypeParameters2.js | 19 ++ .../unusedTypeParameters3.errors.txt | 17 ++ .../reference/unusedTypeParameters3.js | 19 ++ .../unusedTypeParameters4.errors.txt | 10 + .../reference/unusedTypeParameters4.js | 8 + .../unusedTypeParameters5.errors.txt | 14 ++ .../reference/unusedTypeParameters5.js | 17 ++ .../unusedVariablesinBlocks1.errors.txt | 14 ++ .../reference/unusedVariablesinBlocks1.js | 18 ++ .../unusedVariablesinBlocks2.errors.txt | 14 ++ .../reference/unusedVariablesinBlocks2.js | 18 ++ .../unusedVariablesinForLoop.errors.txt | 12 ++ .../reference/unusedVariablesinForLoop.js | 13 ++ .../unusedVariablesinForLoop2.errors.txt | 12 ++ .../reference/unusedVariablesinForLoop2.js | 13 ++ .../unusedVariablesinForLoop3.errors.txt | 12 ++ .../reference/unusedVariablesinForLoop3.js | 14 ++ .../unusedVariablesinForLoop4.errors.txt | 13 ++ .../reference/unusedVariablesinForLoop4.js | 17 ++ .../unusedVariablesinModules1.errors.txt | 12 ++ .../reference/unusedVariablesinModules1.js | 11 ++ .../unusedVariablesinNamespaces1.errors.txt | 10 + .../reference/unusedVariablesinNamespaces1.js | 11 ++ .../unusedVariablesinNamespaces2.errors.txt | 17 ++ .../reference/unusedVariablesinNamespaces2.js | 28 +++ .../unusedVariablesinNamespaces3.errors.txt | 18 ++ .../reference/unusedVariablesinNamespaces3.js | 30 +++ .../cases/compiler/unusedClassesinModule1.ts | 9 + .../compiler/unusedClassesinNamespace1.ts | 8 + .../compiler/unusedClassesinNamespace2.ts | 12 ++ .../compiler/unusedClassesinNamespace3.ts | 14 ++ .../compiler/unusedClassesinNamespace4.ts | 16 ++ .../compiler/unusedClassesinNamespace5.ts | 16 ++ .../compiler/unusedFunctionsinNamespaces1.ts | 7 + .../compiler/unusedFunctionsinNamespaces2.ts | 7 + .../compiler/unusedFunctionsinNamespaces3.ts | 7 + .../compiler/unusedFunctionsinNamespaces4.ts | 11 ++ .../compiler/unusedFunctionsinNamespaces5.ts | 19 ++ .../compiler/unusedFunctionsinNamespaces6.ts | 21 ++ tests/cases/compiler/unusedGetterInClass.ts | 11 ++ .../unusedIdentifiersConsolidated1.ts | 104 ++++++++++ tests/cases/compiler/unusedImports1.ts | 10 + tests/cases/compiler/unusedImports10.ts | 13 ++ tests/cases/compiler/unusedImports2.ts | 18 ++ tests/cases/compiler/unusedImports3.ts | 21 ++ tests/cases/compiler/unusedImports4.ts | 22 +++ tests/cases/compiler/unusedImports5.ts | 22 +++ tests/cases/compiler/unusedImports6.ts | 21 ++ tests/cases/compiler/unusedImports7.ts | 19 ++ tests/cases/compiler/unusedImports8.ts | 22 +++ tests/cases/compiler/unusedImports9.ts | 18 ++ .../compiler/unusedInterfaceinNamespace1.ts | 8 + .../compiler/unusedInterfaceinNamespace2.ts | 12 ++ .../compiler/unusedInterfaceinNamespace3.ts | 16 ++ .../compiler/unusedInterfaceinNamespace4.ts | 20 ++ .../compiler/unusedInterfaceinNamespace5.ts | 26 +++ tests/cases/compiler/unusedLocalsInMethod1.ts | 8 + tests/cases/compiler/unusedLocalsInMethod2.ts | 9 + tests/cases/compiler/unusedLocalsInMethod3.ts | 9 + ...onDeclarationWithinFunctionDeclaration1.ts | 10 + ...onDeclarationWithinFunctionDeclaration2.ts | 13 ++ ...ionDeclarationWithinFunctionExpression1.ts | 10 + ...ionDeclarationWithinFunctionExpression2.ts | 13 ++ ...ionExpressionWithinFunctionDeclaration1.ts | 10 + ...ionExpressionWithinFunctionDeclaration2.ts | 13 ++ ...tionExpressionWithinFunctionExpression1.ts | 10 + ...tionExpressionWithinFunctionExpression2.ts | 13 ++ .../compiler/unusedLocalsinConstructor1.ts | 8 + .../compiler/unusedLocalsinConstructor2.ts | 10 + .../compiler/unusedMethodsInInterface.ts | 7 + tests/cases/compiler/unusedModuleInModule.ts | 6 + .../unusedMultipleParameter1InContructor.ts | 9 + ...dMultipleParameter1InFunctionExpression.ts | 7 + .../unusedMultipleParameter2InContructor.ts | 9 + ...dMultipleParameter2InFunctionExpression.ts | 7 + ...ultipleParameters1InFunctionDeclaration.ts | 7 + ...dMultipleParameters1InMethodDeclaration.ts | 9 + ...ultipleParameters2InFunctionDeclaration.ts | 7 + ...dMultipleParameters2InMethodDeclaration.ts | 9 + .../cases/compiler/unusedNamespaceInModule.ts | 7 + .../compiler/unusedNamespaceInNamespace.ts | 7 + .../compiler/unusedParameterInCatchClause.ts | 6 + .../compiler/unusedParameterUsedInTypeOf.ts | 7 + .../compiler/unusedParametersInLambda1.ts | 9 + .../compiler/unusedParametersInLambda2.ts | 10 + .../unusedParametersinConstructor1.ts | 7 + .../unusedParametersinConstructor2.ts | 8 + .../unusedParametersinConstructor3.ts | 8 + .../compiler/unusedPrivateMethodInClass1.ts | 9 + .../compiler/unusedPrivateMethodInClass2.ts | 14 ++ .../compiler/unusedPrivateMethodInClass3.ts | 19 ++ .../compiler/unusedPrivateMethodInClass4.ts | 20 ++ .../compiler/unusedPrivateVariableInClass1.ts | 6 + .../compiler/unusedPrivateVariableInClass2.ts | 7 + .../compiler/unusedPrivateVariableInClass3.ts | 8 + .../compiler/unusedPrivateVariableInClass4.ts | 12 ++ .../compiler/unusedPrivateVariableInClass5.ts | 12 ++ tests/cases/compiler/unusedSetterInClass.ts | 11 ++ .../unusedSingleParameterInContructor.ts | 8 + ...sedSingleParameterInFunctionDeclaration.ts | 6 + ...usedSingleParameterInFunctionExpression.ts | 6 + ...nusedSingleParameterInMethodDeclaration.ts | 8 + .../unusedTypeParameterInFunction1.ts | 6 + .../unusedTypeParameterInFunction2.ts | 7 + .../unusedTypeParameterInFunction3.ts | 9 + .../unusedTypeParameterInFunction4.ts | 9 + .../unusedTypeParameterInInterface1.ts | 6 + .../unusedTypeParameterInInterface2.ts | 7 + .../compiler/unusedTypeParameterInLambda1.ts | 10 + .../compiler/unusedTypeParameterInLambda2.ts | 11 ++ .../compiler/unusedTypeParameterInLambda3.ts | 7 + .../compiler/unusedTypeParameterInMethod1.ts | 11 ++ .../compiler/unusedTypeParameterInMethod2.ts | 11 ++ .../compiler/unusedTypeParameterInMethod3.ts | 11 ++ .../compiler/unusedTypeParameterInMethod4.ts | 8 + .../compiler/unusedTypeParameterInMethod5.ts | 8 + tests/cases/compiler/unusedTypeParameters1.ts | 6 + tests/cases/compiler/unusedTypeParameters2.ts | 10 + tests/cases/compiler/unusedTypeParameters3.ts | 10 + tests/cases/compiler/unusedTypeParameters4.ts | 6 + tests/cases/compiler/unusedTypeParameters5.ts | 10 + .../compiler/unusedVariablesinBlocks1.ts | 10 + .../compiler/unusedVariablesinBlocks2.ts | 10 + .../compiler/unusedVariablesinForLoop.ts | 8 + .../compiler/unusedVariablesinForLoop2.ts | 8 + .../compiler/unusedVariablesinForLoop3.ts | 8 + .../compiler/unusedVariablesinForLoop4.ts | 9 + .../compiler/unusedVariablesinModules1.ts | 8 + .../compiler/unusedVariablesinNamespaces1.ts | 6 + .../compiler/unusedVariablesinNamespaces2.ts | 13 ++ .../compiler/unusedVariablesinNamespaces3.ts | 14 ++ 324 files changed, 5641 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/unusedClassesinModule1.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinModule1.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace1.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace1.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace2.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace2.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace3.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace3.symbols create mode 100644 tests/baselines/reference/unusedClassesinNamespace3.types create mode 100644 tests/baselines/reference/unusedClassesinNamespace4.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace4.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace5.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace5.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces1.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces2.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces3.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces4.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces5.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces6.js create mode 100644 tests/baselines/reference/unusedGetterInClass.js create mode 100644 tests/baselines/reference/unusedGetterInClass.symbols create mode 100644 tests/baselines/reference/unusedGetterInClass.types create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.js create mode 100644 tests/baselines/reference/unusedImports1.errors.txt create mode 100644 tests/baselines/reference/unusedImports1.js create mode 100644 tests/baselines/reference/unusedImports10.errors.txt create mode 100644 tests/baselines/reference/unusedImports10.js create mode 100644 tests/baselines/reference/unusedImports2.errors.txt create mode 100644 tests/baselines/reference/unusedImports2.js create mode 100644 tests/baselines/reference/unusedImports3.errors.txt create mode 100644 tests/baselines/reference/unusedImports3.js create mode 100644 tests/baselines/reference/unusedImports4.errors.txt create mode 100644 tests/baselines/reference/unusedImports4.js create mode 100644 tests/baselines/reference/unusedImports5.errors.txt create mode 100644 tests/baselines/reference/unusedImports5.js create mode 100644 tests/baselines/reference/unusedImports6.errors.txt create mode 100644 tests/baselines/reference/unusedImports6.js create mode 100644 tests/baselines/reference/unusedImports7.errors.txt create mode 100644 tests/baselines/reference/unusedImports7.js create mode 100644 tests/baselines/reference/unusedImports8.errors.txt create mode 100644 tests/baselines/reference/unusedImports8.js create mode 100644 tests/baselines/reference/unusedImports9.errors.txt create mode 100644 tests/baselines/reference/unusedImports9.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace1.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace2.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace3.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace4.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace4.symbols create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace4.types create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace5.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace5.symbols create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace5.types create mode 100644 tests/baselines/reference/unusedLocalsInMethod1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsInMethod1.js create mode 100644 tests/baselines/reference/unusedLocalsInMethod2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsInMethod2.js create mode 100644 tests/baselines/reference/unusedLocalsInMethod3.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsInMethod3.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js create mode 100644 tests/baselines/reference/unusedLocalsinConstructor1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsinConstructor1.js create mode 100644 tests/baselines/reference/unusedLocalsinConstructor2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsinConstructor2.js create mode 100644 tests/baselines/reference/unusedMethodsInInterface.js create mode 100644 tests/baselines/reference/unusedMethodsInInterface.symbols create mode 100644 tests/baselines/reference/unusedMethodsInInterface.types create mode 100644 tests/baselines/reference/unusedModuleInModule.errors.txt create mode 100644 tests/baselines/reference/unusedModuleInModule.js create mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.js create mode 100644 tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js create mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.js create mode 100644 tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js create mode 100644 tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js create mode 100644 tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js create mode 100644 tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js create mode 100644 tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js create mode 100644 tests/baselines/reference/unusedNamespaceInModule.errors.txt create mode 100644 tests/baselines/reference/unusedNamespaceInModule.js create mode 100644 tests/baselines/reference/unusedNamespaceInNamespace.errors.txt create mode 100644 tests/baselines/reference/unusedNamespaceInNamespace.js create mode 100644 tests/baselines/reference/unusedParameterInCatchClause.errors.txt create mode 100644 tests/baselines/reference/unusedParameterInCatchClause.js create mode 100644 tests/baselines/reference/unusedParameterUsedInTypeOf.js create mode 100644 tests/baselines/reference/unusedParameterUsedInTypeOf.symbols create mode 100644 tests/baselines/reference/unusedParameterUsedInTypeOf.types create mode 100644 tests/baselines/reference/unusedParametersInLambda1.errors.txt create mode 100644 tests/baselines/reference/unusedParametersInLambda1.js create mode 100644 tests/baselines/reference/unusedParametersInLambda2.errors.txt create mode 100644 tests/baselines/reference/unusedParametersInLambda2.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor1.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor1.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor2.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor2.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor3.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor3.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass1.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass2.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass3.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass4.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass1.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass2.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass3.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass4.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass5.js create mode 100644 tests/baselines/reference/unusedSetterInClass.js create mode 100644 tests/baselines/reference/unusedSetterInClass.symbols create mode 100644 tests/baselines/reference/unusedSetterInClass.types create mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.js create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionExpression.js create mode 100644 tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction3.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction4.js create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda3.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod3.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod4.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod5.js create mode 100644 tests/baselines/reference/unusedTypeParameters1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters1.js create mode 100644 tests/baselines/reference/unusedTypeParameters2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters2.js create mode 100644 tests/baselines/reference/unusedTypeParameters3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters3.js create mode 100644 tests/baselines/reference/unusedTypeParameters4.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters4.js create mode 100644 tests/baselines/reference/unusedTypeParameters5.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters5.js create mode 100644 tests/baselines/reference/unusedVariablesinBlocks1.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinBlocks1.js create mode 100644 tests/baselines/reference/unusedVariablesinBlocks2.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinBlocks2.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop2.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop2.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop3.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop3.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop4.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop4.js create mode 100644 tests/baselines/reference/unusedVariablesinModules1.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinModules1.js create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces1.js create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces2.js create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces3.js create mode 100644 tests/cases/compiler/unusedClassesinModule1.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace1.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace2.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace3.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace4.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace5.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces1.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces2.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces3.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces4.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces5.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces6.ts create mode 100644 tests/cases/compiler/unusedGetterInClass.ts create mode 100644 tests/cases/compiler/unusedIdentifiersConsolidated1.ts create mode 100644 tests/cases/compiler/unusedImports1.ts create mode 100644 tests/cases/compiler/unusedImports10.ts create mode 100644 tests/cases/compiler/unusedImports2.ts create mode 100644 tests/cases/compiler/unusedImports3.ts create mode 100644 tests/cases/compiler/unusedImports4.ts create mode 100644 tests/cases/compiler/unusedImports5.ts create mode 100644 tests/cases/compiler/unusedImports6.ts create mode 100644 tests/cases/compiler/unusedImports7.ts create mode 100644 tests/cases/compiler/unusedImports8.ts create mode 100644 tests/cases/compiler/unusedImports9.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace1.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace2.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace3.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace4.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace5.ts create mode 100644 tests/cases/compiler/unusedLocalsInMethod1.ts create mode 100644 tests/cases/compiler/unusedLocalsInMethod2.ts create mode 100644 tests/cases/compiler/unusedLocalsInMethod3.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts create mode 100644 tests/cases/compiler/unusedLocalsinConstructor1.ts create mode 100644 tests/cases/compiler/unusedLocalsinConstructor2.ts create mode 100644 tests/cases/compiler/unusedMethodsInInterface.ts create mode 100644 tests/cases/compiler/unusedModuleInModule.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter1InContructor.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter2InContructor.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts create mode 100644 tests/cases/compiler/unusedNamespaceInModule.ts create mode 100644 tests/cases/compiler/unusedNamespaceInNamespace.ts create mode 100644 tests/cases/compiler/unusedParameterInCatchClause.ts create mode 100644 tests/cases/compiler/unusedParameterUsedInTypeOf.ts create mode 100644 tests/cases/compiler/unusedParametersInLambda1.ts create mode 100644 tests/cases/compiler/unusedParametersInLambda2.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor1.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor2.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor3.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass1.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass2.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass3.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass4.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass1.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass2.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass3.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass4.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass5.ts create mode 100644 tests/cases/compiler/unusedSetterInClass.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInContructor.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction3.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction4.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInInterface1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInInterface2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInLambda1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInLambda2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInLambda3.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod3.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod4.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod5.ts create mode 100644 tests/cases/compiler/unusedTypeParameters1.ts create mode 100644 tests/cases/compiler/unusedTypeParameters2.ts create mode 100644 tests/cases/compiler/unusedTypeParameters3.ts create mode 100644 tests/cases/compiler/unusedTypeParameters4.ts create mode 100644 tests/cases/compiler/unusedTypeParameters5.ts create mode 100644 tests/cases/compiler/unusedVariablesinBlocks1.ts create mode 100644 tests/cases/compiler/unusedVariablesinBlocks2.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop2.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop3.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop4.ts create mode 100644 tests/cases/compiler/unusedVariablesinModules1.ts create mode 100644 tests/cases/compiler/unusedVariablesinNamespaces1.ts create mode 100644 tests/cases/compiler/unusedVariablesinNamespaces2.ts create mode 100644 tests/cases/compiler/unusedVariablesinNamespaces3.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 34d73f9f721..935c8c13fb0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8310,8 +8310,21 @@ namespace ts { return container === declarationContainer; } + function updateReferencesForInterfaceHeritiageClauseTargets(node: InterfaceDeclaration): void { + const extendedTypeNode = getClassExtendsHeritageClauseElement(node); + if (extendedTypeNode) { + const t = getTypeFromTypeNode(extendedTypeNode); + if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + t.symbol.hasReference = true; + } + } + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); + if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + symbol.hasReference = true; + } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -10226,6 +10239,10 @@ namespace ts { return unknownType; } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + prop.hasReference = true; + } + getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { @@ -12168,6 +12185,8 @@ namespace ts { } } } + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } } @@ -13238,6 +13257,9 @@ namespace ts { checkAsyncFunctionReturnType(node); } } + if (!(node).body) { + checkUnusedTypeParameters(node); + } } } @@ -13390,6 +13412,8 @@ namespace ts { checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); const symbol = getSymbolOfNode(node); const firstDeclaration = getDeclarationOfKind(symbol, node.kind); @@ -13582,13 +13606,18 @@ namespace ts { function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) { checkGrammarTypeArguments(node, node.typeArguments); const type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - const symbol = getNodeLinks(node).resolvedSymbol; - const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); + if (type !== unknownType) { + if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + type.symbol.hasReference = true; + } + if (node.typeArguments) { + // Do type argument local checks only if referenced type is successfully resolved + forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + const symbol = getNodeLinks(node).resolvedSymbol; + const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } } } } @@ -14431,6 +14460,8 @@ namespace ts { } checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); if (!node.asteriskToken) { const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -14452,12 +14483,83 @@ namespace ts { } } + function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block | CatchClause): void { + if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + for (const key in node.locals) { + if (hasProperty(node.locals, key)) { + const local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration) { + if (local.valueDeclaration.kind !== SyntaxKind.Parameter && compilerOptions.noUnusedLocals) { + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); + } + else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) { + if (local.valueDeclaration.flags === 0) { + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); + } + } + } + } + } + } + } + + function checkUnusedClassLocals(node: ClassDeclaration): void { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { + if (node.members) { + for (const member of node.members) { + if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { + if (isPrivateNode(member) && !member.symbol.hasReference) { + error(member.name, Diagnostics._0_is_declared_but_never_used, member.symbol.name); + } + } + else if (member.kind === SyntaxKind.Constructor) { + for (const parameter of (member).parameters) { + if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + } + } + } + } + } + } + } + + function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { + if (node.typeParameters) { + for (const typeParameter of node.typeParameters) { + if (!typeParameter.symbol.hasReference) { + error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + } + } + } + } + } + + function isPrivateNode(node: Node): boolean { + return (node.flags & NodeFlags.Private) !== 0; + } + + function checkUnusedModuleLocals(node: ModuleDeclaration | SourceFile): void { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { + for (const key in node.locals) { + if (hasProperty(node.locals, key)) { + const local = node.locals[key]; + if (!local.hasReference && !local.exportSymbol) { + forEach(local.declarations, d => error(d.name, Diagnostics._0_is_declared_but_never_used, local.name)); + } + } + } + } + } + function checkBlock(node: Block) { // Grammar checking for SyntaxKind.Block if (node.kind === SyntaxKind.Block) { checkGrammarStatementInAmbientContext(node); } forEach(node.statements, checkSourceElement); + checkUnusedIdentifiers(node); } function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) { @@ -14962,6 +15064,7 @@ namespace ts { } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInStatement(node: ForInStatement) { @@ -15009,6 +15112,7 @@ namespace ts { } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void { @@ -15448,6 +15552,7 @@ namespace ts { } checkBlock(catchClause.block); + checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { @@ -15609,6 +15714,8 @@ namespace ts { } checkClassLikeDeclaration(node); forEach(node.members, checkSourceElement); + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { @@ -15918,6 +16025,8 @@ namespace ts { if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); + checkUnusedTypeParameters(node); } } @@ -16314,6 +16423,7 @@ namespace ts { if (node.body) { checkSourceElement(node.body); + checkUnusedModuleLocals(node); } } @@ -16494,6 +16604,9 @@ namespace ts { if (target.flags & SymbolFlags.Type) { checkTypeNameIsReserved(node.name, Diagnostics.Import_name_cannot_be_0); } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + target.hasReference = true; + } } } else { @@ -16836,6 +16949,9 @@ namespace ts { deferredNodes = []; forEach(node.statements, checkSourceElement); + if (isExternalModule(node)) { + checkUnusedModuleLocals(node); + } checkDeferredNodes(); deferredNodes = undefined; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2e0bfa8290a..1c1b51f2a29 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -132,6 +132,16 @@ namespace ts { type: "boolean", description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "noUnusedLocals", + type: "boolean", + description: Diagnostics.Report_Errors_on_Unused_Locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: Diagnostics.Report_Errors_on_Unused_Parameters + }, { name: "noLib", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 95475a6178e..e2ad55f95ef 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2792,6 +2792,18 @@ "category": "Message", "code": 6132 }, + "'{0}' is declared but never used.": { + "category": "Error", + "code": 6133 + }, + "Report Errors on Unused Locals.": { + "category": "Message", + "code": 6134 + }, + "Report Errors on Unused Parameters.": { + "category": "Message", + "code": 6135 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2baae322a27..2ffce36427b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2127,6 +2127,7 @@ namespace ts { /* @internal */ parent?: Symbol; // Parent symbol /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums + /* @internal */ hasReference?: boolean; // True if the symbol is referenced elsewhere } /* @internal */ @@ -2557,6 +2558,8 @@ namespace ts { noImplicitAny?: boolean; noImplicitReturns?: boolean; noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; noImplicitUseStrict?: boolean; noLib?: boolean; noResolve?: boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b4ef62c6c3e..99e158e6ab7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1702,7 +1702,7 @@ namespace ts { node.kind === SyntaxKind.ExportAssignment && (node).expression.kind === SyntaxKind.Identifier; } - export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration) { + export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration) { const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } diff --git a/tests/baselines/reference/unusedClassesinModule1.errors.txt b/tests/baselines/reference/unusedClassesinModule1.errors.txt new file mode 100644 index 00000000000..6f2f936ce25 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinModule1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedClassesinModule1.ts(3,11): error TS6133: 'Calculator' is declared but never used. + + +==== tests/cases/compiler/unusedClassesinModule1.ts (1 errors) ==== + + module A { + class Calculator { + ~~~~~~~~~~ +!!! error TS6133: 'Calculator' is declared but never used. + public handelChar() { + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinModule1.js b/tests/baselines/reference/unusedClassesinModule1.js new file mode 100644 index 00000000000..d3fb726c2dd --- /dev/null +++ b/tests/baselines/reference/unusedClassesinModule1.js @@ -0,0 +1,20 @@ +//// [unusedClassesinModule1.ts] + +module A { + class Calculator { + public handelChar() { + } + } +} + +//// [unusedClassesinModule1.js] +var A; +(function (A) { + var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handelChar = function () { + }; + return Calculator; + }()); +})(A || (A = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt new file mode 100644 index 00000000000..dc5dc397fec --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6133: 'c1' is declared but never used. + + +==== tests/cases/compiler/unusedClassesinNamespace1.ts (1 errors) ==== + + namespace Validation { + class c1 { + ~~ +!!! error TS6133: 'c1' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace1.js b/tests/baselines/reference/unusedClassesinNamespace1.js new file mode 100644 index 00000000000..e49b9019a28 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace1.js @@ -0,0 +1,17 @@ +//// [unusedClassesinNamespace1.ts] + +namespace Validation { + class c1 { + + } +} + +//// [unusedClassesinNamespace1.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt new file mode 100644 index 00000000000..322b2697550 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6133: 'c1' is declared but never used. + + +==== tests/cases/compiler/unusedClassesinNamespace2.ts (1 errors) ==== + + namespace Validation { + class c1 { + ~~ +!!! error TS6133: 'c1' is declared but never used. + + } + + export class c2 { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace2.js b/tests/baselines/reference/unusedClassesinNamespace2.js new file mode 100644 index 00000000000..03431e4fd04 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace2.js @@ -0,0 +1,27 @@ +//// [unusedClassesinNamespace2.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } +} + +//// [unusedClassesinNamespace2.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace3.js b/tests/baselines/reference/unusedClassesinNamespace3.js new file mode 100644 index 00000000000..bdb646e87b2 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace3.js @@ -0,0 +1,30 @@ +//// [unusedClassesinNamespace3.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + export let a = new c1(); +} + +//// [unusedClassesinNamespace3.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; + Validation.a = new c1(); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace3.symbols b/tests/baselines/reference/unusedClassesinNamespace3.symbols new file mode 100644 index 00000000000..d8eeb0b5460 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace3.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/unusedClassesinNamespace3.ts === + +namespace Validation { +>Validation : Symbol(Validation, Decl(unusedClassesinNamespace3.ts, 0, 0)) + + class c1 { +>c1 : Symbol(c1, Decl(unusedClassesinNamespace3.ts, 1, 22)) + + } + + export class c2 { +>c2 : Symbol(c2, Decl(unusedClassesinNamespace3.ts, 4, 5)) + + } + + export let a = new c1(); +>a : Symbol(a, Decl(unusedClassesinNamespace3.ts, 10, 14)) +>c1 : Symbol(c1, Decl(unusedClassesinNamespace3.ts, 1, 22)) +} diff --git a/tests/baselines/reference/unusedClassesinNamespace3.types b/tests/baselines/reference/unusedClassesinNamespace3.types new file mode 100644 index 00000000000..cef64a4c4e3 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace3.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/unusedClassesinNamespace3.ts === + +namespace Validation { +>Validation : typeof Validation + + class c1 { +>c1 : c1 + + } + + export class c2 { +>c2 : c2 + + } + + export let a = new c1(); +>a : c1 +>new c1() : c1 +>c1 : typeof c1 +} diff --git a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt new file mode 100644 index 00000000000..2fd6e70524e --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6133: 'c3' is declared but never used. + + +==== tests/cases/compiler/unusedClassesinNamespace4.ts (1 errors) ==== + + namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 extends c1 { + ~~ +!!! error TS6133: 'c3' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace4.js b/tests/baselines/reference/unusedClassesinNamespace4.js new file mode 100644 index 00000000000..65198c1c1aa --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace4.js @@ -0,0 +1,43 @@ +//// [unusedClassesinNamespace4.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 extends c1 { + + } +} + +//// [unusedClassesinNamespace4.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; + var c3 = (function (_super) { + __extends(c3, _super); + function c3() { + _super.apply(this, arguments); + } + return c3; + }(c1)); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt new file mode 100644 index 00000000000..752036b2d03 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6133: 'c3' is declared but never used. + + +==== tests/cases/compiler/unusedClassesinNamespace5.ts (1 errors) ==== + + namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 { + ~~ +!!! error TS6133: 'c3' is declared but never used. + public x: c1; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace5.js b/tests/baselines/reference/unusedClassesinNamespace5.js new file mode 100644 index 00000000000..037a3564bd7 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace5.js @@ -0,0 +1,36 @@ +//// [unusedClassesinNamespace5.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 { + public x: c1; + } +} + +//// [unusedClassesinNamespace5.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; + var c3 = (function () { + function c3() { + } + return c3; + }()); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt new file mode 100644 index 00000000000..428eeae8de5 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6133: 'function1' is declared but never used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces1.ts (1 errors) ==== + + namespace Validation { + function function1() { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.js b/tests/baselines/reference/unusedFunctionsinNamespaces1.js new file mode 100644 index 00000000000..a6eec74b1f5 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.js @@ -0,0 +1,13 @@ +//// [unusedFunctionsinNamespaces1.ts] + +namespace Validation { + function function1() { + } +} + +//// [unusedFunctionsinNamespaces1.js] +var Validation; +(function (Validation) { + function function1() { + } +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt new file mode 100644 index 00000000000..2b0b6def378 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6133: 'function1' is declared but never used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces2.ts (1 errors) ==== + + namespace Validation { + var function1 = function() { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.js b/tests/baselines/reference/unusedFunctionsinNamespaces2.js new file mode 100644 index 00000000000..c908e38e7a6 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.js @@ -0,0 +1,13 @@ +//// [unusedFunctionsinNamespaces2.ts] + +namespace Validation { + var function1 = function() { + } +} + +//// [unusedFunctionsinNamespaces2.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt new file mode 100644 index 00000000000..cfbeecc3c49 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6133: 'param1' is declared but never used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces3.ts (2 errors) ==== + + namespace Validation { + var function1 = function(param1:string) { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + ~~~~~~ +!!! error TS6133: 'param1' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.js b/tests/baselines/reference/unusedFunctionsinNamespaces3.js new file mode 100644 index 00000000000..5501ed62a6f --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.js @@ -0,0 +1,13 @@ +//// [unusedFunctionsinNamespaces3.ts] + +namespace Validation { + var function1 = function(param1:string) { + } +} + +//// [unusedFunctionsinNamespaces3.js] +var Validation; +(function (Validation) { + var function1 = function (param1) { + }; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt new file mode 100644 index 00000000000..72ce63924fd --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6133: 'function1' is declared but never used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces4.ts (1 errors) ==== + + namespace Validation { + var function1 = function() { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + } + + export function function2() { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.js b/tests/baselines/reference/unusedFunctionsinNamespaces4.js new file mode 100644 index 00000000000..41557a62045 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.js @@ -0,0 +1,20 @@ +//// [unusedFunctionsinNamespaces4.ts] + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } +} + +//// [unusedFunctionsinNamespaces4.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; + function function2() { + } + Validation.function2 = function2; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt new file mode 100644 index 00000000000..239680499bd --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): error TS6133: 'function3' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6133: 'function4' is declared but never used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces5.ts (2 errors) ==== + + namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + ~~~~~~~~~ +!!! error TS6133: 'function3' is declared but never used. + function1(); + } + + function function4() { + ~~~~~~~~~ +!!! error TS6133: 'function4' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.js b/tests/baselines/reference/unusedFunctionsinNamespaces5.js new file mode 100644 index 00000000000..4023876b359 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.js @@ -0,0 +1,33 @@ +//// [unusedFunctionsinNamespaces5.ts] + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } +} + +//// [unusedFunctionsinNamespaces5.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; + function function2() { + } + Validation.function2 = function2; + function function3() { + function1(); + } + function function4() { + } +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt new file mode 100644 index 00000000000..f8f0d12dd51 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6133: 'function4' is declared but never used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces6.ts (1 errors) ==== + + namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + ~~~~~~~~~ +!!! error TS6133: 'function4' is declared but never used. + + } + + export let a = function3; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.js b/tests/baselines/reference/unusedFunctionsinNamespaces6.js new file mode 100644 index 00000000000..81ff5d9ea54 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.js @@ -0,0 +1,36 @@ +//// [unusedFunctionsinNamespaces6.ts] + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } + + export let a = function3; +} + +//// [unusedFunctionsinNamespaces6.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; + function function2() { + } + Validation.function2 = function2; + function function3() { + function1(); + } + function function4() { + } + Validation.a = function3; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedGetterInClass.js b/tests/baselines/reference/unusedGetterInClass.js new file mode 100644 index 00000000000..0920ace0195 --- /dev/null +++ b/tests/baselines/reference/unusedGetterInClass.js @@ -0,0 +1,23 @@ +//// [unusedGetterInClass.ts] + +class Employee { + private _fullName: string; + + get fullName(): string { + return this._fullName; + } +} + +//// [unusedGetterInClass.js] +var Employee = (function () { + function Employee() { + } + Object.defineProperty(Employee.prototype, "fullName", { + get: function () { + return this._fullName; + }, + enumerable: true, + configurable: true + }); + return Employee; +}()); diff --git a/tests/baselines/reference/unusedGetterInClass.symbols b/tests/baselines/reference/unusedGetterInClass.symbols new file mode 100644 index 00000000000..3d19dd41241 --- /dev/null +++ b/tests/baselines/reference/unusedGetterInClass.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/unusedGetterInClass.ts === + +class Employee { +>Employee : Symbol(Employee, Decl(unusedGetterInClass.ts, 0, 0)) + + private _fullName: string; +>_fullName : Symbol(Employee._fullName, Decl(unusedGetterInClass.ts, 1, 16)) + + get fullName(): string { +>fullName : Symbol(Employee.fullName, Decl(unusedGetterInClass.ts, 2, 30)) + + return this._fullName; +>this._fullName : Symbol(Employee._fullName, Decl(unusedGetterInClass.ts, 1, 16)) +>this : Symbol(Employee, Decl(unusedGetterInClass.ts, 0, 0)) +>_fullName : Symbol(Employee._fullName, Decl(unusedGetterInClass.ts, 1, 16)) + } +} diff --git a/tests/baselines/reference/unusedGetterInClass.types b/tests/baselines/reference/unusedGetterInClass.types new file mode 100644 index 00000000000..8ad7479c443 --- /dev/null +++ b/tests/baselines/reference/unusedGetterInClass.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/unusedGetterInClass.ts === + +class Employee { +>Employee : Employee + + private _fullName: string; +>_fullName : string + + get fullName(): string { +>fullName : string + + return this._fullName; +>this._fullName : string +>this : this +>_fullName : string + } +} diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt new file mode 100644 index 00000000000..a174074bdf7 --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -0,0 +1,153 @@ +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): error TS6133: 'unusedtypeparameter' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,13): error TS6133: 'unusedprivatevariable' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): error TS6133: 'message' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): error TS6133: 'unUsedPrivateFunction' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): error TS6133: 'numberRegexp' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): error TS6133: 'unUsedPrivateFunction' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): error TS6133: 'usedLocallyInterface2' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): error TS6133: 'dummy' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): error TS6133: 'unusedInterface' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): error TS6133: 'class3' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: 'interface5' is declared but never used. + + +==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== + + function greeter(person: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + } + + class Dummy { + ~~~~~~~~~~~~~~~~~~~ +!!! error TS6133: 'unusedtypeparameter' is declared but never used. + private unusedprivatevariable: string; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6133: 'unusedprivatevariable' is declared but never used. + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + ~~~~~~~ +!!! error TS6133: 'message' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. + } + } + + var user = "Jane User"; + var user2 = "Jane2 User2"; + + namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! error TS6133: 'numberRegexp' is declared but never used. + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6133: 'usedLocallyInterface2' is declared but never used. + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + ~~~~~ +!!! error TS6133: 'dummy' is declared but never used. + } + + interface unusedInterface { + ~~~~~~~~~~~~~~~ +!!! error TS6133: 'unusedInterface' is declared but never used. + } + } + + + namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + ~~~~~~ +!!! error TS6133: 'class3' is declared but never used. + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + ~~~~~~~~~~ +!!! error TS6133: 'interface5' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.js b/tests/baselines/reference/unusedIdentifiersConsolidated1.js new file mode 100644 index 00000000000..521f17bf5ef --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.js @@ -0,0 +1,187 @@ +//// [unusedIdentifiersConsolidated1.ts] + +function greeter(person: string) { + var unused = 20; +} + +class Dummy { + private unusedprivatevariable: string; + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + var unused = 20; + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + } +} + +var user = "Jane User"; +var user2 = "Jane2 User2"; + +namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + } + + interface unusedInterface { + } +} + + +namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + } +} + +//// [unusedIdentifiersConsolidated1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +function greeter(person) { + var unused = 20; +} +var Dummy = (function () { + function Dummy(message) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + Dummy.prototype.greeter = function (person) { + var unused = 20; + this.usedPrivateFunction(); + }; + Dummy.prototype.usedPrivateFunction = function () { + }; + Dummy.prototype.unUsedPrivateFunction = function () { + }; + return Dummy; +}()); +var user = "Jane User"; +var user2 = "Jane2 User2"; +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + LettersOnlyValidator.prototype.unUsedPrivateFunction = function () { + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; + var ZipCodeValidator = (function () { + function ZipCodeValidator() { + } + ZipCodeValidator.prototype.isAcceptable = function (s3) { + return s3.length === 5; + }; + return ZipCodeValidator; + }()); + Validation.ZipCodeValidator = ZipCodeValidator; + var dummy = (function () { + function dummy() { + } + return dummy; + }()); +})(Validation || (Validation = {})); +var Greeter; +(function (Greeter) { + var class1 = (function () { + function class1() { + } + return class1; + }()); + var class2 = (function (_super) { + __extends(class2, _super); + function class2() { + _super.apply(this, arguments); + } + return class2; + }(class1)); + Greeter.class2 = class2; + var class3 = (function () { + function class3() { + } + return class3; + }()); + var class4 = (function () { + function class4() { + } + return class4; + }()); + Greeter.class4 = class4; +})(Greeter || (Greeter = {})); diff --git a/tests/baselines/reference/unusedImports1.errors.txt b/tests/baselines/reference/unusedImports1.errors.txt new file mode 100644 index 00000000000..f2d59c994b5 --- /dev/null +++ b/tests/baselines/reference/unusedImports1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator} from "./file1" + ~~~~~~~~~~ +!!! error TS6133: 'Calculator' is declared but never used. \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports1.js b/tests/baselines/reference/unusedImports1.js new file mode 100644 index 00000000000..afd6eb80843 --- /dev/null +++ b/tests/baselines/reference/unusedImports1.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/unusedImports1.ts] //// + +//// [file1.ts] + +export class Calculator { + +} + +//// [file2.ts] +import {Calculator} from "./file1" + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + return Calculator; +}()); +exports.Calculator = Calculator; +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/unusedImports10.errors.txt b/tests/baselines/reference/unusedImports10.errors.txt new file mode 100644 index 00000000000..c4937a420f9 --- /dev/null +++ b/tests/baselines/reference/unusedImports10.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedImports10.ts(10,12): error TS6133: 'a' is declared but never used. + + +==== tests/cases/compiler/unusedImports10.ts (1 errors) ==== + + module A { + export class Calculator { + public handelChar() { + } + } + } + + module B { + import a = A; + ~ +!!! error TS6133: 'a' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports10.js b/tests/baselines/reference/unusedImports10.js new file mode 100644 index 00000000000..49365e6e3ff --- /dev/null +++ b/tests/baselines/reference/unusedImports10.js @@ -0,0 +1,25 @@ +//// [unusedImports10.ts] + +module A { + export class Calculator { + public handelChar() { + } + } +} + +module B { + import a = A; +} + +//// [unusedImports10.js] +var A; +(function (A) { + var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handelChar = function () { + }; + return Calculator; + }()); + A.Calculator = Calculator; +})(A || (A = {})); diff --git a/tests/baselines/reference/unusedImports2.errors.txt b/tests/baselines/reference/unusedImports2.errors.txt new file mode 100644 index 00000000000..d2b3a3c2bc5 --- /dev/null +++ b/tests/baselines/reference/unusedImports2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator} from "./file1" + import {test} from "./file1" + ~~~~ +!!! error TS6133: 'test' is declared but never used. + + var x = new Calculator(); + x.handleChar(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports2.js b/tests/baselines/reference/unusedImports2.js new file mode 100644 index 00000000000..f8918db5ab1 --- /dev/null +++ b/tests/baselines/reference/unusedImports2.js @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/unusedImports2.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +//// [file2.ts] +import {Calculator} from "./file1" +import {test} from "./file1" + +var x = new Calculator(); +x.handleChar(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); diff --git a/tests/baselines/reference/unusedImports3.errors.txt b/tests/baselines/reference/unusedImports3.errors.txt new file mode 100644 index 00000000000..fe398ab4f8e --- /dev/null +++ b/tests/baselines/reference/unusedImports3.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator, test, test2} from "./file1" + ~~~~~~~~~~ +!!! error TS6133: 'Calculator' is declared but never used. + + test(); + test2(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports3.js b/tests/baselines/reference/unusedImports3.js new file mode 100644 index 00000000000..5c0a3edf16b --- /dev/null +++ b/tests/baselines/reference/unusedImports3.js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/unusedImports3.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator, test, test2} from "./file1" + +test(); +test2(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +file1_1.test(); +file1_1.test2(); diff --git a/tests/baselines/reference/unusedImports4.errors.txt b/tests/baselines/reference/unusedImports4.errors.txt new file mode 100644 index 00000000000..872ef8e452e --- /dev/null +++ b/tests/baselines/reference/unusedImports4.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator, test, test2} from "./file1" + ~~~~ +!!! error TS6133: 'test' is declared but never used. + + var x = new Calculator(); + x.handleChar(); + test2(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports4.js b/tests/baselines/reference/unusedImports4.js new file mode 100644 index 00000000000..e95938091ae --- /dev/null +++ b/tests/baselines/reference/unusedImports4.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/unusedImports4.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test2(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); +file1_1.test2(); diff --git a/tests/baselines/reference/unusedImports5.errors.txt b/tests/baselines/reference/unusedImports5.errors.txt new file mode 100644 index 00000000000..deb9dd00f9c --- /dev/null +++ b/tests/baselines/reference/unusedImports5.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator, test, test2} from "./file1" + ~~~~~ +!!! error TS6133: 'test2' is declared but never used. + + var x = new Calculator(); + x.handleChar(); + test(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports5.js b/tests/baselines/reference/unusedImports5.js new file mode 100644 index 00000000000..cf92d01eb75 --- /dev/null +++ b/tests/baselines/reference/unusedImports5.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/unusedImports5.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); +file1_1.test(); diff --git a/tests/baselines/reference/unusedImports6.errors.txt b/tests/baselines/reference/unusedImports6.errors.txt new file mode 100644 index 00000000000..b27e50ab2d3 --- /dev/null +++ b/tests/baselines/reference/unusedImports6.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export default function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import d from "./file1" + ~ +!!! error TS6133: 'd' is declared but never used. + + + + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports6.js b/tests/baselines/reference/unusedImports6.js new file mode 100644 index 00000000000..2e203a62a1b --- /dev/null +++ b/tests/baselines/reference/unusedImports6.js @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/unusedImports6.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +//// [file2.ts] +import d from "./file1" + + + + + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.__esModule = true; +exports["default"] = test2; +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/unusedImports7.errors.txt b/tests/baselines/reference/unusedImports7.errors.txt new file mode 100644 index 00000000000..1ea8ed60635 --- /dev/null +++ b/tests/baselines/reference/unusedImports7.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export default function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import * as n from "./file1" + ~ +!!! error TS6133: 'n' is declared but never used. + + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports7.js b/tests/baselines/reference/unusedImports7.js new file mode 100644 index 00000000000..67524fcd22a --- /dev/null +++ b/tests/baselines/reference/unusedImports7.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/unusedImports7.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +//// [file2.ts] +import * as n from "./file1" + + + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.__esModule = true; +exports["default"] = test2; +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/unusedImports8.errors.txt b/tests/baselines/reference/unusedImports8.errors.txt new file mode 100644 index 00000000000..d82193106b7 --- /dev/null +++ b/tests/baselines/reference/unusedImports8.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator as calc, test as t1, test2 as t2} from "./file1" + ~~ +!!! error TS6133: 't2' is declared but never used. + + var x = new calc(); + x.handleChar(); + t1(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports8.js b/tests/baselines/reference/unusedImports8.js new file mode 100644 index 00000000000..2554472e6ce --- /dev/null +++ b/tests/baselines/reference/unusedImports8.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/unusedImports8.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator as calc, test as t1, test2 as t2} from "./file1" + +var x = new calc(); +x.handleChar(); +t1(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); +file1_1.test(); diff --git a/tests/baselines/reference/unusedImports9.errors.txt b/tests/baselines/reference/unusedImports9.errors.txt new file mode 100644 index 00000000000..8503a35e290 --- /dev/null +++ b/tests/baselines/reference/unusedImports9.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/file2.ts(1,8): error TS6133: 'c' is declared but never used. + + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import c = require('./file1') + ~ +!!! error TS6133: 'c' is declared but never used. +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports9.js b/tests/baselines/reference/unusedImports9.js new file mode 100644 index 00000000000..cd19e167b19 --- /dev/null +++ b/tests/baselines/reference/unusedImports9.js @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/unusedImports9.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import c = require('./file1') + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt new file mode 100644 index 00000000000..3fa066e5aae --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6133: 'i1' is declared but never used. + + +==== tests/cases/compiler/unusedInterfaceinNamespace1.ts (1 errors) ==== + + namespace Validation { + interface i1 { + ~~ +!!! error TS6133: 'i1' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.js b/tests/baselines/reference/unusedInterfaceinNamespace1.js new file mode 100644 index 00000000000..8b4334c13c7 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.js @@ -0,0 +1,9 @@ +//// [unusedInterfaceinNamespace1.ts] + +namespace Validation { + interface i1 { + + } +} + +//// [unusedInterfaceinNamespace1.js] diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt new file mode 100644 index 00000000000..0635e7be07b --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6133: 'i1' is declared but never used. + + +==== tests/cases/compiler/unusedInterfaceinNamespace2.ts (1 errors) ==== + + namespace Validation { + interface i1 { + ~~ +!!! error TS6133: 'i1' is declared but never used. + + } + + export interface i2 { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.js b/tests/baselines/reference/unusedInterfaceinNamespace2.js new file mode 100644 index 00000000000..fbec39921d3 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.js @@ -0,0 +1,13 @@ +//// [unusedInterfaceinNamespace2.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } +} + +//// [unusedInterfaceinNamespace2.js] diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt new file mode 100644 index 00000000000..8aa0e89ae1a --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6133: 'i3' is declared but never used. + + +==== tests/cases/compiler/unusedInterfaceinNamespace3.ts (1 errors) ==== + + namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + ~~ +!!! error TS6133: 'i3' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.js b/tests/baselines/reference/unusedInterfaceinNamespace3.js new file mode 100644 index 00000000000..7409a3d8623 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.js @@ -0,0 +1,17 @@ +//// [unusedInterfaceinNamespace3.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } +} + +//// [unusedInterfaceinNamespace3.js] diff --git a/tests/baselines/reference/unusedInterfaceinNamespace4.js b/tests/baselines/reference/unusedInterfaceinNamespace4.js new file mode 100644 index 00000000000..51e09a1565b --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace4.js @@ -0,0 +1,30 @@ +//// [unusedInterfaceinNamespace4.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } +} + +//// [unusedInterfaceinNamespace4.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + Validation.c1 = c1; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedInterfaceinNamespace4.symbols b/tests/baselines/reference/unusedInterfaceinNamespace4.symbols new file mode 100644 index 00000000000..90b2ff5df70 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace4.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace4.ts === + +namespace Validation { +>Validation : Symbol(Validation, Decl(unusedInterfaceinNamespace4.ts, 0, 0)) + + interface i1 { +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace4.ts, 1, 22)) + + } + + export interface i2 { +>i2 : Symbol(i2, Decl(unusedInterfaceinNamespace4.ts, 4, 5)) + + } + + interface i3 extends i1 { +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace4.ts, 8, 5)) +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace4.ts, 1, 22)) + + } + + export class c1 implements i3 { +>c1 : Symbol(c1, Decl(unusedInterfaceinNamespace4.ts, 12, 5)) +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace4.ts, 8, 5)) + + } +} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace4.types b/tests/baselines/reference/unusedInterfaceinNamespace4.types new file mode 100644 index 00000000000..1b1efebb299 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace4.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace4.ts === + +namespace Validation { +>Validation : typeof Validation + + interface i1 { +>i1 : i1 + + } + + export interface i2 { +>i2 : i2 + + } + + interface i3 extends i1 { +>i3 : i3 +>i1 : i1 + + } + + export class c1 implements i3 { +>c1 : c1 +>i3 : i3 + + } +} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace5.js b/tests/baselines/reference/unusedInterfaceinNamespace5.js new file mode 100644 index 00000000000..bb29b33ebca --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace5.js @@ -0,0 +1,36 @@ +//// [unusedInterfaceinNamespace5.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } + + interface i4 { + + } + + export let c2:i4; +} + +//// [unusedInterfaceinNamespace5.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + Validation.c1 = c1; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedInterfaceinNamespace5.symbols b/tests/baselines/reference/unusedInterfaceinNamespace5.symbols new file mode 100644 index 00000000000..156dc9a3ef1 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace5.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace5.ts === + +namespace Validation { +>Validation : Symbol(Validation, Decl(unusedInterfaceinNamespace5.ts, 0, 0)) + + interface i1 { +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace5.ts, 1, 22)) + + } + + export interface i2 { +>i2 : Symbol(i2, Decl(unusedInterfaceinNamespace5.ts, 4, 5)) + + } + + interface i3 extends i1 { +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace5.ts, 8, 5)) +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace5.ts, 1, 22)) + + } + + export class c1 implements i3 { +>c1 : Symbol(c1, Decl(unusedInterfaceinNamespace5.ts, 12, 5)) +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace5.ts, 8, 5)) + + } + + interface i4 { +>i4 : Symbol(i4, Decl(unusedInterfaceinNamespace5.ts, 16, 5)) + + } + + export let c2:i4; +>c2 : Symbol(c2, Decl(unusedInterfaceinNamespace5.ts, 22, 14)) +>i4 : Symbol(i4, Decl(unusedInterfaceinNamespace5.ts, 16, 5)) +} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace5.types b/tests/baselines/reference/unusedInterfaceinNamespace5.types new file mode 100644 index 00000000000..db896be80ae --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace5.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace5.ts === + +namespace Validation { +>Validation : typeof Validation + + interface i1 { +>i1 : i1 + + } + + export interface i2 { +>i2 : i2 + + } + + interface i3 extends i1 { +>i3 : i3 +>i1 : i1 + + } + + export class c1 implements i3 { +>c1 : c1 +>i3 : i3 + + } + + interface i4 { +>i4 : i4 + + } + + export let c2:i4; +>c2 : i4 +>i4 : i4 +} diff --git a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt new file mode 100644 index 00000000000..18141e5acdd --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsInMethod1.ts (1 errors) ==== + + class greeter { + public function1() { + var x = 10; + ~ +!!! error TS6133: 'x' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod1.js b/tests/baselines/reference/unusedLocalsInMethod1.js new file mode 100644 index 00000000000..7f2e555ab62 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod1.js @@ -0,0 +1,17 @@ +//// [unusedLocalsInMethod1.ts] + +class greeter { + public function1() { + var x = 10; + } +} + +//// [unusedLocalsInMethod1.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var x = 10; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt new file mode 100644 index 00000000000..524580bcdf4 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsInMethod2.ts (1 errors) ==== + + class greeter { + public function1() { + var x, y = 10; + ~ +!!! error TS6133: 'x' is declared but never used. + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod2.js b/tests/baselines/reference/unusedLocalsInMethod2.js new file mode 100644 index 00000000000..b92de249750 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod2.js @@ -0,0 +1,19 @@ +//// [unusedLocalsInMethod2.ts] + +class greeter { + public function1() { + var x, y = 10; + y++; + } +} + +//// [unusedLocalsInMethod2.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var x, y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt new file mode 100644 index 00000000000..b82ceaedba2 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsInMethod3.ts (1 errors) ==== + + class greeter { + public function1() { + var x, y; + ~ +!!! error TS6133: 'x' is declared but never used. + y = 1; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod3.js b/tests/baselines/reference/unusedLocalsInMethod3.js new file mode 100644 index 00000000000..ff148f7a78f --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod3.js @@ -0,0 +1,19 @@ +//// [unusedLocalsInMethod3.ts] + +class greeter { + public function1() { + var x, y; + y = 1; + } +} + +//// [unusedLocalsInMethod3.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var x, y; + y = 1; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt new file mode 100644 index 00000000000..fa8337c8f17 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): error TS6133: 'unused2' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + function maker(child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js new file mode 100644 index 00000000000..a8da9dcfa87 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js] +function greeter(person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt new file mode 100644 index 00000000000..0e56f97d1a3 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): error TS6133: 'unused3' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + function maker(child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + function maker2(child2: string): void { + ~~~~~~ +!!! error TS6133: 'child2' is declared but never used. + var unused3 = 23; + ~~~~~~~ +!!! error TS6133: 'unused3' is declared but never used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js new file mode 100644 index 00000000000..28b5057d640 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js] +function greeter(person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + function maker2(child2) { + var unused3 = 23; + } + maker2(person2); +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt new file mode 100644 index 00000000000..0b161952835 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): error TS6133: 'unused2' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + function maker(child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js new file mode 100644 index 00000000000..b9c76493239 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js] +var greeter = function (person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + person2 = "dummy value"; +}; diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt new file mode 100644 index 00000000000..7e772d98637 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): error TS6133: 'unused3' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + function maker(child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + function maker2(child2: string): void { + ~~~~~~ +!!! error TS6133: 'child2' is declared but never used. + var unused3 = 23; + ~~~~~~~ +!!! error TS6133: 'unused3' is declared but never used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js new file mode 100644 index 00000000000..e7930da686c --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js] +var greeter = function (person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + function maker2(child2) { + var unused3 = 23; + } + maker2(person2); +}; diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt new file mode 100644 index 00000000000..99a4fef8958 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): error TS6133: 'unused2' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + var maker = function (child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js new file mode 100644 index 00000000000..880053a8667 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js] +function greeter(person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt new file mode 100644 index 00000000000..8eb1e73d87c --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): error TS6133: 'unused3' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + var maker = function(child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + var maker2 = function(child2: string): void { + ~~~~~~ +!!! error TS6133: 'child2' is declared but never used. + var unused3 = 23; + ~~~~~~~ +!!! error TS6133: 'unused3' is declared but never used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js new file mode 100644 index 00000000000..fb37bf9cb5a --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function(child: string): void { + var unused2 = 22; + } + var maker2 = function(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js] +function greeter(person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + var maker2 = function (child2) { + var unused3 = 23; + }; + maker2(person2); +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt new file mode 100644 index 00000000000..dd4778b4f3d --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): error TS6133: 'unused2' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + var maker = function (child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js new file mode 100644 index 00000000000..299c0e97b94 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js] +var greeter = function (person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + person2 = "dummy value"; +}; diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt new file mode 100644 index 00000000000..6d22b7a2bde --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): error TS6133: 'unused3' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + var maker = function (child: string): void { + ~~~~~ +!!! error TS6133: 'maker' is declared but never used. + ~~~~~ +!!! error TS6133: 'child' is declared but never used. + var unused2 = 22; + ~~~~~~~ +!!! error TS6133: 'unused2' is declared but never used. + } + var maker2 = function (child2: string): void { + ~~~~~~ +!!! error TS6133: 'child2' is declared but never used. + var unused3 = 23; + ~~~~~~~ +!!! error TS6133: 'unused3' is declared but never used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js new file mode 100644 index 00000000000..00ba31b16d7 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + var maker2 = function (child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js] +var greeter = function (person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + var maker2 = function (child2) { + var unused3 = 23; + }; + maker2(person2); +}; diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt new file mode 100644 index 00000000000..6fa3ef08839 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsinConstructor1.ts (1 errors) ==== + + class greeter { + constructor() { + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.js b/tests/baselines/reference/unusedLocalsinConstructor1.js new file mode 100644 index 00000000000..28bd7573068 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor1.js @@ -0,0 +1,15 @@ +//// [unusedLocalsinConstructor1.ts] + +class greeter { + constructor() { + var unused = 20; + } +} + +//// [unusedLocalsinConstructor1.js] +var greeter = (function () { + function greeter() { + var unused = 20; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt new file mode 100644 index 00000000000..44c0bddf87c --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsinConstructor2.ts (1 errors) ==== + + class greeter { + constructor() { + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + var used = "dummy"; + used = used + "second part"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.js b/tests/baselines/reference/unusedLocalsinConstructor2.js new file mode 100644 index 00000000000..2fda63d28a3 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor2.js @@ -0,0 +1,19 @@ +//// [unusedLocalsinConstructor2.ts] + +class greeter { + constructor() { + var unused = 20; + var used = "dummy"; + used = used + "second part"; + } +} + +//// [unusedLocalsinConstructor2.js] +var greeter = (function () { + function greeter() { + var unused = 20; + var used = "dummy"; + used = used + "second part"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedMethodsInInterface.js b/tests/baselines/reference/unusedMethodsInInterface.js new file mode 100644 index 00000000000..7a1142d99b9 --- /dev/null +++ b/tests/baselines/reference/unusedMethodsInInterface.js @@ -0,0 +1,8 @@ +//// [unusedMethodsInInterface.ts] + +interface I1 { + f1(); + f2(x: number, y: string); +} + +//// [unusedMethodsInInterface.js] diff --git a/tests/baselines/reference/unusedMethodsInInterface.symbols b/tests/baselines/reference/unusedMethodsInInterface.symbols new file mode 100644 index 00000000000..66e4c6cb100 --- /dev/null +++ b/tests/baselines/reference/unusedMethodsInInterface.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/unusedMethodsInInterface.ts === + +interface I1 { +>I1 : Symbol(I1, Decl(unusedMethodsInInterface.ts, 0, 0)) + + f1(); +>f1 : Symbol(I1.f1, Decl(unusedMethodsInInterface.ts, 1, 14)) + + f2(x: number, y: string); +>f2 : Symbol(I1.f2, Decl(unusedMethodsInInterface.ts, 2, 9)) +>x : Symbol(x, Decl(unusedMethodsInInterface.ts, 3, 7)) +>y : Symbol(y, Decl(unusedMethodsInInterface.ts, 3, 17)) +} diff --git a/tests/baselines/reference/unusedMethodsInInterface.types b/tests/baselines/reference/unusedMethodsInInterface.types new file mode 100644 index 00000000000..eb1befac9f0 --- /dev/null +++ b/tests/baselines/reference/unusedMethodsInInterface.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/unusedMethodsInInterface.ts === + +interface I1 { +>I1 : I1 + + f1(); +>f1 : () => any + + f2(x: number, y: string); +>f2 : (x: number, y: string) => any +>x : number +>y : string +} diff --git a/tests/baselines/reference/unusedModuleInModule.errors.txt b/tests/baselines/reference/unusedModuleInModule.errors.txt new file mode 100644 index 00000000000..2430b07c392 --- /dev/null +++ b/tests/baselines/reference/unusedModuleInModule.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedModuleInModule.ts(3,12): error TS6133: 'B' is declared but never used. + + +==== tests/cases/compiler/unusedModuleInModule.ts (1 errors) ==== + + module A { + module B {} + ~ +!!! error TS6133: 'B' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedModuleInModule.js b/tests/baselines/reference/unusedModuleInModule.js new file mode 100644 index 00000000000..68042be9321 --- /dev/null +++ b/tests/baselines/reference/unusedModuleInModule.js @@ -0,0 +1,7 @@ +//// [unusedModuleInModule.ts] + +module A { + module B {} +} + +//// [unusedModuleInModule.js] diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt new file mode 100644 index 00000000000..28cfc1d578f --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== + + class Dummy { + constructor(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "Dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.js b/tests/baselines/reference/unusedMultipleParameter1InContructor.js new file mode 100644 index 00000000000..e236ea3d26a --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.js @@ -0,0 +1,17 @@ +//// [unusedMultipleParameter1InContructor.ts] + +class Dummy { + constructor(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; + } +} + +//// [unusedMultipleParameter1InContructor.js] +var Dummy = (function () { + function Dummy(person, person2) { + var unused = 20; + person2 = "Dummy value"; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt new file mode 100644 index 00000000000..d841f7064a1 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== + + var func = function(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "Dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js new file mode 100644 index 00000000000..55a697cc3e0 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameter1InFunctionExpression.ts] + +var func = function(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; +} + +//// [unusedMultipleParameter1InFunctionExpression.js] +var func = function (person, person2) { + var unused = 20; + person2 = "Dummy value"; +}; diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt new file mode 100644 index 00000000000..2397a849c5c --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== + + class Dummy { + constructor(person: string, person2: string, person3: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + ~~~~~~~ +!!! error TS6133: 'person3' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "Dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.js b/tests/baselines/reference/unusedMultipleParameter2InContructor.js new file mode 100644 index 00000000000..8ffd4c36591 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.js @@ -0,0 +1,17 @@ +//// [unusedMultipleParameter2InContructor.ts] + +class Dummy { + constructor(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; + } +} + +//// [unusedMultipleParameter2InContructor.js] +var Dummy = (function () { + function Dummy(person, person2, person3) { + var unused = 20; + person2 = "Dummy value"; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt new file mode 100644 index 00000000000..1a4e78cd9fa --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== + + var func = function(person: string, person2: string, person3: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + ~~~~~~~ +!!! error TS6133: 'person3' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "Dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js new file mode 100644 index 00000000000..1c35c1762f3 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameter2InFunctionExpression.ts] + +var func = function(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; +} + +//// [unusedMultipleParameter2InFunctionExpression.js] +var func = function (person, person2, person3) { + var unused = 20; + person2 = "Dummy value"; +}; diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt new file mode 100644 index 00000000000..5ca5eb3bd0c --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js new file mode 100644 index 00000000000..caac12c8735 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameters1InFunctionDeclaration.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; +} + +//// [unusedMultipleParameters1InFunctionDeclaration.js] +function greeter(person, person2) { + var unused = 20; + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt new file mode 100644 index 00000000000..9e917be257e --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (2 errors) ==== + + class Dummy { + public greeter(person: string, person2: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js new file mode 100644 index 00000000000..bc78da7bd75 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js @@ -0,0 +1,19 @@ +//// [unusedMultipleParameters1InMethodDeclaration.ts] + +class Dummy { + public greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; + } +} + +//// [unusedMultipleParameters1InMethodDeclaration.js] +var Dummy = (function () { + function Dummy() { + } + Dummy.prototype.greeter = function (person, person2) { + var unused = 20; + person2 = "dummy value"; + }; + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt new file mode 100644 index 00000000000..0c755b404cd --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== + + function greeter(person: string, person2: string, person3: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + ~~~~~~~ +!!! error TS6133: 'person3' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js new file mode 100644 index 00000000000..1197cabf646 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameters2InFunctionDeclaration.ts] + +function greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; +} + +//// [unusedMultipleParameters2InFunctionDeclaration.js] +function greeter(person, person2, person3) { + var unused = 20; + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt new file mode 100644 index 00000000000..ab3313dc98b --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (3 errors) ==== + + class Dummy { + public greeter(person: string, person2: string, person3: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + ~~~~~~~ +!!! error TS6133: 'person3' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + person2 = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js new file mode 100644 index 00000000000..80f93990b5b --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js @@ -0,0 +1,19 @@ +//// [unusedMultipleParameters2InMethodDeclaration.ts] + +class Dummy { + public greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; + } +} + +//// [unusedMultipleParameters2InMethodDeclaration.js] +var Dummy = (function () { + function Dummy() { + } + Dummy.prototype.greeter = function (person, person2, person3) { + var unused = 20; + person2 = "dummy value"; + }; + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedNamespaceInModule.errors.txt b/tests/baselines/reference/unusedNamespaceInModule.errors.txt new file mode 100644 index 00000000000..78e389f4c47 --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInModule.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedNamespaceInModule.ts(3,15): error TS6133: 'B' is declared but never used. + + +==== tests/cases/compiler/unusedNamespaceInModule.ts (1 errors) ==== + + module A { + namespace B { } + ~ +!!! error TS6133: 'B' is declared but never used. + export namespace C {} + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInModule.js b/tests/baselines/reference/unusedNamespaceInModule.js new file mode 100644 index 00000000000..238ff84767c --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInModule.js @@ -0,0 +1,8 @@ +//// [unusedNamespaceInModule.ts] + +module A { + namespace B { } + export namespace C {} +} + +//// [unusedNamespaceInModule.js] diff --git a/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt new file mode 100644 index 00000000000..53582b8bec7 --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedNamespaceInNamespace.ts(3,15): error TS6133: 'B' is declared but never used. + + +==== tests/cases/compiler/unusedNamespaceInNamespace.ts (1 errors) ==== + + namespace A { + namespace B { } + ~ +!!! error TS6133: 'B' is declared but never used. + export namespace C {} + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInNamespace.js b/tests/baselines/reference/unusedNamespaceInNamespace.js new file mode 100644 index 00000000000..1dc8103d77f --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInNamespace.js @@ -0,0 +1,8 @@ +//// [unusedNamespaceInNamespace.ts] + +namespace A { + namespace B { } + export namespace C {} +} + +//// [unusedNamespaceInNamespace.js] diff --git a/tests/baselines/reference/unusedParameterInCatchClause.errors.txt b/tests/baselines/reference/unusedParameterInCatchClause.errors.txt new file mode 100644 index 00000000000..e996763e2c6 --- /dev/null +++ b/tests/baselines/reference/unusedParameterInCatchClause.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedParameterInCatchClause.ts(3,18): error TS6133: 'ex' is declared but never used. + + +==== tests/cases/compiler/unusedParameterInCatchClause.ts (1 errors) ==== + + function f1() { + try {} catch(ex){} + ~~ +!!! error TS6133: 'ex' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterInCatchClause.js b/tests/baselines/reference/unusedParameterInCatchClause.js new file mode 100644 index 00000000000..153ee17926e --- /dev/null +++ b/tests/baselines/reference/unusedParameterInCatchClause.js @@ -0,0 +1,11 @@ +//// [unusedParameterInCatchClause.ts] + +function f1() { + try {} catch(ex){} +} + +//// [unusedParameterInCatchClause.js] +function f1() { + try { } + catch (ex) { } +} diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.js b/tests/baselines/reference/unusedParameterUsedInTypeOf.js new file mode 100644 index 00000000000..fc2589c31ff --- /dev/null +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.js @@ -0,0 +1,10 @@ +//// [unusedParameterUsedInTypeOf.ts] + +function f1 (a: number, b: typeof a) { + b++; +} + +//// [unusedParameterUsedInTypeOf.js] +function f1(a, b) { + b++; +} diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols new file mode 100644 index 00000000000..9730baca34f --- /dev/null +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/unusedParameterUsedInTypeOf.ts === + +function f1 (a: number, b: typeof a) { +>f1 : Symbol(f1, Decl(unusedParameterUsedInTypeOf.ts, 0, 0)) +>a : Symbol(a, Decl(unusedParameterUsedInTypeOf.ts, 1, 13)) +>b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 1, 23)) +>a : Symbol(a, Decl(unusedParameterUsedInTypeOf.ts, 1, 13)) + + b++; +>b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 1, 23)) +} diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.types b/tests/baselines/reference/unusedParameterUsedInTypeOf.types new file mode 100644 index 00000000000..d3b5bb67661 --- /dev/null +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/unusedParameterUsedInTypeOf.ts === + +function f1 (a: number, b: typeof a) { +>f1 : (a: number, b: number) => void +>a : number +>b : number +>a : number + + b++; +>b++ : number +>b : number +} diff --git a/tests/baselines/reference/unusedParametersInLambda1.errors.txt b/tests/baselines/reference/unusedParametersInLambda1.errors.txt new file mode 100644 index 00000000000..2c54de1d571 --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedParametersInLambda1.ts(4,17): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedParametersInLambda1.ts (1 errors) ==== + + class A { + public f1() { + return (X) => { + ~ +!!! error TS6133: 'X' is declared but never used. + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersInLambda1.js b/tests/baselines/reference/unusedParametersInLambda1.js new file mode 100644 index 00000000000..c3ca54bd6a7 --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda1.js @@ -0,0 +1,19 @@ +//// [unusedParametersInLambda1.ts] + +class A { + public f1() { + return (X) => { + } + } +} + +//// [unusedParametersInLambda1.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function (X) { + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedParametersInLambda2.errors.txt b/tests/baselines/reference/unusedParametersInLambda2.errors.txt new file mode 100644 index 00000000000..3044e6d9c88 --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedParametersInLambda2.ts(4,17): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedParametersInLambda2.ts (1 errors) ==== + + class A { + public f1() { + return (X, Y) => { + ~ +!!! error TS6133: 'X' is declared but never used. + Y; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersInLambda2.js b/tests/baselines/reference/unusedParametersInLambda2.js new file mode 100644 index 00000000000..b7833af340e --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda2.js @@ -0,0 +1,21 @@ +//// [unusedParametersInLambda2.ts] + +class A { + public f1() { + return (X, Y) => { + Y; + } + } +} + +//// [unusedParametersInLambda2.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function (X, Y) { + Y; + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt new file mode 100644 index 00000000000..d09d5906ed1 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6133: 'param1' is declared but never used. + + +==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== + + class greeter { + constructor(param1: string) { + ~~~~~~ +!!! error TS6133: 'param1' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor1.js b/tests/baselines/reference/unusedParametersinConstructor1.js new file mode 100644 index 00000000000..500d7a45eb2 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor1.js @@ -0,0 +1,13 @@ +//// [unusedParametersinConstructor1.ts] + +class greeter { + constructor(param1: string) { + } +} + +//// [unusedParametersinConstructor1.js] +var greeter = (function () { + function greeter(param1) { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt new file mode 100644 index 00000000000..4566713f24f --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6133: 'param1' is declared but never used. + + +==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== + + class greeter { + constructor(param1: string, param2: string) { + ~~~~~~ +!!! error TS6133: 'param1' is declared but never used. + param2 = param2 + "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.js b/tests/baselines/reference/unusedParametersinConstructor2.js new file mode 100644 index 00000000000..97bbf21ee04 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor2.js @@ -0,0 +1,15 @@ +//// [unusedParametersinConstructor2.ts] + +class greeter { + constructor(param1: string, param2: string) { + param2 = param2 + "dummy value"; + } +} + +//// [unusedParametersinConstructor2.js] +var greeter = (function () { + function greeter(param1, param2) { + param2 = param2 + "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt new file mode 100644 index 00000000000..48891e5361e --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6133: 'param3' is declared but never used. + + +==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== + + class greeter { + constructor(param1: string, param2: string, param3: string) { + ~~~~~~ +!!! error TS6133: 'param1' is declared but never used. + ~~~~~~ +!!! error TS6133: 'param3' is declared but never used. + param2 = param2 + "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.js b/tests/baselines/reference/unusedParametersinConstructor3.js new file mode 100644 index 00000000000..06ac99229ac --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor3.js @@ -0,0 +1,15 @@ +//// [unusedParametersinConstructor3.ts] + +class greeter { + constructor(param1: string, param2: string, param3: string) { + param2 = param2 + "dummy value"; + } +} + +//// [unusedParametersinConstructor3.js] +var greeter = (function () { + function greeter(param1, param2, param3) { + param2 = param2 + "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt new file mode 100644 index 00000000000..40357c0b7f0 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6133: 'function1' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (1 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + var y = 10; + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.js b/tests/baselines/reference/unusedPrivateMethodInClass1.js new file mode 100644 index 00000000000..18e6fc339c3 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.js @@ -0,0 +1,19 @@ +//// [unusedPrivateMethodInClass1.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } +} + +//// [unusedPrivateMethodInClass1.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt new file mode 100644 index 00000000000..36a7a3c40d0 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6133: 'function2' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (2 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + var y = 10; + y++; + } + + private function2() { + ~~~~~~~~~ +!!! error TS6133: 'function2' is declared but never used. + var y = 10; + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.js b/tests/baselines/reference/unusedPrivateMethodInClass2.js new file mode 100644 index 00000000000..6a1dbd4df68 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.js @@ -0,0 +1,28 @@ +//// [unusedPrivateMethodInClass2.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } +} + +//// [unusedPrivateMethodInClass2.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + greeter.prototype.function2 = function () { + var y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt new file mode 100644 index 00000000000..365cfb32135 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6133: 'function2' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (2 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + var y = 10; + y++; + } + + private function2() { + ~~~~~~~~~ +!!! error TS6133: 'function2' is declared but never used. + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.js b/tests/baselines/reference/unusedPrivateMethodInClass3.js new file mode 100644 index 00000000000..0009a52f8b6 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.js @@ -0,0 +1,37 @@ +//// [unusedPrivateMethodInClass3.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + } +} + +//// [unusedPrivateMethodInClass3.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + greeter.prototype.function2 = function () { + var y = 10; + y++; + }; + greeter.prototype.function3 = function () { + var y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt new file mode 100644 index 00000000000..324e7d17bbc --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6133: 'function1' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (1 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! error TS6133: 'function1' is declared but never used. + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + this.function2(); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.js b/tests/baselines/reference/unusedPrivateMethodInClass4.js new file mode 100644 index 00000000000..6bf2b928fa4 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.js @@ -0,0 +1,39 @@ +//// [unusedPrivateMethodInClass4.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + this.function2(); + } +} + +//// [unusedPrivateMethodInClass4.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + greeter.prototype.function2 = function () { + var y = 10; + y++; + }; + greeter.prototype.function3 = function () { + var y = 10; + y++; + this.function2(); + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt new file mode 100644 index 00000000000..bb971334135 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== + + class greeter { + private x: string; + ~ +!!! error TS6133: 'x' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.js b/tests/baselines/reference/unusedPrivateVariableInClass1.js new file mode 100644 index 00000000000..464676490d8 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.js @@ -0,0 +1,12 @@ +//// [unusedPrivateVariableInClass1.ts] + +class greeter { + private x: string; +} + +//// [unusedPrivateVariableInClass1.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt new file mode 100644 index 00000000000..3b814e5ca7c --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,13): error TS6133: 'y' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== + + class greeter { + private x: string; + ~ +!!! error TS6133: 'x' is declared but never used. + private y: string; + ~ +!!! error TS6133: 'y' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.js b/tests/baselines/reference/unusedPrivateVariableInClass2.js new file mode 100644 index 00000000000..329e2bbe2b6 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.js @@ -0,0 +1,13 @@ +//// [unusedPrivateVariableInClass2.ts] + +class greeter { + private x: string; + private y: string; +} + +//// [unusedPrivateVariableInClass2.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt new file mode 100644 index 00000000000..5d5e18a2fdf --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,13): error TS6133: 'y' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== + + class greeter { + private x: string; + ~ +!!! error TS6133: 'x' is declared but never used. + private y: string; + ~ +!!! error TS6133: 'y' is declared but never used. + public z: string; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.js b/tests/baselines/reference/unusedPrivateVariableInClass3.js new file mode 100644 index 00000000000..c72b9e61995 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.js @@ -0,0 +1,14 @@ +//// [unusedPrivateVariableInClass3.ts] + +class greeter { + private x: string; + private y: string; + public z: string; +} + +//// [unusedPrivateVariableInClass3.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt new file mode 100644 index 00000000000..83325cf2d8a --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,13): error TS6133: 'y' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== + + class greeter { + private x: string; + private y: string; + ~ +!!! error TS6133: 'y' is declared but never used. + public z: string; + + public method1() { + this.x = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.js b/tests/baselines/reference/unusedPrivateVariableInClass4.js new file mode 100644 index 00000000000..878a7780e85 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.js @@ -0,0 +1,21 @@ +//// [unusedPrivateVariableInClass4.ts] + +class greeter { + private x: string; + private y: string; + public z: string; + + public method1() { + this.x = "dummy value"; + } +} + +//// [unusedPrivateVariableInClass4.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.method1 = function () { + this.x = "dummy value"; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt new file mode 100644 index 00000000000..741406c5284 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,13): error TS6133: 'y' is declared but never used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== + + class greeter { + private x: string; + private y: string; + ~ +!!! error TS6133: 'y' is declared but never used. + public z: string; + + constructor() { + this.x = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.js b/tests/baselines/reference/unusedPrivateVariableInClass5.js new file mode 100644 index 00000000000..4d9b3017222 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.js @@ -0,0 +1,19 @@ +//// [unusedPrivateVariableInClass5.ts] + +class greeter { + private x: string; + private y: string; + public z: string; + + constructor() { + this.x = "dummy value"; + } +} + +//// [unusedPrivateVariableInClass5.js] +var greeter = (function () { + function greeter() { + this.x = "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedSetterInClass.js b/tests/baselines/reference/unusedSetterInClass.js new file mode 100644 index 00000000000..aff12b7d043 --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.js @@ -0,0 +1,23 @@ +//// [unusedSetterInClass.ts] + +class Employee { + private _fullName: string; + + set fullName(newName: string) { + this._fullName = newName; + } +} + +//// [unusedSetterInClass.js] +var Employee = (function () { + function Employee() { + } + Object.defineProperty(Employee.prototype, "fullName", { + set: function (newName) { + this._fullName = newName; + }, + enumerable: true, + configurable: true + }); + return Employee; +}()); diff --git a/tests/baselines/reference/unusedSetterInClass.symbols b/tests/baselines/reference/unusedSetterInClass.symbols new file mode 100644 index 00000000000..511b106aded --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/unusedSetterInClass.ts === + +class Employee { +>Employee : Symbol(Employee, Decl(unusedSetterInClass.ts, 0, 0)) + + private _fullName: string; +>_fullName : Symbol(Employee._fullName, Decl(unusedSetterInClass.ts, 1, 16)) + + set fullName(newName: string) { +>fullName : Symbol(Employee.fullName, Decl(unusedSetterInClass.ts, 2, 30)) +>newName : Symbol(newName, Decl(unusedSetterInClass.ts, 4, 17)) + + this._fullName = newName; +>this._fullName : Symbol(Employee._fullName, Decl(unusedSetterInClass.ts, 1, 16)) +>this : Symbol(Employee, Decl(unusedSetterInClass.ts, 0, 0)) +>_fullName : Symbol(Employee._fullName, Decl(unusedSetterInClass.ts, 1, 16)) +>newName : Symbol(newName, Decl(unusedSetterInClass.ts, 4, 17)) + } +} diff --git a/tests/baselines/reference/unusedSetterInClass.types b/tests/baselines/reference/unusedSetterInClass.types new file mode 100644 index 00000000000..9a74ef383ae --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/unusedSetterInClass.ts === + +class Employee { +>Employee : Employee + + private _fullName: string; +>_fullName : string + + set fullName(newName: string) { +>fullName : string +>newName : string + + this._fullName = newName; +>this._fullName = newName : string +>this._fullName : string +>this : this +>_fullName : string +>newName : string + } +} diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt new file mode 100644 index 00000000000..2549266dfc2 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== + + class Dummy { + constructor(person: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.js b/tests/baselines/reference/unusedSingleParameterInContructor.js new file mode 100644 index 00000000000..172f9e20ab8 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInContructor.js @@ -0,0 +1,15 @@ +//// [unusedSingleParameterInContructor.ts] + +class Dummy { + constructor(person: string) { + var unused = 20; + } +} + +//// [unusedSingleParameterInContructor.js] +var Dummy = (function () { + function Dummy(person) { + var unused = 20; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt new file mode 100644 index 00000000000..e29269e9b05 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== + + function greeter(person: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js new file mode 100644 index 00000000000..0ee7c3d608a --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js @@ -0,0 +1,10 @@ +//// [unusedSingleParameterInFunctionDeclaration.ts] + +function greeter(person: string) { + var unused = 20; +} + +//// [unusedSingleParameterInFunctionDeclaration.js] +function greeter(person) { + var unused = 20; +} diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt new file mode 100644 index 00000000000..ad3e5e67a72 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== + + var func = function(person: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.js b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.js new file mode 100644 index 00000000000..578707e43cc --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.js @@ -0,0 +1,10 @@ +//// [unusedSingleParameterInFunctionExpression.ts] + +var func = function(person: string) { + var unused = 20; +} + +//// [unusedSingleParameterInFunctionExpression.js] +var func = function (person) { + var unused = 20; +}; diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt new file mode 100644 index 00000000000..af806bbadfb --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS6133: 'unused' is declared but never used. + + +==== tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts (2 errors) ==== + + class Dummy { + public greeter(person: string) { + ~~~~~~ +!!! error TS6133: 'person' is declared but never used. + var unused = 20; + ~~~~~~ +!!! error TS6133: 'unused' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js new file mode 100644 index 00000000000..993866086db --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js @@ -0,0 +1,17 @@ +//// [unusedSingleParameterInMethodDeclaration.ts] + +class Dummy { + public greeter(person: string) { + var unused = 20; + } +} + +//// [unusedSingleParameterInMethodDeclaration.js] +var Dummy = (function () { + function Dummy() { + } + Dummy.prototype.greeter = function (person) { + var unused = 20; + }; + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt new file mode 100644 index 00000000000..afbdb09c162 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameterInFunction1.ts(2,13): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction1.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'T' is declared but never used. + + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction1.js b/tests/baselines/reference/unusedTypeParameterInFunction1.js new file mode 100644 index 00000000000..6ecf90343b7 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction1.js @@ -0,0 +1,9 @@ +//// [unusedTypeParameterInFunction1.ts] + +function f1() { + +} + +//// [unusedTypeParameterInFunction1.js] +function f1() { +} diff --git a/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt new file mode 100644 index 00000000000..0097cc99810 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedTypeParameterInFunction2.ts(2,16): error TS6133: 'Y' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction2.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'Y' is declared but never used. + var a: X; + a; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction2.js b/tests/baselines/reference/unusedTypeParameterInFunction2.js new file mode 100644 index 00000000000..7c3eaa91127 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction2.js @@ -0,0 +1,12 @@ +//// [unusedTypeParameterInFunction2.ts] + +function f1() { + var a: X; + a; +} + +//// [unusedTypeParameterInFunction2.js] +function f1() { + var a; + a; +} diff --git a/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt new file mode 100644 index 00000000000..7a2e33769da --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedTypeParameterInFunction3.ts(2,16): error TS6133: 'Y' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction3.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'Y' is declared but never used. + var a: X; + var b: Z; + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction3.js b/tests/baselines/reference/unusedTypeParameterInFunction3.js new file mode 100644 index 00000000000..335a5668acc --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction3.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInFunction3.ts] + +function f1() { + var a: X; + var b: Z; + a; + b; +} + +//// [unusedTypeParameterInFunction3.js] +function f1() { + var a; + var b; + a; + b; +} diff --git a/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt new file mode 100644 index 00000000000..7840ff31df3 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedTypeParameterInFunction4.ts(2,13): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction4.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'X' is declared but never used. + var a: Y; + var b: Z; + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction4.js b/tests/baselines/reference/unusedTypeParameterInFunction4.js new file mode 100644 index 00000000000..e6b26dfbd4e --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction4.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInFunction4.ts] + +function f1() { + var a: Y; + var b: Z; + a; + b; +} + +//// [unusedTypeParameterInFunction4.js] +function f1() { + var a; + var b; + a; + b; +} diff --git a/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt new file mode 100644 index 00000000000..fbe6ef3f0d1 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameterInInterface1.ts(2,15): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInInterface1.ts (1 errors) ==== + + interface int { + ~ +!!! error TS6133: 'T' is declared but never used. + + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInInterface1.js b/tests/baselines/reference/unusedTypeParameterInInterface1.js new file mode 100644 index 00000000000..8f9a6962b35 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface1.js @@ -0,0 +1,7 @@ +//// [unusedTypeParameterInInterface1.ts] + +interface int { + +} + +//// [unusedTypeParameterInInterface1.js] diff --git a/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt new file mode 100644 index 00000000000..ed3e5847774 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedTypeParameterInInterface2.ts(2,18): error TS6133: 'U' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInInterface2.ts (1 errors) ==== + + interface int { + ~ +!!! error TS6133: 'U' is declared but never used. + f1(a: T): string; + c: V; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInInterface2.js b/tests/baselines/reference/unusedTypeParameterInInterface2.js new file mode 100644 index 00000000000..d5a4c490d27 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface2.js @@ -0,0 +1,8 @@ +//// [unusedTypeParameterInInterface2.ts] + +interface int { + f1(a: T): string; + c: V; +} + +//// [unusedTypeParameterInInterface2.js] diff --git a/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt new file mode 100644 index 00000000000..a84df63b317 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedTypeParameterInLambda1.ts(4,17): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInLambda1.ts (1 errors) ==== + + class A { + public f1() { + return () => { + ~ +!!! error TS6133: 'T' is declared but never used. + + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda1.js b/tests/baselines/reference/unusedTypeParameterInLambda1.js new file mode 100644 index 00000000000..0f55a4a32a1 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda1.js @@ -0,0 +1,20 @@ +//// [unusedTypeParameterInLambda1.ts] + +class A { + public f1() { + return () => { + + } + } +} + +//// [unusedTypeParameterInLambda1.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function () { + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt new file mode 100644 index 00000000000..c1104743472 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInLambda2.ts(4,17): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInLambda2.ts (1 errors) ==== + + class A { + public f1() { + return () => { + ~ +!!! error TS6133: 'T' is declared but never used. + var a: X; + a; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda2.js b/tests/baselines/reference/unusedTypeParameterInLambda2.js new file mode 100644 index 00000000000..16545eb13f2 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda2.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInLambda2.ts] + +class A { + public f1() { + return () => { + var a: X; + a; + } + } +} + +//// [unusedTypeParameterInLambda2.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function () { + var a; + a; + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt new file mode 100644 index 00000000000..5477f611e72 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInLambda3.ts (1 errors) ==== + class A { + public x: T; + } + + var y: new (a:T)=>void; + ~ +!!! error TS6133: 'U' is declared but never used. + \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda3.js b/tests/baselines/reference/unusedTypeParameterInLambda3.js new file mode 100644 index 00000000000..27899320fc2 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda3.js @@ -0,0 +1,15 @@ +//// [unusedTypeParameterInLambda3.ts] +class A { + public x: T; +} + +var y: new (a:T)=>void; + + +//// [unusedTypeParameterInLambda3.js] +var A = (function () { + function A() { + } + return A; +}()); +var y; diff --git a/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt new file mode 100644 index 00000000000..3b39d9b35ec --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInMethod1.ts(3,15): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod1.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'X' is declared but never used. + var a: Y; + var b: Z; + a; + b; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod1.js b/tests/baselines/reference/unusedTypeParameterInMethod1.js new file mode 100644 index 00000000000..e5ab22095b8 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod1.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInMethod1.ts] + +class A { + public f1() { + var a: Y; + var b: Z; + a; + b; + } +} + +//// [unusedTypeParameterInMethod1.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + var a; + var b; + a; + b; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt new file mode 100644 index 00000000000..f1dafb5a19e --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInMethod2.ts(3,18): error TS6133: 'Y' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod2.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'Y' is declared but never used. + var a: X; + var b: Z; + a; + b; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod2.js b/tests/baselines/reference/unusedTypeParameterInMethod2.js new file mode 100644 index 00000000000..9fb785634c6 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod2.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInMethod2.ts] + +class A { + public f1() { + var a: X; + var b: Z; + a; + b; + } +} + +//// [unusedTypeParameterInMethod2.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + var a; + var b; + a; + b; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt new file mode 100644 index 00000000000..04a43e3d011 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInMethod3.ts(3,21): error TS6133: 'Z' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod3.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'Z' is declared but never used. + var a: X; + var b: Y; + a; + b; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod3.js b/tests/baselines/reference/unusedTypeParameterInMethod3.js new file mode 100644 index 00000000000..b81d0796dc4 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod3.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInMethod3.ts] + +class A { + public f1() { + var a: X; + var b: Y; + a; + b; + } +} + +//// [unusedTypeParameterInMethod3.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + var a; + var b; + a; + b; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt new file mode 100644 index 00000000000..9026aaad321 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedTypeParameterInMethod4.ts(3,15): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod4.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'X' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod4.js b/tests/baselines/reference/unusedTypeParameterInMethod4.js new file mode 100644 index 00000000000..4db72f193a2 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod4.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInMethod4.ts] + +class A { + public f1() { + + } +} + +//// [unusedTypeParameterInMethod4.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt new file mode 100644 index 00000000000..20d95ec4bb5 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedTypeParameterInMethod5.ts(3,26): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod5.ts (1 errors) ==== + + class A { + public f1 = function() { + ~ +!!! error TS6133: 'X' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod5.js b/tests/baselines/reference/unusedTypeParameterInMethod5.js new file mode 100644 index 00000000000..e1863b4cbb1 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod5.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInMethod5.ts] + +class A { + public f1 = function() { + + } +} + +//// [unusedTypeParameterInMethod5.js] +var A = (function () { + function A() { + this.f1 = function () { + }; + } + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameters1.errors.txt b/tests/baselines/reference/unusedTypeParameters1.errors.txt new file mode 100644 index 00000000000..15d85d0e815 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameters1.ts(2,15): error TS6133: 'typeparameter1' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameters1.ts (1 errors) ==== + + class greeter { + ~~~~~~~~~~~~~~ +!!! error TS6133: 'typeparameter1' is declared but never used. + + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters1.js b/tests/baselines/reference/unusedTypeParameters1.js new file mode 100644 index 00000000000..27de80a9ecc --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters1.js @@ -0,0 +1,12 @@ +//// [unusedTypeParameters1.ts] + +class greeter { + +} + +//// [unusedTypeParameters1.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedTypeParameters2.errors.txt b/tests/baselines/reference/unusedTypeParameters2.errors.txt new file mode 100644 index 00000000000..a82a119d2ca --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedTypeParameters2.ts(2,15): error TS6133: 'typeparameter1' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameters2.ts (1 errors) ==== + + class greeter { + ~~~~~~~~~~~~~~ +!!! error TS6133: 'typeparameter1' is declared but never used. + private x: typeparameter2; + + public function1() { + this.x; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters2.js b/tests/baselines/reference/unusedTypeParameters2.js new file mode 100644 index 00000000000..b28aa5074e7 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters2.js @@ -0,0 +1,19 @@ +//// [unusedTypeParameters2.ts] + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} + +//// [unusedTypeParameters2.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + this.x; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedTypeParameters3.errors.txt b/tests/baselines/reference/unusedTypeParameters3.errors.txt new file mode 100644 index 00000000000..0b051ad476b --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedTypeParameters3.ts(2,15): error TS6133: 'typeparameter1' is declared but never used. +tests/cases/compiler/unusedTypeParameters3.ts(2,47): error TS6133: 'typeparameter3' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameters3.ts (2 errors) ==== + + class greeter { + ~~~~~~~~~~~~~~ +!!! error TS6133: 'typeparameter1' is declared but never used. + ~~~~~~~~~~~~~~ +!!! error TS6133: 'typeparameter3' is declared but never used. + private x: typeparameter2; + + public function1() { + this.x; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters3.js b/tests/baselines/reference/unusedTypeParameters3.js new file mode 100644 index 00000000000..0552acaf540 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters3.js @@ -0,0 +1,19 @@ +//// [unusedTypeParameters3.ts] + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} + +//// [unusedTypeParameters3.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + this.x; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedTypeParameters4.errors.txt b/tests/baselines/reference/unusedTypeParameters4.errors.txt new file mode 100644 index 00000000000..3aad5d5a346 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters4.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameters4.ts(3,13): error TS6133: 'U' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameters4.ts (1 errors) ==== + + var x: { + new (a: T): void; + ~ +!!! error TS6133: 'U' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters4.js b/tests/baselines/reference/unusedTypeParameters4.js new file mode 100644 index 00000000000..4e679ed3f6b --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters4.js @@ -0,0 +1,8 @@ +//// [unusedTypeParameters4.ts] + +var x: { + new (a: T): void; +} + +//// [unusedTypeParameters4.js] +var x; diff --git a/tests/baselines/reference/unusedTypeParameters5.errors.txt b/tests/baselines/reference/unusedTypeParameters5.errors.txt new file mode 100644 index 00000000000..ed150710d94 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters5.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedTypeParameters5.ts(7,16): error TS6133: 'K' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameters5.ts (1 errors) ==== + + class A { + public x: Dummy; + } + + var x: { + new (a: T): A; + ~ +!!! error TS6133: 'K' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters5.js b/tests/baselines/reference/unusedTypeParameters5.js new file mode 100644 index 00000000000..75dfd892eff --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters5.js @@ -0,0 +1,17 @@ +//// [unusedTypeParameters5.ts] + +class A { + public x: Dummy; +} + +var x: { + new (a: T): A; +} + +//// [unusedTypeParameters5.js] +var A = (function () { + function A() { + } + return A; +}()); +var x; diff --git a/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt new file mode 100644 index 00000000000..4f4291395f3 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedVariablesinBlocks1.ts(3,9): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinBlocks1.ts (1 errors) ==== + + function f1 () { + let x = 10; + ~ +!!! error TS6133: 'x' is declared but never used. + { + let x = 11; + x++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks1.js b/tests/baselines/reference/unusedVariablesinBlocks1.js new file mode 100644 index 00000000000..d569485aa82 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks1.js @@ -0,0 +1,18 @@ +//// [unusedVariablesinBlocks1.ts] + +function f1 () { + let x = 10; + { + let x = 11; + x++; + } +} + +//// [unusedVariablesinBlocks1.js] +function f1() { + var x = 10; + { + var x_1 = 11; + x_1++; + } +} diff --git a/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt new file mode 100644 index 00000000000..70af896324c --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedVariablesinBlocks2.ts(5,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinBlocks2.ts (1 errors) ==== + + function f1 () { + let x = 10; + { + let x = 11; + ~ +!!! error TS6133: 'x' is declared but never used. + } + x++; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks2.js b/tests/baselines/reference/unusedVariablesinBlocks2.js new file mode 100644 index 00000000000..0f4cb346398 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks2.js @@ -0,0 +1,18 @@ +//// [unusedVariablesinBlocks2.ts] + +function f1 () { + let x = 10; + { + let x = 11; + } + x++; +} + +//// [unusedVariablesinBlocks2.js] +function f1() { + var x = 10; + { + var x_1 = 11; + } + x++; +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt new file mode 100644 index 00000000000..b44e9dfdab1 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinForLoop.ts(3,13): error TS6133: 'i' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop.ts (1 errors) ==== + + function f1 () { + for(var i = 0; ;) { + ~ +!!! error TS6133: 'i' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop.js b/tests/baselines/reference/unusedVariablesinForLoop.js new file mode 100644 index 00000000000..a87e395d6e7 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop.js @@ -0,0 +1,13 @@ +//// [unusedVariablesinForLoop.ts] + +function f1 () { + for(var i = 0; ;) { + + } +} + +//// [unusedVariablesinForLoop.js] +function f1() { + for (var i = 0;;) { + } +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt new file mode 100644 index 00000000000..71974af00f4 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinForLoop2.ts(3,16): error TS6133: 'elem' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop2.ts (1 errors) ==== + + function f1 () { + for (const elem in ["a", "b", "c"]) { + ~~~~ +!!! error TS6133: 'elem' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop2.js b/tests/baselines/reference/unusedVariablesinForLoop2.js new file mode 100644 index 00000000000..523fdb18f9e --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop2.js @@ -0,0 +1,13 @@ +//// [unusedVariablesinForLoop2.ts] + +function f1 () { + for (const elem in ["a", "b", "c"]) { + + } +} + +//// [unusedVariablesinForLoop2.js] +function f1() { + for (var elem in ["a", "b", "c"]) { + } +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt new file mode 100644 index 00000000000..dbaf91ae70d --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinForLoop3.ts(3,16): error TS6133: 'elem' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop3.ts (1 errors) ==== + + function f1 () { + for (const elem of ["a", "b", "c"]) { + ~~~~ +!!! error TS6133: 'elem' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop3.js b/tests/baselines/reference/unusedVariablesinForLoop3.js new file mode 100644 index 00000000000..833214f3ba5 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop3.js @@ -0,0 +1,14 @@ +//// [unusedVariablesinForLoop3.ts] + +function f1 () { + for (const elem of ["a", "b", "c"]) { + + } +} + +//// [unusedVariablesinForLoop3.js] +function f1() { + for (var _i = 0, _a = ["a", "b", "c"]; _i < _a.length; _i++) { + var elem = _a[_i]; + } +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt new file mode 100644 index 00000000000..d54500d353d --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedVariablesinForLoop4.ts(5,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop4.ts (1 errors) ==== + + function f1 () { + for (const elem of ["a", "b", "c"]) { + elem; + var x = 20; + ~ +!!! error TS6133: 'x' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop4.js b/tests/baselines/reference/unusedVariablesinForLoop4.js new file mode 100644 index 00000000000..6ec7f6fec55 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop4.js @@ -0,0 +1,17 @@ +//// [unusedVariablesinForLoop4.ts] + +function f1 () { + for (const elem of ["a", "b", "c"]) { + elem; + var x = 20; + } +} + +//// [unusedVariablesinForLoop4.js] +function f1() { + for (var _i = 0, _a = ["a", "b", "c"]; _i < _a.length; _i++) { + var elem = _a[_i]; + elem; + var x = 20; + } +} diff --git a/tests/baselines/reference/unusedVariablesinModules1.errors.txt b/tests/baselines/reference/unusedVariablesinModules1.errors.txt new file mode 100644 index 00000000000..00faee6a6b3 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinModules1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinModules1.ts(4,5): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinModules1.ts (1 errors) ==== + + export {}; + + var x: string; + ~ +!!! error TS6133: 'x' is declared but never used. + + export var y: string; \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinModules1.js b/tests/baselines/reference/unusedVariablesinModules1.js new file mode 100644 index 00000000000..18622a32ba9 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinModules1.js @@ -0,0 +1,11 @@ +//// [unusedVariablesinModules1.ts] + +export {}; + +var x: string; + +export var y: string; + +//// [unusedVariablesinModules1.js] +"use strict"; +var x; diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt new file mode 100644 index 00000000000..39c1cdc4e08 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6133: 'lettersRegexp' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinNamespaces1.ts (1 errors) ==== + + namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + ~~~~~~~~~~~~~ +!!! error TS6133: 'lettersRegexp' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.js b/tests/baselines/reference/unusedVariablesinNamespaces1.js new file mode 100644 index 00000000000..a6dca8e413f --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.js @@ -0,0 +1,11 @@ +//// [unusedVariablesinNamespaces1.ts] + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; +} + +//// [unusedVariablesinNamespaces1.js] +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt new file mode 100644 index 00000000000..43d41e6338b --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6133: 'numberRegexp' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinNamespaces2.ts (1 errors) ==== + + namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! error TS6133: 'numberRegexp' is declared but never used. + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.js b/tests/baselines/reference/unusedVariablesinNamespaces2.js new file mode 100644 index 00000000000..b0b64fa644d --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.js @@ -0,0 +1,28 @@ +//// [unusedVariablesinNamespaces2.ts] + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} + +//// [unusedVariablesinNamespaces2.js] +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt new file mode 100644 index 00000000000..a0a274c6b2a --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6133: 'numberRegexp' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinNamespaces3.ts (1 errors) ==== + + namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! error TS6133: 'numberRegexp' is declared but never used. + export const anotherUnusedVariable = "Dummy value"; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.js b/tests/baselines/reference/unusedVariablesinNamespaces3.js new file mode 100644 index 00000000000..16a92a475d9 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.js @@ -0,0 +1,30 @@ +//// [unusedVariablesinNamespaces3.ts] + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + export const anotherUnusedVariable = "Dummy value"; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} + +//// [unusedVariablesinNamespaces3.js] +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + Validation.anotherUnusedVariable = "Dummy value"; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; +})(Validation || (Validation = {})); diff --git a/tests/cases/compiler/unusedClassesinModule1.ts b/tests/cases/compiler/unusedClassesinModule1.ts new file mode 100644 index 00000000000..0efc4966388 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinModule1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + class Calculator { + public handelChar() { + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace1.ts b/tests/cases/compiler/unusedClassesinNamespace1.ts new file mode 100644 index 00000000000..da1feef9195 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace2.ts b/tests/cases/compiler/unusedClassesinNamespace2.ts new file mode 100644 index 00000000000..83d60ff1628 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace2.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace3.ts b/tests/cases/compiler/unusedClassesinNamespace3.ts new file mode 100644 index 00000000000..9d39af37ea2 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace3.ts @@ -0,0 +1,14 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + export let a = new c1(); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace4.ts b/tests/cases/compiler/unusedClassesinNamespace4.ts new file mode 100644 index 00000000000..390df8f7229 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace4.ts @@ -0,0 +1,16 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 extends c1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace5.ts b/tests/cases/compiler/unusedClassesinNamespace5.ts new file mode 100644 index 00000000000..43265e8fc40 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace5.ts @@ -0,0 +1,16 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 { + public x: c1; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces1.ts b/tests/cases/compiler/unusedFunctionsinNamespaces1.ts new file mode 100644 index 00000000000..3e4a1814ba8 --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces1.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + function function1() { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces2.ts b/tests/cases/compiler/unusedFunctionsinNamespaces2.ts new file mode 100644 index 00000000000..5f38bbaaaac --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces3.ts b/tests/cases/compiler/unusedFunctionsinNamespaces3.ts new file mode 100644 index 00000000000..c20759494f6 --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces3.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function(param1:string) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces4.ts b/tests/cases/compiler/unusedFunctionsinNamespaces4.ts new file mode 100644 index 00000000000..b8855ba2650 --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces4.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces5.ts b/tests/cases/compiler/unusedFunctionsinNamespaces5.ts new file mode 100644 index 00000000000..f1d516fa66f --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces5.ts @@ -0,0 +1,19 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces6.ts b/tests/cases/compiler/unusedFunctionsinNamespaces6.ts new file mode 100644 index 00000000000..19f1591249c --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces6.ts @@ -0,0 +1,21 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } + + export let a = function3; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedGetterInClass.ts b/tests/cases/compiler/unusedGetterInClass.ts new file mode 100644 index 00000000000..e5259f91cdc --- /dev/null +++ b/tests/cases/compiler/unusedGetterInClass.ts @@ -0,0 +1,11 @@ +//@target: ES5 +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Employee { + private _fullName: string; + + get fullName(): string { + return this._fullName; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedIdentifiersConsolidated1.ts b/tests/cases/compiler/unusedIdentifiersConsolidated1.ts new file mode 100644 index 00000000000..7c6e9b2e695 --- /dev/null +++ b/tests/cases/compiler/unusedIdentifiersConsolidated1.ts @@ -0,0 +1,104 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string) { + var unused = 20; +} + +class Dummy { + private unusedprivatevariable: string; + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + var unused = 20; + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + } +} + +var user = "Jane User"; +var user2 = "Jane2 User2"; + +namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + } + + interface unusedInterface { + } +} + + +namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports1.ts b/tests/cases/compiler/unusedImports1.ts new file mode 100644 index 00000000000..30fff0c1ed1 --- /dev/null +++ b/tests/cases/compiler/unusedImports1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + +} + +// @Filename: file2.ts +import {Calculator} from "./file1" \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports10.ts b/tests/cases/compiler/unusedImports10.ts new file mode 100644 index 00000000000..1cccfbd38bb --- /dev/null +++ b/tests/cases/compiler/unusedImports10.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + export class Calculator { + public handelChar() { + } + } +} + +module B { + import a = A; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports2.ts b/tests/cases/compiler/unusedImports2.ts new file mode 100644 index 00000000000..00e7fcff33b --- /dev/null +++ b/tests/cases/compiler/unusedImports2.ts @@ -0,0 +1,18 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +// @Filename: file2.ts +import {Calculator} from "./file1" +import {test} from "./file1" + +var x = new Calculator(); +x.handleChar(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports3.ts b/tests/cases/compiler/unusedImports3.ts new file mode 100644 index 00000000000..349c2c9abe8 --- /dev/null +++ b/tests/cases/compiler/unusedImports3.ts @@ -0,0 +1,21 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator, test, test2} from "./file1" + +test(); +test2(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports4.ts b/tests/cases/compiler/unusedImports4.ts new file mode 100644 index 00000000000..472c5965850 --- /dev/null +++ b/tests/cases/compiler/unusedImports4.ts @@ -0,0 +1,22 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test2(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports5.ts b/tests/cases/compiler/unusedImports5.ts new file mode 100644 index 00000000000..85943691ce2 --- /dev/null +++ b/tests/cases/compiler/unusedImports5.ts @@ -0,0 +1,22 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports6.ts b/tests/cases/compiler/unusedImports6.ts new file mode 100644 index 00000000000..6ff45cc1b29 --- /dev/null +++ b/tests/cases/compiler/unusedImports6.ts @@ -0,0 +1,21 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +// @Filename: file2.ts +import d from "./file1" + + + diff --git a/tests/cases/compiler/unusedImports7.ts b/tests/cases/compiler/unusedImports7.ts new file mode 100644 index 00000000000..94df3581745 --- /dev/null +++ b/tests/cases/compiler/unusedImports7.ts @@ -0,0 +1,19 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +// @Filename: file2.ts +import * as n from "./file1" + diff --git a/tests/cases/compiler/unusedImports8.ts b/tests/cases/compiler/unusedImports8.ts new file mode 100644 index 00000000000..e8bd982d038 --- /dev/null +++ b/tests/cases/compiler/unusedImports8.ts @@ -0,0 +1,22 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator as calc, test as t1, test2 as t2} from "./file1" + +var x = new calc(); +x.handleChar(); +t1(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports9.ts b/tests/cases/compiler/unusedImports9.ts new file mode 100644 index 00000000000..2e13e216c15 --- /dev/null +++ b/tests/cases/compiler/unusedImports9.ts @@ -0,0 +1,18 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import c = require('./file1') \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace1.ts b/tests/cases/compiler/unusedInterfaceinNamespace1.ts new file mode 100644 index 00000000000..db50d0da2b6 --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace2.ts b/tests/cases/compiler/unusedInterfaceinNamespace2.ts new file mode 100644 index 00000000000..d0b6eb239ef --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace2.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace3.ts b/tests/cases/compiler/unusedInterfaceinNamespace3.ts new file mode 100644 index 00000000000..48c615be903 --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace3.ts @@ -0,0 +1,16 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace4.ts b/tests/cases/compiler/unusedInterfaceinNamespace4.ts new file mode 100644 index 00000000000..e643f812227 --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace4.ts @@ -0,0 +1,20 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace5.ts b/tests/cases/compiler/unusedInterfaceinNamespace5.ts new file mode 100644 index 00000000000..901124e0f39 --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace5.ts @@ -0,0 +1,26 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } + + interface i4 { + + } + + export let c2:i4; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsInMethod1.ts b/tests/cases/compiler/unusedLocalsInMethod1.ts new file mode 100644 index 00000000000..7da21b2c1af --- /dev/null +++ b/tests/cases/compiler/unusedLocalsInMethod1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + public function1() { + var x = 10; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsInMethod2.ts b/tests/cases/compiler/unusedLocalsInMethod2.ts new file mode 100644 index 00000000000..a376e6de0ac --- /dev/null +++ b/tests/cases/compiler/unusedLocalsInMethod2.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + public function1() { + var x, y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsInMethod3.ts b/tests/cases/compiler/unusedLocalsInMethod3.ts new file mode 100644 index 00000000000..5d949110573 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsInMethod3.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + public function1() { + var x, y; + y = 1; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts new file mode 100644 index 00000000000..0c325f198fa --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts new file mode 100644 index 00000000000..00615f034b7 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts new file mode 100644 index 00000000000..fd0e0f190e9 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts new file mode 100644 index 00000000000..73adf038564 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts new file mode 100644 index 00000000000..9417b13b65a --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts new file mode 100644 index 00000000000..7971ce5a30a --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function(child: string): void { + var unused2 = 22; + } + var maker2 = function(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts new file mode 100644 index 00000000000..edeb341ee7d --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts new file mode 100644 index 00000000000..b407755c259 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + var maker2 = function (child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsinConstructor1.ts b/tests/cases/compiler/unusedLocalsinConstructor1.ts new file mode 100644 index 00000000000..fca303d2b9f --- /dev/null +++ b/tests/cases/compiler/unusedLocalsinConstructor1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor() { + var unused = 20; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsinConstructor2.ts b/tests/cases/compiler/unusedLocalsinConstructor2.ts new file mode 100644 index 00000000000..2e67d98d56e --- /dev/null +++ b/tests/cases/compiler/unusedLocalsinConstructor2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor() { + var unused = 20; + var used = "dummy"; + used = used + "second part"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMethodsInInterface.ts b/tests/cases/compiler/unusedMethodsInInterface.ts new file mode 100644 index 00000000000..29769bc5b11 --- /dev/null +++ b/tests/cases/compiler/unusedMethodsInInterface.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +interface I1 { + f1(); + f2(x: number, y: string); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedModuleInModule.ts b/tests/cases/compiler/unusedModuleInModule.ts new file mode 100644 index 00000000000..dc5f55398a7 --- /dev/null +++ b/tests/cases/compiler/unusedModuleInModule.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + module B {} +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter1InContructor.ts b/tests/cases/compiler/unusedMultipleParameter1InContructor.ts new file mode 100644 index 00000000000..b9565cafca6 --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter1InContructor.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts b/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts new file mode 100644 index 00000000000..3892db7e39d --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var func = function(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter2InContructor.ts b/tests/cases/compiler/unusedMultipleParameter2InContructor.ts new file mode 100644 index 00000000000..34d54c714af --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter2InContructor.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts b/tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts new file mode 100644 index 00000000000..4d5bb2a103b --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var func = function(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts new file mode 100644 index 00000000000..bc63d72f015 --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts new file mode 100644 index 00000000000..c74e702bbae --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + public greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts new file mode 100644 index 00000000000..ad20d044ecc --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts new file mode 100644 index 00000000000..4ede3cd47a4 --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + public greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedNamespaceInModule.ts b/tests/cases/compiler/unusedNamespaceInModule.ts new file mode 100644 index 00000000000..adca8a84187 --- /dev/null +++ b/tests/cases/compiler/unusedNamespaceInModule.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + namespace B { } + export namespace C {} +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedNamespaceInNamespace.ts b/tests/cases/compiler/unusedNamespaceInNamespace.ts new file mode 100644 index 00000000000..8de3768a201 --- /dev/null +++ b/tests/cases/compiler/unusedNamespaceInNamespace.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace A { + namespace B { } + export namespace C {} +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParameterInCatchClause.ts b/tests/cases/compiler/unusedParameterInCatchClause.ts new file mode 100644 index 00000000000..3034ab0aef8 --- /dev/null +++ b/tests/cases/compiler/unusedParameterInCatchClause.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + try {} catch(ex){} +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParameterUsedInTypeOf.ts b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts new file mode 100644 index 00000000000..b69b2412314 --- /dev/null +++ b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts @@ -0,0 +1,7 @@ +//@target: ES5 +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 (a: number, b: typeof a) { + b++; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersInLambda1.ts b/tests/cases/compiler/unusedParametersInLambda1.ts new file mode 100644 index 00000000000..431ac1eb1dc --- /dev/null +++ b/tests/cases/compiler/unusedParametersInLambda1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return (X) => { + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersInLambda2.ts b/tests/cases/compiler/unusedParametersInLambda2.ts new file mode 100644 index 00000000000..ed4dfb3404b --- /dev/null +++ b/tests/cases/compiler/unusedParametersInLambda2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return (X, Y) => { + Y; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor1.ts b/tests/cases/compiler/unusedParametersinConstructor1.ts new file mode 100644 index 00000000000..421636d661b --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor1.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor2.ts b/tests/cases/compiler/unusedParametersinConstructor2.ts new file mode 100644 index 00000000000..d6812f438c5 --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor2.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string, param2: string) { + param2 = param2 + "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor3.ts b/tests/cases/compiler/unusedParametersinConstructor3.ts new file mode 100644 index 00000000000..e6295cd49fa --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor3.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string, param2: string, param3: string) { + param2 = param2 + "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass1.ts b/tests/cases/compiler/unusedPrivateMethodInClass1.ts new file mode 100644 index 00000000000..e31dec6033b --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass2.ts b/tests/cases/compiler/unusedPrivateMethodInClass2.ts new file mode 100644 index 00000000000..5039c265890 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass2.ts @@ -0,0 +1,14 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass3.ts b/tests/cases/compiler/unusedPrivateMethodInClass3.ts new file mode 100644 index 00000000000..a35cd4512ec --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass3.ts @@ -0,0 +1,19 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass4.ts b/tests/cases/compiler/unusedPrivateMethodInClass4.ts new file mode 100644 index 00000000000..5e2741a12bc --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass4.ts @@ -0,0 +1,20 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + this.function2(); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass1.ts b/tests/cases/compiler/unusedPrivateVariableInClass1.ts new file mode 100644 index 00000000000..0877b7cd868 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass2.ts b/tests/cases/compiler/unusedPrivateVariableInClass2.ts new file mode 100644 index 00000000000..acaf1e80412 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass3.ts b/tests/cases/compiler/unusedPrivateVariableInClass3.ts new file mode 100644 index 00000000000..6cfa3184f44 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass3.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; + public z: string; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass4.ts b/tests/cases/compiler/unusedPrivateVariableInClass4.ts new file mode 100644 index 00000000000..23598d5a491 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass4.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; + public z: string; + + public method1() { + this.x = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass5.ts b/tests/cases/compiler/unusedPrivateVariableInClass5.ts new file mode 100644 index 00000000000..51e64afca1d --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass5.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; + public z: string; + + constructor() { + this.x = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSetterInClass.ts b/tests/cases/compiler/unusedSetterInClass.ts new file mode 100644 index 00000000000..a8e45bab434 --- /dev/null +++ b/tests/cases/compiler/unusedSetterInClass.ts @@ -0,0 +1,11 @@ +//@target: ES5 +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Employee { + private _fullName: string; + + set fullName(newName: string) { + this._fullName = newName; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInContructor.ts b/tests/cases/compiler/unusedSingleParameterInContructor.ts new file mode 100644 index 00000000000..0f8f756fb48 --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInContructor.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string) { + var unused = 20; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts b/tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts new file mode 100644 index 00000000000..8122065d7ca --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string) { + var unused = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts b/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts new file mode 100644 index 00000000000..f4a749c33af --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var func = function(person: string) { + var unused = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts b/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts new file mode 100644 index 00000000000..2dee007f210 --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + public greeter(person: string) { + var unused = 20; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction1.ts b/tests/cases/compiler/unusedTypeParameterInFunction1.ts new file mode 100644 index 00000000000..421d2aa7b37 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction2.ts b/tests/cases/compiler/unusedTypeParameterInFunction2.ts new file mode 100644 index 00000000000..76eeb11bb34 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + var a: X; + a; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction3.ts b/tests/cases/compiler/unusedTypeParameterInFunction3.ts new file mode 100644 index 00000000000..37f01468156 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction3.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + var a: X; + var b: Z; + a; + b; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction4.ts b/tests/cases/compiler/unusedTypeParameterInFunction4.ts new file mode 100644 index 00000000000..56549d93976 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction4.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + var a: Y; + var b: Z; + a; + b; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInInterface1.ts b/tests/cases/compiler/unusedTypeParameterInInterface1.ts new file mode 100644 index 00000000000..2098e5d4bc5 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInInterface1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +interface int { + +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInInterface2.ts b/tests/cases/compiler/unusedTypeParameterInInterface2.ts new file mode 100644 index 00000000000..cdcd45a7f30 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInInterface2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +interface int { + f1(a: T): string; + c: V; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInLambda1.ts b/tests/cases/compiler/unusedTypeParameterInLambda1.ts new file mode 100644 index 00000000000..dd4dbe7824a --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInLambda1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return () => { + + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInLambda2.ts b/tests/cases/compiler/unusedTypeParameterInLambda2.ts new file mode 100644 index 00000000000..73177a8b09d --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInLambda2.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return () => { + var a: X; + a; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInLambda3.ts b/tests/cases/compiler/unusedTypeParameterInLambda3.ts new file mode 100644 index 00000000000..eb6582caf4e --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInLambda3.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true +class A { + public x: T; +} + +var y: new (a:T)=>void; diff --git a/tests/cases/compiler/unusedTypeParameterInMethod1.ts b/tests/cases/compiler/unusedTypeParameterInMethod1.ts new file mode 100644 index 00000000000..f58bde3d2a1 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod1.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + var a: Y; + var b: Z; + a; + b; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod2.ts b/tests/cases/compiler/unusedTypeParameterInMethod2.ts new file mode 100644 index 00000000000..f344d188b0a --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod2.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + var a: X; + var b: Z; + a; + b; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod3.ts b/tests/cases/compiler/unusedTypeParameterInMethod3.ts new file mode 100644 index 00000000000..9734136bd03 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod3.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + var a: X; + var b: Y; + a; + b; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod4.ts b/tests/cases/compiler/unusedTypeParameterInMethod4.ts new file mode 100644 index 00000000000..ef487d11118 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod4.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod5.ts b/tests/cases/compiler/unusedTypeParameterInMethod5.ts new file mode 100644 index 00000000000..73cedcf402e --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod5.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1 = function() { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters1.ts b/tests/cases/compiler/unusedTypeParameters1.ts new file mode 100644 index 00000000000..cec2be7efda --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters2.ts b/tests/cases/compiler/unusedTypeParameters2.ts new file mode 100644 index 00000000000..c1018578147 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters3.ts b/tests/cases/compiler/unusedTypeParameters3.ts new file mode 100644 index 00000000000..ea67756d5ad --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters3.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters4.ts b/tests/cases/compiler/unusedTypeParameters4.ts new file mode 100644 index 00000000000..1b470c4ae28 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters4.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var x: { + new (a: T): void; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters5.ts b/tests/cases/compiler/unusedTypeParameters5.ts new file mode 100644 index 00000000000..7a5025a7907 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters5.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public x: Dummy; +} + +var x: { + new (a: T): A; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinBlocks1.ts b/tests/cases/compiler/unusedVariablesinBlocks1.ts new file mode 100644 index 00000000000..b937fbd8ac1 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinBlocks1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + let x = 10; + { + let x = 11; + x++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinBlocks2.ts b/tests/cases/compiler/unusedVariablesinBlocks2.ts new file mode 100644 index 00000000000..248e6302cd0 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinBlocks2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + let x = 10; + { + let x = 11; + } + x++; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop.ts b/tests/cases/compiler/unusedVariablesinForLoop.ts new file mode 100644 index 00000000000..01f8a4bdfc5 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for(var i = 0; ;) { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop2.ts b/tests/cases/compiler/unusedVariablesinForLoop2.ts new file mode 100644 index 00000000000..b5d3496608d --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop2.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for (const elem in ["a", "b", "c"]) { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop3.ts b/tests/cases/compiler/unusedVariablesinForLoop3.ts new file mode 100644 index 00000000000..c08f225e7be --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop3.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for (const elem of ["a", "b", "c"]) { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop4.ts b/tests/cases/compiler/unusedVariablesinForLoop4.ts new file mode 100644 index 00000000000..ac75e065b9e --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop4.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for (const elem of ["a", "b", "c"]) { + elem; + var x = 20; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinModules1.ts b/tests/cases/compiler/unusedVariablesinModules1.ts new file mode 100644 index 00000000000..92a5a14590d --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinModules1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +export {}; + +var x: string; + +export var y: string; \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinNamespaces1.ts b/tests/cases/compiler/unusedVariablesinNamespaces1.ts new file mode 100644 index 00000000000..04febf70260 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinNamespaces1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinNamespaces2.ts b/tests/cases/compiler/unusedVariablesinNamespaces2.ts new file mode 100644 index 00000000000..2178da8fbda --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinNamespaces2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinNamespaces3.ts b/tests/cases/compiler/unusedVariablesinNamespaces3.ts new file mode 100644 index 00000000000..9952da92a7f --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinNamespaces3.ts @@ -0,0 +1,14 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + export const anotherUnusedVariable = "Dummy value"; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} \ No newline at end of file From e182ecf2c964eaf350bbdac8741cbc982aee7b72 Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 24 Jun 2016 17:39:49 -0700 Subject: [PATCH 038/103] Fix 8355: Fix emit metadata different between transpile and tsc --isolatedModule (#9232) * Instead of returning undefined for unknownSymbol return itself * Add Transpile unittest * Wip - Add project tests * Add project tests and baselines * Update existed tests * Add tests for emitting metadata with module targetting system --- src/compiler/checker.ts | 6 ++- ...dataWithImportDeclarationNameCollision4.js | 3 +- ...MetadataCommonJSISolatedModules.errors.txt | 14 +++++++ ...oratorMetadataCommonJSISolatedModules.json | 13 +++++++ .../amd/main.js | 24 ++++++++++++ ...MetadataCommonJSISolatedModules.errors.txt | 14 +++++++ ...oratorMetadataCommonJSISolatedModules.json | 13 +++++++ .../node/main.js | 23 +++++++++++ ...ommonJSISolatedModulesNoResolve.errors.txt | 14 +++++++ ...adataCommonJSISolatedModulesNoResolve.json | 13 +++++++ .../amd/main.js | 24 ++++++++++++ ...ommonJSISolatedModulesNoResolve.errors.txt | 14 +++++++ ...adataCommonJSISolatedModulesNoResolve.json | 13 +++++++ .../node/main.js | 23 +++++++++++ .../emitDecoratorMetadataSystemJS.errors.txt | 14 +++++++ .../amd/emitDecoratorMetadataSystemJS.json | 13 +++++++ .../emitDecoratorMetadataSystemJS/amd/main.js | 24 ++++++++++++ .../emitDecoratorMetadataSystemJS.errors.txt | 14 +++++++ .../node/emitDecoratorMetadataSystemJS.json | 13 +++++++ .../node/main.js | 23 +++++++++++ ...MetadataSystemJSISolatedModules.errors.txt | 14 +++++++ ...oratorMetadataSystemJSISolatedModules.json | 13 +++++++ .../amd/main.js | 24 ++++++++++++ ...MetadataSystemJSISolatedModules.errors.txt | 14 +++++++ ...oratorMetadataSystemJSISolatedModules.json | 13 +++++++ .../node/main.js | 23 +++++++++++ ...ystemJSISolatedModulesNoResolve.errors.txt | 14 +++++++ ...adataSystemJSISolatedModulesNoResolve.json | 13 +++++++ .../amd/main.js | 24 ++++++++++++ ...ystemJSISolatedModulesNoResolve.errors.txt | 14 +++++++ ...adataSystemJSISolatedModulesNoResolve.json | 13 +++++++ .../node/main.js | 23 +++++++++++ ...ata when transpile with CommonJS option.js | 23 +++++++++++ ...adata when transpile with System option.js | 35 +++++++++++++++++ ...oratorMetadataCommonJSISolatedModules.json | 6 +++ ...adataCommonJSISolatedModulesNoResolve.json | 6 +++ .../emitDecoratorMetadataSystemJS.json | 6 +++ ...oratorMetadataSystemJSISolatedModules.json | 6 +++ ...adataSystemJSISolatedModulesNoResolve.json | 6 +++ .../main.ts | 8 ++++ .../tsconfig.json | 13 +++++++ .../main.ts | 8 ++++ .../tsconfig.json | 14 +++++++ .../emitDecoratorMetadataSystemJS/main.ts | 8 ++++ .../tsconfig.json | 12 ++++++ .../main.ts | 8 ++++ .../tsconfig.json | 14 +++++++ .../main.ts | 8 ++++ .../tsconfig.json | 15 ++++++++ tests/cases/unittests/transpile.ts | 38 +++++++++++++++++++ 50 files changed, 746 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json create mode 100644 tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js create mode 100644 tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js create mode 100644 tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js create mode 100644 tests/cases/project/emitDecoratorMetadataCommonJSISolatedModules.json create mode 100644 tests/cases/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json create mode 100644 tests/cases/project/emitDecoratorMetadataSystemJS.json create mode 100644 tests/cases/project/emitDecoratorMetadataSystemJSISolatedModules.json create mode 100644 tests/cases/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/main.ts create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/tsconfig.json create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/main.ts create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/tsconfig.json create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/main.ts create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/tsconfig.json create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/main.ts create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/tsconfig.json create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/main.ts create mode 100644 tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/tsconfig.json diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ad2dc8ff494..06591a7ab3d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1265,9 +1265,13 @@ namespace ts { const right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors); - if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) { + if (!namespace || nodeIsMissing(right)) { return undefined; } + else if (namespace === unknownSymbol) { + return namespace; + } + symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { if (!ignoreErrors) { diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index 4af0beeddcb..a057b496b25 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -46,8 +46,9 @@ var MyClass = (function () { } MyClass = __decorate([ someDecorator, - __metadata('design:paramtypes', [Object]) + __metadata('design:paramtypes', [(typeof (_a = typeof db_1.default !== 'undefined' && db_1.default.db) === 'function' && _a) || Object]) ], MyClass); return MyClass; + var _a; }()); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.json b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.json new file mode 100644 index 00000000000..470c5bf1301 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/emitDecoratorMetadataCommonJSISolatedModules.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js new file mode 100644 index 00000000000..41ab9194c4e --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js @@ -0,0 +1,24 @@ +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +define(["require", "exports", "angular2/core"], function (require, exports, ng) { + "use strict"; + var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; + }()); + exports.MyClass1 = MyClass1; +}); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.json b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.json new file mode 100644 index 00000000000..470c5bf1301 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/emitDecoratorMetadataCommonJSISolatedModules.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js new file mode 100644 index 00000000000..e8bd90fc475 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js @@ -0,0 +1,23 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var ng = require("angular2/core"); +var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; +}()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json new file mode 100644 index 00000000000..91749c0e189 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js new file mode 100644 index 00000000000..41ab9194c4e --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js @@ -0,0 +1,24 @@ +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +define(["require", "exports", "angular2/core"], function (require, exports, ng) { + "use strict"; + var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; + }()); + exports.MyClass1 = MyClass1; +}); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json new file mode 100644 index 00000000000..91749c0e189 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js new file mode 100644 index 00000000000..e8bd90fc475 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js @@ -0,0 +1,23 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var ng = require("angular2/core"); +var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; +}()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.json b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.json new file mode 100644 index 00000000000..5b48b8fe70c --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/emitDecoratorMetadataSystemJS.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js new file mode 100644 index 00000000000..41ab9194c4e --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js @@ -0,0 +1,24 @@ +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +define(["require", "exports", "angular2/core"], function (require, exports, ng) { + "use strict"; + var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; + }()); + exports.MyClass1 = MyClass1; +}); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.json b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.json new file mode 100644 index 00000000000..5b48b8fe70c --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/emitDecoratorMetadataSystemJS.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js new file mode 100644 index 00000000000..e8bd90fc475 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js @@ -0,0 +1,23 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var ng = require("angular2/core"); +var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; +}()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.json b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.json new file mode 100644 index 00000000000..a01c921fdd1 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/emitDecoratorMetadataSystemJSISolatedModules.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js new file mode 100644 index 00000000000..41ab9194c4e --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js @@ -0,0 +1,24 @@ +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +define(["require", "exports", "angular2/core"], function (require, exports, ng) { + "use strict"; + var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; + }()); + exports.MyClass1 = MyClass1; +}); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.json b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.json new file mode 100644 index 00000000000..a01c921fdd1 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/emitDecoratorMetadataSystemJSISolatedModules.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js new file mode 100644 index 00000000000..e8bd90fc475 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js @@ -0,0 +1,23 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var ng = require("angular2/core"); +var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; +}()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json new file mode 100644 index 00000000000..14eafad1200 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js new file mode 100644 index 00000000000..41ab9194c4e --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js @@ -0,0 +1,24 @@ +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +define(["require", "exports", "angular2/core"], function (require, exports, ng) { + "use strict"; + var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; + }()); + exports.MyClass1 = MyClass1; +}); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt new file mode 100644 index 00000000000..d6d803104c9 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.errors.txt @@ -0,0 +1,14 @@ +main.ts(1,21): error TS2307: Cannot find module 'angular2/core'. + + +==== main.ts (1 errors) ==== + import * as ng from "angular2/core"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'angular2/core'. + + declare function foo(...args: any[]); + + @foo + export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} + } \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json new file mode 100644 index 00000000000..14eafad1200 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json @@ -0,0 +1,13 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve", + "baselineCheck": true, + "runTest": true, + "resolvedInputFiles": [ + "lib.d.ts", + "main.ts" + ], + "emittedFiles": [ + "main.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js new file mode 100644 index 00000000000..e8bd90fc475 --- /dev/null +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js @@ -0,0 +1,23 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var ng = require("angular2/core"); +var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + foo, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; +}()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js new file mode 100644 index 00000000000..e5495f226d2 --- /dev/null +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js @@ -0,0 +1,23 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var ng = require("angular2/core"); +var MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + fooexport, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; +}()); +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js new file mode 100644 index 00000000000..491481e6a40 --- /dev/null +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.js @@ -0,0 +1,35 @@ +System.register(["angular2/core"], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var ng; + var MyClass1; + return { + setters:[ + function (ng_1) { + ng = ng_1; + }], + execute: function() { + MyClass1 = (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + fooexport, + __metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object]) + ], MyClass1); + return MyClass1; + var _a; + }()); + } + } +}); +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/cases/project/emitDecoratorMetadataCommonJSISolatedModules.json b/tests/cases/project/emitDecoratorMetadataCommonJSISolatedModules.json new file mode 100644 index 00000000000..27b2e09172b --- /dev/null +++ b/tests/cases/project/emitDecoratorMetadataCommonJSISolatedModules.json @@ -0,0 +1,6 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule", + "baselineCheck": true, + "runTest": true +} \ No newline at end of file diff --git a/tests/cases/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json b/tests/cases/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json new file mode 100644 index 00000000000..8930951b9a4 --- /dev/null +++ b/tests/cases/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve.json @@ -0,0 +1,6 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve", + "baselineCheck": true, + "runTest": true +} \ No newline at end of file diff --git a/tests/cases/project/emitDecoratorMetadataSystemJS.json b/tests/cases/project/emitDecoratorMetadataSystemJS.json new file mode 100644 index 00000000000..1ed6b13dcb3 --- /dev/null +++ b/tests/cases/project/emitDecoratorMetadataSystemJS.json @@ -0,0 +1,6 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS", + "baselineCheck": true, + "runTest": true +} \ No newline at end of file diff --git a/tests/cases/project/emitDecoratorMetadataSystemJSISolatedModules.json b/tests/cases/project/emitDecoratorMetadataSystemJSISolatedModules.json new file mode 100644 index 00000000000..da18f2602af --- /dev/null +++ b/tests/cases/project/emitDecoratorMetadataSystemJSISolatedModules.json @@ -0,0 +1,6 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule", + "baselineCheck": true, + "runTest": true +} \ No newline at end of file diff --git a/tests/cases/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json b/tests/cases/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json new file mode 100644 index 00000000000..d87a1361cdd --- /dev/null +++ b/tests/cases/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve.json @@ -0,0 +1,6 @@ +{ + "scenario": "Emit decorator metadata when commonJS and isolatedModules are on", + "projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve", + "baselineCheck": true, + "runTest": true +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/main.ts b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/main.ts new file mode 100644 index 00000000000..f75e8a4d9d6 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/main.ts @@ -0,0 +1,8 @@ +import * as ng from "angular2/core"; + +declare function foo(...args: any[]); + +@foo +export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/tsconfig.json b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/tsconfig.json new file mode 100644 index 00000000000..27d98c7f2c9 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "isolatedModules": true + }, + "files": [ + "main.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/main.ts b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/main.ts new file mode 100644 index 00000000000..f75e8a4d9d6 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/main.ts @@ -0,0 +1,8 @@ +import * as ng from "angular2/core"; + +declare function foo(...args: any[]); + +@foo +export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/tsconfig.json b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/tsconfig.json new file mode 100644 index 00000000000..a34d38cb68e --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "isolatedModules": true, + "noResolve": true + }, + "files": [ + "main.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/main.ts b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/main.ts new file mode 100644 index 00000000000..f75e8a4d9d6 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/main.ts @@ -0,0 +1,8 @@ +import * as ng from "angular2/core"; + +declare function foo(...args: any[]); + +@foo +export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/tsconfig.json b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/tsconfig.json new file mode 100644 index 00000000000..6c78695c505 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "es5", + "module": "system", + "emitDecoratorMetadata": true, + "experimentalDecorators": true + }, + "files": [ + "main.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/main.ts b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/main.ts new file mode 100644 index 00000000000..f75e8a4d9d6 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/main.ts @@ -0,0 +1,8 @@ +import * as ng from "angular2/core"; + +declare function foo(...args: any[]); + +@foo +export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/tsconfig.json b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/tsconfig.json new file mode 100644 index 00000000000..2a8dcffba74 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModule/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "isolatedModules": true + }, + "files": [ + "main.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/main.ts b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/main.ts new file mode 100644 index 00000000000..f75e8a4d9d6 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/main.ts @@ -0,0 +1,8 @@ +import * as ng from "angular2/core"; + +declare function foo(...args: any[]); + +@foo +export class MyClass1 { + constructor(private _elementRef: ng.ElementRef){} +} \ No newline at end of file diff --git a/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/tsconfig.json b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/tsconfig.json new file mode 100644 index 00000000000..b76669d9329 --- /dev/null +++ b/tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJSIsolatedModuleNoResolve/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "isolatedModules": true, + "noResolve": true + }, + "files": [ + "main.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 206f69142a5..1766e3280d4 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -429,5 +429,43 @@ var x = 0;`, { transpilesCorrectly("Supports setting 'typeRoots'", "x;", { options: { compilerOptions: { typeRoots: ["./folder"] }, fileName: "input.js", reportDiagnostics: true } }); + + transpilesCorrectly("Correctly serialize metadata when transpile with CommonJS option", + `import * as ng from "angular2/core";` + + `declare function foo(...args: any[]);` + + `@foo` + + `export class MyClass1 {` + + ` constructor(private _elementRef: ng.ElementRef){}` + + `}`, { + options: { + compilerOptions: { + target: ScriptTarget.ES5, + module: ModuleKind.CommonJS, + moduleResolution: ModuleResolutionKind.NodeJs, + emitDecoratorMetadata: true, + experimentalDecorators: true, + isolatedModules: true, + } + } + }); + + transpilesCorrectly("Correctly serialize metadata when transpile with System option", + `import * as ng from "angular2/core";` + + `declare function foo(...args: any[]);` + + `@foo` + + `export class MyClass1 {` + + ` constructor(private _elementRef: ng.ElementRef){}` + + `}`, { + options: { + compilerOptions: { + target: ScriptTarget.ES5, + module: ModuleKind.System, + moduleResolution: ModuleResolutionKind.NodeJs, + emitDecoratorMetadata: true, + experimentalDecorators: true, + isolatedModules: true, + } + } + }); }); } From be2ca35b004f2079464fdca454c08a5019020260 Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 24 Jun 2016 17:40:07 -0700 Subject: [PATCH 039/103] Fix 8467: Fix incorrect emit for accessing static property in static propertyDeclaration (#8551) * Fix incorrect emit for accessing static property in static propertyDeclaration * Update tests and baselines * Update function name * Fix when accessing static property inside arrow function * Add tests and baselines --- src/compiler/emitter.ts | 40 ++++++++++--- ...classExpressionWithStaticPropertiesES61.js | 17 ++++-- ...ExpressionWithStaticPropertiesES61.symbols | 17 +++++- ...ssExpressionWithStaticPropertiesES61.types | 17 +++++- ...classExpressionWithStaticPropertiesES62.js | 21 +++++-- ...ExpressionWithStaticPropertiesES62.symbols | 25 +++++++- ...ssExpressionWithStaticPropertiesES62.types | 27 ++++++++- ...classExpressionWithStaticPropertiesES63.js | 23 ++++++++ ...ExpressionWithStaticPropertiesES63.symbols | 42 ++++++++++++++ ...ssExpressionWithStaticPropertiesES63.types | 58 +++++++++++++++++++ ...classExpressionWithStaticPropertiesES61.ts | 6 +- ...classExpressionWithStaticPropertiesES62.ts | 9 ++- ...classExpressionWithStaticPropertiesES63.ts | 11 ++++ 13 files changed, 283 insertions(+), 30 deletions(-) create mode 100644 tests/baselines/reference/classExpressionWithStaticPropertiesES63.js create mode 100644 tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols create mode 100644 tests/baselines/reference/classExpressionWithStaticPropertiesES63.types create mode 100644 tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 46cab8f92f0..0879a3a9ee4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1673,6 +1673,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return false; } + function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node: Identifier) { + if (languageVersion >= ScriptTarget.ES6) { + let parent = node.parent; + if (parent.kind === SyntaxKind.PropertyAccessExpression && (parent).expression === node) { + parent = parent.parent; + while (parent && parent.kind !== SyntaxKind.PropertyDeclaration) { + parent = parent.parent; + } + return parent && parent.kind === SyntaxKind.PropertyDeclaration && (parent.flags & NodeFlags.Static) !== 0 && + parent.parent.kind === SyntaxKind.ClassExpression ? parent.parent : undefined; + } + } + return undefined; + } + function emitIdentifier(node: Identifier) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { @@ -1687,6 +1702,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge write(node.text); } else if (isExpressionIdentifier(node)) { + const classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node); + if (classExpression) { + const declaration = resolver.getReferencedValueDeclaration(node); + if (declaration === classExpression) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } emitExpressionIdentifier(node); } else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { @@ -5086,13 +5109,13 @@ const _super = (function (geti, seti) { } } - function emitPropertyDeclaration(node: ClassLikeDeclaration, property: PropertyDeclaration, receiver?: Identifier, isExpression?: boolean) { + function emitPropertyDeclaration(node: ClassLikeDeclaration, property: PropertyDeclaration, receiver?: string, isExpression?: boolean) { writeLine(); emitLeadingComments(property); emitStart(property); emitStart(property.name); if (receiver) { - emit(receiver); + write(receiver); } else { if (property.flags & NodeFlags.Static) { @@ -5511,13 +5534,16 @@ const _super = (function (geti, seti) { // of it have been initialized by the time it is used. const staticProperties = getInitializedProperties(node, /*isStatic*/ true); const isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression; - let tempVariable: Identifier; + let generatedName: string; if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(TempFlags.Auto); + generatedName = getGeneratedNameForNode(node.name); + const synthesizedNode = createSynthesizedNode(SyntaxKind.Identifier); + synthesizedNode.text = generatedName; + recordTempDeclaration(synthesizedNode); write("("); increaseIndent(); - emit(tempVariable); + emit(synthesizedNode); write(" = "); } @@ -5571,11 +5597,11 @@ const _super = (function (geti, seti) { for (const property of staticProperties) { write(","); writeLine(); - emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true); + emitPropertyDeclaration(node, property, /*receiver*/ generatedName, /*isExpression*/ true); } write(","); writeLine(); - emit(tempVariable); + write(generatedName); decreaseIndent(); write(")"); } diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js index 43f5e7415c4..7ddacb70405 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js @@ -1,10 +1,15 @@ //// [classExpressionWithStaticPropertiesES61.ts] -var v = class C { static a = 1; static b = 2 }; +var v = class C { + static a = 1; + static b = 2; + static c = C.a + 3; +}; //// [classExpressionWithStaticPropertiesES61.js] -var v = (_a = class C { +var v = (C_1 = class C { }, - _a.a = 1, - _a.b = 2, - _a); -var _a; + C_1.a = 1, + C_1.b = 2, + C_1.c = C_1.a + 3, + C_1); +var C_1; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.symbols index c5f53e19bff..1101c0bab2f 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.symbols +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.symbols @@ -1,7 +1,18 @@ === tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts === -var v = class C { static a = 1; static b = 2 }; +var v = class C { >v : Symbol(v, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 3)) >C : Symbol(C, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 7)) ->a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17)) ->b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 31)) + static a = 1; +>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17)) + + static b = 2; +>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES61.ts, 1, 17)) + + static c = C.a + 3; +>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES61.ts, 2, 17)) +>C.a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 7)) +>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17)) + +}; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types index 02c385b7525..0ba6ada4131 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types @@ -1,10 +1,23 @@ === tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts === -var v = class C { static a = 1; static b = 2 }; +var v = class C { >v : typeof C ->class C { static a = 1; static b = 2 } : typeof C +>class C { static a = 1; static b = 2; static c = C.a + 3;} : typeof C >C : typeof C + + static a = 1; >a : number >1 : number + + static b = 2; >b : number >2 : number + static c = C.a + 3; +>c : number +>C.a + 3 : number +>C.a : number +>C : typeof C +>a : number +>3 : number + +}; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js index 1efa56ecaa2..0a4b7645ecc 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js @@ -1,9 +1,20 @@ //// [classExpressionWithStaticPropertiesES62.ts] -var v = class C { static a = 1; static b }; +var v = class C { + static a = 1; + static b + static c = { + x: "hi" + } + static d = C.c.x + " world"; + }; //// [classExpressionWithStaticPropertiesES62.js] -var v = (_a = class C { +var v = (C_1 = class C { }, - _a.a = 1, - _a); -var _a; + C_1.a = 1, + C_1.c = { + x: "hi" + }, + C_1.d = C_1.c.x + " world", + C_1); +var C_1; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.symbols index be57a289f53..697be499595 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.symbols +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.symbols @@ -1,7 +1,26 @@ === tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts === -var v = class C { static a = 1; static b }; +var v = class C { >v : Symbol(v, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 3)) >C : Symbol(C, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 7)) ->a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 17)) ->b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 31)) + static a = 1; +>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 17)) + + static b +>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES62.ts, 1, 17)) + + static c = { +>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12)) + + x: "hi" +>x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16)) + } + static d = C.c.x + " world"; +>d : Symbol(C.d, Decl(classExpressionWithStaticPropertiesES62.ts, 5, 5)) +>C.c.x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16)) +>C.c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 7)) +>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12)) +>x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16)) + + }; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types index e8ded1422f1..97d6940a3fc 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types @@ -1,9 +1,32 @@ === tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts === -var v = class C { static a = 1; static b }; +var v = class C { >v : typeof C ->class C { static a = 1; static b } : typeof C +>class C { static a = 1; static b static c = { x: "hi" } static d = C.c.x + " world"; } : typeof C >C : typeof C + + static a = 1; >a : number >1 : number + + static b >b : any + static c = { +>c : { x: string; } +>{ x: "hi" } : { x: string; } + + x: "hi" +>x : string +>"hi" : string + } + static d = C.c.x + " world"; +>d : string +>C.c.x + " world" : string +>C.c.x : string +>C.c : { x: string; } +>C : typeof C +>c : { x: string; } +>x : string +>" world" : string + + }; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.js b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.js new file mode 100644 index 00000000000..53955735762 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.js @@ -0,0 +1,23 @@ +//// [classExpressionWithStaticPropertiesES63.ts] + +declare var console: any; +const arr: {y(): number}[] = []; +for (let i = 0; i < 3; i++) { + arr.push(class C { + static x = i; + static y = () => C.x * 2; + }); +} +arr.forEach(C => console.log(C.y())); + +//// [classExpressionWithStaticPropertiesES63.js] +const arr = []; +for (let i = 0; i < 3; i++) { + arr.push((C_1 = class C { + }, + C_1.x = i, + C_1.y = () => C_1.x * 2, + C_1)); +} +arr.forEach(C => console.log(C.y())); +var C_1; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols new file mode 100644 index 00000000000..f1a7fa807f5 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts === + +declare var console: any; +>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11)) + +const arr: {y(): number}[] = []; +>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5)) +>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12)) + +for (let i = 0; i < 3; i++) { +>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8)) +>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8)) +>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8)) + + arr.push(class C { +>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13)) + + static x = i; +>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22)) +>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8)) + + static y = () => C.x * 2; +>y : Symbol(C.y, Decl(classExpressionWithStaticPropertiesES63.ts, 5, 21)) +>C.x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13)) +>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22)) + + }); +} +arr.forEach(C => console.log(C.y())); +>arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12)) +>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11)) +>C.y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12)) +>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12)) +>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12)) + diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types new file mode 100644 index 00000000000..92f14f3f65f --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts === + +declare var console: any; +>console : any + +const arr: {y(): number}[] = []; +>arr : { y(): number; }[] +>y : () => number +>[] : undefined[] + +for (let i = 0; i < 3; i++) { +>i : number +>0 : number +>i < 3 : boolean +>i : number +>3 : number +>i++ : number +>i : number + + arr.push(class C { +>arr.push(class C { static x = i; static y = () => C.x * 2; }) : number +>arr.push : (...items: { y(): number; }[]) => number +>arr : { y(): number; }[] +>push : (...items: { y(): number; }[]) => number +>class C { static x = i; static y = () => C.x * 2; } : typeof C +>C : typeof C + + static x = i; +>x : number +>i : number + + static y = () => C.x * 2; +>y : () => number +>() => C.x * 2 : () => number +>C.x * 2 : number +>C.x : number +>C : typeof C +>x : number +>2 : number + + }); +} +arr.forEach(C => console.log(C.y())); +>arr.forEach(C => console.log(C.y())) : void +>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>arr : { y(): number; }[] +>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>C => console.log(C.y()) : (C: { y(): number; }) => any +>C : { y(): number; } +>console.log(C.y()) : any +>console.log : any +>console : any +>log : any +>C.y() : number +>C.y : () => number +>C : { y(): number; } +>y : () => number + diff --git a/tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts b/tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts index 8df07b9569a..3f9fc43835e 100644 --- a/tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts +++ b/tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts @@ -1,2 +1,6 @@ //@target: es6 -var v = class C { static a = 1; static b = 2 }; \ No newline at end of file +var v = class C { + static a = 1; + static b = 2; + static c = C.a + 3; +}; \ No newline at end of file diff --git a/tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts b/tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts index ee0430eb793..afb87b10de9 100644 --- a/tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts +++ b/tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts @@ -1,2 +1,9 @@ //@target: es6 -var v = class C { static a = 1; static b }; \ No newline at end of file +var v = class C { + static a = 1; + static b + static c = { + x: "hi" + } + static d = C.c.x + " world"; + }; \ No newline at end of file diff --git a/tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts b/tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts new file mode 100644 index 00000000000..939a344f9bb --- /dev/null +++ b/tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts @@ -0,0 +1,11 @@ +//@target: es6 + +declare var console: any; +const arr: {y(): number}[] = []; +for (let i = 0; i < 3; i++) { + arr.push(class C { + static x = i; + static y = () => C.x * 2; + }); +} +arr.forEach(C => console.log(C.y())); \ No newline at end of file From 9dfcb4419ca52efce7321ef08e88a1c4c0491c93 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sat, 25 Jun 2016 19:23:46 +0900 Subject: [PATCH 040/103] do not format comma/closeparen in jsxelement --- src/services/formatting/rules.ts | 10 ++++--- .../cases/fourslash/formattingJsxElements.ts | 26 ++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index b4916025af2..5fb6b330b42 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -316,7 +316,7 @@ namespace ts.formatting { // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotForContext), RuleAction.Space)); + this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext, Rules.IsNotForContext), RuleAction.Space)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. this.SpaceAfterTryFinally = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword]), SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); @@ -444,8 +444,8 @@ namespace ts.formatting { /// // Insert space after comma delimiter - this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space)); - this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space)); + this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext), RuleAction.Delete)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space)); @@ -723,6 +723,10 @@ namespace ts.formatting { return context.TokensAreOnSameLine() && context.contextNode.kind !== SyntaxKind.JsxText; } + static isNonJsxElementContext(context: FormattingContext): boolean { + return context.contextNode.kind !== SyntaxKind.JsxElement; + } + static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); } diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts index fbe4bb5d29e..50e9bb8ea8f 100644 --- a/tests/cases/fourslash/formattingJsxElements.ts +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -9,7 +9,7 @@ //// //// ) ////} -//// +//// ////function foo1() { //// return ( ////
@@ -45,8 +45,8 @@ //// class3= {/*5*/ //// }/>/*6*/ //// ) -////} -//// +////} +//// ////(function () { //// return
/*grandchildJsxElementAutoformat*/ /////*containedClosingTagAutoformat*/ -//// +////; +//// +////
,{integer}
;/*commaInJsxElement*/ +////
, {integer}
;/*commaInJsxElement2*/ +////);/*closingParenInJsxElement*/ +////) ;/*closingParenInJsxElement2*/ format.document(); goTo.marker("autoformat"); @@ -114,7 +119,7 @@ verify.indentationIs(12); goTo.marker("danglingBracketAutoformat") // TODO: verify.currentLineContentIs(" >"); -verify.currentLineContentIs(" >"); +verify.currentLineContentIs(" >"); goTo.marker("closingTagAutoformat"); verify.currentLineContentIs("
"); @@ -125,4 +130,13 @@ verify.indentationIs(8); goTo.marker("grandchildJsxElementAutoformat"); verify.currentLineContentIs(" "); goTo.marker("containedClosingTagAutoformat"); -verify.currentLineContentIs(" "); \ No newline at end of file +verify.currentLineContentIs(" "); + +goTo.marker("commaInJsxElement"); +verify.currentLineContentIs("
,{integer}
;"); +goTo.marker("commaInJsxElement2"); +verify.currentLineContentIs("
, {integer}
;"); +goTo.marker("closingParenInJsxElement"); +verify.currentLineContentIs(");"); +goTo.marker("closingParenInJsxElement2"); +verify.currentLineContentIs(") ;"); \ No newline at end of file From 378c6b5fc77957ae4413fbbb68fed44a47efa2d1 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sun, 26 Jun 2016 15:17:05 +0900 Subject: [PATCH 041/103] format jsx expression --- src/services/formatting/rules.ts | 13 +++++++++++++ tests/cases/fourslash/formattingJsxElements.ts | 12 +++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 5fb6b330b42..50d6d596198 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -52,6 +52,10 @@ namespace ts.formatting { public SpaceBeforeCloseBrace: Rule; public NoSpaceBetweenEmptyBraceBrackets: Rule; + // No space after { and before } in JSX expression + public NoSpaceAfterOpenBraceInJsxExpression: Rule; + public NoSpaceBeforeCloseBraceInJsxExpression: Rule; + // Insert new line after { and before } in multi-line contexts. public NewLineAfterOpenBraceInBlockContext: Rule; @@ -276,6 +280,10 @@ namespace ts.formatting { this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space)); this.NoSpaceBetweenEmptyBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), RuleAction.Delete)); + // No space after { and before } in JSX expression + this.NoSpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); + // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsMultilineBlockContext), RuleAction.NewLine)); @@ -395,6 +403,7 @@ namespace ts.formatting { this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, this.NoSpaceAfterCloseBrace, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, + this.NoSpaceAfterOpenBraceInJsxExpression, this.NoSpaceBeforeCloseBraceInJsxExpression, this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, @@ -727,6 +736,10 @@ namespace ts.formatting { return context.contextNode.kind !== SyntaxKind.JsxElement; } + static isJsxExpressionContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.JsxExpression; + } + static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); } diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts index 50e9bb8ea8f..e07149960db 100644 --- a/tests/cases/fourslash/formattingJsxElements.ts +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -66,10 +66,12 @@ /////*containedClosingTagAutoformat*/ ////; //// -////
,{integer}
;/*commaInJsxElement*/ -////
, {integer}
;/*commaInJsxElement2*/ +////
,{integer}
;/*commaInJsxElement*/ +////
, {integer}
;/*commaInJsxElement2*/ ////);/*closingParenInJsxElement*/ ////) ;/*closingParenInJsxElement2*/ +////;/*jsxExpressionSpaces*/ +////;/*jsxExpressionSpaces2*/ format.document(); goTo.marker("autoformat"); @@ -139,4 +141,8 @@ verify.currentLineContentIs("
, {integer}
;"); goTo.marker("closingParenInJsxElement"); verify.currentLineContentIs(");"); goTo.marker("closingParenInJsxElement2"); -verify.currentLineContentIs(") ;"); \ No newline at end of file +verify.currentLineContentIs(") ;"); +goTo.marker("jsxExpressionSpaces"); +verify.currentLineContentIs(";"); +goTo.marker("jsxExpressionSpaces2"); +verify.currentLineContentIs(";"); \ No newline at end of file From 6fba804cd8d8768637609a8c088c13bad6175ac6 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sun, 26 Jun 2016 08:45:16 -0700 Subject: [PATCH 042/103] Remove extra baselines --- .../constDeclarations-useBeforeDefinition2.symbols | 9 --------- .../constDeclarations-useBeforeDefinition2.types | 10 ---------- .../letDeclarations-useBeforeDefinition2.symbols | 9 --------- .../letDeclarations-useBeforeDefinition2.types | 10 ---------- ...n compiler-options input is empty object.errors.txt | 6 ------ ...rror when compiler-options input is empty object.js | 2 -- ...n compiler-options input is empty string.errors.txt | 6 ------ ...rror when compiler-options input is empty string.js | 2 -- 8 files changed, 54 deletions(-) delete mode 100644 tests/baselines/reference/constDeclarations-useBeforeDefinition2.symbols delete mode 100644 tests/baselines/reference/constDeclarations-useBeforeDefinition2.types delete mode 100644 tests/baselines/reference/letDeclarations-useBeforeDefinition2.symbols delete mode 100644 tests/baselines/reference/letDeclarations-useBeforeDefinition2.types delete mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.errors.txt delete mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.js delete mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.errors.txt delete mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.js diff --git a/tests/baselines/reference/constDeclarations-useBeforeDefinition2.symbols b/tests/baselines/reference/constDeclarations-useBeforeDefinition2.symbols deleted file mode 100644 index 281ce427733..00000000000 --- a/tests/baselines/reference/constDeclarations-useBeforeDefinition2.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -c; ->c : Symbol(c, Decl(file2.ts, 0, 5)) - -=== tests/cases/compiler/file2.ts === -const c = 0; ->c : Symbol(c, Decl(file2.ts, 0, 5)) - diff --git a/tests/baselines/reference/constDeclarations-useBeforeDefinition2.types b/tests/baselines/reference/constDeclarations-useBeforeDefinition2.types deleted file mode 100644 index ae60fdfa477..00000000000 --- a/tests/baselines/reference/constDeclarations-useBeforeDefinition2.types +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -c; ->c : number - -=== tests/cases/compiler/file2.ts === -const c = 0; ->c : number ->0 : number - diff --git a/tests/baselines/reference/letDeclarations-useBeforeDefinition2.symbols b/tests/baselines/reference/letDeclarations-useBeforeDefinition2.symbols deleted file mode 100644 index c5a067ede4d..00000000000 --- a/tests/baselines/reference/letDeclarations-useBeforeDefinition2.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -l; ->l : Symbol(l, Decl(file2.ts, 0, 5)) - -=== tests/cases/compiler/file2.ts === -const l = 0; ->l : Symbol(l, Decl(file2.ts, 0, 5)) - diff --git a/tests/baselines/reference/letDeclarations-useBeforeDefinition2.types b/tests/baselines/reference/letDeclarations-useBeforeDefinition2.types deleted file mode 100644 index 793a7a78ba7..00000000000 --- a/tests/baselines/reference/letDeclarations-useBeforeDefinition2.types +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/compiler/file1.ts === - -l; ->l : number - -=== tests/cases/compiler/file2.ts === -const l = 0; ->l : number ->0 : number - diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.errors.txt deleted file mode 100644 index d7d6eb69300..00000000000 --- a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.errors.txt +++ /dev/null @@ -1,6 +0,0 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' - - -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' -==== file.ts (0 errors) ==== - \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.js b/tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.js deleted file mode 100644 index 1ceb1bcd146..00000000000 --- a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty object.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.errors.txt deleted file mode 100644 index d7d6eb69300..00000000000 --- a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.errors.txt +++ /dev/null @@ -1,6 +0,0 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' - - -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' -==== file.ts (0 errors) ==== - \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.js b/tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.js deleted file mode 100644 index 1ceb1bcd146..00000000000 --- a/tests/baselines/reference/transpile/Report an error when compiler-options input is empty string.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=file.js.map \ No newline at end of file From e9a0c56d3c01ff684ebdd026c3dd5d966abba85c Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sun, 26 Jun 2016 20:48:22 -0700 Subject: [PATCH 043/103] Fixed bugs and linting --- src/compiler/program.ts | 40 +++++++++++++++++++++++++++++++++------ src/compiler/utilities.ts | 3 +-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ecddd721211..48a1dcc73e7 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1073,9 +1073,16 @@ namespace ts { // - This calls resolveModuleNames, and then calls findSourceFile for each resolved module. // As all these operations happen - and are nested - within the createProgram call, they close over the below variables. // The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses. - const maxNodeModulesJsDepth = options.maxNodeModuleJsDepth || 2; + const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2; let currentNodeModulesJsDepth = 0; + // If a module has some of its imports skipped due to being at the depth limit under node_modules, then track + // this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed. + const modulesWithElidedImports: Map = {}; + + // Track source files that are JavaScript files found by searching under node_modules, as these shouldn't be compiled. + const jsFilesFoundSearchingNodeModules: Map = {}; + const start = new Date().getTime(); host = host || createCompilerHost(options); @@ -1230,6 +1237,7 @@ namespace ts { (oldOptions.rootDir !== options.rootDir) || (oldOptions.configFilePath !== options.configFilePath) || (oldOptions.baseUrl !== options.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || !arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || !mapIsEqualTo(oldOptions.paths, options.paths)) { @@ -1353,7 +1361,10 @@ namespace ts { getNewLine: () => host.getNewLine(), getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, - getSourceFiles: program.getSourceFiles, + getSourceFiles: () => filter(program.getSourceFiles(), + // Remove JavaScript files found by searching node_modules from the source files to emit + sourceFile => !lookUp(jsFilesFoundSearchingNodeModules, sourceFile.path) + ), writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, @@ -1888,6 +1899,14 @@ namespace ts { reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd); } + // See if we need to reprocess the imports due to prior skipped imports + if (file && lookUp(modulesWithElidedImports, file.path)) { + if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) { // TODO: Check for off-by-ones + modulesWithElidedImports[file.path] = false; + processImportedModules(file, getDirectoryPath(fileName)); + } + } + return file; } @@ -2026,6 +2045,8 @@ namespace ts { for (let i = 0; i < moduleNames.length; i++) { const resolution = resolutions[i]; setResolvedModule(file, moduleNames[i], resolution); + const resolvedPath = resolution ? toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName) : undefined; + // add file to program only if: // - resolution was successful // - noResolve is falsy @@ -2033,20 +2054,27 @@ namespace ts { // - it's not a top level JavaScript module that exceeded the search max const isJsFileUnderNodeModules = resolution && resolution.isExternalLibraryImport && hasJavaScriptFileExtension(resolution.resolvedFileName); + if (isJsFileUnderNodeModules) { + jsFilesFoundSearchingNodeModules[resolvedPath] = true; currentNodeModulesJsDepth++; } - const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && - !(isJsFileUnderNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth); - if (shouldAddFile) { + const elideImport = isJsFileUnderNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth; + const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; + + if (elideImport) { + modulesWithElidedImports[file.path] = true; + } + else if (shouldAddFile) { findSourceFile(resolution.resolvedFileName, - toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), + resolvedPath, /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } + if (isJsFileUnderNodeModules) { currentNodeModulesJsDepth--; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d01678ac767..c7fbeec6a63 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2275,7 +2275,7 @@ namespace ts { else { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; for (const sourceFile of sourceFiles) { - // Don't emit if source file is a declaration file, or TODO: was found by a search under 'node_modules' + // Don't emit if source file is a declaration file if (!isDeclarationFile(sourceFile)) { onSingleFileEmit(host, sourceFile); } @@ -2310,7 +2310,6 @@ namespace ts { function onBundledEmit(host: EmitHost) { // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified const bundledSources = filter(host.getSourceFiles(), - // TODO: Don't emit from source resolved by searching under node_modules sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file (!isExternalModule(sourceFile) || // non module file !!getEmitModuleKind(options))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted From 885b0e902aa74e36874479aa5e2f038fdbaac2c2 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sun, 26 Jun 2016 23:14:43 -0700 Subject: [PATCH 044/103] Added project tests for node_modules JavaScript searches --- .gitignore | 1 + .../amd/importHigher/root.js | 6 +++ .../amd/nodeModulesImportHigher.errors.txt | 40 +++++++++++++++++++ .../amd/nodeModulesImportHigher.json | 18 +++++++++ .../node/importHigher/root.js | 5 +++ .../node/nodeModulesImportHigher.errors.txt | 40 +++++++++++++++++++ .../node/nodeModulesImportHigher.json | 18 +++++++++ .../amd/maxDepthExceeded/root.js | 6 +++ .../nodeModulesMaxDepthExceeded.errors.txt | 32 +++++++++++++++ .../amd/nodeModulesMaxDepthExceeded.json | 17 ++++++++ .../node/maxDepthExceeded/root.js | 5 +++ .../nodeModulesMaxDepthExceeded.errors.txt | 32 +++++++++++++++ .../node/nodeModulesMaxDepthExceeded.json | 17 ++++++++ .../amd/maxDepthIncreased/root.js | 6 +++ .../nodeModulesMaxDepthIncreased.errors.txt | 38 ++++++++++++++++++ .../amd/nodeModulesMaxDepthIncreased.json | 18 +++++++++ .../node/maxDepthIncreased/root.js | 5 +++ .../nodeModulesMaxDepthIncreased.errors.txt | 38 ++++++++++++++++++ .../node/nodeModulesMaxDepthIncreased.json | 18 +++++++++ .../project/nodeModulesImportHigher.json | 8 ++++ .../project/nodeModulesMaxDepthExceeded.json | 8 ++++ .../project/nodeModulesMaxDepthIncreased.json | 8 ++++ .../importHigher/node_modules/m1/index.js | 10 +++++ .../importHigher/node_modules/m2/entry.js | 7 ++++ .../node_modules/m2/node_modules/m3/index.js | 4 ++ .../importHigher/node_modules/m2/package.json | 3 ++ .../NodeModulesSearch/importHigher/root.ts | 6 +++ .../importHigher/tsconfig.json | 7 ++++ .../maxDepthExceeded/node_modules/m1/index.js | 10 +++++ .../maxDepthExceeded/node_modules/m2/entry.js | 7 ++++ .../node_modules/m2/node_modules/m3/index.js | 4 ++ .../node_modules/m2/package.json | 3 ++ .../maxDepthExceeded/root.ts | 4 ++ .../maxDepthExceeded/tsconfig.json | 5 +++ .../node_modules/m1/index.js | 10 +++++ .../node_modules/m2/entry.js | 7 ++++ .../node_modules/m2/node_modules/m3/index.js | 4 ++ .../node_modules/m2/package.json | 3 ++ .../maxDepthIncreased/root.ts | 4 ++ .../maxDepthIncreased/tsconfig.json | 6 +++ 40 files changed, 488 insertions(+) create mode 100644 tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js create mode 100644 tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt create mode 100644 tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.json create mode 100644 tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js create mode 100644 tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt create mode 100644 tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.json create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/root.js create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/root.js create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt create mode 100644 tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json create mode 100644 tests/cases/project/nodeModulesImportHigher.json create mode 100644 tests/cases/project/nodeModulesMaxDepthExceeded.json create mode 100644 tests/cases/project/nodeModulesMaxDepthIncreased.json create mode 100644 tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js create mode 100644 tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js create mode 100644 tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js create mode 100644 tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/package.json create mode 100644 tests/cases/projects/NodeModulesSearch/importHigher/root.ts create mode 100644 tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/node_modules/m3/index.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/package.json create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthExceeded/root.ts create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthExceeded/tsconfig.json create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/package.json create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/tsconfig.json diff --git a/.gitignore b/.gitignore index e61c3510e37..bbb2e62c8bc 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ internal/ **/.vscode !**/.vscode/tasks.json !tests/cases/projects/projectOption/**/node_modules +!tests/cases/projects/NodeModulesSearch/**/* diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js new file mode 100644 index 00000000000..5b8a451c781 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js @@ -0,0 +1,6 @@ +define(["require", "exports", "m1"], function (require, exports, m1) { + "use strict"; + m1.f1("test"); + m1.f2.a = 10; + m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). +}); diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt new file mode 100644 index 00000000000..dd2b221798c --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt @@ -0,0 +1,40 @@ +importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js (0 errors) ==== + var m2 = require('m2'); + + /** + * @param {string} p1 The first param + */ + exports.f1 = function(p1) { + return 42; + }; + + exports.f2 = m2; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js (0 errors) ==== + exports.person = { + "name": "John Doe", + "age": 42 + } + +==== importHigher/root.ts (1 errors) ==== + import * as m1 from "m1"; + import * as m2 from "m2"; + + m1.f1("test"); + m1.f2.a = 10; + m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.json b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.json new file mode 100644 index 00000000000..6f422876d33 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.json @@ -0,0 +1,18 @@ +{ + "scenario": "Verify that a higher import loads a module that was previously skipped", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "importHigher", + "resolvedInputFiles": [ + "lib.d.ts", + "importHigher/node_modules/m2/entry.js", + "importHigher/node_modules/m1/index.js", + "importHigher/node_modules/m2/node_modules/m3/index.js", + "importHigher/root.ts" + ], + "emittedFiles": [ + "importHigher/root.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js new file mode 100644 index 00000000000..59944c663e9 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js @@ -0,0 +1,5 @@ +"use strict"; +var m1 = require("m1"); +m1.f1("test"); +m1.f2.a = 10; +m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt new file mode 100644 index 00000000000..dd2b221798c --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt @@ -0,0 +1,40 @@ +importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js (0 errors) ==== + var m2 = require('m2'); + + /** + * @param {string} p1 The first param + */ + exports.f1 = function(p1) { + return 42; + }; + + exports.f2 = m2; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js (0 errors) ==== + exports.person = { + "name": "John Doe", + "age": 42 + } + +==== importHigher/root.ts (1 errors) ==== + import * as m1 from "m1"; + import * as m2 from "m2"; + + m1.f1("test"); + m1.f2.a = 10; + m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.json b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.json new file mode 100644 index 00000000000..6f422876d33 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.json @@ -0,0 +1,18 @@ +{ + "scenario": "Verify that a higher import loads a module that was previously skipped", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "importHigher", + "resolvedInputFiles": [ + "lib.d.ts", + "importHigher/node_modules/m2/entry.js", + "importHigher/node_modules/m1/index.js", + "importHigher/node_modules/m2/node_modules/m3/index.js", + "importHigher/root.ts" + ], + "emittedFiles": [ + "importHigher/root.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/root.js new file mode 100644 index 00000000000..73cef6fc02c --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/root.js @@ -0,0 +1,6 @@ +define(["require", "exports", "m1"], function (require, exports, m1) { + "use strict"; + m1.f1("test"); + m1.f2.a = "10"; // Error: Should be number + m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". +}); diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt new file mode 100644 index 00000000000..81612e2a387 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt @@ -0,0 +1,32 @@ +maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js (0 errors) ==== + var m2 = require('m2'); + + /** + * @param {string} p1 The first param + */ + exports.f1 = function(p1) { + return 42; + }; + + exports.f2 = m2; + +==== maxDepthExceeded/root.ts (1 errors) ==== + import * as m1 from "m1"; + m1.f1("test"); + m1.f2.a = "10"; // Error: Should be number + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". + \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json new file mode 100644 index 00000000000..80a0a0fb93d --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json @@ -0,0 +1,17 @@ +{ + "scenario": "Verify that JavaScript modules are not resolved if too many hops", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "maxDepthExceeded", + "resolvedInputFiles": [ + "lib.d.ts", + "maxDepthExceeded/node_modules/m2/entry.js", + "maxDepthExceeded/node_modules/m1/index.js", + "maxDepthExceeded/root.ts" + ], + "emittedFiles": [ + "maxDepthExceeded/root.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/root.js new file mode 100644 index 00000000000..28f91fb9b91 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/root.js @@ -0,0 +1,5 @@ +"use strict"; +var m1 = require("m1"); +m1.f1("test"); +m1.f2.a = "10"; // Error: Should be number +m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt new file mode 100644 index 00000000000..81612e2a387 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt @@ -0,0 +1,32 @@ +maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js (0 errors) ==== + var m2 = require('m2'); + + /** + * @param {string} p1 The first param + */ + exports.f1 = function(p1) { + return 42; + }; + + exports.f2 = m2; + +==== maxDepthExceeded/root.ts (1 errors) ==== + import * as m1 from "m1"; + m1.f1("test"); + m1.f2.a = "10"; // Error: Should be number + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". + \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json new file mode 100644 index 00000000000..80a0a0fb93d --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json @@ -0,0 +1,17 @@ +{ + "scenario": "Verify that JavaScript modules are not resolved if too many hops", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "maxDepthExceeded", + "resolvedInputFiles": [ + "lib.d.ts", + "maxDepthExceeded/node_modules/m2/entry.js", + "maxDepthExceeded/node_modules/m1/index.js", + "maxDepthExceeded/root.ts" + ], + "emittedFiles": [ + "maxDepthExceeded/root.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js new file mode 100644 index 00000000000..77951a4889d --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -0,0 +1,6 @@ +define(["require", "exports", "m1"], function (require, exports, m1) { + "use strict"; + m1.f1("test"); + m1.f2.a = 10; + m1.f2.person.age = "10"; // Error: Should be number +}); diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt new file mode 100644 index 00000000000..5a395b70ee6 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt @@ -0,0 +1,38 @@ +maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js (0 errors) ==== + exports.person = { + "name": "John Doe", + "age": 42 + } + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js (0 errors) ==== + var m2 = require('m2'); + + /** + * @param {string} p1 The first param + */ + exports.f1 = function(p1) { + return 42; + }; + + exports.f2 = m2; + +==== maxDepthIncreased/root.ts (1 errors) ==== + import * as m1 from "m1"; + m1.f1("test"); + m1.f2.a = 10; + m1.f2.person.age = "10"; // Error: Should be number + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json new file mode 100644 index 00000000000..1350bf6441e --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json @@ -0,0 +1,18 @@ +{ + "scenario": "Verify that the setting to search node_modules deeper takes effect", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "maxDepthIncreased", + "resolvedInputFiles": [ + "lib.d.ts", + "maxDepthIncreased/node_modules/m2/node_modules/m3/index.js", + "maxDepthIncreased/node_modules/m2/entry.js", + "maxDepthIncreased/node_modules/m1/index.js", + "maxDepthIncreased/root.ts" + ], + "emittedFiles": [ + "maxDepthIncreased/root.js" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js new file mode 100644 index 00000000000..3a0a96991b0 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -0,0 +1,5 @@ +"use strict"; +var m1 = require("m1"); +m1.f1("test"); +m1.f2.a = 10; +m1.f2.person.age = "10"; // Error: Should be number diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt new file mode 100644 index 00000000000..5a395b70ee6 --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt @@ -0,0 +1,38 @@ +maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js (0 errors) ==== + exports.person = { + "name": "John Doe", + "age": 42 + } + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; + +==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js (0 errors) ==== + var m2 = require('m2'); + + /** + * @param {string} p1 The first param + */ + exports.f1 = function(p1) { + return 42; + }; + + exports.f2 = m2; + +==== maxDepthIncreased/root.ts (1 errors) ==== + import * as m1 from "m1"; + m1.f1("test"); + m1.f2.a = 10; + m1.f2.person.age = "10"; // Error: Should be number + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json new file mode 100644 index 00000000000..1350bf6441e --- /dev/null +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json @@ -0,0 +1,18 @@ +{ + "scenario": "Verify that the setting to search node_modules deeper takes effect", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "maxDepthIncreased", + "resolvedInputFiles": [ + "lib.d.ts", + "maxDepthIncreased/node_modules/m2/node_modules/m3/index.js", + "maxDepthIncreased/node_modules/m2/entry.js", + "maxDepthIncreased/node_modules/m1/index.js", + "maxDepthIncreased/root.ts" + ], + "emittedFiles": [ + "maxDepthIncreased/root.js" + ] +} \ No newline at end of file diff --git a/tests/cases/project/nodeModulesImportHigher.json b/tests/cases/project/nodeModulesImportHigher.json new file mode 100644 index 00000000000..2cca8c03f00 --- /dev/null +++ b/tests/cases/project/nodeModulesImportHigher.json @@ -0,0 +1,8 @@ +{ + "scenario": "Verify that a higher import loads a module that was previously skipped", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "importHigher" +} diff --git a/tests/cases/project/nodeModulesMaxDepthExceeded.json b/tests/cases/project/nodeModulesMaxDepthExceeded.json new file mode 100644 index 00000000000..45e1210aa8c --- /dev/null +++ b/tests/cases/project/nodeModulesMaxDepthExceeded.json @@ -0,0 +1,8 @@ +{ + "scenario": "Verify that JavaScript modules are not resolved if too many hops", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "maxDepthExceeded" +} diff --git a/tests/cases/project/nodeModulesMaxDepthIncreased.json b/tests/cases/project/nodeModulesMaxDepthIncreased.json new file mode 100644 index 00000000000..0973ae4bd5b --- /dev/null +++ b/tests/cases/project/nodeModulesMaxDepthIncreased.json @@ -0,0 +1,8 @@ +{ + "scenario": "Verify that the setting to search node_modules deeper takes effect", + "projectRoot": "tests/cases/projects/NodeModulesSearch", + "baselineCheck": true, + "declaration": false, + "moduleResolution": "node", + "project": "maxDepthIncreased" +} diff --git a/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js new file mode 100644 index 00000000000..7ff454a2402 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js @@ -0,0 +1,10 @@ +var m2 = require('m2'); + +/** + * @param {string} p1 The first param + */ +exports.f1 = function(p1) { + return 42; +}; + +exports.f2 = m2; diff --git a/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js new file mode 100644 index 00000000000..ce3eee6d895 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js @@ -0,0 +1,7 @@ +var m3 = require("m3"); + +module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person +}; diff --git a/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js new file mode 100644 index 00000000000..aeec6707697 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js @@ -0,0 +1,4 @@ +exports.person = { + "name": "John Doe", + "age": 42 +} diff --git a/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/package.json b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/package.json new file mode 100644 index 00000000000..33534249d41 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/package.json @@ -0,0 +1,3 @@ +{ + "main": "entry.js" +} diff --git a/tests/cases/projects/NodeModulesSearch/importHigher/root.ts b/tests/cases/projects/NodeModulesSearch/importHigher/root.ts new file mode 100644 index 00000000000..9bf5b1f82c3 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/importHigher/root.ts @@ -0,0 +1,6 @@ +import * as m1 from "m1"; +import * as m2 from "m2"; + +m1.f1("test"); +m1.f2.a = 10; +m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). diff --git a/tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json b/tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json new file mode 100644 index 00000000000..c7b95984b42 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "allowJs": true, + "declaration": false, + "moduleResolution": "node" + } +} diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js new file mode 100644 index 00000000000..7ff454a2402 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js @@ -0,0 +1,10 @@ +var m2 = require('m2'); + +/** + * @param {string} p1 The first param + */ +exports.f1 = function(p1) { + return 42; +}; + +exports.f2 = m2; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js new file mode 100644 index 00000000000..ce3eee6d895 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js @@ -0,0 +1,7 @@ +var m3 = require("m3"); + +module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person +}; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/node_modules/m3/index.js b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/node_modules/m3/index.js new file mode 100644 index 00000000000..aeec6707697 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/node_modules/m3/index.js @@ -0,0 +1,4 @@ +exports.person = { + "name": "John Doe", + "age": 42 +} diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/package.json b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/package.json new file mode 100644 index 00000000000..33534249d41 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/package.json @@ -0,0 +1,3 @@ +{ + "main": "entry.js" +} diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/root.ts b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/root.ts new file mode 100644 index 00000000000..62604408648 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/root.ts @@ -0,0 +1,4 @@ +import * as m1 from "m1"; +m1.f1("test"); +m1.f2.a = "10"; // Error: Should be number +m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/tsconfig.json b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/tsconfig.json new file mode 100644 index 00000000000..0aafe67d688 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "allowJs": true + } +} diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js new file mode 100644 index 00000000000..7ff454a2402 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js @@ -0,0 +1,10 @@ +var m2 = require('m2'); + +/** + * @param {string} p1 The first param + */ +exports.f1 = function(p1) { + return 42; +}; + +exports.f2 = m2; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js new file mode 100644 index 00000000000..ce3eee6d895 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js @@ -0,0 +1,7 @@ +var m3 = require("m3"); + +module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person +}; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js new file mode 100644 index 00000000000..aeec6707697 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js @@ -0,0 +1,4 @@ +exports.person = { + "name": "John Doe", + "age": 42 +} diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/package.json b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/package.json new file mode 100644 index 00000000000..33534249d41 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/package.json @@ -0,0 +1,3 @@ +{ + "main": "entry.js" +} diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts new file mode 100644 index 00000000000..9ed943bebba --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts @@ -0,0 +1,4 @@ +import * as m1 from "m1"; +m1.f1("test"); +m1.f2.a = 10; +m1.f2.person.age = "10"; // Error: Should be number diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/tsconfig.json b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/tsconfig.json new file mode 100644 index 00000000000..5388cc5d39f --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "allowJs": true, + "maxNodeModuleJsDepth": 3 + } +} From 1b43bd8e83f629d86b79ae338d7606689680bbf9 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sun, 26 Jun 2016 23:33:46 -0700 Subject: [PATCH 045/103] Removed old TODO comment --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 48a1dcc73e7..cee0936fafd 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1901,7 +1901,7 @@ namespace ts { // See if we need to reprocess the imports due to prior skipped imports if (file && lookUp(modulesWithElidedImports, file.path)) { - if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) { // TODO: Check for off-by-ones + if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file.path] = false; processImportedModules(file, getDirectoryPath(fileName)); } From cbfbfe1aa6dfe7310c5899cd103f614187eee798 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 27 Jun 2016 16:04:53 +0900 Subject: [PATCH 046/103] make rules optional --- src/harness/fourslash.ts | 1 + src/server/editorServices.ts | 1 + src/services/formatting/rules.ts | 21 ++++++------ src/services/formatting/rulesProvider.ts | 9 ++++++ src/services/services.ts | 1 + .../fourslash/formattingOptionsChangeJsx.ts | 32 +++++++++++++++++++ 6 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 tests/cases/fourslash/formattingOptionsChangeJsx.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index bae2977c44a..a42abbbc609 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -324,6 +324,7 @@ namespace FourSlash { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, }; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e48d6192017..092450e526c 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1580,6 +1580,7 @@ namespace ts.server { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, }); diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 50d6d596198..6e132f03465 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -52,10 +52,6 @@ namespace ts.formatting { public SpaceBeforeCloseBrace: Rule; public NoSpaceBetweenEmptyBraceBrackets: Rule; - // No space after { and before } in JSX expression - public NoSpaceAfterOpenBraceInJsxExpression: Rule; - public NoSpaceBeforeCloseBraceInJsxExpression: Rule; - // Insert new line after { and before } in multi-line contexts. public NewLineAfterOpenBraceInBlockContext: Rule; @@ -229,6 +225,12 @@ namespace ts.formatting { public NoSpaceBeforeTemplateMiddleAndTail: Rule; public SpaceBeforeTemplateMiddleAndTail: Rule; + // No space after { and before } in JSX expression + public NoSpaceAfterOpenBraceInJsxExpression: Rule; + public SpaceAfterOpenBraceInJsxExpression: Rule; + public NoSpaceBeforeCloseBraceInJsxExpression: Rule; + public SpaceBeforeCloseBraceInJsxExpression: Rule; + constructor() { /// /// Common Rules @@ -280,10 +282,6 @@ namespace ts.formatting { this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space)); this.NoSpaceBetweenEmptyBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), RuleAction.Delete)); - // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); - // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsMultilineBlockContext), RuleAction.NewLine)); @@ -403,7 +401,6 @@ namespace ts.formatting { this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, this.NoSpaceAfterCloseBrace, this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext, - this.NoSpaceAfterOpenBraceInJsxExpression, this.NoSpaceBeforeCloseBraceInJsxExpression, this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, @@ -500,6 +497,12 @@ namespace ts.formatting { this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); this.SpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + // No space after { and before } in JSX expression + this.NoSpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); + this.SpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Space)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); + this.SpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Space)); + // Insert space after function keyword for anonymous functions this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); this.NoSpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Delete)); diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index d672a401d89..1be0f9e912d 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -90,6 +90,15 @@ namespace ts.formatting { rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { + rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression); + rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression); + rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression); + } + if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } diff --git a/src/services/services.ts b/src/services/services.ts index a17d9feed24..5142b19b6c0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1267,6 +1267,7 @@ namespace ts { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string | undefined; diff --git a/tests/cases/fourslash/formattingOptionsChangeJsx.ts b/tests/cases/fourslash/formattingOptionsChangeJsx.ts new file mode 100644 index 00000000000..a3c7e28a1ef --- /dev/null +++ b/tests/cases/fourslash/formattingOptionsChangeJsx.ts @@ -0,0 +1,32 @@ +/// + +//@Filename: file.tsx +/////*InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces*/; + +runTest("InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces", ";", ";"); + + +function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { + // Go to the correct file + goTo.marker(propertyName); + + // Set the option to false first + format.setOption(propertyName, false); + + // Format + format.document(); + + // Verify + goTo.marker(propertyName); + verify.currentLineContentIs(expectedStringWhenFalse); + + // Set the option to true + format.setOption(propertyName, true); + + // Format + format.document(); + + // Verify + goTo.marker(propertyName); + verify.currentLineContentIs(expectedStringWhenTrue); +} \ No newline at end of file From de559fb3f4cdd2441403ca4b59d5501700f481ce Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 27 Jun 2016 01:23:22 -0700 Subject: [PATCH 047/103] Fixed the regexp for removing full paths --- src/harness/runnerbase.ts | 12 +++--------- .../declarationEmit_invalidReference2.errors.txt | 2 +- .../declarationFileOverwriteError.errors.txt | 2 +- .../declarationFileOverwriteErrorWithOut.errors.txt | 2 +- .../reference/exportStarFromEmptyModule.errors.txt | 2 +- .../reference/importNonExternalModule.errors.txt | 2 +- .../reference/invalidTripleSlashReference.errors.txt | 4 ++-- ...tionWithDeclarationEmitPathSameAsInput.errors.txt | 2 +- ...utDeclarationFileNameSameAsInputJsFile.errors.txt | 2 +- .../reference/library-reference-5.errors.txt | 2 +- .../baselines/reference/parserRealSource1.errors.txt | 2 +- .../reference/parserRealSource10.errors.txt | 2 +- .../reference/parserRealSource11.errors.txt | 2 +- .../reference/parserRealSource12.errors.txt | 2 +- .../reference/parserRealSource13.errors.txt | 2 +- .../reference/parserRealSource14.errors.txt | 2 +- .../baselines/reference/parserRealSource2.errors.txt | 2 +- .../baselines/reference/parserRealSource3.errors.txt | 2 +- .../baselines/reference/parserRealSource4.errors.txt | 2 +- .../baselines/reference/parserRealSource5.errors.txt | 2 +- .../baselines/reference/parserRealSource6.errors.txt | 2 +- .../baselines/reference/parserRealSource7.errors.txt | 2 +- .../baselines/reference/parserRealSource8.errors.txt | 2 +- .../baselines/reference/parserRealSource9.errors.txt | 2 +- tests/baselines/reference/parserharness.errors.txt | 8 ++++---- tests/baselines/reference/parserindenter.errors.txt | 2 +- .../amd/nodeModulesImportHigher.errors.txt | 6 +++--- .../node/nodeModulesImportHigher.errors.txt | 6 +++--- .../amd/nodeModulesMaxDepthExceeded.errors.txt | 4 ++-- .../node/nodeModulesMaxDepthExceeded.errors.txt | 4 ++-- .../amd/nodeModulesMaxDepthIncreased.errors.txt | 6 +++--- .../node/nodeModulesMaxDepthIncreased.errors.txt | 6 +++--- .../amd/rootDirectoryErrors.errors.txt | 2 +- .../node/rootDirectoryErrors.errors.txt | 2 +- .../reference/requireOfAnEmptyFile1.errors.txt | 2 +- tests/baselines/reference/scannertest1.errors.txt | 2 +- .../reference/selfReferencingFile2.errors.txt | 2 +- 37 files changed, 53 insertions(+), 59 deletions(-) diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index a16eddcbeec..346382b7a57 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -31,18 +31,12 @@ abstract class RunnerBase { /** Replaces instances of full paths with fileNames only */ static removeFullPaths(path: string) { - let fixedPath = path; - - // full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point - const fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; - const fullPathList = fixedPath.match(fullPath); - if (fullPathList) { - fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match))); - } + // If its a full path (starts with "C:" or "/") replace with just the filename + let fixedPath = /^(\w:|\/)/.test(path) ? Harness.Path.getFileName(path) : path; // when running in the browser the 'full path' is the host name, shows up in error baselines const localHost = /http:\/localhost:\d+/g; fixedPath = fixedPath.replace(localHost, ""); return fixedPath; } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/declarationEmit_invalidReference2.errors.txt b/tests/baselines/reference/declarationEmit_invalidReference2.errors.txt index 1f3960a87ab..9d480419022 100644 --- a/tests/baselines/reference/declarationEmit_invalidReference2.errors.txt +++ b/tests/baselines/reference/declarationEmit_invalidReference2.errors.txt @@ -4,5 +4,5 @@ tests/cases/compiler/declarationEmit_invalidReference2.ts(1,1): error TS6053: Fi ==== tests/cases/compiler/declarationEmit_invalidReference2.ts (1 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'invalid.ts' not found. +!!! error TS6053: File 'tests/cases/compiler/invalid.ts' not found. var x = 0; \ No newline at end of file diff --git a/tests/baselines/reference/declarationFileOverwriteError.errors.txt b/tests/baselines/reference/declarationFileOverwriteError.errors.txt index a12c60482e9..1974976dee1 100644 --- a/tests/baselines/reference/declarationFileOverwriteError.errors.txt +++ b/tests/baselines/reference/declarationFileOverwriteError.errors.txt @@ -1,7 +1,7 @@ error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file. -!!! error TS5055: Cannot write file 'a.d.ts' because it would overwrite input file. +!!! error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file. ==== tests/cases/compiler/a.d.ts (0 errors) ==== declare class c { diff --git a/tests/baselines/reference/declarationFileOverwriteErrorWithOut.errors.txt b/tests/baselines/reference/declarationFileOverwriteErrorWithOut.errors.txt index 02251900345..658465de9c2 100644 --- a/tests/baselines/reference/declarationFileOverwriteErrorWithOut.errors.txt +++ b/tests/baselines/reference/declarationFileOverwriteErrorWithOut.errors.txt @@ -1,7 +1,7 @@ error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file. -!!! error TS5055: Cannot write file 'out.d.ts' because it would overwrite input file. +!!! error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file. ==== tests/cases/compiler/out.d.ts (0 errors) ==== declare class c { diff --git a/tests/baselines/reference/exportStarFromEmptyModule.errors.txt b/tests/baselines/reference/exportStarFromEmptyModule.errors.txt index 9d781da2707..8ca80fae408 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.errors.txt +++ b/tests/baselines/reference/exportStarFromEmptyModule.errors.txt @@ -14,7 +14,7 @@ tests/cases/compiler/exportStarFromEmptyModule_module4.ts(4,5): error TS2339: Pr ==== tests/cases/compiler/exportStarFromEmptyModule_module3.ts (1 errors) ==== export * from "./exportStarFromEmptyModule_module2"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2306: File 'exportStarFromEmptyModule_module2.ts' is not a module. +!!! error TS2306: File 'tests/cases/compiler/exportStarFromEmptyModule_module2.ts' is not a module. export * from "./exportStarFromEmptyModule_module1"; export class A { diff --git a/tests/baselines/reference/importNonExternalModule.errors.txt b/tests/baselines/reference/importNonExternalModule.errors.txt index fb8294c5c03..96f8959565c 100644 --- a/tests/baselines/reference/importNonExternalModule.errors.txt +++ b/tests/baselines/reference/importNonExternalModule.errors.txt @@ -4,7 +4,7 @@ tests/cases/conformance/externalModules/foo_1.ts(1,22): error TS2306: File 'test ==== tests/cases/conformance/externalModules/foo_1.ts (1 errors) ==== import foo = require("./foo_0"); ~~~~~~~~~ -!!! error TS2306: File 'foo_0.ts' is not a module. +!!! error TS2306: File 'tests/cases/conformance/externalModules/foo_0.ts' is not a module. // Import should fail. foo_0 not an external module if(foo.answer === 42){ diff --git a/tests/baselines/reference/invalidTripleSlashReference.errors.txt b/tests/baselines/reference/invalidTripleSlashReference.errors.txt index 40d75004a99..1de5ecaaae1 100644 --- a/tests/baselines/reference/invalidTripleSlashReference.errors.txt +++ b/tests/baselines/reference/invalidTripleSlashReference.errors.txt @@ -5,10 +5,10 @@ tests/cases/compiler/invalidTripleSlashReference.ts(2,1): error TS6053: File 'te ==== tests/cases/compiler/invalidTripleSlashReference.ts (2 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'filedoesnotexist.ts' not found. +!!! error TS6053: File 'tests/cases/compiler/filedoesnotexist.ts' not found. /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'otherdoesnotexist.d.ts' not found. +!!! error TS6053: File 'tests/cases/compiler/otherdoesnotexist.d.ts' not found. // this test doesn't actually give the errors you want due to the way the compiler reports errors var x = 1; \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationWithDeclarationEmitPathSameAsInput.errors.txt b/tests/baselines/reference/jsFileCompilationWithDeclarationEmitPathSameAsInput.errors.txt index 84900bccc88..9e9c2adb0ef 100644 --- a/tests/baselines/reference/jsFileCompilationWithDeclarationEmitPathSameAsInput.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithDeclarationEmitPathSameAsInput.errors.txt @@ -1,7 +1,7 @@ error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file. -!!! error TS5055: Cannot write file 'a.d.ts' because it would overwrite input file. +!!! error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file. ==== tests/cases/compiler/a.ts (0 errors) ==== class c { } diff --git a/tests/baselines/reference/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.errors.txt b/tests/baselines/reference/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.errors.txt index 826f906538f..10c7b8c90dd 100644 --- a/tests/baselines/reference/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithOutDeclarationFileNameSameAsInputJsFile.errors.txt @@ -1,7 +1,7 @@ error TS5055: Cannot write file 'tests/cases/compiler/b.d.ts' because it would overwrite input file. -!!! error TS5055: Cannot write file 'b.d.ts' because it would overwrite input file. +!!! error TS5055: Cannot write file 'tests/cases/compiler/b.d.ts' because it would overwrite input file. ==== tests/cases/compiler/a.ts (0 errors) ==== class c { } diff --git a/tests/baselines/reference/library-reference-5.errors.txt b/tests/baselines/reference/library-reference-5.errors.txt index ea571cad1a3..a3729bc3a99 100644 --- a/tests/baselines/reference/library-reference-5.errors.txt +++ b/tests/baselines/reference/library-reference-5.errors.txt @@ -18,7 +18,7 @@ ==== /node_modules/bar/index.d.ts (1 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! message TS4090: Conflicting library definitions for 'alpha' found at 'index.d.ts' and 'index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict. +!!! message TS4090: Conflicting library definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict. declare var bar: any; ==== /node_modules/bar/node_modules/alpha/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/parserRealSource1.errors.txt b/tests/baselines/reference/parserRealSource1.errors.txt index 0d238dabf2b..23d1a1d744a 100644 --- a/tests/baselines/reference/parserRealSource1.errors.txt +++ b/tests/baselines/reference/parserRealSource1.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource1.ts(4,1): error TS60 /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export module CompilerDiagnostics { diff --git a/tests/baselines/reference/parserRealSource10.errors.txt b/tests/baselines/reference/parserRealSource10.errors.txt index b3c40202c4f..d6199636e69 100644 --- a/tests/baselines/reference/parserRealSource10.errors.txt +++ b/tests/baselines/reference/parserRealSource10.errors.txt @@ -348,7 +348,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export enum TokenID { diff --git a/tests/baselines/reference/parserRealSource11.errors.txt b/tests/baselines/reference/parserRealSource11.errors.txt index 718bda19a67..efae0f962fd 100644 --- a/tests/baselines/reference/parserRealSource11.errors.txt +++ b/tests/baselines/reference/parserRealSource11.errors.txt @@ -523,7 +523,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export class ASTSpan { diff --git a/tests/baselines/reference/parserRealSource12.errors.txt b/tests/baselines/reference/parserRealSource12.errors.txt index b7b221cbc03..22fb209d80c 100644 --- a/tests/baselines/reference/parserRealSource12.errors.txt +++ b/tests/baselines/reference/parserRealSource12.errors.txt @@ -215,7 +215,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource12.ts(524,30): error /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export interface IAstWalker { diff --git a/tests/baselines/reference/parserRealSource13.errors.txt b/tests/baselines/reference/parserRealSource13.errors.txt index e9380882e28..6ddc41ed610 100644 --- a/tests/baselines/reference/parserRealSource13.errors.txt +++ b/tests/baselines/reference/parserRealSource13.errors.txt @@ -122,7 +122,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource13.ts(135,36): error /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript.AstWalkerWithDetailCallback { export interface AstWalkerDetailCallback { diff --git a/tests/baselines/reference/parserRealSource14.errors.txt b/tests/baselines/reference/parserRealSource14.errors.txt index bc32a8e585b..4881864e236 100644 --- a/tests/baselines/reference/parserRealSource14.errors.txt +++ b/tests/baselines/reference/parserRealSource14.errors.txt @@ -166,7 +166,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export function lastOf(items: any[]): any { diff --git a/tests/baselines/reference/parserRealSource2.errors.txt b/tests/baselines/reference/parserRealSource2.errors.txt index e552cb77812..42fcff36c70 100644 --- a/tests/baselines/reference/parserRealSource2.errors.txt +++ b/tests/baselines/reference/parserRealSource2.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource2.ts(4,1): error TS60 /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { diff --git a/tests/baselines/reference/parserRealSource3.errors.txt b/tests/baselines/reference/parserRealSource3.errors.txt index 98aae9660a8..5b00994052b 100644 --- a/tests/baselines/reference/parserRealSource3.errors.txt +++ b/tests/baselines/reference/parserRealSource3.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource3.ts(4,1): error TS60 /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { // Note: Any addition to the NodeType should also be supported with addition to AstWalkerDetailCallback diff --git a/tests/baselines/reference/parserRealSource4.errors.txt b/tests/baselines/reference/parserRealSource4.errors.txt index e0ae0d2221e..9722a5b670d 100644 --- a/tests/baselines/reference/parserRealSource4.errors.txt +++ b/tests/baselines/reference/parserRealSource4.errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource4.ts(195,37): error T /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { diff --git a/tests/baselines/reference/parserRealSource5.errors.txt b/tests/baselines/reference/parserRealSource5.errors.txt index 78894b21420..7dc9b5942d5 100644 --- a/tests/baselines/reference/parserRealSource5.errors.txt +++ b/tests/baselines/reference/parserRealSource5.errors.txt @@ -16,7 +16,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource5.ts(61,65): error TS /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { // TODO: refactor indent logic for use in emit diff --git a/tests/baselines/reference/parserRealSource6.errors.txt b/tests/baselines/reference/parserRealSource6.errors.txt index aa646ca1aba..aa6a9f41392 100644 --- a/tests/baselines/reference/parserRealSource6.errors.txt +++ b/tests/baselines/reference/parserRealSource6.errors.txt @@ -67,7 +67,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource6.ts(215,20): error T /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export class TypeCollectionContext { diff --git a/tests/baselines/reference/parserRealSource7.errors.txt b/tests/baselines/reference/parserRealSource7.errors.txt index 7945e5d7034..a3635dabc48 100644 --- a/tests/baselines/reference/parserRealSource7.errors.txt +++ b/tests/baselines/reference/parserRealSource7.errors.txt @@ -309,7 +309,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export class Continuation { diff --git a/tests/baselines/reference/parserRealSource8.errors.txt b/tests/baselines/reference/parserRealSource8.errors.txt index d497b0884db..6249d3fd991 100644 --- a/tests/baselines/reference/parserRealSource8.errors.txt +++ b/tests/baselines/reference/parserRealSource8.errors.txt @@ -140,7 +140,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts(454,35): error T /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { diff --git a/tests/baselines/reference/parserRealSource9.errors.txt b/tests/baselines/reference/parserRealSource9.errors.txt index 9d89848ff20..caa142db60e 100644 --- a/tests/baselines/reference/parserRealSource9.errors.txt +++ b/tests/baselines/reference/parserRealSource9.errors.txt @@ -39,7 +39,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(200,48): error T /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. module TypeScript { export class Binder { diff --git a/tests/baselines/reference/parserharness.errors.txt b/tests/baselines/reference/parserharness.errors.txt index 963ce12ddf1..fd9ad6d3a10 100644 --- a/tests/baselines/reference/parserharness.errors.txt +++ b/tests/baselines/reference/parserharness.errors.txt @@ -128,16 +128,16 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'io.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/compiler/io.ts' not found. /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescript.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/compiler/typescript.ts' not found. /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'typescriptServices.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/services/typescriptServices.ts' not found. /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'diff.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/RealWorld/diff.ts' not found. declare var assert: Harness.Assert; ~~~~~~ diff --git a/tests/baselines/reference/parserindenter.errors.txt b/tests/baselines/reference/parserindenter.errors.txt index 8ccc9220710..2f51281e7aa 100644 --- a/tests/baselines/reference/parserindenter.errors.txt +++ b/tests/baselines/reference/parserindenter.errors.txt @@ -146,7 +146,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserindenter.ts(736,38): /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'formatting.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/parser/ecmascript5/RealWorld/formatting.ts' not found. module Formatting { diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt index dd2b221798c..68a1ef3b7c9 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt @@ -1,7 +1,7 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type 'number'. -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js (0 errors) ==== +==== entry.js (0 errors) ==== var m3 = require("m3"); module.exports = { @@ -10,7 +10,7 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type "person": m3.person }; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); /** @@ -22,7 +22,7 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type exports.f2 = m2; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js (0 errors) ==== +==== index.js (0 errors) ==== exports.person = { "name": "John Doe", "age": 42 diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt index dd2b221798c..68a1ef3b7c9 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt @@ -1,7 +1,7 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type 'number'. -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/entry.js (0 errors) ==== +==== entry.js (0 errors) ==== var m3 = require("m3"); module.exports = { @@ -10,7 +10,7 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type "person": m3.person }; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); /** @@ -22,7 +22,7 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type exports.f2 = m2; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/importHigher/node_modules/m2/node_modules/m3/index.js (0 errors) ==== +==== index.js (0 errors) ==== exports.person = { "name": "John Doe", "age": 42 diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt index 81612e2a387..f03b958275b 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt @@ -1,7 +1,7 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to type 'number'. -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js (0 errors) ==== +==== entry.js (0 errors) ==== var m3 = require("m3"); module.exports = { @@ -10,7 +10,7 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to "person": m3.person }; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); /** diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt index 81612e2a387..f03b958275b 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt @@ -1,7 +1,7 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to type 'number'. -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m2/entry.js (0 errors) ==== +==== entry.js (0 errors) ==== var m3 = require("m3"); module.exports = { @@ -10,7 +10,7 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to "person": m3.person }; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthExceeded/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); /** diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt index 5a395b70ee6..f63c2a789e8 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt @@ -1,13 +1,13 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js (0 errors) ==== +==== index.js (0 errors) ==== exports.person = { "name": "John Doe", "age": 42 } -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js (0 errors) ==== +==== entry.js (0 errors) ==== var m3 = require("m3"); module.exports = { @@ -16,7 +16,7 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to "person": m3.person }; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); /** diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt index 5a395b70ee6..f63c2a789e8 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt @@ -1,13 +1,13 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/node_modules/m3/index.js (0 errors) ==== +==== index.js (0 errors) ==== exports.person = { "name": "John Doe", "age": 42 } -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m2/entry.js (0 errors) ==== +==== entry.js (0 errors) ==== var m3 = require("m3"); module.exports = { @@ -16,7 +16,7 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to "person": m3.person }; -==== C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); /** diff --git a/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt b/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt index dfbdd679685..f0809b38f27 100644 --- a/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt +++ b/tests/baselines/reference/project/rootDirectoryErrors/amd/rootDirectoryErrors.errors.txt @@ -1,7 +1,7 @@ error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. -!!! error TS6059: File 'fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. +!!! error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. ==== FolderA/FolderB/FolderC/fileC.ts (0 errors) ==== class C { } diff --git a/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt b/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt index dfbdd679685..f0809b38f27 100644 --- a/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt +++ b/tests/baselines/reference/project/rootDirectoryErrors/node/rootDirectoryErrors.errors.txt @@ -1,7 +1,7 @@ error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. -!!! error TS6059: File 'fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. +!!! error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files. ==== FolderA/FolderB/FolderC/fileC.ts (0 errors) ==== class C { } diff --git a/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt b/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt index d02593feff9..922ff48ef58 100644 --- a/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt +++ b/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/requireOfAnEmptyFile1_a.ts(3,21): error TS2306: File 'tests import fs = require('./requireOfAnEmptyFile1_b'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2306: File 'requireOfAnEmptyFile1_b.ts' is not a module. +!!! error TS2306: File 'tests/cases/compiler/requireOfAnEmptyFile1_b.ts' is not a module. ==== tests/cases/compiler/requireOfAnEmptyFile1_b.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/scannertest1.errors.txt b/tests/baselines/reference/scannertest1.errors.txt index 3831dbe398e..fce2a0b292a 100644 --- a/tests/baselines/reference/scannertest1.errors.txt +++ b/tests/baselines/reference/scannertest1.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/scanner/ecmascript5/scannertest1.ts(20,23): error TS2304 ==== tests/cases/conformance/scanner/ecmascript5/scannertest1.ts (16 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'References.ts' not found. +!!! error TS6053: File 'tests/cases/conformance/scanner/ecmascript5/References.ts' not found. class CharacterInfo { public static isDecimalDigit(c: number): boolean { diff --git a/tests/baselines/reference/selfReferencingFile2.errors.txt b/tests/baselines/reference/selfReferencingFile2.errors.txt index c993616784a..002e087d60e 100644 --- a/tests/baselines/reference/selfReferencingFile2.errors.txt +++ b/tests/baselines/reference/selfReferencingFile2.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/selfReferencingFile2.ts(1,1): error TS6053: File 'tests/cas ==== tests/cases/compiler/selfReferencingFile2.ts (1 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6053: File 'selfReferencingFile2.ts' not found. +!!! error TS6053: File 'tests/cases/selfReferencingFile2.ts' not found. class selfReferencingFile2 { From d9b8fad72848e39a2984b1fb0b0b9ead7273cd31 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Mon, 27 Jun 2016 11:46:58 -0700 Subject: [PATCH 048/103] Fix type of the disableSizeLimit option --- src/compiler/commandLineParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1c1b51f2a29..0264f9817da 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -423,7 +423,7 @@ namespace ts { description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableProjectSizeLimit", + name: "disableSizeLimit", type: "boolean" }, { From f67f1f7db76e953048a62eb33fdf560ac9adc0c7 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 27 Jun 2016 13:43:07 -0700 Subject: [PATCH 049/103] Update version to 2.0.0 --- package.json | 2 +- scripts/configureNightly.ts | 2 +- src/compiler/program.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ee6ed62964c..29871e77f70 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.9.0", + "version": "2.0.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/scripts/configureNightly.ts b/scripts/configureNightly.ts index 8553c15ebd0..640f330b376 100644 --- a/scripts/configureNightly.ts +++ b/scripts/configureNightly.ts @@ -67,7 +67,7 @@ function getNightlyVersionString(versionString: string): string { const now = new Date(); const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8); - return `${versionString}-dev.${timeStr}-1.0`; + return `${versionString}-dev.${timeStr}`; } main(); \ No newline at end of file diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a01f3a4c5b2..a9438590118 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -9,7 +9,7 @@ namespace ts { /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ - export const version = "1.9.0"; + export const version = "2.0.0"; const emptyArray: any[] = []; From 0b6ba9682769d50e8c11b63e37557942e2f10c10 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 27 Jun 2016 15:04:51 -0700 Subject: [PATCH 050/103] Remove upper boilerplate from issue template Our issue stats did not improve appreciably when we added the issue template. Reduce upper boilerplate text and try to make it more action-oriented --- issue_template.md | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/issue_template.md b/issue_template.md index dcd2280570c..78e0ae8be91 100644 --- a/issue_template.md +++ b/issue_template.md @@ -1,24 +1,13 @@ - + + -For bug reports, please include the information below. -__________________________________________________________ --> - -**TypeScript Version:** - -1.7.5 / 1.8.0-beta / nightly (1.9.0-dev.20160217) +**TypeScript Version:** 1.8.0 / nightly (1.9.0-dev.201xxxxx) **Code** ```ts -// A self-contained demonstration of the problem follows... +// A *self-contained* demonstration of the problem follows... ``` From 9cc48c829d5d85f6e8d7a9d84e65f9d3aa5a5b2c Mon Sep 17 00:00:00 2001 From: Yui Date: Mon, 27 Jun 2016 15:58:29 -0700 Subject: [PATCH 051/103] Remove unused compiler option (#9381) --- src/compiler/commandLineParser.ts | 10 ---------- src/compiler/types.ts | 1 - 2 files changed, 11 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 0264f9817da..6c8f17f0917 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -336,16 +336,6 @@ namespace ts { isFilePath: true } }, - { - name: "typesSearchPaths", - type: "list", - isTSConfigOnly: true, - element: { - name: "typesSearchPaths", - type: "string", - isFilePath: true - } - }, { name: "typeRoots", type: "list", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1a94ef200ba..2f85bbe569e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2590,7 +2590,6 @@ namespace ts { types?: string[]; /** Paths used to used to compute primary types search locations */ typeRoots?: string[]; - typesSearchPaths?: string[]; /*@internal*/ version?: boolean; /*@internal*/ watch?: boolean; From f9338c69fc686466a5ce48706c2bbe31926306f3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 27 Jun 2016 16:28:31 -0700 Subject: [PATCH 052/103] Update LKG --- lib/tsc.js | 401 ++++++++++++++++++------ lib/tsserver.js | 602 +++++++++++++++++++++++++---------- lib/tsserverlibrary.d.ts | 48 ++- lib/tsserverlibrary.js | 602 +++++++++++++++++++++++++---------- lib/typescript.d.ts | 16 +- lib/typescript.js | 610 +++++++++++++++++++++++++----------- lib/typescriptServices.d.ts | 16 +- lib/typescriptServices.js | 610 +++++++++++++++++++++++++----------- 8 files changed, 2100 insertions(+), 805 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 1c6d5b8f47a..0b5e4619e4b 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -2281,6 +2281,9 @@ var ts; Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, + Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." }, + Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -8736,8 +8739,11 @@ var ts; if (lhs.kind === 69) { return lhs.text === rhs.text; } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); + if (lhs.kind === 97) { + return true; + } + return lhs.name.text === rhs.name.text && + tagNamesAreEquivalent(lhs.expression, rhs.expression); } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); @@ -8834,15 +8840,15 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var elementName = parseIdentifierName(); + var expression = token === 97 ? + parseTokenNode() : parseIdentifierName(); while (parseOptional(21)) { - scanJsxIdentifier(); - var node = createNode(139, elementName.pos); - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); + var propertyAccess = createNode(172, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); } - return elementName; + return expression; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); @@ -9620,7 +9626,7 @@ var ts; case 56: return parseExportAssignment(fullStart, decorators, modifiers); case 116: - return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers); + return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } @@ -10134,7 +10140,7 @@ var ts; function nextTokenIsSlash() { return nextToken() === 39; } - function parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers) { + function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { var exportDeclaration = createNode(228, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; @@ -13805,7 +13811,7 @@ var ts; function getTargetOfImportSpecifier(node) { return getExternalModuleMember(node.parent.parent.parent, node); } - function getTargetOfGlobalModuleExportDeclaration(node) { + function getTargetOfNamespaceExportDeclaration(node) { return resolveExternalModuleSymbol(node.parent.symbol); } function getTargetOfExportSpecifier(node) { @@ -13831,7 +13837,7 @@ var ts; case 235: return getTargetOfExportAssignment(node); case 228: - return getTargetOfGlobalModuleExportDeclaration(node); + return getTargetOfNamespaceExportDeclaration(node); } } function resolveSymbol(symbol) { @@ -13914,9 +13920,12 @@ var ts; var left = name.kind === 139 ? name.left : name.expression; var right = name.kind === 139 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + if (!namespace || ts.nodeIsMissing(right)) { return undefined; } + else if (namespace === unknownSymbol) { + return namespace; + } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { if (!ignoreErrors) { @@ -14877,16 +14886,13 @@ var ts; writePunctuation(writer, 27); } } - function buildDisplayForParametersAndDelimiters(thisType, parameters, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { writePunctuation(writer, 17); - if (thisType) { - writeKeyword(writer, 97); - writePunctuation(writer, 54); - writeSpace(writer); - buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack); + if (thisParameter) { + buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { - if (i > 0 || thisType) { + if (i > 0 || thisParameter) { writePunctuation(writer, 24); writeSpace(writer); } @@ -14934,7 +14940,7 @@ var ts; else { buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); } - buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { @@ -15265,12 +15271,13 @@ var ts; if (func.kind === 150 && !ts.hasDynamicName(func)) { var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); if (getter) { - var signature = getSignatureFromDeclaration(getter); + var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); if (thisParameter && declaration === thisParameter) { - return signature.thisType; + ts.Debug.assert(!thisParameter.type); + return getTypeOfSymbol(getterSignature.thisParameter); } - return getReturnTypeOfSignature(signature); + return getReturnTypeOfSignature(getterSignature); } } var type = declaration.symbol.name === "this" @@ -15428,14 +15435,12 @@ var ts; } return undefined; } - function getAnnotatedAccessorThisType(accessor) { - if (accessor) { - var parameter = getAccessorThisParameter(accessor); - if (parameter && parameter.type) { - return getTypeFromTypeNode(accessor.parameters[0].type); - } - } - return undefined; + function getAnnotatedAccessorThisParameter(accessor) { + var parameter = getAccessorThisParameter(accessor); + return parameter && parameter.symbol; + } + function getThisTypeOfDeclaration(declaration) { + return getThisTypeOfSignature(getSignatureFromDeclaration(declaration)); } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); @@ -16015,12 +16020,12 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, thisType, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; - sig.thisType = thisType; + sig.thisParameter = thisParameter; sig.resolvedReturnType = resolvedReturnType; sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; @@ -16029,7 +16034,7 @@ var ts; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); @@ -16113,8 +16118,9 @@ var ts; var s = signature; if (unionSignatures.length > 1) { s = cloneSignature(signature); - if (ts.forEach(unionSignatures, function (sig) { return sig.thisType; })) { - s.thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisType || anyType; })); + if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; })); + s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -16299,6 +16305,7 @@ var ts; var types = containingType.types; var props; var commonFlags = (containingType.flags & 32768) ? 536870912 : 0; + var isReadonly = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -16312,6 +16319,9 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } + if (isReadonlySymbol(prop)) { + isReadonly = true; + } } else if (containingType.flags & 16384) { return undefined; @@ -16339,6 +16349,7 @@ var ts; commonFlags, name); result.containingType = containingType; result.declarations = declarations; + result.isReadonly = isReadonly; result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } @@ -16497,7 +16508,7 @@ var ts; var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - var thisType = undefined; + var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { @@ -16509,7 +16520,7 @@ var ts; } if (i === 0 && paramSymbol.name === "this") { hasThisParameter = true; - thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType; + thisParameter = param.symbol; } else { parameters.push(paramSymbol); @@ -16528,10 +16539,12 @@ var ts; } if ((declaration.kind === 149 || declaration.kind === 150) && !ts.hasDynamicName(declaration) && - (!hasThisParameter || thisType === unknownType)) { + (!hasThisParameter || !thisParameter)) { var otherKind = declaration.kind === 149 ? 150 : 149; - var setter = ts.getDeclarationOfKind(declaration.symbol, otherKind); - thisType = getAnnotatedAccessorThisType(setter); + var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); + if (other) { + thisParameter = getAnnotatedAccessorThisParameter(other); + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); @@ -16549,7 +16562,7 @@ var ts; var typePredicate = declaration.type && declaration.type.kind === 154 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; - links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -16619,6 +16632,11 @@ var ts; } return anyType; } + function getThisTypeOfSignature(signature) { + if (signature.thisParameter) { + return getTypeOfSymbol(signature.thisParameter); + } + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { @@ -17336,7 +17354,7 @@ var ts; if (signature.typePredicate) { freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, signature.thisType && instantiateType(signature.thisType, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -17539,16 +17557,20 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1; - if (source.thisType && target.thisType && source.thisType !== voidType) { - var related = compareTypes(source.thisType, target.thisType, false) - || compareTypes(target.thisType, source.thisType, reportErrors); - if (!related) { - if (reportErrors) { - errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType && sourceThisType !== voidType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType, false) + || compareTypes(targetThisType, sourceThisType, reportErrors); + if (!related) { + if (reportErrors) { + errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + } + return 0; } - return 0; + result &= related; } - result &= related; } var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); @@ -18366,12 +18388,18 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1; - if (!ignoreThisTypes && source.thisType && target.thisType) { - var related = compareTypes(source.thisType, target.thisType); - if (!related) { - return 0; + if (!ignoreThisTypes) { + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType); + if (!related) { + return 0; + } + result &= related; + } } - result &= related; } var targetLen = target.parameters.length; for (var i = 0; i < targetLen; i++) { @@ -19634,8 +19662,20 @@ var ts; } return container === declarationContainer; } + function updateReferencesForInterfaceHeritiageClauseTargets(node) { + var extendedTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (extendedTypeNode) { + var t = getTypeFromTypeNode(extendedTypeNode); + if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + t.symbol.hasReference = true; + } + } + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + symbol.hasReference = true; + } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (container.kind === 180) { @@ -19845,9 +19885,9 @@ var ts; if (type) { return type; } - var signature = getSignatureFromDeclaration(container); - if (signature.thisType) { - return signature.thisType; + var thisType = getThisTypeOfDeclaration(container); + if (thisType) { + return thisType; } } if (ts.isClassLike(container.parent)) { @@ -19990,7 +20030,7 @@ var ts; if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisType; + return getThisTypeOfSignature(contextualSignature); } } return undefined; @@ -20572,7 +20612,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 139) { + if (tagName.kind === 172 || tagName.kind === 97) { return false; } else { @@ -20708,6 +20748,25 @@ var ts; return getResolvedJsxType(node, type, elemClassType); })); } + if (elemType.flags & 2) { + return anyType; + } + else if (elemType.flags & 256) { + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); + if (intrinsicElementsType !== unknownType) { + var stringLiteralTypeName = elemType.text; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + return indexSignatureType; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + } + return anyType; + } var elemInstanceType = getJsxElementInstanceType(node, elemType); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { if (jsxElementType) { @@ -20952,6 +21011,9 @@ var ts; } return unknownType; } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + prop.hasReference = true; + } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { checkClassPropertyAccess(node, left, apparentType, prop); @@ -21264,10 +21326,11 @@ var ts; if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { context.failedTypeParameterIndex = undefined; } - if (signature.thisType) { + var thisType = getThisTypeOfSignature(signature); + if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context, thisArgumentType, signature.thisType); + inferTypes(context, thisArgumentType, thisType); } var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { @@ -21318,12 +21381,13 @@ var ts; return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - if (signature.thisType && signature.thisType !== voidType && node.kind !== 175) { + var thisType = getThisTypeOfSignature(signature); + if (thisType && thisType !== voidType && node.kind !== 175) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; - if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { return false; } } @@ -21739,7 +21803,7 @@ var ts; if (getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } - if (signature.thisType === voidType) { + if (getThisTypeOfSignature(signature) === voidType) { error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void); } return signature; @@ -22219,6 +22283,8 @@ var ts; } } } + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -22229,7 +22295,8 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || + return symbol.isReadonly || + symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || symbol.flags & 3 && (getDeclarationFlagsFromSymbol(symbol) & 2048) !== 0 || symbol.flags & 98304 && !(symbol.flags & 65536) || (symbol.flags & 8) !== 0; @@ -23064,6 +23131,9 @@ var ts; checkAsyncFunctionReturnType(node); } } + if (!node.body) { + checkUnusedTypeParameters(node); + } } } function checkClassForDuplicateDeclarations(node) { @@ -23191,6 +23261,8 @@ var ts; checkSignatureDeclaration(node); checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); var symbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); if (node === firstDeclaration) { @@ -23294,7 +23366,7 @@ var ts; error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorThisType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); + checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } getTypeOfAccessors(getSymbolOfNode(node)); @@ -23339,12 +23411,17 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); + if (type !== unknownType) { + if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + type.symbol.hasReference = true; + } + if (node.typeArguments) { + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } } } } @@ -23874,6 +23951,8 @@ var ts; } } checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); if (!node.asteriskToken) { var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -23887,11 +23966,83 @@ var ts; } } } + function checkUnusedIdentifiers(node) { + if (node.parent.kind !== 222 && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + for (var key in node.locals) { + if (ts.hasProperty(node.locals, key)) { + var local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration) { + if (local.valueDeclaration.kind !== 142 && compilerOptions.noUnusedLocals) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + else if (local.valueDeclaration.kind === 142 && compilerOptions.noUnusedParameters) { + if (local.valueDeclaration.flags === 0) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + } + } + } + } + } + } + function checkUnusedClassLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.members) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 147 || member.kind === 145) { + if (isPrivateNode(member) && !member.symbol.hasReference) { + error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); + } + } + else if (member.kind === 148) { + for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + error(parameter.name, ts.Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + } + } + } + } + } + } + } + function checkUnusedTypeParameters(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.typeParameters) { + for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { + var typeParameter = _a[_i]; + if (!typeParameter.symbol.hasReference) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + } + } + } + } + } + function isPrivateNode(node) { + return (node.flags & 8) !== 0; + } + function checkUnusedModuleLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + var _loop_1 = function(key) { + if (ts.hasProperty(node.locals, key)) { + var local_1 = node.locals[key]; + if (!local_1.hasReference && !local_1.exportSymbol) { + ts.forEach(local_1.declarations, function (d) { return error(d.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name); }); + } + } + }; + for (var key in node.locals) { + _loop_1(key); + } + } + } function checkBlock(node) { if (node.kind === 199) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); + checkUnusedIdentifiers(node); } function checkCollisionWithArgumentsInGeneratedCode(node) { if (!ts.hasDeclaredRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { @@ -24237,6 +24388,7 @@ var ts; } } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); @@ -24265,6 +24417,7 @@ var ts; 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); + checkUnusedIdentifiers(node); } function checkForInOrForOfVariableDeclaration(iterationStatement) { var variableDeclarationList = iterationStatement.initializer; @@ -24561,6 +24714,7 @@ var ts; } } checkBlock(catchClause.block); + checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { checkBlock(node.finallyBlock); @@ -24683,6 +24837,8 @@ var ts; } checkClassLikeDeclaration(node); ts.forEach(node.members, checkSourceElement); + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); } function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); @@ -24923,6 +25079,8 @@ var ts; ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); + checkUnusedTypeParameters(node); } } function checkTypeAliasDeclaration(node) { @@ -25242,6 +25400,7 @@ var ts; } if (node.body) { checkSourceElement(node.body); + checkUnusedModuleLocals(node); } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { @@ -25392,6 +25551,9 @@ var ts; if (target.flags & 793056) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + target.hasReference = true; + } } } else { @@ -25679,6 +25841,9 @@ var ts; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); + if (ts.isExternalModule(node)) { + checkUnusedModuleLocals(node); + } checkDeferredNodes(); deferredNodes = undefined; if (ts.isExternalOrCommonJsModule(node)) { @@ -25967,6 +26132,13 @@ var ts; case 139: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97: + var container = ts.getThisContainer(node, false); + if (ts.isFunctionLike(container)) { + var sig = getSignatureFromDeclaration(container); + if (sig.thisParameter) { + return sig.thisParameter; + } + } case 95: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; @@ -26155,7 +26327,9 @@ var ts; var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { - return parentSymbol.valueDeclaration; + if (parentSymbol.valueDeclaration === ts.getSourceFileOfNode(node)) { + return parentSymbol.valueDeclaration; + } } for (var n = node.parent; n; n = n.parent) { if ((n.kind === 225 || n.kind === 224) && getSymbolOfNode(n) === parentSymbol) { @@ -27048,7 +27222,7 @@ var ts; var GetAccessor = 2; var SetAccessor = 4; var GetOrSetAccessor = GetAccessor | SetAccessor; - var _loop_1 = function(prop) { + var _loop_2 = function(prop) { var name_21 = prop.name; if (prop.kind === 193 || name_21.kind === 140) { @@ -27109,8 +27283,8 @@ var ts; }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_2 = _loop_1(prop); - if (typeof state_2 === "object") return state_2.value; + var state_3 = _loop_2(prop); + if (typeof state_3 === "object") return state_3.value; } } function checkGrammarJsxElement(node) { @@ -29740,6 +29914,8 @@ var ts; return generateNameForExportDefault(); case 192: return generateNameForClassExpression(); + default: + ts.Debug.fail(); } } function getGeneratedNameForNode(node) { @@ -30437,6 +30613,20 @@ var ts; } return false; } + function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node) { + if (languageVersion >= 2) { + var parent_14 = node.parent; + if (parent_14.kind === 172 && parent_14.expression === node) { + parent_14 = parent_14.parent; + while (parent_14 && parent_14.kind !== 145) { + parent_14 = parent_14.parent; + } + return parent_14 && parent_14.kind === 145 && (parent_14.flags & 32) !== 0 && + parent_14.parent.kind === 192 ? parent_14.parent : undefined; + } + } + return undefined; + } function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { @@ -30449,6 +30639,14 @@ var ts; write(node.text); } else if (isExpressionIdentifier(node)) { + var classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node); + if (classExpression) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration === classExpression) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } emitExpressionIdentifier(node); } else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { @@ -32988,7 +33186,7 @@ var ts; emitStart(property); emitStart(property.name); if (receiver) { - emit(receiver); + write(receiver); } else { if (property.flags & 32) { @@ -33271,12 +33469,15 @@ var ts; } var staticProperties = getInitializedProperties(node, true); var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 192; - var tempVariable; + var generatedName; if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); + generatedName = getGeneratedNameForNode(node.name); + var synthesizedNode = ts.createSynthesizedNode(69); + synthesizedNode.text = generatedName; + recordTempDeclaration(synthesizedNode); write("("); increaseIndent(); - emit(tempVariable); + emit(synthesizedNode); write(" = "); } write("class"); @@ -33316,11 +33517,11 @@ var ts; var property = staticProperties_1[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, generatedName, true); } write(","); writeLine(); - emit(tempVariable); + write(generatedName); decreaseIndent(); write(")"); } @@ -35498,7 +35699,7 @@ var ts; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.9.0"; + ts.version = "2.0.0"; var emptyArray = []; var defaultTypeRoots = ["node_modules/@types"]; function findConfigFile(searchPath, fileExists) { @@ -37341,6 +37542,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Locals + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Parameters + }, { name: "noLib", type: "boolean" @@ -37530,16 +37741,6 @@ var ts; isFilePath: true } }, - { - name: "typesSearchPaths", - type: "list", - isTSConfigOnly: true, - element: { - name: "typesSearchPaths", - type: "string", - isFilePath: true - } - }, { name: "typeRoots", type: "list", @@ -37614,7 +37815,7 @@ var ts; description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableProjectSizeLimit", + name: "disableSizeLimit", type: "boolean" }, { @@ -38629,7 +38830,7 @@ var ts; var usageColumn = []; var descriptionColumn = []; var optionsDescriptionMap = {}; - var _loop_2 = function(i) { + var _loop_3 = function(i) { var option = optsList[i]; if (!option.description) { return "continue"; @@ -38660,7 +38861,7 @@ var ts; marginLength = Math.max(usageText_1.length, marginLength); }; for (var i = 0; i < optsList.length; i++) { - _loop_2(i); + _loop_3(i); } var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; usageColumn.push(usageText); diff --git a/lib/tsserver.js b/lib/tsserver.js index bd80f9f800e..33c26a7cdac 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -2286,6 +2286,9 @@ var ts; Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, + Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." }, + Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3950,6 +3953,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Locals + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Parameters + }, { name: "noLib", type: "boolean" @@ -4139,16 +4152,6 @@ var ts; isFilePath: true } }, - { - name: "typesSearchPaths", - type: "list", - isTSConfigOnly: true, - element: { - name: "typesSearchPaths", - type: "string", - isFilePath: true - } - }, { name: "typeRoots", type: "list", @@ -4223,7 +4226,7 @@ var ts; description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableProjectSizeLimit", + name: "disableSizeLimit", type: "boolean" }, { @@ -9645,8 +9648,11 @@ var ts; if (lhs.kind === 69) { return lhs.text === rhs.text; } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); + if (lhs.kind === 97) { + return true; + } + return lhs.name.text === rhs.name.text && + tagNamesAreEquivalent(lhs.expression, rhs.expression); } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); @@ -9743,15 +9749,15 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var elementName = parseIdentifierName(); + var expression = token === 97 ? + parseTokenNode() : parseIdentifierName(); while (parseOptional(21)) { - scanJsxIdentifier(); - var node = createNode(139, elementName.pos); - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); + var propertyAccess = createNode(172, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); } - return elementName; + return expression; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); @@ -10529,7 +10535,7 @@ var ts; case 56: return parseExportAssignment(fullStart, decorators, modifiers); case 116: - return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers); + return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } @@ -11043,7 +11049,7 @@ var ts; function nextTokenIsSlash() { return nextToken() === 39; } - function parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers) { + function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { var exportDeclaration = createNode(228, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; @@ -14714,7 +14720,7 @@ var ts; function getTargetOfImportSpecifier(node) { return getExternalModuleMember(node.parent.parent.parent, node); } - function getTargetOfGlobalModuleExportDeclaration(node) { + function getTargetOfNamespaceExportDeclaration(node) { return resolveExternalModuleSymbol(node.parent.symbol); } function getTargetOfExportSpecifier(node) { @@ -14740,7 +14746,7 @@ var ts; case 235: return getTargetOfExportAssignment(node); case 228: - return getTargetOfGlobalModuleExportDeclaration(node); + return getTargetOfNamespaceExportDeclaration(node); } } function resolveSymbol(symbol) { @@ -14823,9 +14829,12 @@ var ts; var left = name.kind === 139 ? name.left : name.expression; var right = name.kind === 139 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + if (!namespace || ts.nodeIsMissing(right)) { return undefined; } + else if (namespace === unknownSymbol) { + return namespace; + } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { if (!ignoreErrors) { @@ -15786,16 +15795,13 @@ var ts; writePunctuation(writer, 27); } } - function buildDisplayForParametersAndDelimiters(thisType, parameters, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { writePunctuation(writer, 17); - if (thisType) { - writeKeyword(writer, 97); - writePunctuation(writer, 54); - writeSpace(writer); - buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack); + if (thisParameter) { + buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { - if (i > 0 || thisType) { + if (i > 0 || thisParameter) { writePunctuation(writer, 24); writeSpace(writer); } @@ -15843,7 +15849,7 @@ var ts; else { buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); } - buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { @@ -16174,12 +16180,13 @@ var ts; if (func.kind === 150 && !ts.hasDynamicName(func)) { var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); if (getter) { - var signature = getSignatureFromDeclaration(getter); + var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); if (thisParameter && declaration === thisParameter) { - return signature.thisType; + ts.Debug.assert(!thisParameter.type); + return getTypeOfSymbol(getterSignature.thisParameter); } - return getReturnTypeOfSignature(signature); + return getReturnTypeOfSignature(getterSignature); } } var type = declaration.symbol.name === "this" @@ -16337,14 +16344,12 @@ var ts; } return undefined; } - function getAnnotatedAccessorThisType(accessor) { - if (accessor) { - var parameter = getAccessorThisParameter(accessor); - if (parameter && parameter.type) { - return getTypeFromTypeNode(accessor.parameters[0].type); - } - } - return undefined; + function getAnnotatedAccessorThisParameter(accessor) { + var parameter = getAccessorThisParameter(accessor); + return parameter && parameter.symbol; + } + function getThisTypeOfDeclaration(declaration) { + return getThisTypeOfSignature(getSignatureFromDeclaration(declaration)); } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); @@ -16924,12 +16929,12 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, thisType, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; - sig.thisType = thisType; + sig.thisParameter = thisParameter; sig.resolvedReturnType = resolvedReturnType; sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; @@ -16938,7 +16943,7 @@ var ts; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); @@ -17022,8 +17027,9 @@ var ts; var s = signature; if (unionSignatures.length > 1) { s = cloneSignature(signature); - if (ts.forEach(unionSignatures, function (sig) { return sig.thisType; })) { - s.thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisType || anyType; })); + if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; })); + s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -17208,6 +17214,7 @@ var ts; var types = containingType.types; var props; var commonFlags = (containingType.flags & 32768) ? 536870912 : 0; + var isReadonly = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -17221,6 +17228,9 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } + if (isReadonlySymbol(prop)) { + isReadonly = true; + } } else if (containingType.flags & 16384) { return undefined; @@ -17248,6 +17258,7 @@ var ts; commonFlags, name); result.containingType = containingType; result.declarations = declarations; + result.isReadonly = isReadonly; result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } @@ -17406,7 +17417,7 @@ var ts; var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - var thisType = undefined; + var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { @@ -17418,7 +17429,7 @@ var ts; } if (i === 0 && paramSymbol.name === "this") { hasThisParameter = true; - thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType; + thisParameter = param.symbol; } else { parameters.push(paramSymbol); @@ -17437,10 +17448,12 @@ var ts; } if ((declaration.kind === 149 || declaration.kind === 150) && !ts.hasDynamicName(declaration) && - (!hasThisParameter || thisType === unknownType)) { + (!hasThisParameter || !thisParameter)) { var otherKind = declaration.kind === 149 ? 150 : 149; - var setter = ts.getDeclarationOfKind(declaration.symbol, otherKind); - thisType = getAnnotatedAccessorThisType(setter); + var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); + if (other) { + thisParameter = getAnnotatedAccessorThisParameter(other); + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); @@ -17458,7 +17471,7 @@ var ts; var typePredicate = declaration.type && declaration.type.kind === 154 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; - links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -17528,6 +17541,11 @@ var ts; } return anyType; } + function getThisTypeOfSignature(signature) { + if (signature.thisParameter) { + return getTypeOfSymbol(signature.thisParameter); + } + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { @@ -18245,7 +18263,7 @@ var ts; if (signature.typePredicate) { freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, signature.thisType && instantiateType(signature.thisType, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -18448,16 +18466,20 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1; - if (source.thisType && target.thisType && source.thisType !== voidType) { - var related = compareTypes(source.thisType, target.thisType, false) - || compareTypes(target.thisType, source.thisType, reportErrors); - if (!related) { - if (reportErrors) { - errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType && sourceThisType !== voidType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType, false) + || compareTypes(targetThisType, sourceThisType, reportErrors); + if (!related) { + if (reportErrors) { + errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + } + return 0; } - return 0; + result &= related; } - result &= related; } var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); @@ -19275,12 +19297,18 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1; - if (!ignoreThisTypes && source.thisType && target.thisType) { - var related = compareTypes(source.thisType, target.thisType); - if (!related) { - return 0; + if (!ignoreThisTypes) { + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType); + if (!related) { + return 0; + } + result &= related; + } } - result &= related; } var targetLen = target.parameters.length; for (var i = 0; i < targetLen; i++) { @@ -20543,8 +20571,20 @@ var ts; } return container === declarationContainer; } + function updateReferencesForInterfaceHeritiageClauseTargets(node) { + var extendedTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (extendedTypeNode) { + var t = getTypeFromTypeNode(extendedTypeNode); + if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + t.symbol.hasReference = true; + } + } + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + symbol.hasReference = true; + } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (container.kind === 180) { @@ -20754,9 +20794,9 @@ var ts; if (type) { return type; } - var signature = getSignatureFromDeclaration(container); - if (signature.thisType) { - return signature.thisType; + var thisType = getThisTypeOfDeclaration(container); + if (thisType) { + return thisType; } } if (ts.isClassLike(container.parent)) { @@ -20899,7 +20939,7 @@ var ts; if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisType; + return getThisTypeOfSignature(contextualSignature); } } return undefined; @@ -21481,7 +21521,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 139) { + if (tagName.kind === 172 || tagName.kind === 97) { return false; } else { @@ -21617,6 +21657,25 @@ var ts; return getResolvedJsxType(node, type, elemClassType); })); } + if (elemType.flags & 2) { + return anyType; + } + else if (elemType.flags & 256) { + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); + if (intrinsicElementsType !== unknownType) { + var stringLiteralTypeName = elemType.text; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + return indexSignatureType; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + } + return anyType; + } var elemInstanceType = getJsxElementInstanceType(node, elemType); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { if (jsxElementType) { @@ -21861,6 +21920,9 @@ var ts; } return unknownType; } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + prop.hasReference = true; + } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { checkClassPropertyAccess(node, left, apparentType, prop); @@ -22173,10 +22235,11 @@ var ts; if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { context.failedTypeParameterIndex = undefined; } - if (signature.thisType) { + var thisType = getThisTypeOfSignature(signature); + if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context, thisArgumentType, signature.thisType); + inferTypes(context, thisArgumentType, thisType); } var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { @@ -22227,12 +22290,13 @@ var ts; return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - if (signature.thisType && signature.thisType !== voidType && node.kind !== 175) { + var thisType = getThisTypeOfSignature(signature); + if (thisType && thisType !== voidType && node.kind !== 175) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; - if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { return false; } } @@ -22648,7 +22712,7 @@ var ts; if (getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } - if (signature.thisType === voidType) { + if (getThisTypeOfSignature(signature) === voidType) { error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void); } return signature; @@ -23128,6 +23192,8 @@ var ts; } } } + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -23138,7 +23204,8 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || + return symbol.isReadonly || + symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || symbol.flags & 3 && (getDeclarationFlagsFromSymbol(symbol) & 2048) !== 0 || symbol.flags & 98304 && !(symbol.flags & 65536) || (symbol.flags & 8) !== 0; @@ -23973,6 +24040,9 @@ var ts; checkAsyncFunctionReturnType(node); } } + if (!node.body) { + checkUnusedTypeParameters(node); + } } } function checkClassForDuplicateDeclarations(node) { @@ -24100,6 +24170,8 @@ var ts; checkSignatureDeclaration(node); checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); var symbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); if (node === firstDeclaration) { @@ -24203,7 +24275,7 @@ var ts; error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorThisType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); + checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } getTypeOfAccessors(getSymbolOfNode(node)); @@ -24248,12 +24320,17 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); + if (type !== unknownType) { + if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + type.symbol.hasReference = true; + } + if (node.typeArguments) { + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } } } } @@ -24783,6 +24860,8 @@ var ts; } } checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); if (!node.asteriskToken) { var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -24796,11 +24875,83 @@ var ts; } } } + function checkUnusedIdentifiers(node) { + if (node.parent.kind !== 222 && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + for (var key in node.locals) { + if (ts.hasProperty(node.locals, key)) { + var local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration) { + if (local.valueDeclaration.kind !== 142 && compilerOptions.noUnusedLocals) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + else if (local.valueDeclaration.kind === 142 && compilerOptions.noUnusedParameters) { + if (local.valueDeclaration.flags === 0) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + } + } + } + } + } + } + function checkUnusedClassLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.members) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 147 || member.kind === 145) { + if (isPrivateNode(member) && !member.symbol.hasReference) { + error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); + } + } + else if (member.kind === 148) { + for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + error(parameter.name, ts.Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + } + } + } + } + } + } + } + function checkUnusedTypeParameters(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.typeParameters) { + for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { + var typeParameter = _a[_i]; + if (!typeParameter.symbol.hasReference) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + } + } + } + } + } + function isPrivateNode(node) { + return (node.flags & 8) !== 0; + } + function checkUnusedModuleLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + var _loop_1 = function(key) { + if (ts.hasProperty(node.locals, key)) { + var local_1 = node.locals[key]; + if (!local_1.hasReference && !local_1.exportSymbol) { + ts.forEach(local_1.declarations, function (d) { return error(d.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name); }); + } + } + }; + for (var key in node.locals) { + _loop_1(key); + } + } + } function checkBlock(node) { if (node.kind === 199) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); + checkUnusedIdentifiers(node); } function checkCollisionWithArgumentsInGeneratedCode(node) { if (!ts.hasDeclaredRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { @@ -25146,6 +25297,7 @@ var ts; } } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); @@ -25174,6 +25326,7 @@ var ts; 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); + checkUnusedIdentifiers(node); } function checkForInOrForOfVariableDeclaration(iterationStatement) { var variableDeclarationList = iterationStatement.initializer; @@ -25470,6 +25623,7 @@ var ts; } } checkBlock(catchClause.block); + checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { checkBlock(node.finallyBlock); @@ -25592,6 +25746,8 @@ var ts; } checkClassLikeDeclaration(node); ts.forEach(node.members, checkSourceElement); + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); } function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); @@ -25832,6 +25988,8 @@ var ts; ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); + checkUnusedTypeParameters(node); } } function checkTypeAliasDeclaration(node) { @@ -26151,6 +26309,7 @@ var ts; } if (node.body) { checkSourceElement(node.body); + checkUnusedModuleLocals(node); } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { @@ -26301,6 +26460,9 @@ var ts; if (target.flags & 793056) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + target.hasReference = true; + } } } else { @@ -26588,6 +26750,9 @@ var ts; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); + if (ts.isExternalModule(node)) { + checkUnusedModuleLocals(node); + } checkDeferredNodes(); deferredNodes = undefined; if (ts.isExternalOrCommonJsModule(node)) { @@ -26876,6 +27041,13 @@ var ts; case 139: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97: + var container = ts.getThisContainer(node, false); + if (ts.isFunctionLike(container)) { + var sig = getSignatureFromDeclaration(container); + if (sig.thisParameter) { + return sig.thisParameter; + } + } case 95: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; @@ -27064,7 +27236,9 @@ var ts; var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { - return parentSymbol.valueDeclaration; + if (parentSymbol.valueDeclaration === ts.getSourceFileOfNode(node)) { + return parentSymbol.valueDeclaration; + } } for (var n = node.parent; n; n = n.parent) { if ((n.kind === 225 || n.kind === 224) && getSymbolOfNode(n) === parentSymbol) { @@ -27957,7 +28131,7 @@ var ts; var GetAccessor = 2; var SetAccessor = 4; var GetOrSetAccessor = GetAccessor | SetAccessor; - var _loop_1 = function(prop) { + var _loop_2 = function(prop) { var name_22 = prop.name; if (prop.kind === 193 || name_22.kind === 140) { @@ -28018,8 +28192,8 @@ var ts; }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_2 = _loop_1(prop); - if (typeof state_2 === "object") return state_2.value; + var state_3 = _loop_2(prop); + if (typeof state_3 === "object") return state_3.value; } } function checkGrammarJsxElement(node) { @@ -30649,6 +30823,8 @@ var ts; return generateNameForExportDefault(); case 192: return generateNameForClassExpression(); + default: + ts.Debug.fail(); } } function getGeneratedNameForNode(node) { @@ -31346,6 +31522,20 @@ var ts; } return false; } + function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node) { + if (languageVersion >= 2) { + var parent_14 = node.parent; + if (parent_14.kind === 172 && parent_14.expression === node) { + parent_14 = parent_14.parent; + while (parent_14 && parent_14.kind !== 145) { + parent_14 = parent_14.parent; + } + return parent_14 && parent_14.kind === 145 && (parent_14.flags & 32) !== 0 && + parent_14.parent.kind === 192 ? parent_14.parent : undefined; + } + } + return undefined; + } function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { @@ -31358,6 +31548,14 @@ var ts; write(node.text); } else if (isExpressionIdentifier(node)) { + var classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node); + if (classExpression) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration === classExpression) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } emitExpressionIdentifier(node); } else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { @@ -33897,7 +34095,7 @@ var ts; emitStart(property); emitStart(property.name); if (receiver) { - emit(receiver); + write(receiver); } else { if (property.flags & 32) { @@ -34180,12 +34378,15 @@ var ts; } var staticProperties = getInitializedProperties(node, true); var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 192; - var tempVariable; + var generatedName; if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); + generatedName = getGeneratedNameForNode(node.name); + var synthesizedNode = ts.createSynthesizedNode(69); + synthesizedNode.text = generatedName; + recordTempDeclaration(synthesizedNode); write("("); increaseIndent(); - emit(tempVariable); + emit(synthesizedNode); write(" = "); } write("class"); @@ -34225,11 +34426,11 @@ var ts; var property = staticProperties_1[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, generatedName, true); } write(","); writeLine(); - emit(tempVariable); + write(generatedName); decreaseIndent(); write(")"); } @@ -36407,7 +36608,7 @@ var ts; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.9.0"; + ts.version = "2.0.0"; var emptyArray = []; var defaultTypeRoots = ["node_modules/@types"]; function findConfigFile(searchPath, fileExists) { @@ -38689,24 +38890,24 @@ var ts; switch (n.kind) { case 199: if (!ts.isFunctionBlock(n)) { - var parent_14 = n.parent; + var parent_15 = n.parent; var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_14.kind === 204 || - parent_14.kind === 207 || - parent_14.kind === 208 || - parent_14.kind === 206 || - parent_14.kind === 203 || - parent_14.kind === 205 || - parent_14.kind === 212 || - parent_14.kind === 252) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + if (parent_15.kind === 204 || + parent_15.kind === 207 || + parent_15.kind === 208 || + parent_15.kind === 206 || + parent_15.kind === 203 || + parent_15.kind === 205 || + parent_15.kind === 212 || + parent_15.kind === 252) { + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_14.kind === 216) { - var tryStatement = parent_14; + if (parent_15.kind === 216) { + var tryStatement = parent_15; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -40114,7 +40315,7 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(ts.punctuationPart(27)); var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation); + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -40228,6 +40429,8 @@ var ts; case 199: case 226: case 227: + case 233: + case 237: return nodeEndsWith(n, 16, sourceFile); case 252: return isCompletedNode(n.block, sourceFile); @@ -40310,6 +40513,9 @@ var ts; return isCompletedNode(lastSpan, sourceFile); case 197: return ts.nodeIsPresent(n.literal); + case 236: + case 230: + return ts.nodeIsPresent(n.moduleSpecifier); case 185: return isCompletedNode(n.operand, sourceFile); case 187: @@ -41505,7 +41711,7 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73, 82, 89]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 79, 100, 85, 80]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); @@ -41540,8 +41746,8 @@ var ts; this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 129]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 131, 113, 134]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 131, 113, 134, 136]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106, 136])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -41667,6 +41873,8 @@ var ts; case 187: case 188: case 195: + case 238: + case 234: case 154: case 162: case 163: @@ -41754,6 +41962,10 @@ var ts; case 224: case 159: case 225: + case 236: + case 237: + case 230: + case 233: return true; } return false; @@ -42445,7 +42657,8 @@ var ts; var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); if (startLine !== parentStartLine || startPos === column) { - return column; + var baseIndentSize = formatting.SmartIndenter.getBaseIndentation(options); + return baseIndentSize > column ? baseIndentSize : column; } } return -1; @@ -43006,14 +43219,14 @@ var ts; (function (SmartIndenter) { function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { - return 0; + return getBaseIndentation(options); } if (options.IndentStyle === ts.IndentStyle.None) { return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { - return 0; + return getBaseIndentation(options); } var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { @@ -43065,11 +43278,15 @@ var ts; current = current.parent; } if (!current) { - return 0; + return getBaseIndentation(options); } return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; + function getBaseIndentation(options) { + return options.BaseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); @@ -43110,7 +43327,7 @@ var ts; currentStart = parentStart; parent = current.parent; } - return indentationDelta; + return indentationDelta + getBaseIndentation(options); } function getParentStart(parent, child, sourceFile) { var containingList = getContainingList(child, sourceFile); @@ -43336,7 +43553,10 @@ var ts; case 164: case 176: case 184: + case 237: case 233: + case 238: + case 234: return true; } return false; @@ -43358,6 +43578,11 @@ var ts; case 149: case 150: return childKind !== 199; + case 236: + return childKind !== 237; + case 230: + return childKind !== 231 || + child.namedBindings.kind !== 233; case 241: return childKind !== 245; } @@ -44211,8 +44436,8 @@ var ts; if (declaration.kind !== 218 && declaration.kind !== 220) { return false; } - for (var parent_15 = declaration.parent; !ts.isFunctionBlock(parent_15); parent_15 = parent_15.parent) { - if (parent_15.kind === 256 || parent_15.kind === 226) { + for (var parent_16 = declaration.parent; !ts.isFunctionBlock(parent_16); parent_16 = parent_16.parent) { + if (parent_16.kind === 256 || parent_16.kind === 226) { return false; } } @@ -44329,7 +44554,7 @@ var ts; return typeof o.type === "object" && !ts.forEachValue(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function(opt) { + var _loop_3 = function(opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -44345,7 +44570,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_3(opt); } return options; } @@ -45326,13 +45551,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_16 = contextToken.parent, kind = contextToken.kind; + var parent_17 = contextToken.parent, kind = contextToken.kind; if (kind === 21) { - if (parent_16.kind === 172) { + if (parent_17.kind === 172) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_16.kind === 139) { + else if (parent_17.kind === 139) { node = contextToken.parent.left; isRightOfDot = true; } @@ -45620,9 +45845,9 @@ var ts; switch (contextToken.kind) { case 15: case 24: - var parent_17 = contextToken.parent; - if (parent_17 && (parent_17.kind === 171 || parent_17.kind === 167)) { - return parent_17; + var parent_18 = contextToken.parent; + if (parent_18 && (parent_18.kind === 171 || parent_18.kind === 167)) { + return parent_18; } break; } @@ -45645,34 +45870,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_18 = contextToken.parent; + var parent_19 = contextToken.parent; switch (contextToken.kind) { case 26: case 39: case 69: case 246: case 247: - if (parent_18 && (parent_18.kind === 242 || parent_18.kind === 243)) { - return parent_18; + if (parent_19 && (parent_19.kind === 242 || parent_19.kind === 243)) { + return parent_19; } - else if (parent_18.kind === 246) { - return parent_18.parent; + else if (parent_19.kind === 246) { + return parent_19.parent; } break; case 9: - if (parent_18 && ((parent_18.kind === 246) || (parent_18.kind === 247))) { - return parent_18.parent; + if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { + return parent_19.parent; } break; case 16: - if (parent_18 && - parent_18.kind === 248 && - parent_18.parent && - (parent_18.parent.kind === 246)) { - return parent_18.parent.parent; + if (parent_19 && + parent_19.kind === 248 && + parent_19.parent && + (parent_19.parent.kind === 246)) { + return parent_19.parent.parent; } - if (parent_18 && parent_18.kind === 247) { - return parent_18.parent; + if (parent_19 && parent_19.kind === 247) { + return parent_19.parent; } break; } @@ -46873,17 +47098,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_19 = child.parent; - if (ts.isFunctionBlock(parent_19) || parent_19.kind === 256) { - return parent_19; + var parent_20 = child.parent; + if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { + return parent_20; } - if (parent_19.kind === 216) { - var tryStatement = parent_19; + if (parent_20.kind === 216) { + var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_19; + child = parent_20; } return undefined; } @@ -47241,13 +47466,27 @@ var ts; if (node === sourceFile) { return undefined; } - if (node.kind !== 69 && - node.kind !== 9 && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return undefined; + switch (node.kind) { + case 8: + if (!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + break; + } + case 69: + case 97: + case 9: + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + } + return undefined; + } + function isThis(node) { + switch (node.kind) { + case 97: + return true; + case 69: + return node.originalKeywordKind === 97 && node.parent.kind === 142; + default: + return false; } - ts.Debug.assert(node.kind === 69 || node.kind === 8 || node.kind === 9); - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { var typeChecker = program.getTypeChecker(); @@ -47260,7 +47499,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 || node.kind === 165) { + if (isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95) { @@ -47625,7 +47864,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 && node.kind !== 165)) { + if (!node || !isThis(node)) { return; } var container = ts.getThisContainer(node, false); @@ -48465,8 +48704,8 @@ var ts; return; case 142: if (token.parent.name === token) { - var isThis = token.kind === 69 && token.originalKeywordKind === 97; - return isThis ? 3 : 17; + var isThis_1 = token.kind === 69 && token.originalKeywordKind === 97; + return isThis_1 ? 3 : 17; } return; } @@ -48616,7 +48855,7 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } - function isValidBraceCompletionAtPostion(fileName, position, openingBrace) { + function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { if (openingBrace === 60) { return false; } @@ -48741,7 +48980,8 @@ var ts; if (node) { if (node.kind === 69 || node.kind === 9 || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isThis(node)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -48852,7 +49092,7 @@ var ts; getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - isValidBraceCompletionAtPostion: isValidBraceCompletionAtPostion, + isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram @@ -49347,6 +49587,8 @@ var ts; CommandNames.Formatonkey = "formatonkey"; CommandNames.Geterr = "geterr"; CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; CommandNames.NavBar = "navbar"; CommandNames.Navto = "navto"; CommandNames.Occurrences = "occurrences"; @@ -49366,6 +49608,7 @@ var ts; var Errors; (function (Errors) { Errors.NoProject = new Error("No Project."); + Errors.ProjectLanguageServiceDisabled = new Error("The project's language service is disabled."); })(Errors || (Errors = {})); var Session = (function () { function Session(host, byteLength, hrtime, logger) { @@ -49442,6 +49685,12 @@ var ts; var signatureHelpArgs = request.arguments; return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; }, + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); + }, _a[CommandNames.Geterr] = function (request) { var geterrArgs = request.arguments; return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; @@ -49720,6 +49969,24 @@ var ts; }; }); }; + Session.prototype.getDiagnosticsWorker = function (args, selector) { + var file = ts.normalizePath(args.file); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + if (project.languageServiceDiabled) { + throw Errors.ProjectLanguageServiceDisabled; + } + var diagnostics = selector(project, file); + return ts.map(diagnostics, function (originalDiagnostic) { return formatDiag(file, project, originalDiagnostic); }); + }; + Session.prototype.getSyntacticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSyntacticDiagnostics(file); }); + }; + Session.prototype.getSemanticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSemanticDiagnostics(file); }); + }; Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); @@ -49954,6 +50221,7 @@ var ts; var lineText = lineInfo.leaf.text; if (lineText.search("\\S") < 0) { var editorOptions = { + BaseIndentSize: formatOptions.BaseIndentSize, IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: formatOptions.NewLineCharacter, @@ -50257,6 +50525,9 @@ var ts; }; Session.prototype.exit = function () { }; + Session.prototype.requiredResponse = function (response) { + return { response: response, responseRequired: true }; + }; Session.prototype.addProtocolHandler = function (command, handler) { if (this.handlers[command]) { throw new Error("Protocol handler already exists for command \"" + command + "\""); @@ -51511,6 +51782,7 @@ var ts; }; CompilerService.getDefaultFormatCodeOptions = function (host) { return ts.clone({ + BaseIndentSize: 0, IndentSize: 4, TabSize: 4, NewLineCharacter: host.newLine || "\n", @@ -52970,9 +53242,9 @@ var ts; var _this = this; return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPostion = function (fileName, position, openingBrace) { + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPostion('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { var _this = this; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index aef7909bd45..aa24fb95715 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -744,9 +744,10 @@ declare namespace ts { children: NodeArray; closingElement: JsxClosingElement; } + type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxOpeningElement extends Expression { _openingElementBrand?: any; - tagName: EntityName; + tagName: JsxTagNameExpression; attributes: NodeArray; } interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { @@ -761,7 +762,7 @@ declare namespace ts { expression: Expression; } interface JsxClosingElement extends Node { - tagName: EntityName; + tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { expression?: Expression; @@ -1263,7 +1264,7 @@ declare namespace ts { buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(thisParameter: Symbol, 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; } @@ -1446,11 +1447,13 @@ declare namespace ts { members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; + isReadonly?: boolean; id?: number; mergeId?: number; parent?: Symbol; exportSymbol?: Symbol; constEnumOnlyModule?: boolean; + hasReference?: boolean; } interface SymbolLinks { target?: Symbol; @@ -1639,7 +1642,7 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; - thisType?: Type; + thisParameter?: Symbol; resolvedReturnType: Type; minArgumentCount: number; hasRestParameter: boolean; @@ -1757,6 +1760,8 @@ declare namespace ts { noImplicitAny?: boolean; noImplicitReturns?: boolean; noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; noImplicitUseStrict?: boolean; noLib?: boolean; noResolve?: boolean; @@ -1785,7 +1790,6 @@ declare namespace ts { disableSizeLimit?: boolean; types?: string[]; typeRoots?: string[]; - typesSearchPaths?: string[]; version?: boolean; watch?: boolean; [option: string]: CompilerOptionsValue | undefined; @@ -6438,6 +6442,24 @@ declare namespace ts { key: string; message: string; }; + _0_is_declared_but_never_used: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Report_Errors_on_Unused_Locals: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Report_Errors_on_Unused_Parameters: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Variable_0_implicitly_has_an_1_type: { code: number; category: DiagnosticCategory; @@ -6981,7 +7003,7 @@ declare namespace ts { function isLiteralComputedPropertyDeclarationName(node: Node): boolean; function isIdentifierName(node: Identifier): boolean; function isAliasSymbolDeclaration(node: Node): boolean; - function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration): ExpressionWithTypeArguments; + function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments; function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray; function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; @@ -7688,6 +7710,7 @@ declare namespace ts.formatting { declare namespace ts.formatting { namespace SmartIndenter { function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number; + function getBaseIndentation(options: EditorOptions): number; function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number; function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): { @@ -7826,7 +7849,7 @@ declare namespace ts { getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; getNonBoundSourceFile(fileName: string): SourceFile; @@ -7904,6 +7927,7 @@ declare namespace ts { containerKind: string; } interface EditorOptions { + BaseIndentSize?: number; IndentSize: number; TabSize: number; NewLineCharacter: string; @@ -7926,7 +7950,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string; + [s: string]: boolean | number | string | undefined; } interface DefinitionInfo { fileName: string; @@ -8231,6 +8255,8 @@ declare namespace ts.server { const Formatonkey: string; const Geterr: string; const GeterrForProject: string; + const SemanticDiagnosticsSync: string; + const SyntacticDiagnosticsSync: string; const NavBar: string; const Navto: string; const Occurrences: string; @@ -8277,6 +8303,9 @@ declare namespace ts.server { private getDefinition(line, offset, fileName); private getTypeDefinition(line, offset, fileName); private getOccurrences(line, offset, fileName); + private getDiagnosticsWorker(args, selector); + private getSyntacticDiagnosticsSync(args); + private getSemanticDiagnosticsSync(args); private getDocumentHighlights(line, offset, fileName, filesToSearch); private getProjectInfo(fileName, needFileNameList); private getRenameLocations(line, offset, fileName, findInComments, findInStrings); @@ -8300,6 +8329,7 @@ declare namespace ts.server { getDiagnosticsForProject(delay: number, fileName: string): void; getCanonicalFileName(fileName: string): string; exit(): void; + private requiredResponse(response); private handlers; addProtocolHandler(command: string, handler: (request: protocol.Request) => { response?: any; @@ -8731,7 +8761,7 @@ declare namespace ts { getFormattingEditsForDocument(fileName: string, options: string): string; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string): string; getDocCommentTemplateAtPosition(fileName: string, position: number): string; - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; getEmitOutput(fileName: string): string; } interface ClassifierShim extends Shim { diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 22a420c25e4..37ce862d0c1 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -2286,6 +2286,9 @@ var ts; Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, + Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." }, + Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3950,6 +3953,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Locals + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Parameters + }, { name: "noLib", type: "boolean" @@ -4139,16 +4152,6 @@ var ts; isFilePath: true } }, - { - name: "typesSearchPaths", - type: "list", - isTSConfigOnly: true, - element: { - name: "typesSearchPaths", - type: "string", - isFilePath: true - } - }, { name: "typeRoots", type: "list", @@ -4223,7 +4226,7 @@ var ts; description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableProjectSizeLimit", + name: "disableSizeLimit", type: "boolean" }, { @@ -9645,8 +9648,11 @@ var ts; if (lhs.kind === 69) { return lhs.text === rhs.text; } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); + if (lhs.kind === 97) { + return true; + } + return lhs.name.text === rhs.name.text && + tagNamesAreEquivalent(lhs.expression, rhs.expression); } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); @@ -9743,15 +9749,15 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var elementName = parseIdentifierName(); + var expression = token === 97 ? + parseTokenNode() : parseIdentifierName(); while (parseOptional(21)) { - scanJsxIdentifier(); - var node = createNode(139, elementName.pos); - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); + var propertyAccess = createNode(172, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(true); + expression = finishNode(propertyAccess); } - return elementName; + return expression; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); @@ -10529,7 +10535,7 @@ var ts; case 56: return parseExportAssignment(fullStart, decorators, modifiers); case 116: - return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers); + return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } @@ -11043,7 +11049,7 @@ var ts; function nextTokenIsSlash() { return nextToken() === 39; } - function parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers) { + function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { var exportDeclaration = createNode(228, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; @@ -14714,7 +14720,7 @@ var ts; function getTargetOfImportSpecifier(node) { return getExternalModuleMember(node.parent.parent.parent, node); } - function getTargetOfGlobalModuleExportDeclaration(node) { + function getTargetOfNamespaceExportDeclaration(node) { return resolveExternalModuleSymbol(node.parent.symbol); } function getTargetOfExportSpecifier(node) { @@ -14740,7 +14746,7 @@ var ts; case 235: return getTargetOfExportAssignment(node); case 228: - return getTargetOfGlobalModuleExportDeclaration(node); + return getTargetOfNamespaceExportDeclaration(node); } } function resolveSymbol(symbol) { @@ -14823,9 +14829,12 @@ var ts; var left = name.kind === 139 ? name.left : name.expression; var right = name.kind === 139 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + if (!namespace || ts.nodeIsMissing(right)) { return undefined; } + else if (namespace === unknownSymbol) { + return namespace; + } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { if (!ignoreErrors) { @@ -15786,16 +15795,13 @@ var ts; writePunctuation(writer, 27); } } - function buildDisplayForParametersAndDelimiters(thisType, parameters, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { writePunctuation(writer, 17); - if (thisType) { - writeKeyword(writer, 97); - writePunctuation(writer, 54); - writeSpace(writer); - buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack); + if (thisParameter) { + buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { - if (i > 0 || thisType) { + if (i > 0 || thisParameter) { writePunctuation(writer, 24); writeSpace(writer); } @@ -15843,7 +15849,7 @@ var ts; else { buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); } - buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { @@ -16174,12 +16180,13 @@ var ts; if (func.kind === 150 && !ts.hasDynamicName(func)) { var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); if (getter) { - var signature = getSignatureFromDeclaration(getter); + var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); if (thisParameter && declaration === thisParameter) { - return signature.thisType; + ts.Debug.assert(!thisParameter.type); + return getTypeOfSymbol(getterSignature.thisParameter); } - return getReturnTypeOfSignature(signature); + return getReturnTypeOfSignature(getterSignature); } } var type = declaration.symbol.name === "this" @@ -16337,14 +16344,12 @@ var ts; } return undefined; } - function getAnnotatedAccessorThisType(accessor) { - if (accessor) { - var parameter = getAccessorThisParameter(accessor); - if (parameter && parameter.type) { - return getTypeFromTypeNode(accessor.parameters[0].type); - } - } - return undefined; + function getAnnotatedAccessorThisParameter(accessor) { + var parameter = getAccessorThisParameter(accessor); + return parameter && parameter.symbol; + } + function getThisTypeOfDeclaration(declaration) { + return getThisTypeOfSignature(getSignatureFromDeclaration(declaration)); } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); @@ -16924,12 +16929,12 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, thisType, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; - sig.thisType = thisType; + sig.thisParameter = thisParameter; sig.resolvedReturnType = resolvedReturnType; sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; @@ -16938,7 +16943,7 @@ var ts; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); @@ -17022,8 +17027,9 @@ var ts; var s = signature; if (unionSignatures.length > 1) { s = cloneSignature(signature); - if (ts.forEach(unionSignatures, function (sig) { return sig.thisType; })) { - s.thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisType || anyType; })); + if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; })); + s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -17208,6 +17214,7 @@ var ts; var types = containingType.types; var props; var commonFlags = (containingType.flags & 32768) ? 536870912 : 0; + var isReadonly = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -17221,6 +17228,9 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } + if (isReadonlySymbol(prop)) { + isReadonly = true; + } } else if (containingType.flags & 16384) { return undefined; @@ -17248,6 +17258,7 @@ var ts; commonFlags, name); result.containingType = containingType; result.declarations = declarations; + result.isReadonly = isReadonly; result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } @@ -17406,7 +17417,7 @@ var ts; var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - var thisType = undefined; + var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { @@ -17418,7 +17429,7 @@ var ts; } if (i === 0 && paramSymbol.name === "this") { hasThisParameter = true; - thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType; + thisParameter = param.symbol; } else { parameters.push(paramSymbol); @@ -17437,10 +17448,12 @@ var ts; } if ((declaration.kind === 149 || declaration.kind === 150) && !ts.hasDynamicName(declaration) && - (!hasThisParameter || thisType === unknownType)) { + (!hasThisParameter || !thisParameter)) { var otherKind = declaration.kind === 149 ? 150 : 149; - var setter = ts.getDeclarationOfKind(declaration.symbol, otherKind); - thisType = getAnnotatedAccessorThisType(setter); + var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); + if (other) { + thisParameter = getAnnotatedAccessorThisParameter(other); + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); @@ -17458,7 +17471,7 @@ var ts; var typePredicate = declaration.type && declaration.type.kind === 154 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; - links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -17528,6 +17541,11 @@ var ts; } return anyType; } + function getThisTypeOfSignature(signature) { + if (signature.thisParameter) { + return getTypeOfSymbol(signature.thisParameter); + } + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { @@ -18245,7 +18263,7 @@ var ts; if (signature.typePredicate) { freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, signature.thisType && instantiateType(signature.thisType, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -18448,16 +18466,20 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1; - if (source.thisType && target.thisType && source.thisType !== voidType) { - var related = compareTypes(source.thisType, target.thisType, false) - || compareTypes(target.thisType, source.thisType, reportErrors); - if (!related) { - if (reportErrors) { - errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType && sourceThisType !== voidType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType, false) + || compareTypes(targetThisType, sourceThisType, reportErrors); + if (!related) { + if (reportErrors) { + errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + } + return 0; } - return 0; + result &= related; } - result &= related; } var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); @@ -19275,12 +19297,18 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1; - if (!ignoreThisTypes && source.thisType && target.thisType) { - var related = compareTypes(source.thisType, target.thisType); - if (!related) { - return 0; + if (!ignoreThisTypes) { + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType); + if (!related) { + return 0; + } + result &= related; + } } - result &= related; } var targetLen = target.parameters.length; for (var i = 0; i < targetLen; i++) { @@ -20543,8 +20571,20 @@ var ts; } return container === declarationContainer; } + function updateReferencesForInterfaceHeritiageClauseTargets(node) { + var extendedTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (extendedTypeNode) { + var t = getTypeFromTypeNode(extendedTypeNode); + if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + t.symbol.hasReference = true; + } + } + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + symbol.hasReference = true; + } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (container.kind === 180) { @@ -20754,9 +20794,9 @@ var ts; if (type) { return type; } - var signature = getSignatureFromDeclaration(container); - if (signature.thisType) { - return signature.thisType; + var thisType = getThisTypeOfDeclaration(container); + if (thisType) { + return thisType; } } if (ts.isClassLike(container.parent)) { @@ -20899,7 +20939,7 @@ var ts; if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisType; + return getThisTypeOfSignature(contextualSignature); } } return undefined; @@ -21481,7 +21521,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 139) { + if (tagName.kind === 172 || tagName.kind === 97) { return false; } else { @@ -21617,6 +21657,25 @@ var ts; return getResolvedJsxType(node, type, elemClassType); })); } + if (elemType.flags & 2) { + return anyType; + } + else if (elemType.flags & 256) { + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); + if (intrinsicElementsType !== unknownType) { + var stringLiteralTypeName = elemType.text; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + return indexSignatureType; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + } + return anyType; + } var elemInstanceType = getJsxElementInstanceType(node, elemType); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { if (jsxElementType) { @@ -21861,6 +21920,9 @@ var ts; } return unknownType; } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + prop.hasReference = true; + } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { checkClassPropertyAccess(node, left, apparentType, prop); @@ -22173,10 +22235,11 @@ var ts; if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { context.failedTypeParameterIndex = undefined; } - if (signature.thisType) { + var thisType = getThisTypeOfSignature(signature); + if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context, thisArgumentType, signature.thisType); + inferTypes(context, thisArgumentType, thisType); } var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { @@ -22227,12 +22290,13 @@ var ts; return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - if (signature.thisType && signature.thisType !== voidType && node.kind !== 175) { + var thisType = getThisTypeOfSignature(signature); + if (thisType && thisType !== voidType && node.kind !== 175) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; - if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { return false; } } @@ -22648,7 +22712,7 @@ var ts; if (getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } - if (signature.thisType === voidType) { + if (getThisTypeOfSignature(signature) === voidType) { error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void); } return signature; @@ -23128,6 +23192,8 @@ var ts; } } } + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -23138,7 +23204,8 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || + return symbol.isReadonly || + symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || symbol.flags & 3 && (getDeclarationFlagsFromSymbol(symbol) & 2048) !== 0 || symbol.flags & 98304 && !(symbol.flags & 65536) || (symbol.flags & 8) !== 0; @@ -23973,6 +24040,9 @@ var ts; checkAsyncFunctionReturnType(node); } } + if (!node.body) { + checkUnusedTypeParameters(node); + } } } function checkClassForDuplicateDeclarations(node) { @@ -24100,6 +24170,8 @@ var ts; checkSignatureDeclaration(node); checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); var symbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); if (node === firstDeclaration) { @@ -24203,7 +24275,7 @@ var ts; error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorThisType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); + checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } getTypeOfAccessors(getSymbolOfNode(node)); @@ -24248,12 +24320,17 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); + if (type !== unknownType) { + if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + type.symbol.hasReference = true; + } + if (node.typeArguments) { + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } } } } @@ -24783,6 +24860,8 @@ var ts; } } checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); if (!node.asteriskToken) { var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -24796,11 +24875,83 @@ var ts; } } } + function checkUnusedIdentifiers(node) { + if (node.parent.kind !== 222 && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + for (var key in node.locals) { + if (ts.hasProperty(node.locals, key)) { + var local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration) { + if (local.valueDeclaration.kind !== 142 && compilerOptions.noUnusedLocals) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + else if (local.valueDeclaration.kind === 142 && compilerOptions.noUnusedParameters) { + if (local.valueDeclaration.flags === 0) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + } + } + } + } + } + } + function checkUnusedClassLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.members) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 147 || member.kind === 145) { + if (isPrivateNode(member) && !member.symbol.hasReference) { + error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); + } + } + else if (member.kind === 148) { + for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + error(parameter.name, ts.Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + } + } + } + } + } + } + } + function checkUnusedTypeParameters(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.typeParameters) { + for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { + var typeParameter = _a[_i]; + if (!typeParameter.symbol.hasReference) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + } + } + } + } + } + function isPrivateNode(node) { + return (node.flags & 8) !== 0; + } + function checkUnusedModuleLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + var _loop_1 = function(key) { + if (ts.hasProperty(node.locals, key)) { + var local_1 = node.locals[key]; + if (!local_1.hasReference && !local_1.exportSymbol) { + ts.forEach(local_1.declarations, function (d) { return error(d.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name); }); + } + } + }; + for (var key in node.locals) { + _loop_1(key); + } + } + } function checkBlock(node) { if (node.kind === 199) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); + checkUnusedIdentifiers(node); } function checkCollisionWithArgumentsInGeneratedCode(node) { if (!ts.hasDeclaredRestParameter(node) || ts.isInAmbientContext(node) || ts.nodeIsMissing(node.body)) { @@ -25146,6 +25297,7 @@ var ts; } } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); @@ -25174,6 +25326,7 @@ var ts; 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); + checkUnusedIdentifiers(node); } function checkForInOrForOfVariableDeclaration(iterationStatement) { var variableDeclarationList = iterationStatement.initializer; @@ -25470,6 +25623,7 @@ var ts; } } checkBlock(catchClause.block); + checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { checkBlock(node.finallyBlock); @@ -25592,6 +25746,8 @@ var ts; } checkClassLikeDeclaration(node); ts.forEach(node.members, checkSourceElement); + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); } function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); @@ -25832,6 +25988,8 @@ var ts; ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); + checkUnusedTypeParameters(node); } } function checkTypeAliasDeclaration(node) { @@ -26151,6 +26309,7 @@ var ts; } if (node.body) { checkSourceElement(node.body); + checkUnusedModuleLocals(node); } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { @@ -26301,6 +26460,9 @@ var ts; if (target.flags & 793056) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + target.hasReference = true; + } } } else { @@ -26588,6 +26750,9 @@ var ts; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); + if (ts.isExternalModule(node)) { + checkUnusedModuleLocals(node); + } checkDeferredNodes(); deferredNodes = undefined; if (ts.isExternalOrCommonJsModule(node)) { @@ -26876,6 +27041,13 @@ var ts; case 139: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97: + var container = ts.getThisContainer(node, false); + if (ts.isFunctionLike(container)) { + var sig = getSignatureFromDeclaration(container); + if (sig.thisParameter) { + return sig.thisParameter; + } + } case 95: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; @@ -27064,7 +27236,9 @@ var ts; var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { - return parentSymbol.valueDeclaration; + if (parentSymbol.valueDeclaration === ts.getSourceFileOfNode(node)) { + return parentSymbol.valueDeclaration; + } } for (var n = node.parent; n; n = n.parent) { if ((n.kind === 225 || n.kind === 224) && getSymbolOfNode(n) === parentSymbol) { @@ -27957,7 +28131,7 @@ var ts; var GetAccessor = 2; var SetAccessor = 4; var GetOrSetAccessor = GetAccessor | SetAccessor; - var _loop_1 = function(prop) { + var _loop_2 = function(prop) { var name_22 = prop.name; if (prop.kind === 193 || name_22.kind === 140) { @@ -28018,8 +28192,8 @@ var ts; }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_2 = _loop_1(prop); - if (typeof state_2 === "object") return state_2.value; + var state_3 = _loop_2(prop); + if (typeof state_3 === "object") return state_3.value; } } function checkGrammarJsxElement(node) { @@ -30649,6 +30823,8 @@ var ts; return generateNameForExportDefault(); case 192: return generateNameForClassExpression(); + default: + ts.Debug.fail(); } } function getGeneratedNameForNode(node) { @@ -31346,6 +31522,20 @@ var ts; } return false; } + function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node) { + if (languageVersion >= 2) { + var parent_14 = node.parent; + if (parent_14.kind === 172 && parent_14.expression === node) { + parent_14 = parent_14.parent; + while (parent_14 && parent_14.kind !== 145) { + parent_14 = parent_14.parent; + } + return parent_14 && parent_14.kind === 145 && (parent_14.flags & 32) !== 0 && + parent_14.parent.kind === 192 ? parent_14.parent : undefined; + } + } + return undefined; + } function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { @@ -31358,6 +31548,14 @@ var ts; write(node.text); } else if (isExpressionIdentifier(node)) { + var classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node); + if (classExpression) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration === classExpression) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } emitExpressionIdentifier(node); } else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { @@ -33897,7 +34095,7 @@ var ts; emitStart(property); emitStart(property.name); if (receiver) { - emit(receiver); + write(receiver); } else { if (property.flags & 32) { @@ -34180,12 +34378,15 @@ var ts; } var staticProperties = getInitializedProperties(node, true); var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 192; - var tempVariable; + var generatedName; if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0); + generatedName = getGeneratedNameForNode(node.name); + var synthesizedNode = ts.createSynthesizedNode(69); + synthesizedNode.text = generatedName; + recordTempDeclaration(synthesizedNode); write("("); increaseIndent(); - emit(tempVariable); + emit(synthesizedNode); write(" = "); } write("class"); @@ -34225,11 +34426,11 @@ var ts; var property = staticProperties_1[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, generatedName, true); } write(","); writeLine(); - emit(tempVariable); + write(generatedName); decreaseIndent(); write(")"); } @@ -36407,7 +36608,7 @@ var ts; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.9.0"; + ts.version = "2.0.0"; var emptyArray = []; var defaultTypeRoots = ["node_modules/@types"]; function findConfigFile(searchPath, fileExists) { @@ -38689,24 +38890,24 @@ var ts; switch (n.kind) { case 199: if (!ts.isFunctionBlock(n)) { - var parent_14 = n.parent; + var parent_15 = n.parent; var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_14.kind === 204 || - parent_14.kind === 207 || - parent_14.kind === 208 || - parent_14.kind === 206 || - parent_14.kind === 203 || - parent_14.kind === 205 || - parent_14.kind === 212 || - parent_14.kind === 252) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + if (parent_15.kind === 204 || + parent_15.kind === 207 || + parent_15.kind === 208 || + parent_15.kind === 206 || + parent_15.kind === 203 || + parent_15.kind === 205 || + parent_15.kind === 212 || + parent_15.kind === 252) { + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_14.kind === 216) { - var tryStatement = parent_14; + if (parent_15.kind === 216) { + var tryStatement = parent_15; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -40114,7 +40315,7 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(ts.punctuationPart(27)); var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation); + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -40228,6 +40429,8 @@ var ts; case 199: case 226: case 227: + case 233: + case 237: return nodeEndsWith(n, 16, sourceFile); case 252: return isCompletedNode(n.block, sourceFile); @@ -40310,6 +40513,9 @@ var ts; return isCompletedNode(lastSpan, sourceFile); case 197: return ts.nodeIsPresent(n.literal); + case 236: + case 230: + return ts.nodeIsPresent(n.moduleSpecifier); case 185: return isCompletedNode(n.operand, sourceFile); case 187: @@ -41505,7 +41711,7 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73, 82, 89]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 79, 100, 85, 80]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); @@ -41540,8 +41746,8 @@ var ts; this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 129]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 131, 113, 134]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 131, 113, 134, 136]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106, 136])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -41667,6 +41873,8 @@ var ts; case 187: case 188: case 195: + case 238: + case 234: case 154: case 162: case 163: @@ -41754,6 +41962,10 @@ var ts; case 224: case 159: case 225: + case 236: + case 237: + case 230: + case 233: return true; } return false; @@ -42445,7 +42657,8 @@ var ts; var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); if (startLine !== parentStartLine || startPos === column) { - return column; + var baseIndentSize = formatting.SmartIndenter.getBaseIndentation(options); + return baseIndentSize > column ? baseIndentSize : column; } } return -1; @@ -43006,14 +43219,14 @@ var ts; (function (SmartIndenter) { function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { - return 0; + return getBaseIndentation(options); } if (options.IndentStyle === ts.IndentStyle.None) { return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { - return 0; + return getBaseIndentation(options); } var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { @@ -43065,11 +43278,15 @@ var ts; current = current.parent; } if (!current) { - return 0; + return getBaseIndentation(options); } return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; + function getBaseIndentation(options) { + return options.BaseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); @@ -43110,7 +43327,7 @@ var ts; currentStart = parentStart; parent = current.parent; } - return indentationDelta; + return indentationDelta + getBaseIndentation(options); } function getParentStart(parent, child, sourceFile) { var containingList = getContainingList(child, sourceFile); @@ -43336,7 +43553,10 @@ var ts; case 164: case 176: case 184: + case 237: case 233: + case 238: + case 234: return true; } return false; @@ -43358,6 +43578,11 @@ var ts; case 149: case 150: return childKind !== 199; + case 236: + return childKind !== 237; + case 230: + return childKind !== 231 || + child.namedBindings.kind !== 233; case 241: return childKind !== 245; } @@ -44211,8 +44436,8 @@ var ts; if (declaration.kind !== 218 && declaration.kind !== 220) { return false; } - for (var parent_15 = declaration.parent; !ts.isFunctionBlock(parent_15); parent_15 = parent_15.parent) { - if (parent_15.kind === 256 || parent_15.kind === 226) { + for (var parent_16 = declaration.parent; !ts.isFunctionBlock(parent_16); parent_16 = parent_16.parent) { + if (parent_16.kind === 256 || parent_16.kind === 226) { return false; } } @@ -44329,7 +44554,7 @@ var ts; return typeof o.type === "object" && !ts.forEachValue(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function(opt) { + var _loop_3 = function(opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -44345,7 +44570,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_3(opt); } return options; } @@ -45326,13 +45551,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_16 = contextToken.parent, kind = contextToken.kind; + var parent_17 = contextToken.parent, kind = contextToken.kind; if (kind === 21) { - if (parent_16.kind === 172) { + if (parent_17.kind === 172) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_16.kind === 139) { + else if (parent_17.kind === 139) { node = contextToken.parent.left; isRightOfDot = true; } @@ -45620,9 +45845,9 @@ var ts; switch (contextToken.kind) { case 15: case 24: - var parent_17 = contextToken.parent; - if (parent_17 && (parent_17.kind === 171 || parent_17.kind === 167)) { - return parent_17; + var parent_18 = contextToken.parent; + if (parent_18 && (parent_18.kind === 171 || parent_18.kind === 167)) { + return parent_18; } break; } @@ -45645,34 +45870,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_18 = contextToken.parent; + var parent_19 = contextToken.parent; switch (contextToken.kind) { case 26: case 39: case 69: case 246: case 247: - if (parent_18 && (parent_18.kind === 242 || parent_18.kind === 243)) { - return parent_18; + if (parent_19 && (parent_19.kind === 242 || parent_19.kind === 243)) { + return parent_19; } - else if (parent_18.kind === 246) { - return parent_18.parent; + else if (parent_19.kind === 246) { + return parent_19.parent; } break; case 9: - if (parent_18 && ((parent_18.kind === 246) || (parent_18.kind === 247))) { - return parent_18.parent; + if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { + return parent_19.parent; } break; case 16: - if (parent_18 && - parent_18.kind === 248 && - parent_18.parent && - (parent_18.parent.kind === 246)) { - return parent_18.parent.parent; + if (parent_19 && + parent_19.kind === 248 && + parent_19.parent && + (parent_19.parent.kind === 246)) { + return parent_19.parent.parent; } - if (parent_18 && parent_18.kind === 247) { - return parent_18.parent; + if (parent_19 && parent_19.kind === 247) { + return parent_19.parent; } break; } @@ -46873,17 +47098,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_19 = child.parent; - if (ts.isFunctionBlock(parent_19) || parent_19.kind === 256) { - return parent_19; + var parent_20 = child.parent; + if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { + return parent_20; } - if (parent_19.kind === 216) { - var tryStatement = parent_19; + if (parent_20.kind === 216) { + var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_19; + child = parent_20; } return undefined; } @@ -47241,13 +47466,27 @@ var ts; if (node === sourceFile) { return undefined; } - if (node.kind !== 69 && - node.kind !== 9 && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return undefined; + switch (node.kind) { + case 8: + if (!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + break; + } + case 69: + case 97: + case 9: + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + } + return undefined; + } + function isThis(node) { + switch (node.kind) { + case 97: + return true; + case 69: + return node.originalKeywordKind === 97 && node.parent.kind === 142; + default: + return false; } - ts.Debug.assert(node.kind === 69 || node.kind === 8 || node.kind === 9); - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { var typeChecker = program.getTypeChecker(); @@ -47260,7 +47499,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 || node.kind === 165) { + if (isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95) { @@ -47625,7 +47864,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 && node.kind !== 165)) { + if (!node || !isThis(node)) { return; } var container = ts.getThisContainer(node, false); @@ -48465,8 +48704,8 @@ var ts; return; case 142: if (token.parent.name === token) { - var isThis = token.kind === 69 && token.originalKeywordKind === 97; - return isThis ? 3 : 17; + var isThis_1 = token.kind === 69 && token.originalKeywordKind === 97; + return isThis_1 ? 3 : 17; } return; } @@ -48616,7 +48855,7 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } - function isValidBraceCompletionAtPostion(fileName, position, openingBrace) { + function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { if (openingBrace === 60) { return false; } @@ -48741,7 +48980,8 @@ var ts; if (node) { if (node.kind === 69 || node.kind === 9 || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isThis(node)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -48852,7 +49092,7 @@ var ts; getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - isValidBraceCompletionAtPostion: isValidBraceCompletionAtPostion, + isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram @@ -49347,6 +49587,8 @@ var ts; CommandNames.Formatonkey = "formatonkey"; CommandNames.Geterr = "geterr"; CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; CommandNames.NavBar = "navbar"; CommandNames.Navto = "navto"; CommandNames.Occurrences = "occurrences"; @@ -49366,6 +49608,7 @@ var ts; var Errors; (function (Errors) { Errors.NoProject = new Error("No Project."); + Errors.ProjectLanguageServiceDisabled = new Error("The project's language service is disabled."); })(Errors || (Errors = {})); var Session = (function () { function Session(host, byteLength, hrtime, logger) { @@ -49442,6 +49685,12 @@ var ts; var signatureHelpArgs = request.arguments; return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; }, + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); + }, _a[CommandNames.Geterr] = function (request) { var geterrArgs = request.arguments; return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; @@ -49720,6 +49969,24 @@ var ts; }; }); }; + Session.prototype.getDiagnosticsWorker = function (args, selector) { + var file = ts.normalizePath(args.file); + var project = this.projectService.getProjectForFile(file); + if (!project) { + throw Errors.NoProject; + } + if (project.languageServiceDiabled) { + throw Errors.ProjectLanguageServiceDisabled; + } + var diagnostics = selector(project, file); + return ts.map(diagnostics, function (originalDiagnostic) { return formatDiag(file, project, originalDiagnostic); }); + }; + Session.prototype.getSyntacticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSyntacticDiagnostics(file); }); + }; + Session.prototype.getSemanticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSemanticDiagnostics(file); }); + }; Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); @@ -49954,6 +50221,7 @@ var ts; var lineText = lineInfo.leaf.text; if (lineText.search("\\S") < 0) { var editorOptions = { + BaseIndentSize: formatOptions.BaseIndentSize, IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, NewLineCharacter: formatOptions.NewLineCharacter, @@ -50257,6 +50525,9 @@ var ts; }; Session.prototype.exit = function () { }; + Session.prototype.requiredResponse = function (response) { + return { response: response, responseRequired: true }; + }; Session.prototype.addProtocolHandler = function (command, handler) { if (this.handlers[command]) { throw new Error("Protocol handler already exists for command \"" + command + "\""); @@ -51511,6 +51782,7 @@ var ts; }; CompilerService.getDefaultFormatCodeOptions = function (host) { return ts.clone({ + BaseIndentSize: 0, IndentSize: 4, TabSize: 4, NewLineCharacter: host.newLine || "\n", @@ -52736,9 +53008,9 @@ var ts; var _this = this; return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPostion = function (fileName, position, openingBrace) { + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPostion('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { var _this = this; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 73bf72e135e..c1a94516b6f 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -753,9 +753,10 @@ declare namespace ts { children: NodeArray; closingElement: JsxClosingElement; } + type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxOpeningElement extends Expression { _openingElementBrand?: any; - tagName: EntityName; + tagName: JsxTagNameExpression; attributes: NodeArray; } interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { @@ -770,7 +771,7 @@ declare namespace ts { expression: Expression; } interface JsxClosingElement extends Node { - tagName: EntityName; + tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { expression?: Expression; @@ -1271,7 +1272,7 @@ declare namespace ts { buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(thisParameter: Symbol, 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; } @@ -1483,7 +1484,6 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; - thisType?: Type; } enum IndexKind { String = 0, @@ -1564,6 +1564,8 @@ declare namespace ts { noImplicitAny?: boolean; noImplicitReturns?: boolean; noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; noImplicitUseStrict?: boolean; noLib?: boolean; noResolve?: boolean; @@ -1590,7 +1592,6 @@ declare namespace ts { types?: string[]; /** Paths used to used to compute primary types search locations */ typeRoots?: string[]; - typesSearchPaths?: string[]; [option: string]: CompilerOptionsValue | undefined; } interface TypingOptions { @@ -2055,7 +2056,7 @@ declare namespace ts { getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; dispose(): void; @@ -2133,6 +2134,7 @@ declare namespace ts { containerKind: string; } interface EditorOptions { + BaseIndentSize?: number; IndentSize: number; TabSize: number; NewLineCharacter: string; @@ -2155,7 +2157,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string; + [s: string]: boolean | number | string | undefined; } interface DefinitionInfo { fileName: string; diff --git a/lib/typescript.js b/lib/typescript.js index 30d49888df1..d4d4c481c81 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -3300,6 +3300,9 @@ var ts; Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, + Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." }, + Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -11077,8 +11080,14 @@ var ts; if (lhs.kind === 69 /* Identifier */) { return lhs.text === rhs.text; } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); + if (lhs.kind === 97 /* ThisKeyword */) { + return true; + } + // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only + // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression + // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element + return lhs.name.text === rhs.name.text && + tagNamesAreEquivalent(lhs.expression, rhs.expression); } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); @@ -11189,15 +11198,20 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var elementName = parseIdentifierName(); + // JsxElement can have name in the form of + // propertyAccessExpression + // primaryExpression in the form of an identifier and "this" keyword + // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword + // We only want to consider "this" as a primaryExpression + var expression = token === 97 /* ThisKeyword */ ? + parseTokenNode() : parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { - scanJsxIdentifier(); - var node = createNode(139 /* QualifiedName */, elementName.pos); // !!! - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); + var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + expression = finishNode(propertyAccess); } - return elementName; + return expression; } function parseJsxExpression(inExpressionContext) { var node = createNode(248 /* JsxExpression */); @@ -12058,7 +12072,7 @@ var ts; case 56 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); case 116 /* AsKeyword */: - return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers); + return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } @@ -12647,7 +12661,7 @@ var ts; function nextTokenIsSlash() { return nextToken() === 39 /* SlashToken */; } - function parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers) { + function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { var exportDeclaration = createNode(228 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; @@ -17123,7 +17137,7 @@ var ts; function getTargetOfImportSpecifier(node) { return getExternalModuleMember(node.parent.parent.parent, node); } - function getTargetOfGlobalModuleExportDeclaration(node) { + function getTargetOfNamespaceExportDeclaration(node) { return resolveExternalModuleSymbol(node.parent.symbol); } function getTargetOfExportSpecifier(node) { @@ -17149,7 +17163,7 @@ var ts; case 235 /* ExportAssignment */: return getTargetOfExportAssignment(node); case 228 /* NamespaceExportDeclaration */: - return getTargetOfGlobalModuleExportDeclaration(node); + return getTargetOfNamespaceExportDeclaration(node); } } function resolveSymbol(symbol) { @@ -17249,9 +17263,12 @@ var ts; var left = name.kind === 139 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 139 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + if (!namespace || ts.nodeIsMissing(right)) { return undefined; } + else if (namespace === unknownSymbol) { + return namespace; + } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { if (!ignoreErrors) { @@ -18332,16 +18349,13 @@ var ts; writePunctuation(writer, 27 /* GreaterThanToken */); } } - function buildDisplayForParametersAndDelimiters(thisType, parameters, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { writePunctuation(writer, 17 /* OpenParenToken */); - if (thisType) { - writeKeyword(writer, 97 /* ThisKeyword */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack); + if (thisParameter) { + buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { - if (i > 0 || thisType) { + if (i > 0 || thisParameter) { writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } @@ -18391,7 +18405,7 @@ var ts; else { buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); } - buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { @@ -18787,12 +18801,14 @@ var ts; if (func.kind === 150 /* SetAccessor */ && !ts.hasDynamicName(func)) { var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149 /* GetAccessor */); if (getter) { - var signature = getSignatureFromDeclaration(getter); + var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); if (thisParameter && declaration === thisParameter) { - return signature.thisType; + // Use the type from the *getter* + ts.Debug.assert(!thisParameter.type); + return getTypeOfSymbol(getterSignature.thisParameter); } - return getReturnTypeOfSignature(signature); + return getReturnTypeOfSignature(getterSignature); } } // Use contextual parameter type if one is available @@ -18993,14 +19009,12 @@ var ts; } return undefined; } - function getAnnotatedAccessorThisType(accessor) { - if (accessor) { - var parameter = getAccessorThisParameter(accessor); - if (parameter && parameter.type) { - return getTypeFromTypeNode(accessor.parameters[0].type); - } - } - return undefined; + function getAnnotatedAccessorThisParameter(accessor) { + var parameter = getAccessorThisParameter(accessor); + return parameter && parameter.symbol; + } + function getThisTypeOfDeclaration(declaration) { + return getThisTypeOfSignature(getSignatureFromDeclaration(declaration)); } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); @@ -19641,12 +19655,12 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, thisType, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; - sig.thisType = thisType; + sig.thisParameter = thisParameter; sig.resolvedReturnType = resolvedReturnType; sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; @@ -19655,7 +19669,7 @@ var ts; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); @@ -19749,8 +19763,9 @@ var ts; // Union the result types when more than one signature matches if (unionSignatures.length > 1) { s = cloneSignature(signature); - if (ts.forEach(unionSignatures, function (sig) { return sig.thisType; })) { - s.thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisType || anyType; })); + if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; })); + s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; @@ -19960,6 +19975,7 @@ var ts; var props; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = (containingType.flags & 32768 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; + var isReadonly = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -19973,6 +19989,9 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } + if (isReadonlySymbol(prop)) { + isReadonly = true; + } } else if (containingType.flags & 16384 /* Union */) { // A union type requires the property to be present in all constituent types @@ -20001,6 +20020,7 @@ var ts; commonFlags, name); result.containingType = containingType; result.declarations = declarations; + result.isReadonly = isReadonly; result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } @@ -20172,7 +20192,7 @@ var ts; var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - var thisType = undefined; + var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the @@ -20188,7 +20208,7 @@ var ts; } if (i === 0 && paramSymbol.name === "this") { hasThisParameter = true; - thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType; + thisParameter = param.symbol; } else { parameters.push(paramSymbol); @@ -20209,10 +20229,12 @@ var ts; // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation if ((declaration.kind === 149 /* GetAccessor */ || declaration.kind === 150 /* SetAccessor */) && !ts.hasDynamicName(declaration) && - (!hasThisParameter || thisType === unknownType)) { + (!hasThisParameter || !thisParameter)) { var otherKind = declaration.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; - var setter = ts.getDeclarationOfKind(declaration.symbol, otherKind); - thisType = getAnnotatedAccessorThisType(setter); + var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); + if (other) { + thisParameter = getAnnotatedAccessorThisParameter(other); + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); @@ -20230,7 +20252,7 @@ var ts; var typePredicate = declaration.type && declaration.type.kind === 154 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; - links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -20305,6 +20327,11 @@ var ts; } return anyType; } + function getThisTypeOfSignature(signature) { + if (signature.thisParameter) { + return getTypeOfSymbol(signature.thisParameter); + } + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { @@ -21080,7 +21107,7 @@ var ts; if (signature.typePredicate) { freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, signature.thisType && instantiateType(signature.thisType, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -21315,17 +21342,21 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1 /* True */; - if (source.thisType && target.thisType && source.thisType !== voidType) { - // void sources are assignable to anything. - var related = compareTypes(source.thisType, target.thisType, /*reportErrors*/ false) - || compareTypes(target.thisType, source.thisType, reportErrors); - if (!related) { - if (reportErrors) { - errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType && sourceThisType !== voidType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + // void sources are assignable to anything. + var related = compareTypes(sourceThisType, targetThisType, /*reportErrors*/ false) + || compareTypes(targetThisType, sourceThisType, reportErrors); + if (!related) { + if (reportErrors) { + errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + } + return 0 /* False */; } - return 0 /* False */; + result &= related; } - result &= related; } var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); @@ -22265,12 +22296,18 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1 /* True */; - if (!ignoreThisTypes && source.thisType && target.thisType) { - var related = compareTypes(source.thisType, target.thisType); - if (!related) { - return 0 /* False */; + if (!ignoreThisTypes) { + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType); + if (!related) { + return 0 /* False */; + } + result &= related; + } } - result &= related; } var targetLen = target.parameters.length; for (var i = 0; i < targetLen; i++) { @@ -23698,8 +23735,20 @@ var ts; } return container === declarationContainer; } + function updateReferencesForInterfaceHeritiageClauseTargets(node) { + var extendedTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (extendedTypeNode) { + var t = getTypeFromTypeNode(extendedTypeNode); + if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + t.symbol.hasReference = true; + } + } + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + symbol.hasReference = true; + } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects @@ -23963,9 +24012,9 @@ var ts; if (type) { return type; } - var signature = getSignatureFromDeclaration(container); - if (signature.thisType) { - return signature.thisType; + var thisType = getThisTypeOfDeclaration(container); + if (thisType) { + return thisType; } } if (ts.isClassLike(container.parent)) { @@ -24184,7 +24233,7 @@ var ts; if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisType; + return getThisTypeOfSignature(contextualSignature); } } return undefined; @@ -24917,7 +24966,8 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 139 /* QualifiedName */) { + // TODO (yuisu): comment + if (tagName.kind === 172 /* PropertyAccessExpression */ || tagName.kind === 97 /* ThisKeyword */) { return false; } else { @@ -25093,6 +25143,28 @@ var ts; return getResolvedJsxType(node, type, elemClassType); })); } + // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type + if (elemType.flags & 2 /* String */) { + return anyType; + } + else if (elemType.flags & 256 /* StringLiteral */) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); + if (intrinsicElementsType !== unknownType) { + var stringLiteralTypeName = elemType.text; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + return indexSignatureType; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } // Get the element instance type (the result of newing or invoking this tag) var elemInstanceType = getJsxElementInstanceType(node, elemType); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { @@ -25401,6 +25473,9 @@ var ts; } return unknownType; } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + prop.hasReference = true; + } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { checkClassPropertyAccess(node, left, apparentType, prop); @@ -25806,10 +25881,11 @@ var ts; if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { context.failedTypeParameterIndex = undefined; } - if (signature.thisType) { + var thisType = getThisTypeOfSignature(signature); + if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context, thisArgumentType, signature.thisType); + inferTypes(context, thisArgumentType, thisType); } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. @@ -25873,7 +25949,8 @@ var ts; return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - if (signature.thisType && signature.thisType !== voidType && node.kind !== 175 /* NewExpression */) { + var thisType = getThisTypeOfSignature(signature); + if (thisType && thisType !== voidType && node.kind !== 175 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -25881,7 +25958,7 @@ var ts; var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; - if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { return false; } } @@ -26526,7 +26603,7 @@ var ts; if (getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } - if (signature.thisType === voidType) { + if (getThisTypeOfSignature(signature) === voidType) { error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void); } return signature; @@ -27126,6 +27203,8 @@ var ts; } } } + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -27141,7 +27220,9 @@ var ts; // Variables declared with 'const' // Get accessors without matching set accessors // Enum members - return symbol.flags & 4 /* Property */ && (getDeclarationFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || + // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) + return symbol.isReadonly || + symbol.flags & 4 /* Property */ && (getDeclarationFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || symbol.flags & 3 /* Variable */ && (getDeclarationFlagsFromSymbol(symbol) & 2048 /* Const */) !== 0 || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || (symbol.flags & 8 /* EnumMember */) !== 0; @@ -28089,6 +28170,9 @@ var ts; checkAsyncFunctionReturnType(node); } } + if (!node.body) { + checkUnusedTypeParameters(node); + } } } function checkClassForDuplicateDeclarations(node) { @@ -28228,6 +28312,8 @@ var ts; // Grammar check for checking only related to constructorDeclaration checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); var symbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); // Only type check the symbol once @@ -28351,7 +28437,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 4.5 // If both accessors include type annotations, the specified types must be identical. checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorThisType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); + checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } getTypeOfAccessors(getSymbolOfNode(node)); @@ -28396,13 +28482,18 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); + if (type !== unknownType) { + if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + type.symbol.hasReference = true; + } + if (node.typeArguments) { + // Do type argument local checks only if referenced type is successfully resolved + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } } } } @@ -29137,6 +29228,8 @@ var ts; } } checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); if (!node.asteriskToken) { var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -29155,12 +29248,84 @@ var ts; } } } + function checkUnusedIdentifiers(node) { + if (node.parent.kind !== 222 /* InterfaceDeclaration */ && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + for (var key in node.locals) { + if (ts.hasProperty(node.locals, key)) { + var local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration) { + if (local.valueDeclaration.kind !== 142 /* Parameter */ && compilerOptions.noUnusedLocals) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + else if (local.valueDeclaration.kind === 142 /* Parameter */ && compilerOptions.noUnusedParameters) { + if (local.valueDeclaration.flags === 0) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + } + } + } + } + } + } + function checkUnusedClassLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.members) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 147 /* MethodDeclaration */ || member.kind === 145 /* PropertyDeclaration */) { + if (isPrivateNode(member) && !member.symbol.hasReference) { + error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); + } + } + else if (member.kind === 148 /* Constructor */) { + for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + error(parameter.name, ts.Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + } + } + } + } + } + } + } + function checkUnusedTypeParameters(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.typeParameters) { + for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { + var typeParameter = _a[_i]; + if (!typeParameter.symbol.hasReference) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + } + } + } + } + } + function isPrivateNode(node) { + return (node.flags & 8 /* Private */) !== 0; + } + function checkUnusedModuleLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + var _loop_1 = function(key) { + if (ts.hasProperty(node.locals, key)) { + var local_1 = node.locals[key]; + if (!local_1.hasReference && !local_1.exportSymbol) { + ts.forEach(local_1.declarations, function (d) { return error(d.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name); }); + } + } + }; + for (var key in node.locals) { + _loop_1(key); + } + } + } function checkBlock(node) { // Grammar checking for SyntaxKind.Block if (node.kind === 199 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); + checkUnusedIdentifiers(node); } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact @@ -29602,6 +29767,7 @@ var ts; } } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInStatement(node) { // Grammar checking @@ -29643,6 +29809,7 @@ var ts; 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); + checkUnusedIdentifiers(node); } function checkForInOrForOfVariableDeclaration(iterationStatement) { var variableDeclarationList = iterationStatement.initializer; @@ -30034,6 +30201,7 @@ var ts; } } checkBlock(catchClause.block); + checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { checkBlock(node.finallyBlock); @@ -30170,6 +30338,8 @@ var ts; } checkClassLikeDeclaration(node); ts.forEach(node.members, checkSourceElement); + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); } function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); @@ -30447,6 +30617,8 @@ var ts; ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); + checkUnusedTypeParameters(node); } } function checkTypeAliasDeclaration(node) { @@ -30805,6 +30977,7 @@ var ts; } if (node.body) { checkSourceElement(node.body); + checkUnusedModuleLocals(node); } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { @@ -30978,6 +31151,9 @@ var ts; if (target.flags & 793056 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + target.hasReference = true; + } } } else { @@ -31297,6 +31473,9 @@ var ts; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); + if (ts.isExternalModule(node)) { + checkUnusedModuleLocals(node); + } checkDeferredNodes(); deferredNodes = undefined; if (ts.isExternalOrCommonJsModule(node)) { @@ -31615,6 +31794,14 @@ var ts; case 139 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97 /* ThisKeyword */: + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var sig = getSignatureFromDeclaration(container); + if (sig.thisParameter) { + return sig.thisParameter; + } + } + // fallthrough case 95 /* SuperKeyword */: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; @@ -31855,7 +32042,10 @@ var ts; var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 256 /* SourceFile */) { - return parentSymbol.valueDeclaration; + // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. + if (parentSymbol.valueDeclaration === ts.getSourceFileOfNode(node)) { + return parentSymbol.valueDeclaration; + } } for (var n = node.parent; n; n = n.parent) { if ((n.kind === 225 /* ModuleDeclaration */ || n.kind === 224 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { @@ -32821,7 +33011,7 @@ var ts; var GetAccessor = 2; var SetAccessor = 4; var GetOrSetAccessor = GetAccessor | SetAccessor; - var _loop_1 = function(prop) { + var _loop_2 = function(prop) { var name_21 = prop.name; if (prop.kind === 193 /* OmittedExpression */ || name_21.kind === 140 /* ComputedPropertyName */) { @@ -32895,8 +33085,8 @@ var ts; }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_2 = _loop_1(prop); - if (typeof state_2 === "object") return state_2.value; + var state_3 = _loop_2(prop); + if (typeof state_3 === "object") return state_3.value; } } function checkGrammarJsxElement(node) { @@ -35814,6 +36004,8 @@ var ts; return generateNameForExportDefault(); case 192 /* ClassExpression */: return generateNameForClassExpression(); + default: + ts.Debug.fail(); } } function getGeneratedNameForNode(node) { @@ -36629,6 +36821,20 @@ var ts; } return false; } + function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node) { + if (languageVersion >= 2 /* ES6 */) { + var parent_14 = node.parent; + if (parent_14.kind === 172 /* PropertyAccessExpression */ && parent_14.expression === node) { + parent_14 = parent_14.parent; + while (parent_14 && parent_14.kind !== 145 /* PropertyDeclaration */) { + parent_14 = parent_14.parent; + } + return parent_14 && parent_14.kind === 145 /* PropertyDeclaration */ && (parent_14.flags & 32 /* Static */) !== 0 && + parent_14.parent.kind === 192 /* ClassExpression */ ? parent_14.parent : undefined; + } + } + return undefined; + } function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { @@ -36642,6 +36848,14 @@ var ts; write(node.text); } else if (isExpressionIdentifier(node)) { + var classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node); + if (classExpression) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration === classExpression) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } emitExpressionIdentifier(node); } else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { @@ -39666,7 +39880,7 @@ var ts; emitStart(property); emitStart(property.name); if (receiver) { - emit(receiver); + write(receiver); } else { if (property.flags & 32 /* Static */) { @@ -40057,12 +40271,15 @@ var ts; // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 192 /* ClassExpression */; - var tempVariable; + var generatedName; if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0 /* Auto */); + generatedName = getGeneratedNameForNode(node.name); + var synthesizedNode = ts.createSynthesizedNode(69 /* Identifier */); + synthesizedNode.text = generatedName; + recordTempDeclaration(synthesizedNode); write("("); increaseIndent(); - emit(tempVariable); + emit(synthesizedNode); write(" = "); } write("class"); @@ -40110,11 +40327,11 @@ var ts; var property = staticProperties_1[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true); + emitPropertyDeclaration(node, property, /*receiver*/ generatedName, /*isExpression*/ true); } write(","); writeLine(); - emit(tempVariable); + write(generatedName); decreaseIndent(); write(")"); } @@ -42612,7 +42829,7 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.9.0"; + ts.version = "2.0.0"; var emptyArray = []; var defaultTypeRoots = ["node_modules/@types"]; function findConfigFile(searchPath, fileExists) { @@ -44697,6 +44914,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Locals + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Parameters + }, { name: "noLib", type: "boolean" @@ -44891,16 +45118,6 @@ var ts; isFilePath: true } }, - { - name: "typesSearchPaths", - type: "list", - isTSConfigOnly: true, - element: { - name: "typesSearchPaths", - type: "string", - isFilePath: true - } - }, { name: "typeRoots", type: "list", @@ -44978,7 +45195,7 @@ var ts; description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableProjectSizeLimit", + name: "disableSizeLimit", type: "boolean" }, { @@ -45737,28 +45954,28 @@ var ts; switch (n.kind) { case 199 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_14 = n.parent; + var parent_15 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_14.kind === 204 /* DoStatement */ || - parent_14.kind === 207 /* ForInStatement */ || - parent_14.kind === 208 /* ForOfStatement */ || - parent_14.kind === 206 /* ForStatement */ || - parent_14.kind === 203 /* IfStatement */ || - parent_14.kind === 205 /* WhileStatement */ || - parent_14.kind === 212 /* WithStatement */ || - parent_14.kind === 252 /* CatchClause */) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + if (parent_15.kind === 204 /* DoStatement */ || + parent_15.kind === 207 /* ForInStatement */ || + parent_15.kind === 208 /* ForOfStatement */ || + parent_15.kind === 206 /* ForStatement */ || + parent_15.kind === 203 /* IfStatement */ || + parent_15.kind === 205 /* WhileStatement */ || + parent_15.kind === 212 /* WithStatement */ || + parent_15.kind === 252 /* CatchClause */) { + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_14.kind === 216 /* TryStatement */) { + if (parent_15.kind === 216 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_14; + var tryStatement = parent_15; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -47447,8 +47664,8 @@ var ts; return undefined; } function getArgumentIndex(argumentsList, node) { - // The list we got back can include commas. In the presence of errors it may - // also just have nodes without commas. For example "Foo(a b c)" will have 3 + // The list we got back can include commas. In the presence of errors it may + // also just have nodes without commas. For example "Foo(a b c)" will have 3 // args without commas. We want to find what index we're at. So we count // forward until we hit ourselves, only incrementing the index if it isn't a // comma. @@ -47479,8 +47696,8 @@ var ts; // 'a' ''. So, in the case where the last child is a comma, we increase the // arg count by one to compensate. // - // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then - // we'll have: 'a' '' '' + // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then + // we'll have: 'a' '' '' // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); @@ -47628,7 +47845,7 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation); + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -47745,6 +47962,8 @@ var ts; case 199 /* Block */: case 226 /* ModuleBlock */: case 227 /* CaseBlock */: + case 233 /* NamedImports */: + case 237 /* NamedExports */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); case 252 /* CatchClause */: return isCompletedNode(n.block, sourceFile); @@ -47832,6 +48051,9 @@ var ts; return isCompletedNode(lastSpan, sourceFile); case 197 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); + case 236 /* ExportDeclaration */: + case 230 /* ImportDeclaration */: + return ts.nodeIsPresent(n.moduleSpecifier); case 185 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); case 187 /* BinaryExpression */: @@ -49282,7 +49504,7 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */, 82 /* ExportKeyword */, 89 /* ImportKeyword */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); @@ -49339,8 +49561,8 @@ var ts; // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 129 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */, 136 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */, 136 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -49495,6 +49717,8 @@ var ts; case 187 /* BinaryExpression */: case 188 /* ConditionalExpression */: case 195 /* AsExpression */: + case 238 /* ExportSpecifier */: + case 234 /* ImportSpecifier */: case 154 /* TypePredicate */: case 162 /* UnionType */: case 163 /* IntersectionType */: @@ -49613,6 +49837,10 @@ var ts; case 224 /* EnumDeclaration */: case 159 /* TypeLiteral */: case 225 /* ModuleDeclaration */: + case 236 /* ExportDeclaration */: + case 237 /* NamedExports */: + case 230 /* ImportDeclaration */: + case 233 /* NamedImports */: return true; } return false; @@ -50420,7 +50648,10 @@ var ts; var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); if (startLine !== parentStartLine || startPos === column) { - return column; + // Use the base indent size if it is greater than + // the indentation of the inherited predecessor. + var baseIndentSize = formatting.SmartIndenter.getBaseIndentation(options); + return baseIndentSize > column ? baseIndentSize : column; } } return -1 /* Unknown */; @@ -51060,7 +51291,7 @@ var ts; })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { - return 0; // past EOF + return getBaseIndentation(options); // past EOF } // no indentation when the indent style is set to none, // so we can return fast @@ -51069,7 +51300,7 @@ var ts; } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { - return 0; + return getBaseIndentation(options); } // no indentation in string \regex\template literals var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); @@ -51131,12 +51362,16 @@ var ts; current = current.parent; } if (!current) { - // no parent was found - return 0 to be indented on the level of SourceFile - return 0; + // no parent was found - return the base indentation of the SourceFile + return getBaseIndentation(options); } return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; + function getBaseIndentation(options) { + return options.BaseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); @@ -51182,7 +51417,7 @@ var ts; currentStart = parentStart; parent = current.parent; } - return indentationDelta; + return indentationDelta + getBaseIndentation(options); } function getParentStart(parent, child, sourceFile) { var containingList = getContainingList(child, sourceFile); @@ -51440,7 +51675,10 @@ var ts; case 164 /* ParenthesizedType */: case 176 /* TaggedTemplateExpression */: case 184 /* AwaitExpression */: + case 237 /* NamedExports */: case 233 /* NamedImports */: + case 238 /* ExportSpecifier */: + case 234 /* ImportSpecifier */: return true; } return false; @@ -51463,6 +51701,11 @@ var ts; case 149 /* GetAccessor */: case 150 /* SetAccessor */: return childKind !== 199 /* Block */; + case 236 /* ExportDeclaration */: + return childKind !== 237 /* NamedExports */; + case 230 /* ImportDeclaration */: + return childKind !== 231 /* ImportClause */ || + child.namedBindings.kind !== 233 /* NamedImports */; case 241 /* JsxElement */: return childKind !== 245 /* JsxClosingElement */; } @@ -52468,9 +52711,9 @@ var ts; return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_15 = declaration.parent; !ts.isFunctionBlock(parent_15); parent_15 = parent_15.parent) { + for (var parent_16 = declaration.parent; !ts.isFunctionBlock(parent_16); parent_16 = parent_16.parent) { // Reached source file or module block - if (parent_15.kind === 256 /* SourceFile */ || parent_15.kind === 226 /* ModuleBlock */) { + if (parent_16.kind === 256 /* SourceFile */ || parent_16.kind === 226 /* ModuleBlock */) { return false; } } @@ -52601,7 +52844,7 @@ var ts; return typeof o.type === "object" && !ts.forEachValue(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function(opt) { + var _loop_3 = function(opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -52620,7 +52863,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_3(opt); } return options; } @@ -53821,13 +54064,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_16 = contextToken.parent, kind = contextToken.kind; + var parent_17 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_16.kind === 172 /* PropertyAccessExpression */) { + if (parent_17.kind === 172 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_16.kind === 139 /* QualifiedName */) { + else if (parent_17.kind === 139 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -54203,9 +54446,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_17 = contextToken.parent; - if (parent_17 && (parent_17.kind === 171 /* ObjectLiteralExpression */ || parent_17.kind === 167 /* ObjectBindingPattern */)) { - return parent_17; + var parent_18 = contextToken.parent; + if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { + return parent_18; } break; } @@ -54232,37 +54475,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_18 = contextToken.parent; + var parent_19 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_18 && (parent_18.kind === 242 /* JsxSelfClosingElement */ || parent_18.kind === 243 /* JsxOpeningElement */)) { - return parent_18; + if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { + return parent_19; } - else if (parent_18.kind === 246 /* JsxAttribute */) { - return parent_18.parent; + else if (parent_19.kind === 246 /* JsxAttribute */) { + return parent_19.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_18 && ((parent_18.kind === 246 /* JsxAttribute */) || (parent_18.kind === 247 /* JsxSpreadAttribute */))) { - return parent_18.parent; + if (parent_19 && ((parent_19.kind === 246 /* JsxAttribute */) || (parent_19.kind === 247 /* JsxSpreadAttribute */))) { + return parent_19.parent; } break; case 16 /* CloseBraceToken */: - if (parent_18 && - parent_18.kind === 248 /* JsxExpression */ && - parent_18.parent && - (parent_18.parent.kind === 246 /* JsxAttribute */)) { - return parent_18.parent.parent; + if (parent_19 && + parent_19.kind === 248 /* JsxExpression */ && + parent_19.parent && + (parent_19.parent.kind === 246 /* JsxAttribute */)) { + return parent_19.parent.parent; } - if (parent_18 && parent_18.kind === 247 /* JsxSpreadAttribute */) { - return parent_18.parent; + if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { + return parent_19.parent; } break; } @@ -55594,19 +55837,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_19 = child.parent; - if (ts.isFunctionBlock(parent_19) || parent_19.kind === 256 /* SourceFile */) { - return parent_19; + var parent_20 = child.parent; + if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256 /* SourceFile */) { + return parent_20; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_19.kind === 216 /* TryStatement */) { - var tryStatement = parent_19; + if (parent_20.kind === 216 /* TryStatement */) { + var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_19; + child = parent_20; } return undefined; } @@ -55986,16 +56229,31 @@ var ts; if (node === sourceFile) { return undefined; } - if (node.kind !== 69 /* Identifier */ && - // TODO (drosen): This should be enabled in a later release - currently breaks rename. - // node.kind !== SyntaxKind.ThisKeyword && - // node.kind !== SyntaxKind.SuperKeyword && - node.kind !== 9 /* StringLiteral */ && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return undefined; + switch (node.kind) { + case 8 /* NumericLiteral */: + if (!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + break; + } + // Fallthrough + case 69 /* Identifier */: + case 97 /* ThisKeyword */: + // case SyntaxKind.SuperKeyword: TODO:GH#9268 + case 9 /* StringLiteral */: + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + } + return undefined; + } + function isThis(node) { + switch (node.kind) { + case 97 /* ThisKeyword */: + // case SyntaxKind.ThisType: TODO: GH#9267 + return true; + case 69 /* Identifier */: + // 'this' as a parameter + return node.originalKeywordKind === 97 /* ThisKeyword */ && node.parent.kind === 142 /* Parameter */; + default: + return false; } - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { var typeChecker = program.getTypeChecker(); @@ -56012,7 +56270,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 /* ThisKeyword */ || node.kind === 165 /* ThisType */) { + if (isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95 /* SuperKeyword */) { @@ -56447,7 +56705,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 165 /* ThisType */)) { + if (!node || !isThis(node)) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); @@ -57453,8 +57711,8 @@ var ts; return; case 142 /* Parameter */: if (token.parent.name === token) { - var isThis = token.kind === 69 /* Identifier */ && token.originalKeywordKind === 97 /* ThisKeyword */; - return isThis ? 3 /* keyword */ : 17 /* parameterName */; + var isThis_1 = token.kind === 69 /* Identifier */ && token.originalKeywordKind === 97 /* ThisKeyword */; + return isThis_1 ? 3 /* keyword */ : 17 /* parameterName */; } return; } @@ -57645,7 +57903,7 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } - function isValidBraceCompletionAtPostion(fileName, position, openingBrace) { + function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too // expensive to do during typing scenarios // i.e. whether we're dealing with: @@ -57847,11 +58105,11 @@ var ts; var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - // Can only rename an identifier. if (node) { if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isThis(node)) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -57965,7 +58223,7 @@ var ts; getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - isValidBraceCompletionAtPostion: isValidBraceCompletionAtPostion, + isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram @@ -59503,9 +59761,9 @@ var ts; var _this = this; return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPostion = function (fileName, position, openingBrace) { + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPostion('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 76690ff9d0f..e69723c237d 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -753,9 +753,10 @@ declare namespace ts { children: NodeArray; closingElement: JsxClosingElement; } + type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxOpeningElement extends Expression { _openingElementBrand?: any; - tagName: EntityName; + tagName: JsxTagNameExpression; attributes: NodeArray; } interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { @@ -770,7 +771,7 @@ declare namespace ts { expression: Expression; } interface JsxClosingElement extends Node { - tagName: EntityName; + tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { expression?: Expression; @@ -1271,7 +1272,7 @@ declare namespace ts { buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(thisParameter: Symbol, 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; } @@ -1483,7 +1484,6 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; - thisType?: Type; } enum IndexKind { String = 0, @@ -1564,6 +1564,8 @@ declare namespace ts { noImplicitAny?: boolean; noImplicitReturns?: boolean; noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; noImplicitUseStrict?: boolean; noLib?: boolean; noResolve?: boolean; @@ -1590,7 +1592,6 @@ declare namespace ts { types?: string[]; /** Paths used to used to compute primary types search locations */ typeRoots?: string[]; - typesSearchPaths?: string[]; [option: string]: CompilerOptionsValue | undefined; } interface TypingOptions { @@ -2055,7 +2056,7 @@ declare namespace ts { getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; dispose(): void; @@ -2133,6 +2134,7 @@ declare namespace ts { containerKind: string; } interface EditorOptions { + BaseIndentSize?: number; IndentSize: number; TabSize: number; NewLineCharacter: string; @@ -2155,7 +2157,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string; + [s: string]: boolean | number | string | undefined; } interface DefinitionInfo { fileName: string; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 30d49888df1..d4d4c481c81 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -3300,6 +3300,9 @@ var ts; Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, + Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." }, + Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -11077,8 +11080,14 @@ var ts; if (lhs.kind === 69 /* Identifier */) { return lhs.text === rhs.text; } - return lhs.right.text === rhs.right.text && - tagNamesAreEquivalent(lhs.left, rhs.left); + if (lhs.kind === 97 /* ThisKeyword */) { + return true; + } + // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only + // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression + // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element + return lhs.name.text === rhs.name.text && + tagNamesAreEquivalent(lhs.expression, rhs.expression); } function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); @@ -11189,15 +11198,20 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var elementName = parseIdentifierName(); + // JsxElement can have name in the form of + // propertyAccessExpression + // primaryExpression in the form of an identifier and "this" keyword + // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword + // We only want to consider "this" as a primaryExpression + var expression = token === 97 /* ThisKeyword */ ? + parseTokenNode() : parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { - scanJsxIdentifier(); - var node = createNode(139 /* QualifiedName */, elementName.pos); // !!! - node.left = elementName; - node.right = parseIdentifierName(); - elementName = finishNode(node); + var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + expression = finishNode(propertyAccess); } - return elementName; + return expression; } function parseJsxExpression(inExpressionContext) { var node = createNode(248 /* JsxExpression */); @@ -12058,7 +12072,7 @@ var ts; case 56 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); case 116 /* AsKeyword */: - return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers); + return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } @@ -12647,7 +12661,7 @@ var ts; function nextTokenIsSlash() { return nextToken() === 39 /* SlashToken */; } - function parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers) { + function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { var exportDeclaration = createNode(228 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; @@ -17123,7 +17137,7 @@ var ts; function getTargetOfImportSpecifier(node) { return getExternalModuleMember(node.parent.parent.parent, node); } - function getTargetOfGlobalModuleExportDeclaration(node) { + function getTargetOfNamespaceExportDeclaration(node) { return resolveExternalModuleSymbol(node.parent.symbol); } function getTargetOfExportSpecifier(node) { @@ -17149,7 +17163,7 @@ var ts; case 235 /* ExportAssignment */: return getTargetOfExportAssignment(node); case 228 /* NamespaceExportDeclaration */: - return getTargetOfGlobalModuleExportDeclaration(node); + return getTargetOfNamespaceExportDeclaration(node); } } function resolveSymbol(symbol) { @@ -17249,9 +17263,12 @@ var ts; var left = name.kind === 139 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 139 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); - if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { + if (!namespace || ts.nodeIsMissing(right)) { return undefined; } + else if (namespace === unknownSymbol) { + return namespace; + } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { if (!ignoreErrors) { @@ -18332,16 +18349,13 @@ var ts; writePunctuation(writer, 27 /* GreaterThanToken */); } } - function buildDisplayForParametersAndDelimiters(thisType, parameters, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { writePunctuation(writer, 17 /* OpenParenToken */); - if (thisType) { - writeKeyword(writer, 97 /* ThisKeyword */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack); + if (thisParameter) { + buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { - if (i > 0 || thisType) { + if (i > 0 || thisParameter) { writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } @@ -18391,7 +18405,7 @@ var ts; else { buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); } - buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { @@ -18787,12 +18801,14 @@ var ts; if (func.kind === 150 /* SetAccessor */ && !ts.hasDynamicName(func)) { var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149 /* GetAccessor */); if (getter) { - var signature = getSignatureFromDeclaration(getter); + var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); if (thisParameter && declaration === thisParameter) { - return signature.thisType; + // Use the type from the *getter* + ts.Debug.assert(!thisParameter.type); + return getTypeOfSymbol(getterSignature.thisParameter); } - return getReturnTypeOfSignature(signature); + return getReturnTypeOfSignature(getterSignature); } } // Use contextual parameter type if one is available @@ -18993,14 +19009,12 @@ var ts; } return undefined; } - function getAnnotatedAccessorThisType(accessor) { - if (accessor) { - var parameter = getAccessorThisParameter(accessor); - if (parameter && parameter.type) { - return getTypeFromTypeNode(accessor.parameters[0].type); - } - } - return undefined; + function getAnnotatedAccessorThisParameter(accessor) { + var parameter = getAccessorThisParameter(accessor); + return parameter && parameter.symbol; + } + function getThisTypeOfDeclaration(declaration) { + return getThisTypeOfSignature(getSignatureFromDeclaration(declaration)); } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); @@ -19641,12 +19655,12 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, thisType, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; - sig.thisType = thisType; + sig.thisParameter = thisParameter; sig.resolvedReturnType = resolvedReturnType; sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; @@ -19655,7 +19669,7 @@ var ts; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); @@ -19749,8 +19763,9 @@ var ts; // Union the result types when more than one signature matches if (unionSignatures.length > 1) { s = cloneSignature(signature); - if (ts.forEach(unionSignatures, function (sig) { return sig.thisType; })) { - s.thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisType || anyType; })); + if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; })); + s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; @@ -19960,6 +19975,7 @@ var ts; var props; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = (containingType.flags & 32768 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; + var isReadonly = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -19973,6 +19989,9 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } + if (isReadonlySymbol(prop)) { + isReadonly = true; + } } else if (containingType.flags & 16384 /* Union */) { // A union type requires the property to be present in all constituent types @@ -20001,6 +20020,7 @@ var ts; commonFlags, name); result.containingType = containingType; result.declarations = declarations; + result.isReadonly = isReadonly; result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } @@ -20172,7 +20192,7 @@ var ts; var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - var thisType = undefined; + var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the @@ -20188,7 +20208,7 @@ var ts; } if (i === 0 && paramSymbol.name === "this") { hasThisParameter = true; - thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType; + thisParameter = param.symbol; } else { parameters.push(paramSymbol); @@ -20209,10 +20229,12 @@ var ts; // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation if ((declaration.kind === 149 /* GetAccessor */ || declaration.kind === 150 /* SetAccessor */) && !ts.hasDynamicName(declaration) && - (!hasThisParameter || thisType === unknownType)) { + (!hasThisParameter || !thisParameter)) { var otherKind = declaration.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; - var setter = ts.getDeclarationOfKind(declaration.symbol, otherKind); - thisType = getAnnotatedAccessorThisType(setter); + var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); + if (other) { + thisParameter = getAnnotatedAccessorThisParameter(other); + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); @@ -20230,7 +20252,7 @@ var ts; var typePredicate = declaration.type && declaration.type.kind === 154 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; - links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -20305,6 +20327,11 @@ var ts; } return anyType; } + function getThisTypeOfSignature(signature) { + if (signature.thisParameter) { + return getTypeOfSymbol(signature.thisParameter); + } + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { @@ -21080,7 +21107,7 @@ var ts; if (signature.typePredicate) { freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); } - var result = createSignature(signature.declaration, freshTypeParameters, signature.thisType && instantiateType(signature.thisType, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -21315,17 +21342,21 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1 /* True */; - if (source.thisType && target.thisType && source.thisType !== voidType) { - // void sources are assignable to anything. - var related = compareTypes(source.thisType, target.thisType, /*reportErrors*/ false) - || compareTypes(target.thisType, source.thisType, reportErrors); - if (!related) { - if (reportErrors) { - errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType && sourceThisType !== voidType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + // void sources are assignable to anything. + var related = compareTypes(sourceThisType, targetThisType, /*reportErrors*/ false) + || compareTypes(targetThisType, sourceThisType, reportErrors); + if (!related) { + if (reportErrors) { + errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); + } + return 0 /* False */; } - return 0 /* False */; + result &= related; } - result &= related; } var sourceMax = getNumNonRestParameters(source); var targetMax = getNumNonRestParameters(target); @@ -22265,12 +22296,18 @@ var ts; source = getErasedSignature(source); target = getErasedSignature(target); var result = -1 /* True */; - if (!ignoreThisTypes && source.thisType && target.thisType) { - var related = compareTypes(source.thisType, target.thisType); - if (!related) { - return 0 /* False */; + if (!ignoreThisTypes) { + var sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType) { + var targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + var related = compareTypes(sourceThisType, targetThisType); + if (!related) { + return 0 /* False */; + } + result &= related; + } } - result &= related; } var targetLen = target.parameters.length; for (var i = 0; i < targetLen; i++) { @@ -23698,8 +23735,20 @@ var ts; } return container === declarationContainer; } + function updateReferencesForInterfaceHeritiageClauseTargets(node) { + var extendedTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (extendedTypeNode) { + var t = getTypeFromTypeNode(extendedTypeNode); + if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + t.symbol.hasReference = true; + } + } + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + symbol.hasReference = true; + } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects @@ -23963,9 +24012,9 @@ var ts; if (type) { return type; } - var signature = getSignatureFromDeclaration(container); - if (signature.thisType) { - return signature.thisType; + var thisType = getThisTypeOfDeclaration(container); + if (thisType) { + return thisType; } } if (ts.isClassLike(container.parent)) { @@ -24184,7 +24233,7 @@ var ts; if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisType; + return getThisTypeOfSignature(contextualSignature); } } return undefined; @@ -24917,7 +24966,8 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 139 /* QualifiedName */) { + // TODO (yuisu): comment + if (tagName.kind === 172 /* PropertyAccessExpression */ || tagName.kind === 97 /* ThisKeyword */) { return false; } else { @@ -25093,6 +25143,28 @@ var ts; return getResolvedJsxType(node, type, elemClassType); })); } + // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type + if (elemType.flags & 2 /* String */) { + return anyType; + } + else if (elemType.flags & 256 /* StringLiteral */) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); + if (intrinsicElementsType !== unknownType) { + var stringLiteralTypeName = elemType.text; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + return indexSignatureType; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } // Get the element instance type (the result of newing or invoking this tag) var elemInstanceType = getJsxElementInstanceType(node, elemType); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { @@ -25401,6 +25473,9 @@ var ts; } return unknownType; } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + prop.hasReference = true; + } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { checkClassPropertyAccess(node, left, apparentType, prop); @@ -25806,10 +25881,11 @@ var ts; if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) { context.failedTypeParameterIndex = undefined; } - if (signature.thisType) { + var thisType = getThisTypeOfSignature(signature); + if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context, thisArgumentType, signature.thisType); + inferTypes(context, thisArgumentType, thisType); } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. @@ -25873,7 +25949,8 @@ var ts; return typeArgumentsAreAssignable; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - if (signature.thisType && signature.thisType !== voidType && node.kind !== 175 /* NewExpression */) { + var thisType = getThisTypeOfSignature(signature); + if (thisType && thisType !== voidType && node.kind !== 175 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -25881,7 +25958,7 @@ var ts; var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; - if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { return false; } } @@ -26526,7 +26603,7 @@ var ts; if (getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } - if (signature.thisType === voidType) { + if (getThisTypeOfSignature(signature) === voidType) { error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void); } return signature; @@ -27126,6 +27203,8 @@ var ts; } } } + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } } function checkArithmeticOperandType(operand, type, diagnostic) { @@ -27141,7 +27220,9 @@ var ts; // Variables declared with 'const' // Get accessors without matching set accessors // Enum members - return symbol.flags & 4 /* Property */ && (getDeclarationFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || + // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) + return symbol.isReadonly || + symbol.flags & 4 /* Property */ && (getDeclarationFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || symbol.flags & 3 /* Variable */ && (getDeclarationFlagsFromSymbol(symbol) & 2048 /* Const */) !== 0 || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || (symbol.flags & 8 /* EnumMember */) !== 0; @@ -28089,6 +28170,9 @@ var ts; checkAsyncFunctionReturnType(node); } } + if (!node.body) { + checkUnusedTypeParameters(node); + } } } function checkClassForDuplicateDeclarations(node) { @@ -28228,6 +28312,8 @@ var ts; // Grammar check for checking only related to constructorDeclaration checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); var symbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); // Only type check the symbol once @@ -28351,7 +28437,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 4.5 // If both accessors include type annotations, the specified types must be identical. checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorThisType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); + checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } getTypeOfAccessors(getSymbolOfNode(node)); @@ -28396,13 +28482,18 @@ var ts; function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); var type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var symbol = getNodeLinks(node).resolvedSymbol; - var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); + if (type !== unknownType) { + if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + type.symbol.hasReference = true; + } + if (node.typeArguments) { + // Do type argument local checks only if referenced type is successfully resolved + ts.forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + var symbol = getNodeLinks(node).resolvedSymbol; + var typeParameters = symbol.flags & 524288 /* TypeAlias */ ? getSymbolLinks(symbol).typeParameters : type.target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } } } } @@ -29137,6 +29228,8 @@ var ts; } } checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); if (!node.asteriskToken) { var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -29155,12 +29248,84 @@ var ts; } } } + function checkUnusedIdentifiers(node) { + if (node.parent.kind !== 222 /* InterfaceDeclaration */ && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + for (var key in node.locals) { + if (ts.hasProperty(node.locals, key)) { + var local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration) { + if (local.valueDeclaration.kind !== 142 /* Parameter */ && compilerOptions.noUnusedLocals) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + else if (local.valueDeclaration.kind === 142 /* Parameter */ && compilerOptions.noUnusedParameters) { + if (local.valueDeclaration.flags === 0) { + error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + } + } + } + } + } + } + } + function checkUnusedClassLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.members) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 147 /* MethodDeclaration */ || member.kind === 145 /* PropertyDeclaration */) { + if (isPrivateNode(member) && !member.symbol.hasReference) { + error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); + } + } + else if (member.kind === 148 /* Constructor */) { + for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + error(parameter.name, ts.Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + } + } + } + } + } + } + } + function checkUnusedTypeParameters(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + if (node.typeParameters) { + for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { + var typeParameter = _a[_i]; + if (!typeParameter.symbol.hasReference) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + } + } + } + } + } + function isPrivateNode(node) { + return (node.flags & 8 /* Private */) !== 0; + } + function checkUnusedModuleLocals(node) { + if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { + var _loop_1 = function(key) { + if (ts.hasProperty(node.locals, key)) { + var local_1 = node.locals[key]; + if (!local_1.hasReference && !local_1.exportSymbol) { + ts.forEach(local_1.declarations, function (d) { return error(d.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name); }); + } + } + }; + for (var key in node.locals) { + _loop_1(key); + } + } + } function checkBlock(node) { // Grammar checking for SyntaxKind.Block if (node.kind === 199 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); + checkUnusedIdentifiers(node); } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact @@ -29602,6 +29767,7 @@ var ts; } } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInStatement(node) { // Grammar checking @@ -29643,6 +29809,7 @@ var ts; 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); + checkUnusedIdentifiers(node); } function checkForInOrForOfVariableDeclaration(iterationStatement) { var variableDeclarationList = iterationStatement.initializer; @@ -30034,6 +30201,7 @@ var ts; } } checkBlock(catchClause.block); + checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { checkBlock(node.finallyBlock); @@ -30170,6 +30338,8 @@ var ts; } checkClassLikeDeclaration(node); ts.forEach(node.members, checkSourceElement); + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); } function checkClassLikeDeclaration(node) { checkGrammarClassDeclarationHeritageClauses(node); @@ -30447,6 +30617,8 @@ var ts; ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); + checkUnusedTypeParameters(node); } } function checkTypeAliasDeclaration(node) { @@ -30805,6 +30977,7 @@ var ts; } if (node.body) { checkSourceElement(node.body); + checkUnusedModuleLocals(node); } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { @@ -30978,6 +31151,9 @@ var ts; if (target.flags & 793056 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !ts.isInAmbientContext(node)) { + target.hasReference = true; + } } } else { @@ -31297,6 +31473,9 @@ var ts; potentialThisCollisions.length = 0; deferredNodes = []; ts.forEach(node.statements, checkSourceElement); + if (ts.isExternalModule(node)) { + checkUnusedModuleLocals(node); + } checkDeferredNodes(); deferredNodes = undefined; if (ts.isExternalOrCommonJsModule(node)) { @@ -31615,6 +31794,14 @@ var ts; case 139 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97 /* ThisKeyword */: + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var sig = getSignatureFromDeclaration(container); + if (sig.thisParameter) { + return sig.thisParameter; + } + } + // fallthrough case 95 /* SuperKeyword */: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; @@ -31855,7 +32042,10 @@ var ts; var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 256 /* SourceFile */) { - return parentSymbol.valueDeclaration; + // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. + if (parentSymbol.valueDeclaration === ts.getSourceFileOfNode(node)) { + return parentSymbol.valueDeclaration; + } } for (var n = node.parent; n; n = n.parent) { if ((n.kind === 225 /* ModuleDeclaration */ || n.kind === 224 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { @@ -32821,7 +33011,7 @@ var ts; var GetAccessor = 2; var SetAccessor = 4; var GetOrSetAccessor = GetAccessor | SetAccessor; - var _loop_1 = function(prop) { + var _loop_2 = function(prop) { var name_21 = prop.name; if (prop.kind === 193 /* OmittedExpression */ || name_21.kind === 140 /* ComputedPropertyName */) { @@ -32895,8 +33085,8 @@ var ts; }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_2 = _loop_1(prop); - if (typeof state_2 === "object") return state_2.value; + var state_3 = _loop_2(prop); + if (typeof state_3 === "object") return state_3.value; } } function checkGrammarJsxElement(node) { @@ -35814,6 +36004,8 @@ var ts; return generateNameForExportDefault(); case 192 /* ClassExpression */: return generateNameForClassExpression(); + default: + ts.Debug.fail(); } } function getGeneratedNameForNode(node) { @@ -36629,6 +36821,20 @@ var ts; } return false; } + function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node) { + if (languageVersion >= 2 /* ES6 */) { + var parent_14 = node.parent; + if (parent_14.kind === 172 /* PropertyAccessExpression */ && parent_14.expression === node) { + parent_14 = parent_14.parent; + while (parent_14 && parent_14.kind !== 145 /* PropertyDeclaration */) { + parent_14 = parent_14.parent; + } + return parent_14 && parent_14.kind === 145 /* PropertyDeclaration */ && (parent_14.flags & 32 /* Static */) !== 0 && + parent_14.parent.kind === 192 /* ClassExpression */ ? parent_14.parent : undefined; + } + } + return undefined; + } function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { @@ -36642,6 +36848,14 @@ var ts; write(node.text); } else if (isExpressionIdentifier(node)) { + var classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node); + if (classExpression) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration === classExpression) { + write(getGeneratedNameForNode(declaration.name)); + return; + } + } emitExpressionIdentifier(node); } else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { @@ -39666,7 +39880,7 @@ var ts; emitStart(property); emitStart(property.name); if (receiver) { - emit(receiver); + write(receiver); } else { if (property.flags & 32 /* Static */) { @@ -40057,12 +40271,15 @@ var ts; // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 192 /* ClassExpression */; - var tempVariable; + var generatedName; if (isClassExpressionWithStaticProperties) { - tempVariable = createAndRecordTempVariable(0 /* Auto */); + generatedName = getGeneratedNameForNode(node.name); + var synthesizedNode = ts.createSynthesizedNode(69 /* Identifier */); + synthesizedNode.text = generatedName; + recordTempDeclaration(synthesizedNode); write("("); increaseIndent(); - emit(tempVariable); + emit(synthesizedNode); write(" = "); } write("class"); @@ -40110,11 +40327,11 @@ var ts; var property = staticProperties_1[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true); + emitPropertyDeclaration(node, property, /*receiver*/ generatedName, /*isExpression*/ true); } write(","); writeLine(); - emit(tempVariable); + write(generatedName); decreaseIndent(); write(")"); } @@ -42612,7 +42829,7 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.9.0"; + ts.version = "2.0.0"; var emptyArray = []; var defaultTypeRoots = ["node_modules/@types"]; function findConfigFile(searchPath, fileExists) { @@ -44697,6 +44914,16 @@ var ts; type: "boolean", description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Locals + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_Errors_on_Unused_Parameters + }, { name: "noLib", type: "boolean" @@ -44891,16 +45118,6 @@ var ts; isFilePath: true } }, - { - name: "typesSearchPaths", - type: "list", - isTSConfigOnly: true, - element: { - name: "typesSearchPaths", - type: "string", - isFilePath: true - } - }, { name: "typeRoots", type: "list", @@ -44978,7 +45195,7 @@ var ts; description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableProjectSizeLimit", + name: "disableSizeLimit", type: "boolean" }, { @@ -45737,28 +45954,28 @@ var ts; switch (n.kind) { case 199 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_14 = n.parent; + var parent_15 = n.parent; var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_14.kind === 204 /* DoStatement */ || - parent_14.kind === 207 /* ForInStatement */ || - parent_14.kind === 208 /* ForOfStatement */ || - parent_14.kind === 206 /* ForStatement */ || - parent_14.kind === 203 /* IfStatement */ || - parent_14.kind === 205 /* WhileStatement */ || - parent_14.kind === 212 /* WithStatement */ || - parent_14.kind === 252 /* CatchClause */) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + if (parent_15.kind === 204 /* DoStatement */ || + parent_15.kind === 207 /* ForInStatement */ || + parent_15.kind === 208 /* ForOfStatement */ || + parent_15.kind === 206 /* ForStatement */ || + parent_15.kind === 203 /* IfStatement */ || + parent_15.kind === 205 /* WhileStatement */ || + parent_15.kind === 212 /* WithStatement */ || + parent_15.kind === 252 /* CatchClause */) { + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_14.kind === 216 /* TryStatement */) { + if (parent_15.kind === 216 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_14; + var tryStatement = parent_15; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_14, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_15, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -47447,8 +47664,8 @@ var ts; return undefined; } function getArgumentIndex(argumentsList, node) { - // The list we got back can include commas. In the presence of errors it may - // also just have nodes without commas. For example "Foo(a b c)" will have 3 + // The list we got back can include commas. In the presence of errors it may + // also just have nodes without commas. For example "Foo(a b c)" will have 3 // args without commas. We want to find what index we're at. So we count // forward until we hit ourselves, only incrementing the index if it isn't a // comma. @@ -47479,8 +47696,8 @@ var ts; // 'a' ''. So, in the case where the last child is a comma, we increase the // arg count by one to compensate. // - // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then - // we'll have: 'a' '' '' + // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then + // we'll have: 'a' '' '' // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); @@ -47628,7 +47845,7 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation); + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -47745,6 +47962,8 @@ var ts; case 199 /* Block */: case 226 /* ModuleBlock */: case 227 /* CaseBlock */: + case 233 /* NamedImports */: + case 237 /* NamedExports */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); case 252 /* CatchClause */: return isCompletedNode(n.block, sourceFile); @@ -47832,6 +48051,9 @@ var ts; return isCompletedNode(lastSpan, sourceFile); case 197 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); + case 236 /* ExportDeclaration */: + case 230 /* ImportDeclaration */: + return ts.nodeIsPresent(n.moduleSpecifier); case 185 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); case 187 /* BinaryExpression */: @@ -49282,7 +49504,7 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */, 82 /* ExportKeyword */, 89 /* ImportKeyword */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); @@ -49339,8 +49561,8 @@ var ts; // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 129 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */, 136 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */, 136 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -49495,6 +49717,8 @@ var ts; case 187 /* BinaryExpression */: case 188 /* ConditionalExpression */: case 195 /* AsExpression */: + case 238 /* ExportSpecifier */: + case 234 /* ImportSpecifier */: case 154 /* TypePredicate */: case 162 /* UnionType */: case 163 /* IntersectionType */: @@ -49613,6 +49837,10 @@ var ts; case 224 /* EnumDeclaration */: case 159 /* TypeLiteral */: case 225 /* ModuleDeclaration */: + case 236 /* ExportDeclaration */: + case 237 /* NamedExports */: + case 230 /* ImportDeclaration */: + case 233 /* NamedImports */: return true; } return false; @@ -50420,7 +50648,10 @@ var ts; var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); if (startLine !== parentStartLine || startPos === column) { - return column; + // Use the base indent size if it is greater than + // the indentation of the inherited predecessor. + var baseIndentSize = formatting.SmartIndenter.getBaseIndentation(options); + return baseIndentSize > column ? baseIndentSize : column; } } return -1 /* Unknown */; @@ -51060,7 +51291,7 @@ var ts; })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { - return 0; // past EOF + return getBaseIndentation(options); // past EOF } // no indentation when the indent style is set to none, // so we can return fast @@ -51069,7 +51300,7 @@ var ts; } var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { - return 0; + return getBaseIndentation(options); } // no indentation in string \regex\template literals var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); @@ -51131,12 +51362,16 @@ var ts; current = current.parent; } if (!current) { - // no parent was found - return 0 to be indented on the level of SourceFile - return 0; + // no parent was found - return the base indentation of the SourceFile + return getBaseIndentation(options); } return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; + function getBaseIndentation(options) { + return options.BaseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); @@ -51182,7 +51417,7 @@ var ts; currentStart = parentStart; parent = current.parent; } - return indentationDelta; + return indentationDelta + getBaseIndentation(options); } function getParentStart(parent, child, sourceFile) { var containingList = getContainingList(child, sourceFile); @@ -51440,7 +51675,10 @@ var ts; case 164 /* ParenthesizedType */: case 176 /* TaggedTemplateExpression */: case 184 /* AwaitExpression */: + case 237 /* NamedExports */: case 233 /* NamedImports */: + case 238 /* ExportSpecifier */: + case 234 /* ImportSpecifier */: return true; } return false; @@ -51463,6 +51701,11 @@ var ts; case 149 /* GetAccessor */: case 150 /* SetAccessor */: return childKind !== 199 /* Block */; + case 236 /* ExportDeclaration */: + return childKind !== 237 /* NamedExports */; + case 230 /* ImportDeclaration */: + return childKind !== 231 /* ImportClause */ || + child.namedBindings.kind !== 233 /* NamedImports */; case 241 /* JsxElement */: return childKind !== 245 /* JsxClosingElement */; } @@ -52468,9 +52711,9 @@ var ts; return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_15 = declaration.parent; !ts.isFunctionBlock(parent_15); parent_15 = parent_15.parent) { + for (var parent_16 = declaration.parent; !ts.isFunctionBlock(parent_16); parent_16 = parent_16.parent) { // Reached source file or module block - if (parent_15.kind === 256 /* SourceFile */ || parent_15.kind === 226 /* ModuleBlock */) { + if (parent_16.kind === 256 /* SourceFile */ || parent_16.kind === 226 /* ModuleBlock */) { return false; } } @@ -52601,7 +52844,7 @@ var ts; return typeof o.type === "object" && !ts.forEachValue(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function(opt) { + var _loop_3 = function(opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -52620,7 +52863,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_3(opt); } return options; } @@ -53821,13 +54064,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_16 = contextToken.parent, kind = contextToken.kind; + var parent_17 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_16.kind === 172 /* PropertyAccessExpression */) { + if (parent_17.kind === 172 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_16.kind === 139 /* QualifiedName */) { + else if (parent_17.kind === 139 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -54203,9 +54446,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_17 = contextToken.parent; - if (parent_17 && (parent_17.kind === 171 /* ObjectLiteralExpression */ || parent_17.kind === 167 /* ObjectBindingPattern */)) { - return parent_17; + var parent_18 = contextToken.parent; + if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { + return parent_18; } break; } @@ -54232,37 +54475,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_18 = contextToken.parent; + var parent_19 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_18 && (parent_18.kind === 242 /* JsxSelfClosingElement */ || parent_18.kind === 243 /* JsxOpeningElement */)) { - return parent_18; + if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { + return parent_19; } - else if (parent_18.kind === 246 /* JsxAttribute */) { - return parent_18.parent; + else if (parent_19.kind === 246 /* JsxAttribute */) { + return parent_19.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_18 && ((parent_18.kind === 246 /* JsxAttribute */) || (parent_18.kind === 247 /* JsxSpreadAttribute */))) { - return parent_18.parent; + if (parent_19 && ((parent_19.kind === 246 /* JsxAttribute */) || (parent_19.kind === 247 /* JsxSpreadAttribute */))) { + return parent_19.parent; } break; case 16 /* CloseBraceToken */: - if (parent_18 && - parent_18.kind === 248 /* JsxExpression */ && - parent_18.parent && - (parent_18.parent.kind === 246 /* JsxAttribute */)) { - return parent_18.parent.parent; + if (parent_19 && + parent_19.kind === 248 /* JsxExpression */ && + parent_19.parent && + (parent_19.parent.kind === 246 /* JsxAttribute */)) { + return parent_19.parent.parent; } - if (parent_18 && parent_18.kind === 247 /* JsxSpreadAttribute */) { - return parent_18.parent; + if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { + return parent_19.parent; } break; } @@ -55594,19 +55837,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_19 = child.parent; - if (ts.isFunctionBlock(parent_19) || parent_19.kind === 256 /* SourceFile */) { - return parent_19; + var parent_20 = child.parent; + if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256 /* SourceFile */) { + return parent_20; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_19.kind === 216 /* TryStatement */) { - var tryStatement = parent_19; + if (parent_20.kind === 216 /* TryStatement */) { + var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_19; + child = parent_20; } return undefined; } @@ -55986,16 +56229,31 @@ var ts; if (node === sourceFile) { return undefined; } - if (node.kind !== 69 /* Identifier */ && - // TODO (drosen): This should be enabled in a later release - currently breaks rename. - // node.kind !== SyntaxKind.ThisKeyword && - // node.kind !== SyntaxKind.SuperKeyword && - node.kind !== 9 /* StringLiteral */ && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return undefined; + switch (node.kind) { + case 8 /* NumericLiteral */: + if (!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + break; + } + // Fallthrough + case 69 /* Identifier */: + case 97 /* ThisKeyword */: + // case SyntaxKind.SuperKeyword: TODO:GH#9268 + case 9 /* StringLiteral */: + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + } + return undefined; + } + function isThis(node) { + switch (node.kind) { + case 97 /* ThisKeyword */: + // case SyntaxKind.ThisType: TODO: GH#9267 + return true; + case 69 /* Identifier */: + // 'this' as a parameter + return node.originalKeywordKind === 97 /* ThisKeyword */ && node.parent.kind === 142 /* Parameter */; + default: + return false; } - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { var typeChecker = program.getTypeChecker(); @@ -56012,7 +56270,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 /* ThisKeyword */ || node.kind === 165 /* ThisType */) { + if (isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95 /* SuperKeyword */) { @@ -56447,7 +56705,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 165 /* ThisType */)) { + if (!node || !isThis(node)) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); @@ -57453,8 +57711,8 @@ var ts; return; case 142 /* Parameter */: if (token.parent.name === token) { - var isThis = token.kind === 69 /* Identifier */ && token.originalKeywordKind === 97 /* ThisKeyword */; - return isThis ? 3 /* keyword */ : 17 /* parameterName */; + var isThis_1 = token.kind === 69 /* Identifier */ && token.originalKeywordKind === 97 /* ThisKeyword */; + return isThis_1 ? 3 /* keyword */ : 17 /* parameterName */; } return; } @@ -57645,7 +57903,7 @@ var ts; (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } - function isValidBraceCompletionAtPostion(fileName, position, openingBrace) { + function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too // expensive to do during typing scenarios // i.e. whether we're dealing with: @@ -57847,11 +58105,11 @@ var ts; var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - // Can only rename an identifier. if (node) { if (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isThis(node)) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -57965,7 +58223,7 @@ var ts; getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - isValidBraceCompletionAtPostion: isValidBraceCompletionAtPostion, + isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram @@ -59503,9 +59761,9 @@ var ts; var _this = this; return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPostion = function (fileName, position, openingBrace) { + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPostion('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { From d8e3bd99e8430d85432066fe4e7fb00819fabb95 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 27 Jun 2016 16:32:29 -0700 Subject: [PATCH 053/103] Added emitHost method to return source from node modules --- src/compiler/program.ts | 6 ++---- src/compiler/utilities.ts | 17 +++++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cee0936fafd..fdc39e1eb35 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1361,10 +1361,8 @@ namespace ts { getNewLine: () => host.getNewLine(), getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, - getSourceFiles: () => filter(program.getSourceFiles(), - // Remove JavaScript files found by searching node_modules from the source files to emit - sourceFile => !lookUp(jsFilesFoundSearchingNodeModules, sourceFile.path) - ), + getSourceFiles: program.getSourceFiles, + getFilesFromNodeModules: () => jsFilesFoundSearchingNodeModules, writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 6daf0903489..571c49bf440 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -34,6 +34,7 @@ namespace ts { export interface EmitHost extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; + getFilesFromNodeModules(): Map; getCommonSourceDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -2274,9 +2275,10 @@ namespace ts { } else { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + const nodeModulesFiles = host.getFilesFromNodeModules(); for (const sourceFile of sourceFiles) { - // Don't emit if source file is a declaration file - if (!isDeclarationFile(sourceFile)) { + // Don't emit if source file is a declaration file, or was located under node_modules + if (!isDeclarationFile(sourceFile) && !lookUp(nodeModulesFiles, sourceFile.path)) { onSingleFileEmit(host, sourceFile); } } @@ -2308,11 +2310,14 @@ namespace ts { } function onBundledEmit(host: EmitHost) { - // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified + // Can emit only sources that are not declaration file and are either non module code or module with + // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. + const nodeModulesFiles = host.getFilesFromNodeModules(); const bundledSources = filter(host.getSourceFiles(), - sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file - (!isExternalModule(sourceFile) || // non module file - !!getEmitModuleKind(options))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted + sourceFile => !isDeclarationFile(sourceFile) && + !lookUp(nodeModulesFiles, sourceFile.path) && + (!isExternalModule(sourceFile) || + !!getEmitModuleKind(options))); if (bundledSources.length) { const jsFilePath = options.outFile || options.out; const emitFileNames: EmitFileNames = { From ddad35a6809807c2446af73a49b858a704b12030 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 27 Jun 2016 16:49:53 -0700 Subject: [PATCH 054/103] Marked new method internal --- src/compiler/utilities.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 571c49bf440..e8f2832cd59 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -34,6 +34,8 @@ namespace ts { export interface EmitHost extends ScriptReferenceHost { getSourceFiles(): SourceFile[]; + + /* @internal */ getFilesFromNodeModules(): Map; getCommonSourceDirectory(): string; From 8ddba289eb98d51cb711350c4e29038cc65670f8 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 27 Jun 2016 22:18:52 -0700 Subject: [PATCH 055/103] Update issue_template.md --- issue_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/issue_template.md b/issue_template.md index 78e0ae8be91..7799960ec78 100644 --- a/issue_template.md +++ b/issue_template.md @@ -2,7 +2,7 @@ -**TypeScript Version:** 1.8.0 / nightly (1.9.0-dev.201xxxxx) +**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx) **Code** From 6e984eb3a37b18b9b075217b094ea6284f1e7279 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 29 Jun 2016 03:28:22 +0900 Subject: [PATCH 056/103] new options should be optional for compatibility --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 5142b19b6c0..529ce8a7bf7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1267,7 +1267,7 @@ namespace ts { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; - InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean; + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string | undefined; From 3fdaf194f7c02a27920fade8304ea6b9de457c1c Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Tue, 28 Jun 2016 21:26:18 +0200 Subject: [PATCH 057/103] VarDate interface and relevant Date.prototype members --- src/lib/scripthost.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index 7faae06714c..baf93f55d55 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -276,3 +276,13 @@ interface VBArrayConstructor { } declare var VBArray: VBArrayConstructor; + +/** + * Automation date (VT_DATE) + */ +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; + getVarDate: () => VarDate; +} \ No newline at end of file From 6ff91b84aba99fbf66ac8f4e1d63068794ca8dcd Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 28 Jun 2016 11:43:07 -0700 Subject: [PATCH 058/103] Add getCurrentDirectory to ServerHost --- src/compiler/program.ts | 18 ++++++++++++++++-- src/server/editorServices.ts | 1 + .../fourslash/server/typeReferenceOnServer.ts | 9 +++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/server/typeReferenceOnServer.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7593f4f5434..decbb835a8c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -187,8 +187,22 @@ namespace ts { const typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) { - return options.typeRoots || - map(defaultTypeRoots, d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d)); + if (options.typeRoots) { + return options.typeRoots; + } + + let currentDirectory: string; + if (options.configFilePath) { + currentDirectory = getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + + if (!currentDirectory) { + return undefined; + } + return map(defaultTypeRoots, d => combinePaths(currentDirectory, d)); } /** diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e48d6192017..e4b989b0ca7 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -113,6 +113,7 @@ namespace ts.server { this.moduleResolutionHost = { fileExists: fileName => this.fileExists(fileName), readFile: fileName => this.host.readFile(fileName), + getCurrentDirectory: () => this.host.getCurrentDirectory(), directoryExists: directoryName => this.host.directoryExists(directoryName) }; } diff --git a/tests/cases/fourslash/server/typeReferenceOnServer.ts b/tests/cases/fourslash/server/typeReferenceOnServer.ts new file mode 100644 index 00000000000..574ea6f60c4 --- /dev/null +++ b/tests/cases/fourslash/server/typeReferenceOnServer.ts @@ -0,0 +1,9 @@ +/// + +/////// +////var x: number; +////x./*1*/ + +goTo.marker("1"); +verify.not.completionListIsEmpty(); + From d5cad239e858ca71e89aa8963a7d875928652a65 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 28 Jun 2016 12:10:26 -0700 Subject: [PATCH 059/103] Add nullchecks for typeRoots, remove getCurrentDirectory from ServerHost as it is always the installation location --- src/compiler/program.ts | 10 ++++++---- src/server/editorServices.ts | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index decbb835a8c..fb74f1dcaab 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -242,7 +242,7 @@ namespace ts { const failedLookupLocations: string[] = []; // Check primary library paths - if (typeRoots.length) { + if (typeRoots && typeRoots.length) { if (traceEnabled) { trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } @@ -1060,9 +1060,11 @@ namespace ts { let result: string[] = []; if (host.directoryExists && host.getDirectories) { const typeRoots = getEffectiveTypeRoots(options, host); - for (const root of typeRoots) { - if (host.directoryExists(root)) { - result = result.concat(host.getDirectories(root)); + if (typeRoots) { + for (const root of typeRoots) { + if (host.directoryExists(root)) { + result = result.concat(host.getDirectories(root)); + } } } } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e4b989b0ca7..e48d6192017 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -113,7 +113,6 @@ namespace ts.server { this.moduleResolutionHost = { fileExists: fileName => this.fileExists(fileName), readFile: fileName => this.host.readFile(fileName), - getCurrentDirectory: () => this.host.getCurrentDirectory(), directoryExists: directoryName => this.host.directoryExists(directoryName) }; } From 67f0ffe7fb1f579102269de7781e2d08f899ebfb Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 28 Jun 2016 13:06:26 -0700 Subject: [PATCH 060/103] Port 9396 to release 2.0 --- src/compiler/program.ts | 28 +++++++++++++++---- .../fourslash/server/typeReferenceOnServer.ts | 9 ++++++ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/server/typeReferenceOnServer.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7593f4f5434..fb74f1dcaab 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -187,8 +187,22 @@ namespace ts { const typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) { - return options.typeRoots || - map(defaultTypeRoots, d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d)); + if (options.typeRoots) { + return options.typeRoots; + } + + let currentDirectory: string; + if (options.configFilePath) { + currentDirectory = getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + + if (!currentDirectory) { + return undefined; + } + return map(defaultTypeRoots, d => combinePaths(currentDirectory, d)); } /** @@ -228,7 +242,7 @@ namespace ts { const failedLookupLocations: string[] = []; // Check primary library paths - if (typeRoots.length) { + if (typeRoots && typeRoots.length) { if (traceEnabled) { trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } @@ -1046,9 +1060,11 @@ namespace ts { let result: string[] = []; if (host.directoryExists && host.getDirectories) { const typeRoots = getEffectiveTypeRoots(options, host); - for (const root of typeRoots) { - if (host.directoryExists(root)) { - result = result.concat(host.getDirectories(root)); + if (typeRoots) { + for (const root of typeRoots) { + if (host.directoryExists(root)) { + result = result.concat(host.getDirectories(root)); + } } } } diff --git a/tests/cases/fourslash/server/typeReferenceOnServer.ts b/tests/cases/fourslash/server/typeReferenceOnServer.ts new file mode 100644 index 00000000000..574ea6f60c4 --- /dev/null +++ b/tests/cases/fourslash/server/typeReferenceOnServer.ts @@ -0,0 +1,9 @@ +/// + +/////// +////var x: number; +////x./*1*/ + +goTo.marker("1"); +verify.not.completionListIsEmpty(); + From 29107e636b39ceb12abe5eb061891a6092ab5918 Mon Sep 17 00:00:00 2001 From: Yui Date: Tue, 28 Jun 2016 13:33:11 -0700 Subject: [PATCH 061/103] Fix 9363: Object destructuring broken-variables are bound to the wrong object (#9383) * Fix emit incorrect destructuring mapping in var declaration * Add tests and baselines * Add additional tests and baselines --- src/compiler/emitter.ts | 4 ++- .../destructuringParameterDeclaration7ES5.js | 27 +++++++++++++++ ...tructuringParameterDeclaration7ES5.symbols | 33 +++++++++++++++++++ ...estructuringParameterDeclaration7ES5.types | 33 +++++++++++++++++++ .../destructuringParameterDeclaration7ES5.ts | 14 ++++++++ 5 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/destructuringParameterDeclaration7ES5.js create mode 100644 tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols create mode 100644 tests/baselines/reference/destructuringParameterDeclaration7ES5.types create mode 100644 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0879a3a9ee4..30f0e74adb4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4545,8 +4545,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } write(";"); - tempIndex++; } + // Regardless of whether we will emit a var declaration for the binding pattern, we generate the temporary + // variable for the parameter (see: emitParameter) + tempIndex++; } else if (initializer) { writeLine(); diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5.js b/tests/baselines/reference/destructuringParameterDeclaration7ES5.js new file mode 100644 index 00000000000..f9dac1ae2fa --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5.js @@ -0,0 +1,27 @@ +//// [destructuringParameterDeclaration7ES5.ts] + +interface ISomething { + foo: string, + bar: string +} + +function foo({}, {foo, bar}: ISomething) {} + +function baz([], {foo, bar}: ISomething) {} + +function one([], {}) {} + +function two([], [a, b, c]: number[]) {} + + +//// [destructuringParameterDeclaration7ES5.js] +function foo(_a, _b) { + var foo = _b.foo, bar = _b.bar; +} +function baz(_a, _b) { + var foo = _b.foo, bar = _b.bar; +} +function one(_a, _b) { } +function two(_a, _b) { + var a = _b[0], b = _b[1], c = _b[2]; +} diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols new file mode 100644 index 00000000000..44709f18e1b --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts === + +interface ISomething { +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) + + foo: string, +>foo : Symbol(ISomething.foo, Decl(destructuringParameterDeclaration7ES5.ts, 1, 22)) + + bar: string +>bar : Symbol(ISomething.bar, Decl(destructuringParameterDeclaration7ES5.ts, 2, 16)) +} + +function foo({}, {foo, bar}: ISomething) {} +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 4, 1)) +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 6, 18)) +>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 6, 22)) +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) + +function baz([], {foo, bar}: ISomething) {} +>baz : Symbol(baz, Decl(destructuringParameterDeclaration7ES5.ts, 6, 43)) +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 8, 18)) +>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 8, 22)) +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) + +function one([], {}) {} +>one : Symbol(one, Decl(destructuringParameterDeclaration7ES5.ts, 8, 43)) + +function two([], [a, b, c]: number[]) {} +>two : Symbol(two, Decl(destructuringParameterDeclaration7ES5.ts, 10, 23)) +>a : Symbol(a, Decl(destructuringParameterDeclaration7ES5.ts, 12, 18)) +>b : Symbol(b, Decl(destructuringParameterDeclaration7ES5.ts, 12, 20)) +>c : Symbol(c, Decl(destructuringParameterDeclaration7ES5.ts, 12, 23)) + diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5.types b/tests/baselines/reference/destructuringParameterDeclaration7ES5.types new file mode 100644 index 00000000000..7d64383b0b6 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts === + +interface ISomething { +>ISomething : ISomething + + foo: string, +>foo : string + + bar: string +>bar : string +} + +function foo({}, {foo, bar}: ISomething) {} +>foo : ({}: {}, {foo, bar}: ISomething) => void +>foo : string +>bar : string +>ISomething : ISomething + +function baz([], {foo, bar}: ISomething) {} +>baz : ([]: any[], {foo, bar}: ISomething) => void +>foo : string +>bar : string +>ISomething : ISomething + +function one([], {}) {} +>one : ([]: any[], {}: {}) => void + +function two([], [a, b, c]: number[]) {} +>two : ([]: any[], [a, b, c]: number[]) => void +>a : number +>b : number +>c : number + diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts new file mode 100644 index 00000000000..97822e92e2d --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts @@ -0,0 +1,14 @@ +// @target: es5 + +interface ISomething { + foo: string, + bar: string +} + +function foo({}, {foo, bar}: ISomething) {} + +function baz([], {foo, bar}: ISomething) {} + +function one([], {}) {} + +function two([], [a, b, c]: number[]) {} From 8ff873e7a614afbb27cff26775a3b218cf26bd5f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 28 Jun 2016 13:34:01 -0700 Subject: [PATCH 062/103] Fix crash in async functions when targetting ES5. When targetting ES5 and with --noImplicitReturns, an async function whose return type could not be determined would cause a compiler crash. --- src/compiler/checker.ts | 2 +- .../asyncFunctionNoReturnType.errors.txt | 25 +++++++++++++++++++ .../reference/asyncFunctionNoReturnType.js | 20 +++++++++++++++ .../compiler/asyncFunctionNoReturnType.ts | 5 ++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/asyncFunctionNoReturnType.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionNoReturnType.js create mode 100644 tests/cases/compiler/asyncFunctionNoReturnType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06591a7ab3d..ce001e1e088 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15388,7 +15388,7 @@ namespace ts { function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean { const unwrappedReturnType = isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; - return maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any); + return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any); } function checkReturnStatement(node: ReturnStatement) { diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt b/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt new file mode 100644 index 00000000000..a7dbb6ecb64 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt @@ -0,0 +1,25 @@ +error TS2318: Cannot find global type 'Promise'. +tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher. +tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1057: An async function or method must have a valid awaitable return type. +tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value. +tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'. +tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all code paths return a value. + + +!!! error TS2318: Cannot find global type 'Promise'. +==== tests/cases/compiler/asyncFunctionNoReturnType.ts (5 errors) ==== + async () => { + ~~~~~ +!!! error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher. + ~~~~~~~~~~~~~ +!!! error TS1057: An async function or method must have a valid awaitable return type. + ~~~~~~~~~~~~~ +!!! error TS7030: Not all code paths return a value. + if (window) + ~~~~~~ +!!! error TS2304: Cannot find name 'window'. + return; + ~~~~~~~ +!!! error TS7030: Not all code paths return a value. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.js b/tests/baselines/reference/asyncFunctionNoReturnType.js new file mode 100644 index 00000000000..dd84e17c88b --- /dev/null +++ b/tests/baselines/reference/asyncFunctionNoReturnType.js @@ -0,0 +1,20 @@ +//// [asyncFunctionNoReturnType.ts] +async () => { + if (window) + return; +} + + +//// [asyncFunctionNoReturnType.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +(function () __awaiter(this, void 0, void 0, function* () { + if (window) + return; +})); diff --git a/tests/cases/compiler/asyncFunctionNoReturnType.ts b/tests/cases/compiler/asyncFunctionNoReturnType.ts new file mode 100644 index 00000000000..4a4b5316d72 --- /dev/null +++ b/tests/cases/compiler/asyncFunctionNoReturnType.ts @@ -0,0 +1,5 @@ +// @noImplicitReturns: true +async () => { + if (window) + return; +} From ddadb472a6241bd14a267b915f5c4669bd094a28 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 28 Jun 2016 14:45:56 -0700 Subject: [PATCH 063/103] Add This type to lib --- src/lib/dom.generated.d.ts | 3936 +++++++++++++++--------------- src/lib/webworker.generated.d.ts | 166 +- 2 files changed, 2051 insertions(+), 2051 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 0911586dd5d..d2938f6e983 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -917,14 +917,14 @@ declare var AnimationEvent: { } interface ApplicationCache extends EventTarget { - oncached: (ev: Event) => any; - onchecking: (ev: Event) => any; - ondownloading: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onnoupdate: (ev: Event) => any; - onobsolete: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - onupdateready: (ev: Event) => any; + oncached: (this: this, ev: Event) => any; + onchecking: (this: this, ev: Event) => any; + ondownloading: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onnoupdate: (this: this, ev: Event) => any; + onobsolete: (this: this, ev: Event) => any; + onprogress: (this: this, ev: ProgressEvent) => any; + onupdateready: (this: this, ev: Event) => any; readonly status: number; abort(): void; swapCache(): void; @@ -935,14 +935,14 @@ interface ApplicationCache extends EventTarget { readonly OBSOLETE: number; readonly UNCACHED: number; readonly UPDATEREADY: number; - addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "obsolete", 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: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "checking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "downloading", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "noupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "obsolete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "updateready", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1001,11 +1001,11 @@ interface AudioBufferSourceNode extends AudioNode { loop: boolean; loopEnd: number; loopStart: number; - onended: (ev: MediaStreamErrorEvent) => any; + onended: (this: this, ev: MediaStreamErrorEvent) => any; readonly playbackRate: AudioParam; start(when?: number, offset?: number, duration?: number): void; stop(when?: number): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1129,14 +1129,14 @@ declare var AudioTrack: { interface AudioTrackList extends EventTarget { readonly length: number; - onaddtrack: (ev: TrackEvent) => any; - onchange: (ev: Event) => any; - onremovetrack: (ev: TrackEvent) => any; + onaddtrack: (this: this, ev: TrackEvent) => any; + onchange: (this: this, ev: Event) => any; + onremovetrack: (this: this, ev: TrackEvent) => any; getTrackById(id: string): AudioTrack | null; item(index: number): AudioTrack; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (this: this, ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (this: this, ev: TrackEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [index: number]: AudioTrack; } @@ -2290,7 +2290,7 @@ declare var DeviceRotationRate: { interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent { /** - * Sets or gets the URL for the current document. + * Sets or gets the URL for the current document. */ readonly URL: string; /** @@ -2318,7 +2318,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ applets: HTMLCollectionOf; /** - * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. */ bgColor: string; /** @@ -2346,19 +2346,19 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ designMode: string; /** - * Sets or retrieves a value that indicates the reading order of the object. + * Sets or retrieves a value that indicates the reading order of the object. */ dir: string; /** - * Gets an object representing the document type declaration associated with the current document. + * Gets an object representing the document type declaration associated with the current document. */ readonly doctype: DocumentType; /** - * Gets a reference to the root node of the document. + * Gets a reference to the root node of the document. */ documentElement: HTMLElement; /** - * Sets or gets the security domain of the document. + * Sets or gets the security domain of the document. */ domain: string; /** @@ -2382,7 +2382,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ images: HTMLCollectionOf; /** - * Gets the implementation object of the current document. + * Gets the implementation object of the current document. */ readonly implementation: DOMImplementation; /** @@ -2390,11 +2390,11 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly inputEncoding: string | null; /** - * Gets the date that the page was last modified, if the page supplies one. + * Gets the date that the page was last modified, if the page supplies one. */ readonly lastModified: string; /** - * Sets or gets the color of the document links. + * Sets or gets the color of the document links. */ linkColor: string; /** @@ -2402,7 +2402,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ links: HTMLCollectionOf; /** - * Contains information about the current URL. + * Contains information about the current URL. */ readonly location: Location; msCSSOMElementFloatMetrics: boolean; @@ -2411,294 +2411,294 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the user aborts the download. * @param ev The event. */ - onabort: (ev: UIEvent) => any; + onabort: (this: this, ev: UIEvent) => any; /** * Fires when the object is set as the active element. * @param ev The event. */ - onactivate: (ev: UIEvent) => any; + onactivate: (this: this, ev: UIEvent) => any; /** * Fires immediately before the object is set as the active element. * @param ev The event. */ - onbeforeactivate: (ev: UIEvent) => any; + onbeforeactivate: (this: this, ev: UIEvent) => 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 loses the input focus. + onbeforedeactivate: (this: this, ev: UIEvent) => any; + /** + * Fires when the object loses the input focus. * @param ev The focus event. */ - onblur: (ev: FocusEvent) => any; + onblur: (this: this, ev: FocusEvent) => any; /** - * Occurs when playback is possible, but would require further buffering. + * Occurs when playback is possible, but would require further buffering. * @param ev The event. */ - oncanplay: (ev: Event) => any; - oncanplaythrough: (ev: Event) => any; + oncanplay: (this: this, ev: Event) => any; + oncanplaythrough: (this: this, ev: Event) => any; /** - * Fires when the contents of the object or selection have changed. + * Fires when the contents of the object or selection have changed. * @param ev The event. */ - onchange: (ev: Event) => any; + onchange: (this: this, ev: Event) => any; /** * Fires when the user clicks the left mouse button on the object * @param ev The mouse event. */ - onclick: (ev: MouseEvent) => any; + onclick: (this: this, ev: MouseEvent) => any; /** - * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * Fires when the user clicks the right mouse button in the client area, opening the context menu. * @param ev The mouse event. */ - oncontextmenu: (ev: PointerEvent) => any; + oncontextmenu: (this: this, ev: PointerEvent) => any; /** * Fires when the user double-clicks the object. * @param ev The mouse event. */ - ondblclick: (ev: MouseEvent) => any; + ondblclick: (this: this, ev: MouseEvent) => 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; + ondeactivate: (this: this, ev: UIEvent) => any; /** * Fires on the source object continuously during a drag operation. * @param ev The event. */ - ondrag: (ev: DragEvent) => any; + ondrag: (this: this, ev: DragEvent) => 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; - /** + ondragend: (this: this, ev: DragEvent) => 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; - /** + ondragenter: (this: this, ev: DragEvent) => 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; + ondragleave: (this: this, ev: DragEvent) => any; /** * 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; + ondragover: (this: this, ev: DragEvent) => any; /** - * Fires on the source object when the user starts to drag a text selection or selected object. + * 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; - ondrop: (ev: DragEvent) => any; + ondragstart: (this: this, ev: DragEvent) => any; + ondrop: (this: this, ev: DragEvent) => any; /** - * Occurs when the duration attribute is updated. + * Occurs when the duration attribute is updated. * @param ev The event. */ - ondurationchange: (ev: Event) => any; + ondurationchange: (this: this, ev: Event) => any; /** - * Occurs when the media element is reset to its initial state. + * Occurs when the media element is reset to its initial state. * @param ev The event. */ - onemptied: (ev: Event) => any; + onemptied: (this: this, ev: Event) => any; /** - * Occurs when the end of playback is reached. + * Occurs when the end of playback is reached. * @param ev The event */ - onended: (ev: MediaStreamErrorEvent) => any; + onended: (this: this, ev: MediaStreamErrorEvent) => any; /** * Fires when an error occurs during object loading. * @param ev The event. */ - onerror: (ev: ErrorEvent) => any; + onerror: (this: this, ev: ErrorEvent) => any; /** - * Fires when the object receives focus. + * Fires when the object receives focus. * @param ev The event. */ - onfocus: (ev: FocusEvent) => any; - onfullscreenchange: (ev: Event) => any; - onfullscreenerror: (ev: Event) => any; - oninput: (ev: Event) => any; - oninvalid: (ev: Event) => any; + onfocus: (this: this, ev: FocusEvent) => any; + onfullscreenchange: (this: this, ev: Event) => any; + onfullscreenerror: (this: this, ev: Event) => any; + oninput: (this: this, ev: Event) => any; + oninvalid: (this: this, ev: Event) => any; /** * Fires when the user presses a key. * @param ev The keyboard event */ - onkeydown: (ev: KeyboardEvent) => any; + onkeydown: (this: this, ev: KeyboardEvent) => any; /** * Fires when the user presses an alphanumeric key. * @param ev The event. */ - onkeypress: (ev: KeyboardEvent) => any; + onkeypress: (this: this, ev: KeyboardEvent) => any; /** * Fires when the user releases a key. * @param ev The keyboard event */ - onkeyup: (ev: KeyboardEvent) => any; + onkeyup: (this: this, ev: KeyboardEvent) => any; /** - * Fires immediately after the browser loads the object. + * Fires immediately after the browser loads the object. * @param ev The event. */ - onload: (ev: Event) => any; + onload: (this: this, ev: Event) => any; /** - * Occurs when media data is loaded at the current playback position. + * Occurs when media data is loaded at the current playback position. * @param ev The event. */ - onloadeddata: (ev: Event) => any; + onloadeddata: (this: this, ev: Event) => any; /** * Occurs when the duration and dimensions of the media have been determined. * @param ev The event. */ - onloadedmetadata: (ev: Event) => any; + onloadedmetadata: (this: this, ev: Event) => any; /** - * Occurs when Internet Explorer begins looking for media data. + * Occurs when Internet Explorer begins looking for media data. * @param ev The event. */ - onloadstart: (ev: Event) => any; + onloadstart: (this: this, ev: Event) => any; /** - * Fires when the user clicks the object with either mouse button. + * Fires when the user clicks the object with either mouse button. * @param ev The mouse event. */ - onmousedown: (ev: MouseEvent) => any; + onmousedown: (this: this, ev: MouseEvent) => any; /** - * Fires when the user moves the mouse over the object. + * Fires when the user moves the mouse over the object. * @param ev The mouse event. */ - onmousemove: (ev: MouseEvent) => any; + onmousemove: (this: this, ev: MouseEvent) => any; /** - * Fires when the user moves the mouse pointer outside the boundaries of the object. + * Fires when the user moves the mouse pointer outside the boundaries of the object. * @param ev The mouse event. */ - onmouseout: (ev: MouseEvent) => any; + onmouseout: (this: this, ev: MouseEvent) => any; /** * Fires when the user moves the mouse pointer into the object. * @param ev The mouse event. */ - onmouseover: (ev: MouseEvent) => any; + onmouseover: (this: this, ev: MouseEvent) => any; /** - * Fires when the user releases a mouse button while the mouse is over the object. + * Fires when the user releases a mouse button while the mouse is over the object. * @param ev The mouse event. */ - onmouseup: (ev: MouseEvent) => any; + onmouseup: (this: this, ev: MouseEvent) => any; /** - * Fires when the wheel button is rotated. + * Fires when the wheel button is rotated. * @param ev The mouse event */ - onmousewheel: (ev: WheelEvent) => any; - onmscontentzoom: (ev: UIEvent) => any; - onmsgesturechange: (ev: MSGestureEvent) => any; - onmsgesturedoubletap: (ev: MSGestureEvent) => any; - onmsgestureend: (ev: MSGestureEvent) => any; - onmsgesturehold: (ev: MSGestureEvent) => any; - onmsgesturestart: (ev: MSGestureEvent) => any; - onmsgesturetap: (ev: MSGestureEvent) => any; - onmsinertiastart: (ev: MSGestureEvent) => any; - onmsmanipulationstatechanged: (ev: MSManipulationEvent) => any; - onmspointercancel: (ev: MSPointerEvent) => any; - onmspointerdown: (ev: MSPointerEvent) => any; - onmspointerenter: (ev: MSPointerEvent) => any; - onmspointerleave: (ev: MSPointerEvent) => any; - onmspointermove: (ev: MSPointerEvent) => any; - onmspointerout: (ev: MSPointerEvent) => any; - onmspointerover: (ev: MSPointerEvent) => any; - onmspointerup: (ev: MSPointerEvent) => any; + onmousewheel: (this: this, ev: WheelEvent) => any; + onmscontentzoom: (this: this, ev: UIEvent) => any; + onmsgesturechange: (this: this, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: this, ev: MSGestureEvent) => any; + onmsgestureend: (this: this, ev: MSGestureEvent) => any; + onmsgesturehold: (this: this, ev: MSGestureEvent) => any; + onmsgesturestart: (this: this, ev: MSGestureEvent) => any; + onmsgesturetap: (this: this, ev: MSGestureEvent) => any; + onmsinertiastart: (this: this, ev: MSGestureEvent) => any; + onmsmanipulationstatechanged: (this: this, ev: MSManipulationEvent) => any; + onmspointercancel: (this: this, ev: MSPointerEvent) => any; + onmspointerdown: (this: this, ev: MSPointerEvent) => any; + onmspointerenter: (this: this, ev: MSPointerEvent) => any; + onmspointerleave: (this: this, ev: MSPointerEvent) => any; + onmspointermove: (this: this, ev: MSPointerEvent) => any; + onmspointerout: (this: this, ev: MSPointerEvent) => any; + onmspointerover: (this: this, ev: MSPointerEvent) => any; + onmspointerup: (this: this, ev: MSPointerEvent) => any; /** - * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * 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; + onmssitemodejumplistitemremoved: (this: this, ev: MSSiteModeEvent) => 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; + onmsthumbnailclick: (this: this, ev: MSSiteModeEvent) => any; /** * Occurs when playback is paused. * @param ev The event. */ - onpause: (ev: Event) => any; + onpause: (this: this, ev: Event) => any; /** - * Occurs when the play method is requested. + * Occurs when the play method is requested. * @param ev The event. */ - onplay: (ev: Event) => any; + onplay: (this: this, ev: Event) => any; /** - * Occurs when the audio or video has started playing. + * Occurs when the audio or video has started playing. * @param ev The event. */ - onplaying: (ev: Event) => any; - onpointerlockchange: (ev: Event) => any; - onpointerlockerror: (ev: Event) => any; + onplaying: (this: this, ev: Event) => any; + onpointerlockchange: (this: this, ev: Event) => any; + onpointerlockerror: (this: this, ev: Event) => any; /** - * Occurs to indicate progress while downloading media data. + * Occurs to indicate progress while downloading media data. * @param ev The event. */ - onprogress: (ev: ProgressEvent) => any; + onprogress: (this: this, ev: ProgressEvent) => any; /** - * Occurs when the playback rate is increased or decreased. + * Occurs when the playback rate is increased or decreased. * @param ev The event. */ - onratechange: (ev: Event) => any; + onratechange: (this: this, ev: Event) => any; /** * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (ev: ProgressEvent) => any; + onreadystatechange: (this: this, ev: ProgressEvent) => any; /** - * Fires when the user resets a form. + * Fires when the user resets a form. * @param ev The event. */ - onreset: (ev: Event) => any; + onreset: (this: this, ev: Event) => any; /** - * Fires when the user repositions the scroll box in the scroll bar on the object. + * Fires when the user repositions the scroll box in the scroll bar on the object. * @param ev The event. */ - onscroll: (ev: UIEvent) => any; + onscroll: (this: this, ev: UIEvent) => any; /** - * Occurs when the seek operation ends. + * Occurs when the seek operation ends. * @param ev The event. */ - onseeked: (ev: Event) => any; + onseeked: (this: this, ev: Event) => any; /** - * Occurs when the current playback position is moved. + * Occurs when the current playback position is moved. * @param ev The event. */ - onseeking: (ev: Event) => any; + onseeking: (this: this, ev: Event) => any; /** * Fires when the current selection changes. * @param ev The event. */ - onselect: (ev: UIEvent) => any; + onselect: (this: this, ev: UIEvent) => any; /** * Fires when the selection state of a document changes. * @param ev The event. */ - onselectionchange: (ev: Event) => any; - onselectstart: (ev: Event) => any; + onselectionchange: (this: this, ev: Event) => any; + onselectstart: (this: this, ev: Event) => any; /** - * Occurs when the download has stopped. + * Occurs when the download has stopped. * @param ev The event. */ - onstalled: (ev: Event) => any; + onstalled: (this: this, ev: Event) => any; /** * Fires when the user clicks the Stop button or leaves the Web page. * @param ev The event. */ - onstop: (ev: Event) => any; - onsubmit: (ev: Event) => any; + onstop: (this: this, ev: Event) => any; + onsubmit: (this: this, ev: Event) => any; /** - * Occurs if the load operation has been intentionally halted. + * Occurs if the load operation has been intentionally halted. * @param ev The event. */ - onsuspend: (ev: Event) => any; + onsuspend: (this: this, ev: Event) => any; /** * Occurs to indicate the current playback position. * @param ev The event. */ - ontimeupdate: (ev: Event) => any; + ontimeupdate: (this: this, ev: Event) => any; ontouchcancel: (ev: TouchEvent) => any; ontouchend: (ev: TouchEvent) => any; ontouchmove: (ev: TouchEvent) => any; @@ -2707,14 +2707,14 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Occurs when the volume is changed, or playback is muted or unmuted. * @param ev The event. */ - onvolumechange: (ev: Event) => any; + onvolumechange: (this: this, ev: Event) => any; /** - * Occurs when playback stops because the next frame of a video resource is not available. + * Occurs when playback stops because the next frame of a video resource is not available. * @param ev The event. */ - onwaiting: (ev: Event) => any; - onwebkitfullscreenchange: (ev: Event) => any; - onwebkitfullscreenerror: (ev: Event) => any; + onwaiting: (this: this, ev: Event) => any; + onwebkitfullscreenchange: (this: this, ev: Event) => any; + onwebkitfullscreenerror: (this: this, ev: Event) => any; plugins: HTMLCollectionOf; readonly pointerLockElement: Element; /** @@ -2743,7 +2743,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ title: string; readonly visibilityState: string; - /** + /** * Sets or gets the color of the links that the user has visited. */ vlinkColor: string; @@ -2933,7 +2933,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; createNSResolver(nodeResolver: Node): XPathNSResolver; /** - * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * 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. @@ -2942,11 +2942,11 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): NodeIterator; createProcessingInstruction(target: string, data: string): ProcessingInstruction; /** - * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. */ createRange(): Range; /** - * Creates a text string from the specified value. + * Creates a text string from the specified value. * @param data String that specifies the nodeValue property of the text node. */ createTextNode(data: string): Text; @@ -2961,7 +2961,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): TreeWalker; /** - * Returns the element for the specified x coordinate and the specified y coordinate. + * Returns the element for the specified x coordinate and the specified y coordinate. * @param x The x-offset * @param y The y-offset */ @@ -3199,7 +3199,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @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): Document; - /** + /** * 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. */ @@ -3221,7 +3221,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven queryCommandSupported(commandId: string): boolean; /** * 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. + * @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; /** @@ -3237,112 +3237,112 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven webkitCancelFullScreen(): void; webkitExitFullscreen(): void; /** - * Writes one or more HTML expressions to a document in the specified window. + * 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; /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * 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; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "fullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "fullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerlockchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "pointerlockerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "fullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "fullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mssitemodejumplistitemremoved", listener: (this: this, ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msthumbnailclick", listener: (this: this, ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerlockchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointerlockerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectionchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stop", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3430,33 +3430,33 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec id: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (ev: AriaRequestEvent) => any; - oncommand: (ev: CommandEvent) => any; - ongotpointercapture: (ev: PointerEvent) => any; - onlostpointercapture: (ev: PointerEvent) => any; - onmsgesturechange: (ev: MSGestureEvent) => any; - onmsgesturedoubletap: (ev: MSGestureEvent) => any; - onmsgestureend: (ev: MSGestureEvent) => any; - onmsgesturehold: (ev: MSGestureEvent) => any; - onmsgesturestart: (ev: MSGestureEvent) => any; - onmsgesturetap: (ev: MSGestureEvent) => any; - onmsgotpointercapture: (ev: MSPointerEvent) => any; - onmsinertiastart: (ev: MSGestureEvent) => any; - onmslostpointercapture: (ev: MSPointerEvent) => any; - onmspointercancel: (ev: MSPointerEvent) => any; - onmspointerdown: (ev: MSPointerEvent) => any; - onmspointerenter: (ev: MSPointerEvent) => any; - onmspointerleave: (ev: MSPointerEvent) => any; - onmspointermove: (ev: MSPointerEvent) => any; - onmspointerout: (ev: MSPointerEvent) => any; - onmspointerover: (ev: MSPointerEvent) => any; - onmspointerup: (ev: MSPointerEvent) => any; + onariarequest: (this: this, ev: AriaRequestEvent) => any; + oncommand: (this: this, ev: CommandEvent) => any; + ongotpointercapture: (this: this, ev: PointerEvent) => any; + onlostpointercapture: (this: this, ev: PointerEvent) => any; + onmsgesturechange: (this: this, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: this, ev: MSGestureEvent) => any; + onmsgestureend: (this: this, ev: MSGestureEvent) => any; + onmsgesturehold: (this: this, ev: MSGestureEvent) => any; + onmsgesturestart: (this: this, ev: MSGestureEvent) => any; + onmsgesturetap: (this: this, ev: MSGestureEvent) => any; + onmsgotpointercapture: (this: this, ev: MSPointerEvent) => any; + onmsinertiastart: (this: this, ev: MSGestureEvent) => any; + onmslostpointercapture: (this: this, ev: MSPointerEvent) => any; + onmspointercancel: (this: this, ev: MSPointerEvent) => any; + onmspointerdown: (this: this, ev: MSPointerEvent) => any; + onmspointerenter: (this: this, ev: MSPointerEvent) => any; + onmspointerleave: (this: this, ev: MSPointerEvent) => any; + onmspointermove: (this: this, ev: MSPointerEvent) => any; + onmspointerout: (this: this, ev: MSPointerEvent) => any; + onmspointerover: (this: this, ev: MSPointerEvent) => any; + onmspointerup: (this: this, ev: MSPointerEvent) => any; ontouchcancel: (ev: TouchEvent) => any; ontouchend: (ev: TouchEvent) => any; ontouchmove: (ev: TouchEvent) => any; ontouchstart: (ev: TouchEvent) => any; - onwebkitfullscreenchange: (ev: Event) => any; - onwebkitfullscreenerror: (ev: Event) => any; + onwebkitfullscreenchange: (this: this, ev: Event) => any; + onwebkitfullscreenerror: (this: this, ev: Event) => any; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; @@ -3675,42 +3675,42 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; closest(selector: string): Element | null; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3971,12 +3971,12 @@ interface HTMLAnchorElement extends HTMLElement { */ target: string; /** - * Retrieves or sets the text of the object as a string. + * Retrieves or sets the text of the object as a string. */ text: string; type: string; urn: string; - /** + /** * Returns a string representation of an object. */ toString(): string; @@ -4078,7 +4078,7 @@ interface HTMLAreaElement extends HTMLElement { */ host: string; /** - * Sets or retrieves the host name part of the location or URL. + * Sets or retrieves the host name part of the location or URL. */ hostname: string; /** @@ -4114,7 +4114,7 @@ interface HTMLAreaElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - /** + /** * Returns a string representation of an object. */ toString(): string; @@ -4201,147 +4201,147 @@ interface HTMLBodyElement extends HTMLElement { bgProperties: string; link: any; noWrap: boolean; - onafterprint: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onblur: (ev: FocusEvent) => any; - onerror: (ev: ErrorEvent) => any; - onfocus: (ev: FocusEvent) => any; - onhashchange: (ev: HashChangeEvent) => any; - onload: (ev: Event) => any; - onmessage: (ev: MessageEvent) => any; - onoffline: (ev: Event) => any; - ononline: (ev: Event) => any; - onorientationchange: (ev: Event) => any; - onpagehide: (ev: PageTransitionEvent) => any; - onpageshow: (ev: PageTransitionEvent) => any; - onpopstate: (ev: PopStateEvent) => any; - onresize: (ev: UIEvent) => any; - onstorage: (ev: StorageEvent) => any; - onunload: (ev: Event) => any; + onafterprint: (this: this, ev: Event) => any; + onbeforeprint: (this: this, ev: Event) => any; + onbeforeunload: (this: this, ev: BeforeUnloadEvent) => any; + onblur: (this: this, ev: FocusEvent) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onfocus: (this: this, ev: FocusEvent) => any; + onhashchange: (this: this, ev: HashChangeEvent) => any; + onload: (this: this, ev: Event) => any; + onmessage: (this: this, ev: MessageEvent) => any; + onoffline: (this: this, ev: Event) => any; + ononline: (this: this, ev: Event) => any; + onorientationchange: (this: this, ev: Event) => any; + onpagehide: (this: this, ev: PageTransitionEvent) => any; + onpageshow: (this: this, ev: PageTransitionEvent) => any; + onpopstate: (this: this, ev: PopStateEvent) => any; + onresize: (this: this, ev: UIEvent) => any; + onstorage: (this: this, ev: StorageEvent) => any; + onunload: (this: this, ev: Event) => any; text: any; vLink: any; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (this: this, ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (this: this, ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (this: this, ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (this: this, ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (this: this, ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (this: this, ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4380,7 +4380,7 @@ interface HTMLButtonElement extends HTMLElement { * Overrides the target attribute on a form element. */ formTarget: string; - /** + /** * Sets or retrieves the name of the object. */ name: string; @@ -4397,7 +4397,7 @@ interface HTMLButtonElement extends HTMLElement { * Returns a ValidityState object that represents the validity states of an element. */ readonly validity: ValidityState; - /** + /** * Sets or retrieves the default or selected value of the control. */ value: string; @@ -4504,7 +4504,7 @@ declare var HTMLDirectoryElement: { interface HTMLDivElement extends HTMLElement { /** - * Sets or retrieves how the object is aligned with adjacent text. + * Sets or retrieves how the object is aligned with adjacent text. */ align: string; /** @@ -4544,73 +4544,73 @@ interface HTMLElement extends Element { readonly offsetParent: Element; readonly offsetTop: number; readonly offsetWidth: number; - onabort: (ev: UIEvent) => any; - onactivate: (ev: UIEvent) => any; - onbeforeactivate: (ev: UIEvent) => any; - onbeforecopy: (ev: ClipboardEvent) => any; - onbeforecut: (ev: ClipboardEvent) => any; - onbeforedeactivate: (ev: UIEvent) => any; - onbeforepaste: (ev: ClipboardEvent) => any; - onblur: (ev: FocusEvent) => any; - oncanplay: (ev: Event) => any; - oncanplaythrough: (ev: Event) => any; - onchange: (ev: Event) => any; - onclick: (ev: MouseEvent) => any; - oncontextmenu: (ev: PointerEvent) => any; - oncopy: (ev: ClipboardEvent) => any; - oncuechange: (ev: Event) => any; - oncut: (ev: ClipboardEvent) => any; - ondblclick: (ev: MouseEvent) => any; - ondeactivate: (ev: UIEvent) => any; - ondrag: (ev: DragEvent) => any; - ondragend: (ev: DragEvent) => any; - ondragenter: (ev: DragEvent) => any; - ondragleave: (ev: DragEvent) => any; - ondragover: (ev: DragEvent) => any; - ondragstart: (ev: DragEvent) => any; - ondrop: (ev: DragEvent) => any; - ondurationchange: (ev: Event) => any; - onemptied: (ev: Event) => any; - onended: (ev: MediaStreamErrorEvent) => any; - onerror: (ev: ErrorEvent) => any; - onfocus: (ev: FocusEvent) => any; - oninput: (ev: Event) => any; - oninvalid: (ev: Event) => any; - onkeydown: (ev: KeyboardEvent) => any; - onkeypress: (ev: KeyboardEvent) => any; - onkeyup: (ev: KeyboardEvent) => any; - onload: (ev: Event) => any; - onloadeddata: (ev: Event) => any; - onloadedmetadata: (ev: Event) => any; - onloadstart: (ev: Event) => any; - onmousedown: (ev: MouseEvent) => any; - onmouseenter: (ev: MouseEvent) => any; - onmouseleave: (ev: MouseEvent) => any; - onmousemove: (ev: MouseEvent) => any; - onmouseout: (ev: MouseEvent) => any; - onmouseover: (ev: MouseEvent) => any; - onmouseup: (ev: MouseEvent) => any; - onmousewheel: (ev: WheelEvent) => any; - onmscontentzoom: (ev: UIEvent) => any; - onmsmanipulationstatechanged: (ev: MSManipulationEvent) => any; - onpaste: (ev: ClipboardEvent) => any; - onpause: (ev: Event) => any; - onplay: (ev: Event) => any; - onplaying: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - onratechange: (ev: Event) => any; - onreset: (ev: Event) => any; - onscroll: (ev: UIEvent) => any; - onseeked: (ev: Event) => any; - onseeking: (ev: Event) => any; - onselect: (ev: UIEvent) => any; - onselectstart: (ev: Event) => any; - onstalled: (ev: Event) => any; - onsubmit: (ev: Event) => any; - onsuspend: (ev: Event) => any; - ontimeupdate: (ev: Event) => any; - onvolumechange: (ev: Event) => any; - onwaiting: (ev: Event) => any; + onabort: (this: this, ev: UIEvent) => any; + onactivate: (this: this, ev: UIEvent) => any; + onbeforeactivate: (this: this, ev: UIEvent) => any; + onbeforecopy: (this: this, ev: ClipboardEvent) => any; + onbeforecut: (this: this, ev: ClipboardEvent) => any; + onbeforedeactivate: (this: this, ev: UIEvent) => any; + onbeforepaste: (this: this, ev: ClipboardEvent) => any; + onblur: (this: this, ev: FocusEvent) => any; + oncanplay: (this: this, ev: Event) => any; + oncanplaythrough: (this: this, ev: Event) => any; + onchange: (this: this, ev: Event) => any; + onclick: (this: this, ev: MouseEvent) => any; + oncontextmenu: (this: this, ev: PointerEvent) => any; + oncopy: (this: this, ev: ClipboardEvent) => any; + oncuechange: (this: this, ev: Event) => any; + oncut: (this: this, ev: ClipboardEvent) => any; + ondblclick: (this: this, ev: MouseEvent) => any; + ondeactivate: (this: this, ev: UIEvent) => any; + ondrag: (this: this, ev: DragEvent) => any; + ondragend: (this: this, ev: DragEvent) => any; + ondragenter: (this: this, ev: DragEvent) => any; + ondragleave: (this: this, ev: DragEvent) => any; + ondragover: (this: this, ev: DragEvent) => any; + ondragstart: (this: this, ev: DragEvent) => any; + ondrop: (this: this, ev: DragEvent) => any; + ondurationchange: (this: this, ev: Event) => any; + onemptied: (this: this, ev: Event) => any; + onended: (this: this, ev: MediaStreamErrorEvent) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onfocus: (this: this, ev: FocusEvent) => any; + oninput: (this: this, ev: Event) => any; + oninvalid: (this: this, ev: Event) => any; + onkeydown: (this: this, ev: KeyboardEvent) => any; + onkeypress: (this: this, ev: KeyboardEvent) => any; + onkeyup: (this: this, ev: KeyboardEvent) => any; + onload: (this: this, ev: Event) => any; + onloadeddata: (this: this, ev: Event) => any; + onloadedmetadata: (this: this, ev: Event) => any; + onloadstart: (this: this, ev: Event) => any; + onmousedown: (this: this, ev: MouseEvent) => any; + onmouseenter: (this: this, ev: MouseEvent) => any; + onmouseleave: (this: this, ev: MouseEvent) => any; + onmousemove: (this: this, ev: MouseEvent) => any; + onmouseout: (this: this, ev: MouseEvent) => any; + onmouseover: (this: this, ev: MouseEvent) => any; + onmouseup: (this: this, ev: MouseEvent) => any; + onmousewheel: (this: this, ev: WheelEvent) => any; + onmscontentzoom: (this: this, ev: UIEvent) => any; + onmsmanipulationstatechanged: (this: this, ev: MSManipulationEvent) => any; + onpaste: (this: this, ev: ClipboardEvent) => any; + onpause: (this: this, ev: Event) => any; + onplay: (this: this, ev: Event) => any; + onplaying: (this: this, ev: Event) => any; + onprogress: (this: this, ev: ProgressEvent) => any; + onratechange: (this: this, ev: Event) => any; + onreset: (this: this, ev: Event) => any; + onscroll: (this: this, ev: UIEvent) => any; + onseeked: (this: this, ev: Event) => any; + onseeking: (this: this, ev: Event) => any; + onselect: (this: this, ev: UIEvent) => any; + onselectstart: (this: this, ev: Event) => any; + onstalled: (this: this, ev: Event) => any; + onsubmit: (this: this, ev: Event) => any; + onsuspend: (this: this, ev: Event) => any; + ontimeupdate: (this: this, ev: Event) => any; + onvolumechange: (this: this, ev: Event) => any; + onwaiting: (this: this, ev: Event) => any; outerHTML: string; outerText: string; spellcheck: boolean; @@ -4627,109 +4627,109 @@ interface HTMLElement extends Element { msGetInputContext(): MSInputMethodContext; scrollIntoView(top?: boolean): void; setActive(): void; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4971,7 +4971,7 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { /** * Raised when the object has been completely received from the server. */ - onload: (ev: Event) => any; + onload: (this: this, ev: Event) => any; /** * Sets or retrieves whether the frame can be scrolled. */ @@ -4984,110 +4984,110 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string | number; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5115,152 +5115,152 @@ interface HTMLFrameSetElement extends HTMLElement { */ frameSpacing: any; name: string; - onafterprint: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; + onafterprint: (this: this, ev: Event) => any; + onbeforeprint: (this: this, ev: Event) => any; + onbeforeunload: (this: this, ev: BeforeUnloadEvent) => any; /** * Fires when the object loses the input focus. */ - onblur: (ev: FocusEvent) => any; - onerror: (ev: ErrorEvent) => any; + onblur: (this: this, ev: FocusEvent) => any; + onerror: (this: this, ev: ErrorEvent) => any; /** * Fires when the object receives focus. */ - onfocus: (ev: FocusEvent) => any; - onhashchange: (ev: HashChangeEvent) => any; - onload: (ev: Event) => any; - onmessage: (ev: MessageEvent) => any; - onoffline: (ev: Event) => any; - ononline: (ev: Event) => any; - onorientationchange: (ev: Event) => any; - onpagehide: (ev: PageTransitionEvent) => any; - onpageshow: (ev: PageTransitionEvent) => any; - onresize: (ev: UIEvent) => any; - onstorage: (ev: StorageEvent) => any; - onunload: (ev: Event) => any; + onfocus: (this: this, ev: FocusEvent) => any; + onhashchange: (this: this, ev: HashChangeEvent) => any; + onload: (this: this, ev: Event) => any; + onmessage: (this: this, ev: MessageEvent) => any; + onoffline: (this: this, ev: Event) => any; + ononline: (this: this, ev: Event) => any; + onorientationchange: (this: this, ev: Event) => any; + onpagehide: (this: this, ev: PageTransitionEvent) => any; + onpageshow: (this: this, ev: PageTransitionEvent) => any; + onresize: (this: this, ev: UIEvent) => any; + onstorage: (this: this, ev: StorageEvent) => any; + onunload: (this: this, ev: Event) => any; /** * Sets or retrieves the frame heights of the object. */ rows: string; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (this: this, ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (this: this, ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (this: this, ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (this: this, ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (this: this, ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5380,7 +5380,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { /** * Raised when the object has been completely received from the server. */ - onload: (ev: Event) => any; + onload: (this: this, ev: Event) => any; readonly sandbox: DOMSettableTokenList; /** * Sets or retrieves whether the frame can be scrolled. @@ -5398,110 +5398,110 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5647,7 +5647,7 @@ interface HTMLInputElement extends HTMLElement { */ readonly files: FileList | null; /** - * Retrieves a reference to the form that the object is embedded in. + * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; /** @@ -5921,9 +5921,9 @@ interface HTMLMarqueeElement extends HTMLElement { height: string; hspace: number; loop: number; - onbounce: (ev: Event) => any; - onfinish: (ev: Event) => any; - onstart: (ev: Event) => any; + onbounce: (this: this, ev: Event) => any; + onfinish: (this: this, ev: Event) => any; + onstart: (this: this, ev: Event) => any; scrollAmount: number; scrollDelay: number; trueSpeed: boolean; @@ -5931,112 +5931,112 @@ interface HTMLMarqueeElement extends HTMLElement { width: string; start(): void; stop(): void; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "bounce", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "finish", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "start", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6134,8 +6134,8 @@ interface HTMLMediaElement extends HTMLElement { * Gets the current network activity for the element. */ readonly networkState: number; - onencrypted: (ev: MediaEncryptedEvent) => any; - onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + onencrypted: (this: this, ev: MediaEncryptedEvent) => any; + onmsneedkey: (this: this, ev: MSMediaKeyNeededEvent) => any; /** * Gets a flag that specifies whether playback is paused. */ @@ -6213,111 +6213,111 @@ interface HTMLMediaElement extends HTMLElement { readonly NETWORK_IDLE: number; readonly NETWORK_LOADING: number; readonly NETWORK_NO_SOURCE: number; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "encrypted", listener: (ev: MediaEncryptedEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "encrypted", listener: (this: this, ev: MediaEncryptedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (this: this, ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6367,7 +6367,7 @@ interface HTMLMetaElement extends HTMLElement { */ scheme: string; /** - * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; } @@ -6630,7 +6630,7 @@ declare var HTMLOptionsCollection: { interface HTMLParagraphElement extends HTMLElement { /** - * Sets or retrieves how the object is aligned with adjacent text. + * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; @@ -6732,10 +6732,10 @@ interface HTMLScriptElement extends HTMLElement { */ defer: boolean; /** - * Sets or retrieves the event for which the script is written. + * Sets or retrieves the event for which the script is written. */ event: string; - /** + /** * Sets or retrieves the object that is bound to the event script. */ htmlFor: string; @@ -6744,7 +6744,7 @@ interface HTMLScriptElement extends HTMLElement { */ src: string; /** - * Retrieves or sets the text of the object as a string. + * Retrieves or sets the text of the object as a string. */ text: string; /** @@ -6765,7 +6765,7 @@ interface HTMLSelectElement extends HTMLElement { autofocus: boolean; disabled: boolean; /** - * Retrieves a reference to the form that the object is embedded in. + * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; /** @@ -6791,7 +6791,7 @@ interface HTMLSelectElement extends HTMLElement { selectedIndex: number; selectedOptions: HTMLCollectionOf; /** - * Sets or retrieves the number of rows in the list box. + * Sets or retrieves the number of rows in the list box. */ size: number; /** @@ -6817,7 +6817,7 @@ interface HTMLSelectElement extends HTMLElement { /** * 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. + * @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?: HTMLElement | number): void; /** @@ -7012,7 +7012,7 @@ interface HTMLTableElement extends HTMLElement { */ border: string; /** - * Sets or retrieves the border color of the object. + * Sets or retrieves the border color of the object. */ borderColor: any; /** @@ -7307,7 +7307,7 @@ declare var HTMLTextAreaElement: { interface HTMLTitleElement extends HTMLElement { /** - * Retrieves or sets the text of the object as a string. + * Retrieves or sets the text of the object as a string. */ text: string; } @@ -7369,9 +7369,9 @@ interface HTMLVideoElement extends HTMLMediaElement { msStereo3DPackingMode: string; msStereo3DRenderMode: string; msZoom: boolean; - onMSVideoFormatChanged: (ev: Event) => any; - onMSVideoFrameStepCompleted: (ev: Event) => any; - onMSVideoOptimalLayoutChanged: (ev: Event) => any; + onMSVideoFormatChanged: (this: this, ev: Event) => any; + onMSVideoFrameStepCompleted: (this: this, ev: Event) => any; + onMSVideoOptimalLayoutChanged: (this: this, ev: Event) => any; /** * 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. */ @@ -7398,114 +7398,114 @@ interface HTMLVideoElement extends HTMLMediaElement { webkitEnterFullscreen(): void; webkitExitFullScreen(): void; webkitExitFullscreen(): void; - addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSVideoFormatChanged", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "encrypted", listener: (ev: MediaEncryptedEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (this: this, ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFormatChanged", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFrameStepCompleted", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "encrypted", listener: (this: this, ev: MediaEncryptedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (this: this, ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (this: this, ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7575,8 +7575,8 @@ declare var IDBCursorWithValue: { interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; - onabort: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; + onabort: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -7584,8 +7584,8 @@ interface IDBDatabase extends EventTarget { deleteObjectStore(name: string): void; transaction(storeNames: string | string[], mode?: string): IDBTransaction; addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7663,12 +7663,12 @@ declare var IDBObjectStore: { } interface IDBOpenDBRequest extends IDBRequest { - onblocked: (ev: Event) => any; - onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + onblocked: (this: this, ev: Event) => any; + onupgradeneeded: (this: this, ev: IDBVersionChangeEvent) => any; + addEventListener(type: "blocked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (this: this, ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7679,14 +7679,14 @@ declare var IDBOpenDBRequest: { interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (ev: ErrorEvent) => any; - onsuccess: (ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onsuccess: (this: this, ev: Event) => any; readonly readyState: string; readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7699,17 +7699,17 @@ interface IDBTransaction extends EventTarget { readonly db: IDBDatabase; readonly error: DOMError; readonly mode: string; - onabort: (ev: Event) => any; - oncomplete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; + onabort: (this: this, ev: Event) => any; + oncomplete: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; readonly READ_WRITE: string; readonly VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7843,16 +7843,16 @@ declare var MSApp: MSApp; interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; - oncomplete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; + oncomplete: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; readonly readyState: number; readonly result: any; start(): void; readonly COMPLETED: number; readonly ERROR: number; readonly STARTED: number; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8017,17 +8017,17 @@ declare var MSHTMLWebViewElement: { interface MSInputMethodContext extends EventTarget { readonly compositionEndOffset: number; readonly compositionStartOffset: number; - oncandidatewindowhide: (ev: Event) => any; - oncandidatewindowshow: (ev: Event) => any; - oncandidatewindowupdate: (ev: Event) => any; + oncandidatewindowhide: (this: this, ev: Event) => any; + oncandidatewindowshow: (this: this, ev: Event) => any; + oncandidatewindowupdate: (this: this, ev: Event) => any; readonly target: HTMLElement; getCandidateWindowClientRect(): ClientRect; getCompositionAlternatives(): string[]; hasComposition(): boolean; isCandidateWindowVisible(): boolean; - addEventListener(type: "MSCandidateWindowHide", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "MSCandidateWindowShow", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "MSCandidateWindowUpdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSCandidateWindowHide", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSCandidateWindowShow", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSCandidateWindowUpdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8203,8 +8203,8 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; - oncomplete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; + oncomplete: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -8216,8 +8216,8 @@ interface MSWebViewAsyncOperation extends EventTarget { readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; readonly TYPE_INVOKE_SCRIPT: number; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8255,11 +8255,11 @@ declare var MediaDeviceInfo: { } interface MediaDevices extends EventTarget { - ondevicechange: (ev: Event) => any; + ondevicechange: (this: this, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): PromiseLike; - addEventListener(type: "devicechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "devicechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8412,10 +8412,10 @@ declare var MediaSource: { interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; - onactive: (ev: Event) => any; - onaddtrack: (ev: TrackEvent) => any; - oninactive: (ev: Event) => any; - onremovetrack: (ev: TrackEvent) => any; + onactive: (this: this, ev: Event) => any; + onaddtrack: (this: this, ev: TrackEvent) => any; + oninactive: (this: this, ev: Event) => any; + onremovetrack: (this: this, ev: TrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -8424,10 +8424,10 @@ interface MediaStream extends EventTarget { getVideoTracks(): MediaStreamTrack[]; removeTrack(track: MediaStreamTrack): void; stop(): void; - addEventListener(type: "active", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; - addEventListener(type: "inactive", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "active", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (this: this, ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "inactive", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (this: this, ev: TrackEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8470,10 +8470,10 @@ interface MediaStreamTrack extends EventTarget { readonly kind: string; readonly label: string; readonly muted: boolean; - onended: (ev: MediaStreamErrorEvent) => any; - onmute: (ev: Event) => any; - onoverconstrained: (ev: MediaStreamErrorEvent) => any; - onunmute: (ev: Event) => any; + onended: (this: this, ev: MediaStreamErrorEvent) => any; + onmute: (this: this, ev: Event) => any; + onoverconstrained: (this: this, ev: MediaStreamErrorEvent) => any; + onunmute: (this: this, ev: Event) => any; readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; @@ -8483,10 +8483,10 @@ interface MediaStreamTrack extends EventTarget { getConstraints(): MediaTrackConstraints; getSettings(): MediaTrackSettings; stop(): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mute", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "overconstrained", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "unmute", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mute", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "overconstrained", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unmute", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8528,11 +8528,11 @@ declare var MessageEvent: { } interface MessagePort extends EventTarget { - onmessage: (ev: MessageEvent) => any; + onmessage: (this: this, 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: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8885,9 +8885,9 @@ declare var OfflineAudioCompletionEvent: { } interface OfflineAudioContext extends AudioContext { - oncomplete: (ev: Event) => any; + oncomplete: (this: this, ev: Event) => any; startRendering(): PromiseLike; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8899,12 +8899,12 @@ declare var OfflineAudioContext: { interface OscillatorNode extends AudioNode { readonly detune: AudioParam; readonly frequency: AudioParam; - onended: (ev: MediaStreamErrorEvent) => any; + onended: (this: this, ev: MediaStreamErrorEvent) => any; type: string; setPeriodicWave(periodicWave: PeriodicWave): void; start(when?: number): void; stop(when?: number): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9283,8 +9283,8 @@ declare var RTCDTMFToneChangeEvent: { } interface RTCDtlsTransport extends RTCStatsProvider { - ondtlsstatechange: ((ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((ev: ErrorEvent) => any) | null; + ondtlsstatechange: ((this: this, ev: RTCDtlsTransportStateChangedEvent) => any) | null; + onerror: ((this: this, ev: ErrorEvent) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -9292,8 +9292,8 @@ interface RTCDtlsTransport extends RTCStatsProvider { getRemoteParameters(): RTCDtlsParameters | null; start(remoteParameters: RTCDtlsParameters): void; stop(): void; - addEventListener(type: "dtlsstatechange", listener: (ev: RTCDtlsTransportStateChangedEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dtlsstatechange", listener: (this: this, ev: RTCDtlsTransportStateChangedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9315,11 +9315,11 @@ interface RTCDtmfSender extends EventTarget { readonly canInsertDTMF: boolean; readonly duration: number; readonly interToneGap: number; - ontonechange: (ev: RTCDTMFToneChangeEvent) => any; + ontonechange: (this: this, ev: RTCDTMFToneChangeEvent) => any; readonly sender: RTCRtpSender; readonly toneBuffer: string; insertDTMF(tones: string, duration?: number, interToneGap?: number): void; - addEventListener(type: "tonechange", listener: (ev: RTCDTMFToneChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "tonechange", listener: (this: this, ev: RTCDTMFToneChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9339,13 +9339,13 @@ declare var RTCIceCandidatePairChangedEvent: { interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((ev: ErrorEvent) => any) | null; - onlocalcandidate: ((ev: RTCIceGathererEvent) => any) | null; + onerror: ((this: this, ev: ErrorEvent) => any) | null; + onlocalcandidate: ((this: this, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; getLocalCandidates(): RTCIceCandidate[]; getLocalParameters(): RTCIceParameters; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "localcandidate", listener: (ev: RTCIceGathererEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "localcandidate", listener: (this: this, ev: RTCIceGathererEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9366,8 +9366,8 @@ declare var RTCIceGathererEvent: { interface RTCIceTransport extends RTCStatsProvider { readonly component: string; readonly iceGatherer: RTCIceGatherer | null; - oncandidatepairchange: ((ev: RTCIceCandidatePairChangedEvent) => any) | null; - onicestatechange: ((ev: RTCIceTransportStateChangedEvent) => any) | null; + oncandidatepairchange: ((this: this, ev: RTCIceCandidatePairChangedEvent) => any) | null; + onicestatechange: ((this: this, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; @@ -9378,8 +9378,8 @@ interface RTCIceTransport extends RTCStatsProvider { setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; - addEventListener(type: "candidatepairchange", listener: (ev: RTCIceCandidatePairChangedEvent) => any, useCapture?: boolean): void; - addEventListener(type: "icestatechange", listener: (ev: RTCIceTransportStateChangedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "candidatepairchange", listener: (this: this, ev: RTCIceCandidatePairChangedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "icestatechange", listener: (this: this, ev: RTCIceTransportStateChangedEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9398,7 +9398,7 @@ declare var RTCIceTransportStateChangedEvent: { } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((ev: ErrorEvent) => any) | null; + onerror: ((this: this, ev: ErrorEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -9407,7 +9407,7 @@ interface RTCRtpReceiver extends RTCStatsProvider { requestSendCSRC(csrc: number): void; setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; stop(): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9418,8 +9418,8 @@ declare var RTCRtpReceiver: { } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((ev: ErrorEvent) => any) | null; - onssrcconflict: ((ev: RTCSsrcConflictEvent) => any) | null; + onerror: ((this: this, ev: ErrorEvent) => any) | null; + onssrcconflict: ((this: this, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -9427,8 +9427,8 @@ interface RTCRtpSender extends RTCStatsProvider { setTrack(track: MediaStreamTrack): void; setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; stop(): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ssrcconflict", listener: (ev: RTCSsrcConflictEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ssrcconflict", listener: (this: this, ev: RTCSsrcConflictEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9439,9 +9439,9 @@ declare var RTCRtpSender: { } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((ev: ErrorEvent) => any) | null; + onerror: ((this: this, ev: ErrorEvent) => any) | null; readonly transport: RTCIceTransport; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9736,66 +9736,66 @@ declare var SVGDescElement: { } interface SVGElement extends Element { - onclick: (ev: MouseEvent) => any; - ondblclick: (ev: MouseEvent) => any; - onfocusin: (ev: FocusEvent) => any; - onfocusout: (ev: FocusEvent) => any; - onload: (ev: Event) => any; - onmousedown: (ev: MouseEvent) => any; - onmousemove: (ev: MouseEvent) => any; - onmouseout: (ev: MouseEvent) => any; - onmouseover: (ev: MouseEvent) => any; - onmouseup: (ev: MouseEvent) => any; + onclick: (this: this, ev: MouseEvent) => any; + ondblclick: (this: this, ev: MouseEvent) => any; + onfocusin: (this: this, ev: FocusEvent) => any; + onfocusout: (this: this, ev: FocusEvent) => any; + onload: (this: this, ev: Event) => any; + onmousedown: (this: this, ev: MouseEvent) => any; + onmousemove: (this: this, ev: MouseEvent) => any; + onmouseout: (this: this, ev: MouseEvent) => any; + onmouseover: (this: this, ev: MouseEvent) => any; + onmouseup: (this: this, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; readonly viewportElement: SVGElement; xmlbase: string; className: any; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10926,12 +10926,12 @@ interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTest currentScale: number; readonly currentTranslate: SVGPoint; readonly height: SVGAnimatedLength; - onabort: (ev: Event) => any; - onerror: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - onscroll: (ev: UIEvent) => any; - onunload: (ev: Event) => any; - onzoom: (ev: SVGZoomEvent) => any; + onabort: (this: this, ev: Event) => any; + onerror: (this: this, ev: Event) => any; + onresize: (this: this, ev: UIEvent) => any; + onscroll: (this: this, ev: UIEvent) => any; + onunload: (this: this, ev: Event) => any; + onzoom: (this: this, ev: SVGZoomEvent) => any; readonly pixelUnitToMillimeterX: number; readonly pixelUnitToMillimeterY: number; readonly screenPixelToMillimeterX: number; @@ -10963,58 +10963,58 @@ interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTest unpauseAnimations(): void; unsuspendRedraw(suspendHandleID: number): void; unsuspendRedrawAll(): void; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "SVGAbort", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "SVGError", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "SVGUnload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "SVGZoom", listener: (ev: SVGZoomEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "SVGAbort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGError", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGUnload", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGZoom", listener: (this: this, ev: SVGZoomEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (this: this, ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (this: this, ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (this: this, ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11295,14 +11295,14 @@ interface Screen extends EventTarget { readonly logicalXDPI: number; readonly logicalYDPI: number; readonly msOrientation: string; - onmsorientationchange: (ev: Event) => any; + onmsorientationchange: (this: this, ev: Event) => any; readonly pixelDepth: number; readonly systemXDPI: number; readonly systemYDPI: number; readonly width: number; msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; - addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSOrientationChange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11323,8 +11323,8 @@ declare var ScriptNotifyEvent: { interface ScriptProcessorNode extends AudioNode { readonly bufferSize: number; - onaudioprocess: (ev: AudioProcessingEvent) => any; - addEventListener(type: "audioprocess", listener: (ev: AudioProcessingEvent) => any, useCapture?: boolean): void; + onaudioprocess: (this: this, ev: AudioProcessingEvent) => any; + addEventListener(type: "audioprocess", listener: (this: this, ev: AudioProcessingEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11563,9 +11563,9 @@ interface TextTrack extends EventTarget { readonly label: string; readonly language: string; mode: any; - oncuechange: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; + oncuechange: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onload: (this: this, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; removeCue(cue: TextTrackCue): void; @@ -11576,9 +11576,9 @@ interface TextTrack extends EventTarget { readonly LOADING: number; readonly NONE: number; readonly SHOWING: number; - addEventListener(type: "cuechange", listener: (ev: Event) => 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: "cuechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11597,15 +11597,15 @@ declare var TextTrack: { interface TextTrackCue extends EventTarget { endTime: number; id: string; - onenter: (ev: Event) => any; - onexit: (ev: Event) => any; + onenter: (this: this, ev: Event) => any; + onexit: (this: this, ev: Event) => any; pauseOnExit: boolean; startTime: number; text: string; readonly track: TextTrack; getCueAsHTML(): DocumentFragment; - addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "enter", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "exit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11628,9 +11628,9 @@ declare var TextTrackCueList: { interface TextTrackList extends EventTarget { readonly length: number; - onaddtrack: ((ev: TrackEvent) => any) | null; + onaddtrack: ((this: this, ev: TrackEvent) => any) | null; item(index: number): TextTrack; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (this: this, ev: TrackEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [index: number]: TextTrack; } @@ -11822,15 +11822,15 @@ declare var VideoTrack: { interface VideoTrackList extends EventTarget { readonly length: number; - onaddtrack: (ev: TrackEvent) => any; - onchange: (ev: Event) => any; - onremovetrack: (ev: TrackEvent) => any; + onaddtrack: (this: this, ev: TrackEvent) => any; + onchange: (this: this, ev: Event) => any; + onremovetrack: (this: this, ev: TrackEvent) => any; readonly selectedIndex: number; getTrackById(id: string): VideoTrack | null; item(index: number): VideoTrack; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (this: this, ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (this: this, ev: TrackEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [index: number]: VideoTrack; } @@ -12780,10 +12780,10 @@ interface WebSocket extends EventTarget { binaryType: string; readonly bufferedAmount: number; readonly extensions: string; - onclose: (ev: CloseEvent) => any; - onerror: (ev: ErrorEvent) => any; - onmessage: (ev: MessageEvent) => any; - onopen: (ev: Event) => any; + onclose: (this: this, ev: CloseEvent) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onmessage: (this: this, ev: MessageEvent) => any; + onopen: (this: this, ev: Event) => any; readonly protocol: string; readonly readyState: number; readonly url: string; @@ -12793,10 +12793,10 @@ interface WebSocket extends EventTarget { readonly CLOSING: number; readonly CONNECTING: number; readonly OPEN: number; - addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "close", listener: (this: this, ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "open", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12856,97 +12856,97 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window name: string; readonly navigator: Navigator; offscreenBuffering: string | boolean; - onabort: (ev: UIEvent) => any; - onafterprint: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onblur: (ev: FocusEvent) => any; - oncanplay: (ev: Event) => any; - oncanplaythrough: (ev: Event) => any; - onchange: (ev: Event) => any; - onclick: (ev: MouseEvent) => any; - oncompassneedscalibration: (ev: Event) => any; - oncontextmenu: (ev: PointerEvent) => any; - ondblclick: (ev: MouseEvent) => any; - ondevicelight: (ev: DeviceLightEvent) => any; - ondevicemotion: (ev: DeviceMotionEvent) => any; - ondeviceorientation: (ev: DeviceOrientationEvent) => any; - ondrag: (ev: DragEvent) => any; - ondragend: (ev: DragEvent) => any; - ondragenter: (ev: DragEvent) => any; - ondragleave: (ev: DragEvent) => any; - ondragover: (ev: DragEvent) => any; - ondragstart: (ev: DragEvent) => any; - ondrop: (ev: DragEvent) => any; - ondurationchange: (ev: Event) => any; - onemptied: (ev: Event) => any; - onended: (ev: MediaStreamErrorEvent) => any; + onabort: (this: this, ev: UIEvent) => any; + onafterprint: (this: this, ev: Event) => any; + onbeforeprint: (this: this, ev: Event) => any; + onbeforeunload: (this: this, ev: BeforeUnloadEvent) => any; + onblur: (this: this, ev: FocusEvent) => any; + oncanplay: (this: this, ev: Event) => any; + oncanplaythrough: (this: this, ev: Event) => any; + onchange: (this: this, ev: Event) => any; + onclick: (this: this, ev: MouseEvent) => any; + oncompassneedscalibration: (this: this, ev: Event) => any; + oncontextmenu: (this: this, ev: PointerEvent) => any; + ondblclick: (this: this, ev: MouseEvent) => any; + ondevicelight: (this: this, ev: DeviceLightEvent) => any; + ondevicemotion: (this: this, ev: DeviceMotionEvent) => any; + ondeviceorientation: (this: this, ev: DeviceOrientationEvent) => any; + ondrag: (this: this, ev: DragEvent) => any; + ondragend: (this: this, ev: DragEvent) => any; + ondragenter: (this: this, ev: DragEvent) => any; + ondragleave: (this: this, ev: DragEvent) => any; + ondragover: (this: this, ev: DragEvent) => any; + ondragstart: (this: this, ev: DragEvent) => any; + ondrop: (this: this, ev: DragEvent) => any; + ondurationchange: (this: this, ev: Event) => any; + onemptied: (this: this, ev: Event) => any; + onended: (this: this, ev: MediaStreamErrorEvent) => any; onerror: ErrorEventHandler; - onfocus: (ev: FocusEvent) => any; - onhashchange: (ev: HashChangeEvent) => any; - oninput: (ev: Event) => any; - oninvalid: (ev: Event) => any; - onkeydown: (ev: KeyboardEvent) => any; - onkeypress: (ev: KeyboardEvent) => any; - onkeyup: (ev: KeyboardEvent) => any; - onload: (ev: Event) => any; - onloadeddata: (ev: Event) => any; - onloadedmetadata: (ev: Event) => any; - onloadstart: (ev: Event) => any; - onmessage: (ev: MessageEvent) => any; - onmousedown: (ev: MouseEvent) => any; - onmouseenter: (ev: MouseEvent) => any; - onmouseleave: (ev: MouseEvent) => any; - onmousemove: (ev: MouseEvent) => any; - onmouseout: (ev: MouseEvent) => any; - onmouseover: (ev: MouseEvent) => any; - onmouseup: (ev: MouseEvent) => any; - onmousewheel: (ev: WheelEvent) => any; - onmsgesturechange: (ev: MSGestureEvent) => any; - onmsgesturedoubletap: (ev: MSGestureEvent) => any; - onmsgestureend: (ev: MSGestureEvent) => any; - onmsgesturehold: (ev: MSGestureEvent) => any; - onmsgesturestart: (ev: MSGestureEvent) => any; - onmsgesturetap: (ev: MSGestureEvent) => any; - onmsinertiastart: (ev: MSGestureEvent) => any; - onmspointercancel: (ev: MSPointerEvent) => any; - onmspointerdown: (ev: MSPointerEvent) => any; - onmspointerenter: (ev: MSPointerEvent) => any; - onmspointerleave: (ev: MSPointerEvent) => any; - onmspointermove: (ev: MSPointerEvent) => any; - onmspointerout: (ev: MSPointerEvent) => any; - onmspointerover: (ev: MSPointerEvent) => any; - onmspointerup: (ev: MSPointerEvent) => any; - onoffline: (ev: Event) => any; - ononline: (ev: Event) => any; - onorientationchange: (ev: Event) => any; - onpagehide: (ev: PageTransitionEvent) => any; - onpageshow: (ev: PageTransitionEvent) => any; - onpause: (ev: Event) => any; - onplay: (ev: Event) => any; - onplaying: (ev: Event) => any; - onpopstate: (ev: PopStateEvent) => any; - onprogress: (ev: ProgressEvent) => any; - onratechange: (ev: Event) => any; - onreadystatechange: (ev: ProgressEvent) => any; - onreset: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - onscroll: (ev: UIEvent) => any; - onseeked: (ev: Event) => any; - onseeking: (ev: Event) => any; - onselect: (ev: UIEvent) => any; - onstalled: (ev: Event) => any; - onstorage: (ev: StorageEvent) => any; - onsubmit: (ev: Event) => any; - onsuspend: (ev: Event) => any; - ontimeupdate: (ev: Event) => any; + onfocus: (this: this, ev: FocusEvent) => any; + onhashchange: (this: this, ev: HashChangeEvent) => any; + oninput: (this: this, ev: Event) => any; + oninvalid: (this: this, ev: Event) => any; + onkeydown: (this: this, ev: KeyboardEvent) => any; + onkeypress: (this: this, ev: KeyboardEvent) => any; + onkeyup: (this: this, ev: KeyboardEvent) => any; + onload: (this: this, ev: Event) => any; + onloadeddata: (this: this, ev: Event) => any; + onloadedmetadata: (this: this, ev: Event) => any; + onloadstart: (this: this, ev: Event) => any; + onmessage: (this: this, ev: MessageEvent) => any; + onmousedown: (this: this, ev: MouseEvent) => any; + onmouseenter: (this: this, ev: MouseEvent) => any; + onmouseleave: (this: this, ev: MouseEvent) => any; + onmousemove: (this: this, ev: MouseEvent) => any; + onmouseout: (this: this, ev: MouseEvent) => any; + onmouseover: (this: this, ev: MouseEvent) => any; + onmouseup: (this: this, ev: MouseEvent) => any; + onmousewheel: (this: this, ev: WheelEvent) => any; + onmsgesturechange: (this: this, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: this, ev: MSGestureEvent) => any; + onmsgestureend: (this: this, ev: MSGestureEvent) => any; + onmsgesturehold: (this: this, ev: MSGestureEvent) => any; + onmsgesturestart: (this: this, ev: MSGestureEvent) => any; + onmsgesturetap: (this: this, ev: MSGestureEvent) => any; + onmsinertiastart: (this: this, ev: MSGestureEvent) => any; + onmspointercancel: (this: this, ev: MSPointerEvent) => any; + onmspointerdown: (this: this, ev: MSPointerEvent) => any; + onmspointerenter: (this: this, ev: MSPointerEvent) => any; + onmspointerleave: (this: this, ev: MSPointerEvent) => any; + onmspointermove: (this: this, ev: MSPointerEvent) => any; + onmspointerout: (this: this, ev: MSPointerEvent) => any; + onmspointerover: (this: this, ev: MSPointerEvent) => any; + onmspointerup: (this: this, ev: MSPointerEvent) => any; + onoffline: (this: this, ev: Event) => any; + ononline: (this: this, ev: Event) => any; + onorientationchange: (this: this, ev: Event) => any; + onpagehide: (this: this, ev: PageTransitionEvent) => any; + onpageshow: (this: this, ev: PageTransitionEvent) => any; + onpause: (this: this, ev: Event) => any; + onplay: (this: this, ev: Event) => any; + onplaying: (this: this, ev: Event) => any; + onpopstate: (this: this, ev: PopStateEvent) => any; + onprogress: (this: this, ev: ProgressEvent) => any; + onratechange: (this: this, ev: Event) => any; + onreadystatechange: (this: this, ev: ProgressEvent) => any; + onreset: (this: this, ev: Event) => any; + onresize: (this: this, ev: UIEvent) => any; + onscroll: (this: this, ev: UIEvent) => any; + onseeked: (this: this, ev: Event) => any; + onseeking: (this: this, ev: Event) => any; + onselect: (this: this, ev: UIEvent) => any; + onstalled: (this: this, ev: Event) => any; + onstorage: (this: this, ev: StorageEvent) => any; + onsubmit: (this: this, ev: Event) => any; + onsuspend: (this: this, ev: Event) => any; + ontimeupdate: (this: this, ev: Event) => any; ontouchcancel: (ev: TouchEvent) => any; ontouchend: (ev: TouchEvent) => any; ontouchmove: (ev: TouchEvent) => any; ontouchstart: (ev: TouchEvent) => any; - onunload: (ev: Event) => any; - onvolumechange: (ev: Event) => any; - onwaiting: (ev: Event) => any; + onunload: (this: this, ev: Event) => any; + onvolumechange: (this: this, ev: Event) => any; + onwaiting: (this: this, ev: Event) => any; readonly opener: Window; orientation: string | number; readonly outerHeight: number; @@ -13002,101 +13002,101 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; - addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => 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: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "devicelight", listener: (ev: DeviceLightEvent) => 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: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", 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: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", 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: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (this: this, ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (this: this, ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "compassneedscalibration", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicelight", listener: (this: this, ev: DeviceLightEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicemotion", listener: (this: this, ev: DeviceMotionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deviceorientation", listener: (this: this, ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (this: this, ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (this: this, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (this: this, ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (this: this, ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (this: this, ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (this: this, ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (this: this, ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (this: this, ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (this: this, ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (this: this, ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [index: number]: Window; } @@ -13107,11 +13107,11 @@ declare var Window: { } interface Worker extends EventTarget, AbstractWorker { - onmessage: (ev: MessageEvent) => any; + onmessage: (this: this, 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: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13129,7 +13129,7 @@ declare var XMLDocument: { } interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { - onreadystatechange: (ev: ProgressEvent) => any; + onreadystatechange: (this: this, ev: ProgressEvent) => any; readonly readyState: number; readonly response: any; readonly responseText: string; @@ -13156,14 +13156,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - addEventListener(type: "abort", listener: (ev: Event) => 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: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13279,8 +13279,8 @@ declare var XSLTProcessor: { } interface AbstractWorker { - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onerror: (this: this, ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13392,24 +13392,24 @@ interface GetSVGDocument { } interface GlobalEventHandlers { - onpointercancel: (ev: PointerEvent) => any; - onpointerdown: (ev: PointerEvent) => any; - onpointerenter: (ev: PointerEvent) => any; - onpointerleave: (ev: PointerEvent) => any; - onpointermove: (ev: PointerEvent) => any; - onpointerout: (ev: PointerEvent) => any; - onpointerover: (ev: PointerEvent) => any; - onpointerup: (ev: PointerEvent) => any; - onwheel: (ev: WheelEvent) => any; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + onpointercancel: (this: this, ev: PointerEvent) => any; + onpointerdown: (this: this, ev: PointerEvent) => any; + onpointerenter: (this: this, ev: PointerEvent) => any; + onpointerleave: (this: this, ev: PointerEvent) => any; + onpointermove: (this: this, ev: PointerEvent) => any; + onpointerout: (this: this, ev: PointerEvent) => any; + onpointerover: (this: this, ev: PointerEvent) => any; + onpointerup: (this: this, ev: PointerEvent) => any; + onwheel: (this: this, ev: WheelEvent) => any; + addEventListener(type: "pointercancel", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (this: this, ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13437,24 +13437,24 @@ interface LinkStyle { } interface MSBaseReader { - onabort: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; - onloadend: (ev: ProgressEvent) => any; - onloadstart: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; + onabort: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onload: (this: this, ev: Event) => any; + onloadend: (this: this, ev: ProgressEvent) => any; + onloadstart: (this: this, ev: Event) => any; + onprogress: (this: this, ev: ProgressEvent) => any; readonly readyState: number; readonly result: any; abort(): void; readonly DONE: number; readonly EMPTY: number; readonly LOADING: number; - addEventListener(type: "abort", listener: (ev: Event) => 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: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13956,20 +13956,20 @@ interface WindowTimersExtension { } interface XMLHttpRequestEventTarget { - onabort: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; - onloadend: (ev: ProgressEvent) => any; - onloadstart: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: Event) => 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: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + onabort: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onload: (this: this, ev: Event) => any; + onloadend: (this: this, ev: ProgressEvent) => any; + onloadstart: (this: this, ev: Event) => any; + onprogress: (this: this, ev: ProgressEvent) => any; + ontimeout: (this: this, ev: ProgressEvent) => any; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14281,97 +14281,97 @@ declare var msCredentials: MSCredentials; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; -declare var onabort: (ev: UIEvent) => any; -declare var onafterprint: (ev: Event) => any; -declare var onbeforeprint: (ev: Event) => any; -declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; -declare var onblur: (ev: FocusEvent) => any; -declare var oncanplay: (ev: Event) => any; -declare var oncanplaythrough: (ev: Event) => any; -declare var onchange: (ev: Event) => any; -declare var onclick: (ev: MouseEvent) => any; -declare var oncompassneedscalibration: (ev: Event) => any; -declare var oncontextmenu: (ev: PointerEvent) => any; -declare var ondblclick: (ev: MouseEvent) => any; -declare var ondevicelight: (ev: DeviceLightEvent) => any; -declare var ondevicemotion: (ev: DeviceMotionEvent) => any; -declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; -declare var ondrag: (ev: DragEvent) => any; -declare var ondragend: (ev: DragEvent) => any; -declare var ondragenter: (ev: DragEvent) => any; -declare var ondragleave: (ev: DragEvent) => any; -declare var ondragover: (ev: DragEvent) => any; -declare var ondragstart: (ev: DragEvent) => any; -declare var ondrop: (ev: DragEvent) => any; -declare var ondurationchange: (ev: Event) => any; -declare var onemptied: (ev: Event) => any; -declare var onended: (ev: MediaStreamErrorEvent) => any; +declare var onabort: (this: Window, ev: UIEvent) => any; +declare var onafterprint: (this: Window, ev: Event) => any; +declare var onbeforeprint: (this: Window, ev: Event) => any; +declare var onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; +declare var onblur: (this: Window, ev: FocusEvent) => any; +declare var oncanplay: (this: Window, ev: Event) => any; +declare var oncanplaythrough: (this: Window, ev: Event) => any; +declare var onchange: (this: Window, ev: Event) => any; +declare var onclick: (this: Window, ev: MouseEvent) => any; +declare var oncompassneedscalibration: (this: Window, ev: Event) => any; +declare var oncontextmenu: (this: Window, ev: PointerEvent) => any; +declare var ondblclick: (this: Window, ev: MouseEvent) => any; +declare var ondevicelight: (this: Window, ev: DeviceLightEvent) => any; +declare var ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; +declare var ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; +declare var ondrag: (this: Window, ev: DragEvent) => any; +declare var ondragend: (this: Window, ev: DragEvent) => any; +declare var ondragenter: (this: Window, ev: DragEvent) => any; +declare var ondragleave: (this: Window, ev: DragEvent) => any; +declare var ondragover: (this: Window, ev: DragEvent) => any; +declare var ondragstart: (this: Window, ev: DragEvent) => any; +declare var ondrop: (this: Window, ev: DragEvent) => any; +declare var ondurationchange: (this: Window, ev: Event) => any; +declare var onemptied: (this: Window, ev: Event) => any; +declare var onended: (this: Window, ev: MediaStreamErrorEvent) => any; declare var onerror: ErrorEventHandler; -declare var onfocus: (ev: FocusEvent) => any; -declare var onhashchange: (ev: HashChangeEvent) => any; -declare var oninput: (ev: Event) => any; -declare var oninvalid: (ev: Event) => any; -declare var onkeydown: (ev: KeyboardEvent) => any; -declare var onkeypress: (ev: KeyboardEvent) => any; -declare var onkeyup: (ev: KeyboardEvent) => any; -declare var onload: (ev: Event) => any; -declare var onloadeddata: (ev: Event) => any; -declare var onloadedmetadata: (ev: Event) => any; -declare var onloadstart: (ev: Event) => any; -declare var onmessage: (ev: MessageEvent) => any; -declare var onmousedown: (ev: MouseEvent) => any; -declare var onmouseenter: (ev: MouseEvent) => any; -declare var onmouseleave: (ev: MouseEvent) => any; -declare var onmousemove: (ev: MouseEvent) => any; -declare var onmouseout: (ev: MouseEvent) => any; -declare var onmouseover: (ev: MouseEvent) => any; -declare var onmouseup: (ev: MouseEvent) => any; -declare var onmousewheel: (ev: WheelEvent) => any; -declare var onmsgesturechange: (ev: MSGestureEvent) => any; -declare var onmsgesturedoubletap: (ev: MSGestureEvent) => any; -declare var onmsgestureend: (ev: MSGestureEvent) => any; -declare var onmsgesturehold: (ev: MSGestureEvent) => any; -declare var onmsgesturestart: (ev: MSGestureEvent) => any; -declare var onmsgesturetap: (ev: MSGestureEvent) => any; -declare var onmsinertiastart: (ev: MSGestureEvent) => any; -declare var onmspointercancel: (ev: MSPointerEvent) => any; -declare var onmspointerdown: (ev: MSPointerEvent) => any; -declare var onmspointerenter: (ev: MSPointerEvent) => any; -declare var onmspointerleave: (ev: MSPointerEvent) => any; -declare var onmspointermove: (ev: MSPointerEvent) => any; -declare var onmspointerout: (ev: MSPointerEvent) => any; -declare var onmspointerover: (ev: MSPointerEvent) => any; -declare var onmspointerup: (ev: MSPointerEvent) => any; -declare var onoffline: (ev: Event) => any; -declare var ononline: (ev: Event) => any; -declare var onorientationchange: (ev: Event) => any; -declare var onpagehide: (ev: PageTransitionEvent) => any; -declare var onpageshow: (ev: PageTransitionEvent) => any; -declare var onpause: (ev: Event) => any; -declare var onplay: (ev: Event) => any; -declare var onplaying: (ev: Event) => any; -declare var onpopstate: (ev: PopStateEvent) => any; -declare var onprogress: (ev: ProgressEvent) => any; -declare var onratechange: (ev: Event) => any; -declare var onreadystatechange: (ev: ProgressEvent) => any; -declare var onreset: (ev: Event) => any; -declare var onresize: (ev: UIEvent) => any; -declare var onscroll: (ev: UIEvent) => any; -declare var onseeked: (ev: Event) => any; -declare var onseeking: (ev: Event) => any; -declare var onselect: (ev: UIEvent) => any; -declare var onstalled: (ev: Event) => any; -declare var onstorage: (ev: StorageEvent) => any; -declare var onsubmit: (ev: Event) => any; -declare var onsuspend: (ev: Event) => any; -declare var ontimeupdate: (ev: Event) => any; +declare var onfocus: (this: Window, ev: FocusEvent) => any; +declare var onhashchange: (this: Window, ev: HashChangeEvent) => any; +declare var oninput: (this: Window, ev: Event) => any; +declare var oninvalid: (this: Window, ev: Event) => any; +declare var onkeydown: (this: Window, ev: KeyboardEvent) => any; +declare var onkeypress: (this: Window, ev: KeyboardEvent) => any; +declare var onkeyup: (this: Window, ev: KeyboardEvent) => any; +declare var onload: (this: Window, ev: Event) => any; +declare var onloadeddata: (this: Window, ev: Event) => any; +declare var onloadedmetadata: (this: Window, ev: Event) => any; +declare var onloadstart: (this: Window, ev: Event) => any; +declare var onmessage: (this: Window, ev: MessageEvent) => any; +declare var onmousedown: (this: Window, ev: MouseEvent) => any; +declare var onmouseenter: (this: Window, ev: MouseEvent) => any; +declare var onmouseleave: (this: Window, ev: MouseEvent) => any; +declare var onmousemove: (this: Window, ev: MouseEvent) => any; +declare var onmouseout: (this: Window, ev: MouseEvent) => any; +declare var onmouseover: (this: Window, ev: MouseEvent) => any; +declare var onmouseup: (this: Window, ev: MouseEvent) => any; +declare var onmousewheel: (this: Window, ev: WheelEvent) => any; +declare var onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgestureend: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; +declare var onmspointercancel: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerdown: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerenter: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerleave: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointermove: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerout: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerover: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerup: (this: Window, ev: MSPointerEvent) => any; +declare var onoffline: (this: Window, ev: Event) => any; +declare var ononline: (this: Window, ev: Event) => any; +declare var onorientationchange: (this: Window, ev: Event) => any; +declare var onpagehide: (this: Window, ev: PageTransitionEvent) => any; +declare var onpageshow: (this: Window, ev: PageTransitionEvent) => any; +declare var onpause: (this: Window, ev: Event) => any; +declare var onplay: (this: Window, ev: Event) => any; +declare var onplaying: (this: Window, ev: Event) => any; +declare var onpopstate: (this: Window, ev: PopStateEvent) => any; +declare var onprogress: (this: Window, ev: ProgressEvent) => any; +declare var onratechange: (this: Window, ev: Event) => any; +declare var onreadystatechange: (this: Window, ev: ProgressEvent) => any; +declare var onreset: (this: Window, ev: Event) => any; +declare var onresize: (this: Window, ev: UIEvent) => any; +declare var onscroll: (this: Window, ev: UIEvent) => any; +declare var onseeked: (this: Window, ev: Event) => any; +declare var onseeking: (this: Window, ev: Event) => any; +declare var onselect: (this: Window, ev: UIEvent) => any; +declare var onstalled: (this: Window, ev: Event) => any; +declare var onstorage: (this: Window, ev: StorageEvent) => any; +declare var onsubmit: (this: Window, ev: Event) => any; +declare var onsuspend: (this: Window, ev: Event) => any; +declare var ontimeupdate: (this: Window, ev: Event) => any; declare var ontouchcancel: (ev: TouchEvent) => any; declare var ontouchend: (ev: TouchEvent) => any; declare var ontouchmove: (ev: TouchEvent) => any; declare var ontouchstart: (ev: TouchEvent) => any; -declare var onunload: (ev: Event) => any; -declare var onvolumechange: (ev: Event) => any; -declare var onwaiting: (ev: Event) => any; +declare var onunload: (this: Window, ev: Event) => any; +declare var onvolumechange: (this: Window, ev: Event) => any; +declare var onwaiting: (this: Window, ev: Event) => any; declare var opener: Window; declare var orientation: string | number; declare var outerHeight: number; @@ -14441,113 +14441,113 @@ declare function setImmediate(handler: any, ...args: any[]): number; declare var sessionStorage: Storage; declare var localStorage: Storage; declare var console: Console; -declare var onpointercancel: (ev: PointerEvent) => any; -declare var onpointerdown: (ev: PointerEvent) => any; -declare var onpointerenter: (ev: PointerEvent) => any; -declare var onpointerleave: (ev: PointerEvent) => any; -declare var onpointermove: (ev: PointerEvent) => any; -declare var onpointerout: (ev: PointerEvent) => any; -declare var onpointerover: (ev: PointerEvent) => any; -declare var onpointerup: (ev: PointerEvent) => any; -declare var onwheel: (ev: WheelEvent) => any; +declare var onpointercancel: (this: Window, ev: PointerEvent) => any; +declare var onpointerdown: (this: Window, ev: PointerEvent) => any; +declare var onpointerenter: (this: Window, ev: PointerEvent) => any; +declare var onpointerleave: (this: Window, ev: PointerEvent) => any; +declare var onpointermove: (this: Window, ev: PointerEvent) => any; +declare var onpointerout: (this: Window, ev: PointerEvent) => any; +declare var onpointerover: (this: Window, ev: PointerEvent) => any; +declare var onpointerup: (this: Window, ev: PointerEvent) => any; +declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; -declare function addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "devicelight", listener: (ev: DeviceLightEvent) => 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: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pause", 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: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureChange", listener: (this: Window, ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureDoubleTap", listener: (this: Window, ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureEnd", listener: (this: Window, ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureHold", listener: (this: Window, ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureStart", listener: (this: Window, ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureTap", listener: (this: Window, ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSInertiaStart", listener: (this: Window, ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerCancel", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerDown", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerEnter", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerLeave", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerMove", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerOut", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerOver", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerUp", listener: (this: Window, ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "abort", listener: (this: Window, ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "afterprint", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeprint", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeunload", listener: (this: Window, ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "blur", listener: (this: Window, ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplay", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplaythrough", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "change", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "click", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "compassneedscalibration", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "contextmenu", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dblclick", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicelight", listener: (this: Window, ev: DeviceLightEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicemotion", listener: (this: Window, ev: DeviceMotionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "deviceorientation", listener: (this: Window, ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drag", listener: (this: Window, ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragend", listener: (this: Window, ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragenter", listener: (this: Window, ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragleave", listener: (this: Window, ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragover", listener: (this: Window, ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragstart", listener: (this: Window, ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drop", listener: (this: Window, ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "durationchange", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "emptied", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ended", listener: (this: Window, ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focus", listener: (this: Window, ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "hashchange", listener: (this: Window, ev: HashChangeEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "input", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "invalid", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keydown", listener: (this: Window, ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keypress", listener: (this: Window, ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keyup", listener: (this: Window, ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "load", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadeddata", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadedmetadata", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadstart", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (this: Window, ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousedown", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseenter", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseleave", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousemove", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseout", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseover", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseup", listener: (this: Window, ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousewheel", listener: (this: Window, ev: WheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "offline", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "online", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "orientationchange", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pagehide", listener: (this: Window, ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pageshow", listener: (this: Window, ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pause", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "play", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "playing", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointercancel", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerdown", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerenter", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerleave", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointermove", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerout", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerover", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerup", listener: (this: Window, ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "popstate", listener: (this: Window, ev: PopStateEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "progress", listener: (this: Window, ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ratechange", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "readystatechange", listener: (this: Window, ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "reset", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "resize", listener: (this: Window, ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "scroll", listener: (this: Window, ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeked", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeking", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "select", listener: (this: Window, ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "stalled", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "storage", listener: (this: Window, ev: StorageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "submit", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "suspend", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "timeupdate", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "unload", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "volumechange", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "waiting", listener: (this: Window, ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "wheel", listener: (this: Window, ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 56c8cc84367..c61a1a8b8a6 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -342,8 +342,8 @@ declare var IDBCursorWithValue: { interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; - onabort: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; + onabort: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -351,8 +351,8 @@ interface IDBDatabase extends EventTarget { deleteObjectStore(name: string): void; transaction(storeNames: string | string[], mode?: string): IDBTransaction; addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -430,12 +430,12 @@ declare var IDBObjectStore: { } interface IDBOpenDBRequest extends IDBRequest { - onblocked: (ev: Event) => any; - onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + onblocked: (this: this, ev: Event) => any; + onupgradeneeded: (this: this, ev: IDBVersionChangeEvent) => any; + addEventListener(type: "blocked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (this: this, ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -446,14 +446,14 @@ declare var IDBOpenDBRequest: { interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (ev: ErrorEvent) => any; - onsuccess: (ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onsuccess: (this: this, ev: Event) => any; readonly readyState: string; readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -466,17 +466,17 @@ interface IDBTransaction extends EventTarget { readonly db: IDBDatabase; readonly error: DOMError; readonly mode: string; - onabort: (ev: Event) => any; - oncomplete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; + onabort: (this: this, ev: Event) => any; + oncomplete: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; readonly READ_WRITE: string; readonly VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -535,16 +535,16 @@ declare var MSApp: MSApp; interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; - oncomplete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; + oncomplete: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; readonly readyState: number; readonly result: any; start(): void; readonly COMPLETED: number; readonly ERROR: number; readonly STARTED: number; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -628,11 +628,11 @@ declare var MessageEvent: { } interface MessagePort extends EventTarget { - onmessage: (ev: MessageEvent) => any; + onmessage: (this: this, 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: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -684,10 +684,10 @@ interface WebSocket extends EventTarget { binaryType: string; readonly bufferedAmount: number; readonly extensions: string; - onclose: (ev: CloseEvent) => any; - onerror: (ev: ErrorEvent) => any; - onmessage: (ev: MessageEvent) => any; - onopen: (ev: Event) => any; + onclose: (this: this, ev: CloseEvent) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onmessage: (this: this, ev: MessageEvent) => any; + onopen: (this: this, ev: Event) => any; readonly protocol: string; readonly readyState: number; readonly url: string; @@ -697,10 +697,10 @@ interface WebSocket extends EventTarget { readonly CLOSING: number; readonly CONNECTING: number; readonly OPEN: number; - addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "close", listener: (this: this, ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "open", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -714,11 +714,11 @@ declare var WebSocket: { } interface Worker extends EventTarget, AbstractWorker { - onmessage: (ev: MessageEvent) => any; + onmessage: (this: this, 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: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -728,7 +728,7 @@ declare var Worker: { } interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { - onreadystatechange: (ev: ProgressEvent) => any; + onreadystatechange: (this: this, ev: ProgressEvent) => any; readonly readyState: number; readonly response: any; readonly responseText: string; @@ -754,14 +754,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - addEventListener(type: "abort", listener: (ev: Event) => 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: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -786,30 +786,30 @@ declare var XMLHttpRequestUpload: { } interface AbstractWorker { - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onerror: (this: this, ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } interface MSBaseReader { - onabort: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; - onloadend: (ev: ProgressEvent) => any; - onloadstart: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; + onabort: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onload: (this: this, ev: Event) => any; + onloadend: (this: this, ev: ProgressEvent) => any; + onloadstart: (this: this, ev: Event) => any; + onprogress: (this: this, ev: ProgressEvent) => any; readonly readyState: number; readonly result: any; abort(): void; readonly DONE: number; readonly EMPTY: number; readonly LOADING: number; - addEventListener(type: "abort", listener: (ev: Event) => 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: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -838,20 +838,20 @@ interface WindowConsole { } interface XMLHttpRequestEventTarget { - onabort: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; - onloadend: (ev: ProgressEvent) => any; - onloadstart: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: Event) => 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: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + onabort: (this: this, ev: Event) => any; + onerror: (this: this, ev: ErrorEvent) => any; + onload: (this: this, ev: Event) => any; + onloadend: (this: this, ev: ProgressEvent) => any; + onloadstart: (this: this, ev: Event) => any; + onprogress: (this: this, ev: ProgressEvent) => any; + ontimeout: (this: this, ev: ProgressEvent) => any; + addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -869,13 +869,13 @@ declare var FileReaderSync: { interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole { readonly location: WorkerLocation; - onerror: (ev: ErrorEvent) => any; + onerror: (this: this, ev: ErrorEvent) => any; readonly self: WorkerGlobalScope; close(): void; msWriteProfilerMark(profilerMarkName: string): void; toString(): string; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -911,9 +911,9 @@ declare var WorkerNavigator: { } interface DedicatedWorkerGlobalScope { - onmessage: (ev: MessageEvent) => any; + onmessage: (this: this, ev: MessageEvent) => any; postMessage(data: any): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1169,7 +1169,7 @@ interface FunctionStringCallback { (data: string): void; } declare var location: WorkerLocation; -declare var onerror: (ev: ErrorEvent) => any; +declare var onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; declare var self: WorkerGlobalScope; declare function close(): void; declare function msWriteProfilerMark(profilerMarkName: string): void; @@ -1192,11 +1192,11 @@ declare function setTimeout(handler: (...args: any[]) => void, timeout: number): declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; -declare var onmessage: (ev: MessageEvent) => any; +declare var onmessage: (this: WorkerGlobalScope, ev: MessageEvent) => any; declare function postMessage(data: any): void; declare var console: Console; -declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "error", listener: (this: WorkerGlobalScope, ev: ErrorEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (this: WorkerGlobalScope, ev: MessageEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AlgorithmIdentifier = string | Algorithm; type IDBKeyPath = string; From 690c682b6e852372f9ba312ef41fc9a547725ec6 Mon Sep 17 00:00:00 2001 From: Yui Date: Tue, 28 Jun 2016 15:55:46 -0700 Subject: [PATCH 064/103] Merge master into release-2.0 (#9400) * do not format comma/closeparen in jsxelement * format jsx expression * make rules optional * Remove upper boilerplate from issue template Our issue stats did not improve appreciably when we added the issue template. Reduce upper boilerplate text and try to make it more action-oriented * Update issue_template.md * new options should be optional for compatibility * Add getCurrentDirectory to ServerHost * Add nullchecks for typeRoots, remove getCurrentDirectory from ServerHost as it is always the installation location * VarDate interface and relevant Date.prototype members * Fix 9363: Object destructuring broken-variables are bound to the wrong object (#9383) * Fix emit incorrect destructuring mapping in var declaration * Add tests and baselines * Add additional tests and baselines --- issue_template.md | 21 +++--------- src/compiler/emitter.ts | 4 ++- src/harness/fourslash.ts | 1 + src/lib/scripthost.d.ts | 10 ++++++ src/server/editorServices.ts | 1 + src/services/formatting/rules.ts | 26 +++++++++++++-- src/services/formatting/rulesProvider.ts | 9 +++++ src/services/services.ts | 1 + .../destructuringParameterDeclaration7ES5.js | 27 +++++++++++++++ ...tructuringParameterDeclaration7ES5.symbols | 33 +++++++++++++++++++ ...estructuringParameterDeclaration7ES5.types | 33 +++++++++++++++++++ .../destructuringParameterDeclaration7ES5.ts | 14 ++++++++ .../cases/fourslash/formattingJsxElements.ts | 32 ++++++++++++++---- .../fourslash/formattingOptionsChangeJsx.ts | 32 ++++++++++++++++++ 14 files changed, 218 insertions(+), 26 deletions(-) create mode 100644 tests/baselines/reference/destructuringParameterDeclaration7ES5.js create mode 100644 tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols create mode 100644 tests/baselines/reference/destructuringParameterDeclaration7ES5.types create mode 100644 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts create mode 100644 tests/cases/fourslash/formattingOptionsChangeJsx.ts diff --git a/issue_template.md b/issue_template.md index dcd2280570c..7799960ec78 100644 --- a/issue_template.md +++ b/issue_template.md @@ -1,24 +1,13 @@ - + + -For bug reports, please include the information below. -__________________________________________________________ --> - -**TypeScript Version:** - -1.7.5 / 1.8.0-beta / nightly (1.9.0-dev.20160217) +**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx) **Code** ```ts -// A self-contained demonstration of the problem follows... +// A *self-contained* demonstration of the problem follows... ``` diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0879a3a9ee4..30f0e74adb4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4545,8 +4545,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } write(";"); - tempIndex++; } + // Regardless of whether we will emit a var declaration for the binding pattern, we generate the temporary + // variable for the parameter (see: emitParameter) + tempIndex++; } else if (initializer) { writeLine(); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index bae2977c44a..a42abbbc609 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -324,6 +324,7 @@ namespace FourSlash { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, }; diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index 7faae06714c..baf93f55d55 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -276,3 +276,13 @@ interface VBArrayConstructor { } declare var VBArray: VBArrayConstructor; + +/** + * Automation date (VT_DATE) + */ +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; + getVarDate: () => VarDate; +} \ No newline at end of file diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e48d6192017..092450e526c 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1580,6 +1580,7 @@ namespace ts.server { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, }); diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index b95b23cfca8..110ac9bf4ea 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -225,6 +225,12 @@ namespace ts.formatting { public NoSpaceBeforeTemplateMiddleAndTail: Rule; public SpaceBeforeTemplateMiddleAndTail: Rule; + // No space after { and before } in JSX expression + public NoSpaceAfterOpenBraceInJsxExpression: Rule; + public SpaceAfterOpenBraceInJsxExpression: Rule; + public NoSpaceBeforeCloseBraceInJsxExpression: Rule; + public SpaceBeforeCloseBraceInJsxExpression: Rule; + constructor() { /// /// Common Rules @@ -316,7 +322,7 @@ namespace ts.formatting { // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotForContext), RuleAction.Space)); + this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext, Rules.IsNotForContext), RuleAction.Space)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. this.SpaceAfterTryFinally = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword]), SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); @@ -444,8 +450,8 @@ namespace ts.formatting { /// // Insert space after comma delimiter - this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space)); - this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space)); + this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isNonJsxElementContext), RuleAction.Delete)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space)); @@ -491,6 +497,12 @@ namespace ts.formatting { this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); this.SpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + // No space after { and before } in JSX expression + this.NoSpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); + this.SpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Space)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Delete)); + this.SpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.isJsxExpressionContext), RuleAction.Space)); + // Insert space after function keyword for anonymous functions this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); this.NoSpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Delete)); @@ -729,6 +741,14 @@ namespace ts.formatting { return context.TokensAreOnSameLine() && context.contextNode.kind !== SyntaxKind.JsxText; } + static isNonJsxElementContext(context: FormattingContext): boolean { + return context.contextNode.kind !== SyntaxKind.JsxElement; + } + + static isJsxExpressionContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.JsxExpression; + } + static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); } diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index d672a401d89..1be0f9e912d 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -90,6 +90,15 @@ namespace ts.formatting { rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { + rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression); + rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression); + rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression); + } + if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } diff --git a/src/services/services.ts b/src/services/services.ts index a17d9feed24..529ce8a7bf7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1267,6 +1267,7 @@ namespace ts { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string | undefined; diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5.js b/tests/baselines/reference/destructuringParameterDeclaration7ES5.js new file mode 100644 index 00000000000..f9dac1ae2fa --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5.js @@ -0,0 +1,27 @@ +//// [destructuringParameterDeclaration7ES5.ts] + +interface ISomething { + foo: string, + bar: string +} + +function foo({}, {foo, bar}: ISomething) {} + +function baz([], {foo, bar}: ISomething) {} + +function one([], {}) {} + +function two([], [a, b, c]: number[]) {} + + +//// [destructuringParameterDeclaration7ES5.js] +function foo(_a, _b) { + var foo = _b.foo, bar = _b.bar; +} +function baz(_a, _b) { + var foo = _b.foo, bar = _b.bar; +} +function one(_a, _b) { } +function two(_a, _b) { + var a = _b[0], b = _b[1], c = _b[2]; +} diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols new file mode 100644 index 00000000000..44709f18e1b --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts === + +interface ISomething { +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) + + foo: string, +>foo : Symbol(ISomething.foo, Decl(destructuringParameterDeclaration7ES5.ts, 1, 22)) + + bar: string +>bar : Symbol(ISomething.bar, Decl(destructuringParameterDeclaration7ES5.ts, 2, 16)) +} + +function foo({}, {foo, bar}: ISomething) {} +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 4, 1)) +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 6, 18)) +>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 6, 22)) +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) + +function baz([], {foo, bar}: ISomething) {} +>baz : Symbol(baz, Decl(destructuringParameterDeclaration7ES5.ts, 6, 43)) +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 8, 18)) +>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 8, 22)) +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) + +function one([], {}) {} +>one : Symbol(one, Decl(destructuringParameterDeclaration7ES5.ts, 8, 43)) + +function two([], [a, b, c]: number[]) {} +>two : Symbol(two, Decl(destructuringParameterDeclaration7ES5.ts, 10, 23)) +>a : Symbol(a, Decl(destructuringParameterDeclaration7ES5.ts, 12, 18)) +>b : Symbol(b, Decl(destructuringParameterDeclaration7ES5.ts, 12, 20)) +>c : Symbol(c, Decl(destructuringParameterDeclaration7ES5.ts, 12, 23)) + diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5.types b/tests/baselines/reference/destructuringParameterDeclaration7ES5.types new file mode 100644 index 00000000000..7d64383b0b6 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts === + +interface ISomething { +>ISomething : ISomething + + foo: string, +>foo : string + + bar: string +>bar : string +} + +function foo({}, {foo, bar}: ISomething) {} +>foo : ({}: {}, {foo, bar}: ISomething) => void +>foo : string +>bar : string +>ISomething : ISomething + +function baz([], {foo, bar}: ISomething) {} +>baz : ([]: any[], {foo, bar}: ISomething) => void +>foo : string +>bar : string +>ISomething : ISomething + +function one([], {}) {} +>one : ([]: any[], {}: {}) => void + +function two([], [a, b, c]: number[]) {} +>two : ([]: any[], [a, b, c]: number[]) => void +>a : number +>b : number +>c : number + diff --git a/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts new file mode 100644 index 00000000000..97822e92e2d --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts @@ -0,0 +1,14 @@ +// @target: es5 + +interface ISomething { + foo: string, + bar: string +} + +function foo({}, {foo, bar}: ISomething) {} + +function baz([], {foo, bar}: ISomething) {} + +function one([], {}) {} + +function two([], [a, b, c]: number[]) {} diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts index fbe4bb5d29e..e07149960db 100644 --- a/tests/cases/fourslash/formattingJsxElements.ts +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -9,7 +9,7 @@ ////
//// ) ////} -//// +//// ////function foo1() { //// return ( ////
@@ -45,8 +45,8 @@ //// class3= {/*5*/ //// }/>/*6*/ //// ) -////} -//// +////} +//// ////(function () { //// return
/*grandchildJsxElementAutoformat*/ /////*containedClosingTagAutoformat*/ -//// +////; +//// +////
,{integer}
;/*commaInJsxElement*/ +////
, {integer}
;/*commaInJsxElement2*/ +////);/*closingParenInJsxElement*/ +////) ;/*closingParenInJsxElement2*/ +////;/*jsxExpressionSpaces*/ +////;/*jsxExpressionSpaces2*/ format.document(); goTo.marker("autoformat"); @@ -114,7 +121,7 @@ verify.indentationIs(12); goTo.marker("danglingBracketAutoformat") // TODO: verify.currentLineContentIs(" >"); -verify.currentLineContentIs(" >"); +verify.currentLineContentIs(" >"); goTo.marker("closingTagAutoformat"); verify.currentLineContentIs("
"); @@ -125,4 +132,17 @@ verify.indentationIs(8); goTo.marker("grandchildJsxElementAutoformat"); verify.currentLineContentIs(" "); goTo.marker("containedClosingTagAutoformat"); -verify.currentLineContentIs(" "); \ No newline at end of file +verify.currentLineContentIs(" "); + +goTo.marker("commaInJsxElement"); +verify.currentLineContentIs("
,{integer}
;"); +goTo.marker("commaInJsxElement2"); +verify.currentLineContentIs("
, {integer}
;"); +goTo.marker("closingParenInJsxElement"); +verify.currentLineContentIs(");"); +goTo.marker("closingParenInJsxElement2"); +verify.currentLineContentIs(") ;"); +goTo.marker("jsxExpressionSpaces"); +verify.currentLineContentIs(";"); +goTo.marker("jsxExpressionSpaces2"); +verify.currentLineContentIs(";"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOptionsChangeJsx.ts b/tests/cases/fourslash/formattingOptionsChangeJsx.ts new file mode 100644 index 00000000000..a3c7e28a1ef --- /dev/null +++ b/tests/cases/fourslash/formattingOptionsChangeJsx.ts @@ -0,0 +1,32 @@ +/// + +//@Filename: file.tsx +/////*InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces*/; + +runTest("InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces", ";", ";"); + + +function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { + // Go to the correct file + goTo.marker(propertyName); + + // Set the option to false first + format.setOption(propertyName, false); + + // Format + format.document(); + + // Verify + goTo.marker(propertyName); + verify.currentLineContentIs(expectedStringWhenFalse); + + // Set the option to true + format.setOption(propertyName, true); + + // Format + format.document(); + + // Verify + goTo.marker(propertyName); + verify.currentLineContentIs(expectedStringWhenTrue); +} \ No newline at end of file From 17a428c21f6820b05519a381c0448b5c0cb14ce4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 28 Jun 2016 16:04:52 -0700 Subject: [PATCH 065/103] Fix #9402: Do not report unused identifier errors for catch variables --- src/compiler/checker.ts | 1 - .../reference/unusedParameterInCatchClause.errors.txt | 10 ---------- .../reference/unusedParameterInCatchClause.symbols | 8 ++++++++ .../reference/unusedParameterInCatchClause.types | 8 ++++++++ 4 files changed, 16 insertions(+), 11 deletions(-) delete mode 100644 tests/baselines/reference/unusedParameterInCatchClause.errors.txt create mode 100644 tests/baselines/reference/unusedParameterInCatchClause.symbols create mode 100644 tests/baselines/reference/unusedParameterInCatchClause.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06591a7ab3d..a7b69c96e1c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15563,7 +15563,6 @@ namespace ts { } checkBlock(catchClause.block); - checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { diff --git a/tests/baselines/reference/unusedParameterInCatchClause.errors.txt b/tests/baselines/reference/unusedParameterInCatchClause.errors.txt deleted file mode 100644 index e996763e2c6..00000000000 --- a/tests/baselines/reference/unusedParameterInCatchClause.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/unusedParameterInCatchClause.ts(3,18): error TS6133: 'ex' is declared but never used. - - -==== tests/cases/compiler/unusedParameterInCatchClause.ts (1 errors) ==== - - function f1() { - try {} catch(ex){} - ~~ -!!! error TS6133: 'ex' is declared but never used. - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterInCatchClause.symbols b/tests/baselines/reference/unusedParameterInCatchClause.symbols new file mode 100644 index 00000000000..9406d3ea53e --- /dev/null +++ b/tests/baselines/reference/unusedParameterInCatchClause.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/unusedParameterInCatchClause.ts === + +function f1() { +>f1 : Symbol(f1, Decl(unusedParameterInCatchClause.ts, 0, 0)) + + try {} catch(ex){} +>ex : Symbol(ex, Decl(unusedParameterInCatchClause.ts, 2, 17)) +} diff --git a/tests/baselines/reference/unusedParameterInCatchClause.types b/tests/baselines/reference/unusedParameterInCatchClause.types new file mode 100644 index 00000000000..ad23b5d753b --- /dev/null +++ b/tests/baselines/reference/unusedParameterInCatchClause.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/unusedParameterInCatchClause.ts === + +function f1() { +>f1 : () => void + + try {} catch(ex){} +>ex : any +} From 27e66b0bc85bc59d51dfb360b5581451a89c1e06 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 02:16:18 +0300 Subject: [PATCH 066/103] getVarDate should be on the Date interface --- src/lib/scripthost.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index baf93f55d55..b163a7e5154 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -284,5 +284,8 @@ interface VarDate { } interface DateConstructor { new (vd: VarDate): Date; +} + +interface Date { getVarDate: () => VarDate; -} \ No newline at end of file +} From aeadbe4376acae542b4c8344b50e0d98fafbc879 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 28 Jun 2016 23:37:26 -0700 Subject: [PATCH 067/103] Defere checking unsed identifier checks --- src/compiler/checker.ts | 152 +++++++++++++++++++++++++++------------- 1 file changed, 103 insertions(+), 49 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7b69c96e1c..05cb7df24fb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -51,6 +51,7 @@ namespace ts { const compilerOptions = host.getCompilerOptions(); const languageVersion = compilerOptions.target || ScriptTarget.ES3; const modulekind = getEmitModuleKind(compilerOptions); + const noUnusedIdentifiers = compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters; const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System; const strictNullChecks = compilerOptions.strictNullChecks; @@ -8323,7 +8324,7 @@ namespace ts { const extendedTypeNode = getClassExtendsHeritageClauseElement(node); if (extendedTypeNode) { const t = getTypeFromTypeNode(extendedTypeNode); - if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + if (t !== unknownType && t.symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { t.symbol.hasReference = true; } } @@ -8331,7 +8332,7 @@ namespace ts { function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); - if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + if (symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { symbol.hasReference = true; } @@ -10248,7 +10249,7 @@ namespace ts { return unknownType; } - if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + if (noUnusedIdentifiers && !isInAmbientContext(node)) { prop.hasReference = true; } @@ -12155,47 +12156,54 @@ namespace ts { } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node: ArrowFunction | FunctionExpression | MethodDeclaration) { - Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); + if (node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)) { - const isAsync = isAsyncFunctionLike(node); - const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { - // return is not necessary in the body of generators - checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); - } - - if (node.body) { - if (!node.type) { - // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors - // we need. An example is the noImplicitAny errors resulting from widening the return expression - // of a function. Because checking of function expression bodies is deferred, there was never an - // appropriate time to do this during the main walk of the file (see the comment at the top of - // checkFunctionExpressionBodies). So it must be done now. - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + const isAsync = isAsyncFunctionLike(node); + const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if (!node.asteriskToken) { + // return is not necessary in the body of generators + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } - if (node.body.kind === SyntaxKind.Block) { - checkSourceElement(node.body); - } - else { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so we - // should not be checking assignability of a promise to the return type. Instead, we need to - // check assignability of the awaited type of the expression body against the promised type of - // its return type annotation. - const exprType = checkExpression(node.body); - if (returnOrPromisedType) { - if (isAsync) { - const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + if (node.body) { + if (!node.type) { + // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors + // we need. An example is the noImplicitAny errors resulting from widening the return expression + // of a function. Because checking of function expression bodies is deferred, there was never an + // appropriate time to do this during the main walk of the file (see the comment at the top of + // checkFunctionExpressionBodies). So it must be done now. + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + + if (node.body.kind === SyntaxKind.Block) { + checkSourceElement(node.body); + } + else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. + const exprType = checkExpression(node.body); + if (returnOrPromisedType) { + if (isAsync) { + const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + } } - else { - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); } } } - checkUnusedIdentifiers(node); - checkUnusedTypeParameters(node); + } + else { + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); + } } } @@ -13423,8 +13431,10 @@ namespace ts { checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); - checkUnusedIdentifiers(node); - checkUnusedTypeParameters(node); + + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); + } const symbol = getSymbolOfNode(node); const firstDeclaration = getDeclarationOfKind(symbol, node.kind); @@ -13586,6 +13596,8 @@ namespace ts { function checkAccessorDeferred(node: AccessorDeclaration) { checkSourceElement(node.body); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } function checkMissingDeclaration(node: Node) { @@ -13618,7 +13630,7 @@ namespace ts { checkGrammarTypeArguments(node, node.typeArguments); const type = getTypeFromTypeReference(node); if (type !== unknownType) { - if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + if (type.symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { type.symbol.hasReference = true; } if (node.typeArguments) { @@ -14471,8 +14483,7 @@ namespace ts { } checkSourceElement(node.body); - checkUnusedIdentifiers(node); - checkUnusedTypeParameters(node); + if (!node.asteriskToken) { const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -14492,10 +14503,19 @@ namespace ts { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } } + + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); + } + } + + function checkFunctionOrConstructorDeclarationDeferred(node: FunctionDeclaration | ConstructorDeclaration) { + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block | CatchClause): void { - if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { const local = node.locals[key]; @@ -14514,7 +14534,7 @@ namespace ts { } } - function checkUnusedClassLocals(node: ClassDeclaration): void { + function checkUnusedClassLocals(node: ClassDeclaration | ClassExpression): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.members) { for (const member of node.members) { @@ -14535,7 +14555,7 @@ namespace ts { } } - function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) { + function checkUnusedTypeParameters(node: ClassDeclaration | ClassExpression | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.typeParameters) { for (const typeParameter of node.typeParameters) { @@ -14570,6 +14590,12 @@ namespace ts { checkGrammarStatementInAmbientContext(node); } forEach(node.statements, checkSourceElement); + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); + } + } + + function checkBlockDeferred(node: Block | ForInStatement | ForOfStatement) { checkUnusedIdentifiers(node); } @@ -15075,7 +15101,9 @@ namespace ts { } checkSourceElement(node.statement); - checkUnusedIdentifiers(node); + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); + } } function checkForInStatement(node: ForInStatement) { @@ -15123,7 +15151,9 @@ namespace ts { } checkSourceElement(node.statement); - checkUnusedIdentifiers(node); + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); + } } function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void { @@ -15716,6 +15746,8 @@ namespace ts { function checkClassExpressionDeferred(node: ClassExpression) { forEach(node.members, checkSourceElement); + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); } function checkClassDeclaration(node: ClassDeclaration) { @@ -15724,6 +15756,13 @@ namespace ts { } checkClassLikeDeclaration(node); forEach(node.members, checkSourceElement); + + if (produceDiagnostics && noUnusedIdentifiers) { + checkNodeDeferred(node); + } + } + + function checkClassDeclarationDefered(node: ClassDeclaration) { checkUnusedClassLocals(node); checkUnusedTypeParameters(node); } @@ -16614,7 +16653,7 @@ namespace ts { if (target.flags & SymbolFlags.Type) { checkTypeNameIsReserved(node.name, Diagnostics.Import_name_cannot_be_0); } - if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + if (noUnusedIdentifiers && !isInAmbientContext(node)) { target.hasReference = true; } } @@ -16929,6 +16968,18 @@ namespace ts { case SyntaxKind.ClassExpression: checkClassExpressionDeferred(node); break; + case SyntaxKind.Constructor: + case SyntaxKind.FunctionDeclaration: + checkFunctionOrConstructorDeclarationDeferred(node); + break; + case SyntaxKind.Block: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + checkBlockDeferred(node); + break; + case SyntaxKind.ClassDeclaration: + checkClassDeclarationDefered(node); + break; } } } @@ -16959,10 +17010,13 @@ namespace ts { deferredNodes = []; forEach(node.statements, checkSourceElement); + + checkDeferredNodes(); + if (isExternalModule(node)) { checkUnusedModuleLocals(node); } - checkDeferredNodes(); + deferredNodes = undefined; if (isExternalOrCommonJsModule(node)) { From 5f8cf1af3e4be61037cbafd698535d32d292941f Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Wed, 29 Jun 2016 08:44:06 -0700 Subject: [PATCH 068/103] Don't emit source files found under node_modules --- src/compiler/program.ts | 18 ++++++++++-------- src/compiler/utilities.ts | 8 +++----- .../moduleAugmentationInDependency2.js | 2 -- .../pathMappingBasedModuleResolution5_node.js | 3 --- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index fb74f1dcaab..5cb3b8dad7e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1097,7 +1097,7 @@ namespace ts { const modulesWithElidedImports: Map = {}; // Track source files that are JavaScript files found by searching under node_modules, as these shouldn't be compiled. - const jsFilesFoundSearchingNodeModules: Map = {}; + const sourceFilesFoundSearchingNodeModules: Map = {}; const start = new Date().getTime(); @@ -1378,7 +1378,7 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - getFilesFromNodeModules: () => jsFilesFoundSearchingNodeModules, + isSourceFileFromNodeModules: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, @@ -2066,15 +2066,17 @@ namespace ts { // - noResolve is falsy // - module name comes from the list of imports // - it's not a top level JavaScript module that exceeded the search max - const isJsFileUnderNodeModules = resolution && resolution.isExternalLibraryImport && - hasJavaScriptFileExtension(resolution.resolvedFileName); + const isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; + const isJsFileFromNodeModules = isFromNodeModulesSearch && hasJavaScriptFileExtension(resolution.resolvedFileName); - if (isJsFileUnderNodeModules) { - jsFilesFoundSearchingNodeModules[resolvedPath] = true; + if (isFromNodeModulesSearch) { + sourceFilesFoundSearchingNodeModules[resolvedPath] = true; + } + if (isJsFileFromNodeModules) { currentNodeModulesJsDepth++; } - const elideImport = isJsFileUnderNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth; + const elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth; const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { @@ -2089,7 +2091,7 @@ namespace ts { file.imports[i].end); } - if (isJsFileUnderNodeModules) { + if (isJsFileFromNodeModules) { currentNodeModulesJsDepth--; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e8f2832cd59..e4111e3f925 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -36,7 +36,7 @@ namespace ts { getSourceFiles(): SourceFile[]; /* @internal */ - getFilesFromNodeModules(): Map; + isSourceFileFromNodeModules(file: SourceFile): boolean; getCommonSourceDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -2277,10 +2277,9 @@ namespace ts { } else { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - const nodeModulesFiles = host.getFilesFromNodeModules(); for (const sourceFile of sourceFiles) { // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !lookUp(nodeModulesFiles, sourceFile.path)) { + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromNodeModules(sourceFile)) { onSingleFileEmit(host, sourceFile); } } @@ -2314,10 +2313,9 @@ namespace ts { function onBundledEmit(host: EmitHost) { // Can emit only sources that are not declaration file and are either non module code or module with // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - const nodeModulesFiles = host.getFilesFromNodeModules(); const bundledSources = filter(host.getSourceFiles(), sourceFile => !isDeclarationFile(sourceFile) && - !lookUp(nodeModulesFiles, sourceFile.path) && + !host.isSourceFileFromNodeModules(sourceFile) && (!isExternalModule(sourceFile) || !!getEmitModuleKind(options))); if (bundledSources.length) { diff --git a/tests/baselines/reference/moduleAugmentationInDependency2.js b/tests/baselines/reference/moduleAugmentationInDependency2.js index 381f1e72d8f..0a5d83695a3 100644 --- a/tests/baselines/reference/moduleAugmentationInDependency2.js +++ b/tests/baselines/reference/moduleAugmentationInDependency2.js @@ -8,8 +8,6 @@ export {}; //// [app.ts] import "A" -//// [index.js] -"use strict"; //// [app.js] "use strict"; require("A"); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js index 1958800f918..e4440299cc7 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js @@ -31,9 +31,6 @@ exports.x = 1; //// [file2.js] "use strict"; exports.y = 1; -//// [file4.js] -"use strict"; -exports.z1 = 1; //// [file1.js] "use strict"; var file1_1 = require("folder2/file1"); From c5e680c8be31b0b7651e3ccb078d421e34a76e57 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 29 Jun 2016 09:12:50 -0700 Subject: [PATCH 069/103] Destructuring assignment removes undefined from type when default value is given --- src/compiler/checker.ts | 6 ++++++ .../destructuringAssignmentWithDefault.js | 11 +++++++++++ .../destructuringAssignmentWithDefault.symbols | 12 ++++++++++++ .../destructuringAssignmentWithDefault.types | 17 +++++++++++++++++ .../destructuringAssignmentWithDefault.ts | 4 ++++ 5 files changed, 50 insertions(+) create mode 100644 tests/baselines/reference/destructuringAssignmentWithDefault.js create mode 100644 tests/baselines/reference/destructuringAssignmentWithDefault.symbols create mode 100644 tests/baselines/reference/destructuringAssignmentWithDefault.types create mode 100644 tests/cases/compiler/destructuringAssignmentWithDefault.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06591a7ab3d..9ec2ec3309b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12544,6 +12544,12 @@ namespace ts { if (exprOrAssignment.kind === SyntaxKind.ShorthandPropertyAssignment) { const prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { + // In strict null checking mode, if a default value of a non-undefined type is specified, remove + // undefined from the final type. + if (strictNullChecks && + !(getCombinedTypeFlags(checkExpressionCached(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) { + sourceType = getTypeWithFacts(sourceType, TypeFacts.NEUndefined); + } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); } target = (exprOrAssignment).name; diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.js b/tests/baselines/reference/destructuringAssignmentWithDefault.js new file mode 100644 index 00000000000..ce3837e1162 --- /dev/null +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.js @@ -0,0 +1,11 @@ +//// [destructuringAssignmentWithDefault.ts] +const a: { x?: number } = { }; +let x = 0; +({x = 1} = a); + + +//// [destructuringAssignmentWithDefault.js] +var a = {}; +var x = 0; +(_a = a.x, x = _a === void 0 ? 1 : _a, a); +var _a; diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.symbols b/tests/baselines/reference/destructuringAssignmentWithDefault.symbols new file mode 100644 index 00000000000..b011834c4f0 --- /dev/null +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/destructuringAssignmentWithDefault.ts === +const a: { x?: number } = { }; +>a : Symbol(a, Decl(destructuringAssignmentWithDefault.ts, 0, 5)) +>x : Symbol(x, Decl(destructuringAssignmentWithDefault.ts, 0, 10)) + +let x = 0; +>x : Symbol(x, Decl(destructuringAssignmentWithDefault.ts, 1, 3)) + +({x = 1} = a); +>x : Symbol(x, Decl(destructuringAssignmentWithDefault.ts, 2, 2)) +>a : Symbol(a, Decl(destructuringAssignmentWithDefault.ts, 0, 5)) + diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.types b/tests/baselines/reference/destructuringAssignmentWithDefault.types new file mode 100644 index 00000000000..1dc1fe23533 --- /dev/null +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/destructuringAssignmentWithDefault.ts === +const a: { x?: number } = { }; +>a : { x?: number | undefined; } +>x : number | undefined +>{ } : {} + +let x = 0; +>x : number +>0 : number + +({x = 1} = a); +>({x = 1} = a) : { x?: number | undefined; } +>{x = 1} = a : { x?: number | undefined; } +>{x = 1} : { x?: number; } +>x : number +>a : { x?: number | undefined; } + diff --git a/tests/cases/compiler/destructuringAssignmentWithDefault.ts b/tests/cases/compiler/destructuringAssignmentWithDefault.ts new file mode 100644 index 00000000000..45ade402eb8 --- /dev/null +++ b/tests/cases/compiler/destructuringAssignmentWithDefault.ts @@ -0,0 +1,4 @@ +// @strictNullChecks: true +const a: { x?: number } = { }; +let x = 0; +({x = 1} = a); From 72325131940a10cf073bc5f01499ab29e384e57e Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 29 Jun 2016 12:01:33 -0700 Subject: [PATCH 070/103] Add nullcheck when calculating indentations for implort clause --- src/services/formatting/smartIndenter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 120a5be6e4e..4eebf4b9431 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -497,7 +497,7 @@ namespace ts.formatting { return childKind !== SyntaxKind.NamedExports; case SyntaxKind.ImportDeclaration: return childKind !== SyntaxKind.ImportClause || - (child).namedBindings.kind !== SyntaxKind.NamedImports; + ((child).namedBindings && (child).namedBindings.kind !== SyntaxKind.NamedImports); case SyntaxKind.JsxElement: return childKind !== SyntaxKind.JsxClosingElement; } From e7fcb661c3b2667522078c58d9b258226888b17a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 12:06:47 -0700 Subject: [PATCH 071/103] Use a deferred list to check for unused identifiers --- src/compiler/checker.ts | 267 ++++++++++++++++++++++------------------ 1 file changed, 147 insertions(+), 120 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 05cb7df24fb..938776c35e8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -188,6 +188,7 @@ namespace ts { let jsxElementClassType: Type; let deferredNodes: Node[]; + let deferredUnusedIdentifierNodes: Node[]; let flowLoopStart = 0; let flowLoopCount = 0; @@ -395,7 +396,7 @@ namespace ts { target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && source.valueDeclaration.kind !== SyntaxKind.ModuleDeclaration))) { + (target.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && source.valueDeclaration.kind !== SyntaxKind.ModuleDeclaration))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -665,8 +666,8 @@ namespace ts { useResult = result.flags & SymbolFlags.TypeParameter // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === (location).type || - lastLocation.kind === SyntaxKind.Parameter || - lastLocation.kind === SyntaxKind.TypeParameter + lastLocation.kind === SyntaxKind.Parameter || + lastLocation.kind === SyntaxKind.TypeParameter // local types not visible outside the function body : false; } @@ -855,7 +856,7 @@ namespace ts { if (!result) { if (nameNotFoundMessage) { if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && - !checkAndReportErrorForExtendingInterface(errorLocation)) { + !checkAndReportErrorForExtendingInterface(errorLocation)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); } } @@ -962,7 +963,7 @@ namespace ts { return true; } return false; - } + } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); @@ -1023,8 +1024,8 @@ namespace ts { const exportDefaultSymbol = isShorthandAmbientModule(moduleSymbol.valueDeclaration) ? moduleSymbol : moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : + resolveSymbol(moduleSymbol.exports["default"]); if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); @@ -4537,7 +4538,7 @@ namespace ts { : undefined; const typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : - getTypeParametersFromJSDocTemplate(declaration); + getTypeParametersFromJSDocTemplate(declaration); const returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ? createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) : @@ -5166,7 +5167,7 @@ namespace ts { if (typeSet.length === 0) { return typeSet.containsNull ? typeSet.containsNonWideningType ? nullType : nullWideningType : typeSet.containsUndefined ? typeSet.containsNonWideningType ? undefinedType : undefinedWideningType : - neverType; + neverType; } else if (typeSet.length === 1) { return typeSet[0]; @@ -5402,8 +5403,8 @@ namespace ts { const count = sources.length; const mapper: TypeMapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + createArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } @@ -5726,8 +5727,8 @@ namespace ts { } function isSignatureAssignableTo(source: Signature, - target: Signature, - ignoreReturnTypes: boolean): boolean { + target: Signature, + ignoreReturnTypes: boolean): boolean { return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False; } @@ -5735,11 +5736,11 @@ namespace ts { * See signatureRelatedTo, compareSignaturesIdentical */ function compareSignaturesRelated(source: Signature, - target: Signature, - ignoreReturnTypes: boolean, - reportErrors: boolean, - errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void, - compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary { + target: Signature, + ignoreReturnTypes: boolean, + reportErrors: boolean, + errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void, + compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return Ternary.True; @@ -5821,10 +5822,10 @@ namespace ts { } function compareTypePredicateRelatedTo(source: TypePredicate, - target: TypePredicate, - reportErrors: boolean, - errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void, - compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary { + target: TypePredicate, + reportErrors: boolean, + errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void, + compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary { if (source.kind !== target.kind) { if (reportErrors) { errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); @@ -6905,7 +6906,7 @@ namespace ts { function isStringLiteralUnionType(type: Type): boolean { return type.flags & TypeFlags.StringLiteral ? true : type.flags & TypeFlags.Union ? forEach((type).types, isStringLiteralUnionType) : - false; + false; } /** @@ -6987,11 +6988,11 @@ namespace ts { const resolved = type; const members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); const regularNew = createAnonymousType(resolved.symbol, - members, - resolved.callSignatures, - resolved.constructSignatures, - resolved.stringIndexInfo, - resolved.numberIndexInfo); + members, + resolved.callSignatures, + resolved.constructSignatures, + resolved.stringIndexInfo, + resolved.numberIndexInfo); regularNew.flags = resolved.flags & ~TypeFlags.FreshObjectLiteral; (type).regularType = regularNew; return regularNew; @@ -7819,7 +7820,7 @@ namespace ts { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. - for (let i = visitedFlowStart; i < visitedFlowCount; i++) { + for (let i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { return visitedFlowTypes[i]; } @@ -8206,7 +8207,7 @@ namespace ts { const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type; return isTypeAssignableTo(candidate, targetType) ? candidate : isTypeAssignableTo(type, candidate) ? type : - getIntersectionType([type, candidate]); + getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type { @@ -8625,9 +8626,9 @@ namespace ts { getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') const className = (((container.parent as BinaryExpression) // x.prototype.y = f - .left as PropertyAccessExpression) // x.prototype.y - .expression as PropertyAccessExpression) // x.prototype - .expression; // x + .left as PropertyAccessExpression) // x.prototype.y + .expression as PropertyAccessExpression) // x.prototype + .expression; // x const classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) { return getInferredClassType(classSymbol); @@ -9872,7 +9873,7 @@ namespace ts { elemType = checkExpression(node.tagName); } if (elemType.flags & TypeFlags.Union) { - const types = ( elemType).types; + const types = (elemType).types; return getUnionType(types.map(type => { return getResolvedJsxType(node, type, elemClassType); })); @@ -11804,7 +11805,7 @@ namespace ts { // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && (parameter.valueDeclaration.name.kind === SyntaxKind.ObjectBindingPattern || - parameter.valueDeclaration.name.kind === SyntaxKind.ArrayBindingPattern)) { + parameter.valueDeclaration.name.kind === SyntaxKind.ArrayBindingPattern)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -12156,53 +12157,47 @@ namespace ts { } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node: ArrowFunction | FunctionExpression | MethodDeclaration) { - if (node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)) { + Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - const isAsync = isAsyncFunctionLike(node); - const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { - // return is not necessary in the body of generators - checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); - } - - if (node.body) { - if (!node.type) { - // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors - // we need. An example is the noImplicitAny errors resulting from widening the return expression - // of a function. Because checking of function expression bodies is deferred, there was never an - // appropriate time to do this during the main walk of the file (see the comment at the top of - // checkFunctionExpressionBodies). So it must be done now. - getReturnTypeOfSignature(getSignatureFromDeclaration(node)); - } - - if (node.body.kind === SyntaxKind.Block) { - checkSourceElement(node.body); - } - else { - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so we - // should not be checking assignability of a promise to the return type. Instead, we need to - // check assignability of the awaited type of the expression body against the promised type of - // its return type annotation. - const exprType = checkExpression(node.body); - if (returnOrPromisedType) { - if (isAsync) { - const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); - } - else { - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); - } - } - if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); - } - } - } + const isAsync = isAsyncFunctionLike(node); + const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if (!node.asteriskToken) { + // return is not necessary in the body of generators + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } - else { + + if (node.body) { + if (!node.type) { + // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors + // we need. An example is the noImplicitAny errors resulting from widening the return expression + // of a function. Because checking of function expression bodies is deferred, there was never an + // appropriate time to do this during the main walk of the file (see the comment at the top of + // checkFunctionExpressionBodies). So it must be done now. + getReturnTypeOfSignature(getSignatureFromDeclaration(node)); + } + + if (node.body.kind === SyntaxKind.Block) { + checkSourceElement(node.body); + } + else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. + const exprType = checkExpression(node.body); + if (returnOrPromisedType) { + if (isAsync) { + const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + } + } + } if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); + checkUnusedIdentifiersDeferred(node) } } } @@ -13433,7 +13428,7 @@ namespace ts { checkSourceElement(node.body); if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); + checkUnusedIdentifiersDeferred(node); } const symbol = getSymbolOfNode(node); @@ -13580,6 +13575,9 @@ namespace ts { } if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) { checkSourceElement(node.body); + if (noUnusedIdentifiers) { + checkUnusedIdentifiersDeferred(node); + } } else { checkNodeDeferred(node); @@ -13596,8 +13594,9 @@ namespace ts { function checkAccessorDeferred(node: AccessorDeclaration) { checkSourceElement(node.body); - checkUnusedIdentifiers(node); - checkUnusedTypeParameters(node); + if (produceDiagnostics && noUnusedIdentifiers) { + checkUnusedIdentifiersDeferred(node); + } } function checkMissingDeclaration(node: Node) { @@ -14505,16 +14504,57 @@ namespace ts { } if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); + checkUnusedIdentifiersDeferred(node) } } - function checkFunctionOrConstructorDeclarationDeferred(node: FunctionDeclaration | ConstructorDeclaration) { - checkUnusedIdentifiers(node); - checkUnusedTypeParameters(node); + function checkUnusedIdentifiersDeferred(node: Node) { + deferredUnusedIdentifierNodes.push(node); } - function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block | CatchClause): void { + function checkUnusedIdentifiersDeferredNodes() { + for (const node of deferredUnusedIdentifierNodes) { + switch (node.kind) { + case SyntaxKind.SourceFile: + case SyntaxKind.ModuleDeclaration: + checkUnusedModuleLocals(node); + break; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); + break; + case SyntaxKind.InterfaceDeclaration: + checkUnusedTypeParameters(node); + break; + case SyntaxKind.Block: + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + checkUnusedIdentifiers(node); + break; + case SyntaxKind.Constructor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ArrowFunction: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + checkUnusedIdentifiers(node); + + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + checkUnusedTypeParameters(node); + break; + }; + } + } + + function checkUnusedIdentifiers(node: FunctionLikeDeclaration | ForStatement | Block): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { @@ -14590,15 +14630,11 @@ namespace ts { checkGrammarStatementInAmbientContext(node); } forEach(node.statements, checkSourceElement); - if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); + if (produceDiagnostics && noUnusedIdentifiers && node.locals) { + checkUnusedIdentifiersDeferred(node); } } - function checkBlockDeferred(node: Block | ForInStatement | ForOfStatement) { - checkUnusedIdentifiers(node); - } - function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) { // no rest parameters \ declaration context \ overload - no codegen impact if (!hasDeclaredRestParameter(node) || isInAmbientContext(node) || nodeIsMissing((node).body)) { @@ -15101,8 +15137,8 @@ namespace ts { } checkSourceElement(node.statement); - if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); + if (produceDiagnostics && noUnusedIdentifiers && node.locals) { + checkUnusedIdentifiersDeferred(node); } } @@ -15151,8 +15187,8 @@ namespace ts { } checkSourceElement(node.statement); - if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); + if (produceDiagnostics && noUnusedIdentifiers && node.locals) { + checkUnusedIdentifiersDeferred(node) } } @@ -15746,8 +15782,9 @@ namespace ts { function checkClassExpressionDeferred(node: ClassExpression) { forEach(node.members, checkSourceElement); - checkUnusedClassLocals(node); - checkUnusedTypeParameters(node); + if (produceDiagnostics && noUnusedIdentifiers) { + checkUnusedIdentifiersDeferred(node) + } } function checkClassDeclaration(node: ClassDeclaration) { @@ -15758,15 +15795,10 @@ namespace ts { forEach(node.members, checkSourceElement); if (produceDiagnostics && noUnusedIdentifiers) { - checkNodeDeferred(node); + checkUnusedIdentifiersDeferred(node); } } - function checkClassDeclarationDefered(node: ClassDeclaration) { - checkUnusedClassLocals(node); - checkUnusedTypeParameters(node); - } - function checkClassLikeDeclaration(node: ClassLikeDeclaration) { checkGrammarClassDeclarationHeritageClauses(node); checkDecorators(node); @@ -16472,7 +16504,9 @@ namespace ts { if (node.body) { checkSourceElement(node.body); - checkUnusedModuleLocals(node); + if (produceDiagnostics && noUnusedIdentifiers) { + checkUnusedIdentifiersDeferred(node); + } } } @@ -16968,18 +17002,6 @@ namespace ts { case SyntaxKind.ClassExpression: checkClassExpressionDeferred(node); break; - case SyntaxKind.Constructor: - case SyntaxKind.FunctionDeclaration: - checkFunctionOrConstructorDeclarationDeferred(node); - break; - case SyntaxKind.Block: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - checkBlockDeferred(node); - break; - case SyntaxKind.ClassDeclaration: - checkClassDeclarationDefered(node); - break; } } } @@ -17009,15 +17031,20 @@ namespace ts { potentialThisCollisions.length = 0; deferredNodes = []; + deferredUnusedIdentifierNodes = []; + forEach(node.statements, checkSourceElement); checkDeferredNodes(); - if (isExternalModule(node)) { - checkUnusedModuleLocals(node); + if (isExternalModule(node) && produceDiagnostics && noUnusedIdentifiers) { + checkUnusedIdentifiersDeferred(node); } + checkUnusedIdentifiersDeferredNodes(); + deferredNodes = undefined; + deferredUnusedIdentifierNodes = undefined; if (isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); From 7836ba093e1f1dab8d79a58eae96918e5bb0cfe7 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 12:07:08 -0700 Subject: [PATCH 072/103] push checks to checkUnusedIdentifiersDeferred --- src/compiler/checker.ts | 125 ++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 69 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 938776c35e8..6a7cbce6083 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12196,9 +12196,7 @@ namespace ts { } } } - if (produceDiagnostics && noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node) - } + checkUnusedIdentifiersDeferred(node); } } @@ -13426,10 +13424,7 @@ namespace ts { checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); - - if (produceDiagnostics && noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node); - } + checkUnusedIdentifiersDeferred(node); const symbol = getSymbolOfNode(node); const firstDeclaration = getDeclarationOfKind(symbol, node.kind); @@ -13575,9 +13570,7 @@ namespace ts { } if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) { checkSourceElement(node.body); - if (noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node); - } + checkUnusedIdentifiersDeferred(node); } else { checkNodeDeferred(node); @@ -13594,9 +13587,7 @@ namespace ts { function checkAccessorDeferred(node: AccessorDeclaration) { checkSourceElement(node.body); - if (produceDiagnostics && noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node); - } + checkUnusedIdentifiersDeferred(node); } function checkMissingDeclaration(node: Node) { @@ -14503,54 +14494,56 @@ namespace ts { } } - if (produceDiagnostics && noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node) - } + checkUnusedIdentifiersDeferred(node); } function checkUnusedIdentifiersDeferred(node: Node) { - deferredUnusedIdentifierNodes.push(node); + if (deferredUnusedIdentifierNodes) { + deferredUnusedIdentifierNodes.push(node); + } } function checkUnusedIdentifiersDeferredNodes() { - for (const node of deferredUnusedIdentifierNodes) { - switch (node.kind) { - case SyntaxKind.SourceFile: - case SyntaxKind.ModuleDeclaration: - checkUnusedModuleLocals(node); - break; - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - checkUnusedClassLocals(node); - checkUnusedTypeParameters(node); - break; - case SyntaxKind.InterfaceDeclaration: - checkUnusedTypeParameters(node); - break; - case SyntaxKind.Block: - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - checkUnusedIdentifiers(node); - break; - case SyntaxKind.Constructor: - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - checkUnusedIdentifiers(node); + if (deferredUnusedIdentifierNodes) { + for (const node of deferredUnusedIdentifierNodes) { + switch (node.kind) { + case SyntaxKind.SourceFile: + case SyntaxKind.ModuleDeclaration: + checkUnusedModuleLocals(node); + break; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + checkUnusedClassLocals(node); + checkUnusedTypeParameters(node); + break; + case SyntaxKind.InterfaceDeclaration: + checkUnusedTypeParameters(node); + break; + case SyntaxKind.Block: + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + checkUnusedIdentifiers(node); + break; + case SyntaxKind.Constructor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ArrowFunction: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + checkUnusedIdentifiers(node); - case SyntaxKind.MethodSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - checkUnusedTypeParameters(node); - break; - }; + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + checkUnusedTypeParameters(node); + break; + }; + } } } @@ -14630,7 +14623,7 @@ namespace ts { checkGrammarStatementInAmbientContext(node); } forEach(node.statements, checkSourceElement); - if (produceDiagnostics && noUnusedIdentifiers && node.locals) { + if (node.locals) { checkUnusedIdentifiersDeferred(node); } } @@ -15137,7 +15130,7 @@ namespace ts { } checkSourceElement(node.statement); - if (produceDiagnostics && noUnusedIdentifiers && node.locals) { + if (node.locals) { checkUnusedIdentifiersDeferred(node); } } @@ -15187,8 +15180,8 @@ namespace ts { } checkSourceElement(node.statement); - if (produceDiagnostics && noUnusedIdentifiers && node.locals) { - checkUnusedIdentifiersDeferred(node) + if (node.locals) { + checkUnusedIdentifiersDeferred(node); } } @@ -15782,9 +15775,7 @@ namespace ts { function checkClassExpressionDeferred(node: ClassExpression) { forEach(node.members, checkSourceElement); - if (produceDiagnostics && noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node) - } + checkUnusedIdentifiersDeferred(node); } function checkClassDeclaration(node: ClassDeclaration) { @@ -15794,9 +15785,7 @@ namespace ts { checkClassLikeDeclaration(node); forEach(node.members, checkSourceElement); - if (produceDiagnostics && noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node); - } + checkUnusedIdentifiersDeferred(node); } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { @@ -16504,9 +16493,7 @@ namespace ts { if (node.body) { checkSourceElement(node.body); - if (produceDiagnostics && noUnusedIdentifiers) { - checkUnusedIdentifiersDeferred(node); - } + checkUnusedIdentifiersDeferred(node); } } @@ -17031,13 +17018,13 @@ namespace ts { potentialThisCollisions.length = 0; deferredNodes = []; - deferredUnusedIdentifierNodes = []; + deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; forEach(node.statements, checkSourceElement); checkDeferredNodes(); - if (isExternalModule(node) && produceDiagnostics && noUnusedIdentifiers) { + if (isExternalModule(node)) { checkUnusedIdentifiersDeferred(node); } From b1b3ae07e0aaab8e7a897e47277d66994cd3ea2b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 12:09:49 -0700 Subject: [PATCH 073/103] use isParameterPropertyDeclaration to test for paramter propoerties --- 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 6a7cbce6083..65f0a8dd888 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14557,7 +14557,7 @@ namespace ts { error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) { - if (local.valueDeclaration.flags === 0) { + if (!isParameterPropertyDeclaration(local.valueDeclaration)) { error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } From c28487db92a5079767300df89ece6e28d52e7bf3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 13:18:06 -0700 Subject: [PATCH 074/103] Report unused identifiers in for statements --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 65f0a8dd888..06813b82557 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15090,6 +15090,7 @@ namespace ts { if (node.condition) checkExpression(node.condition); if (node.incrementor) checkExpression(node.incrementor); checkSourceElement(node.statement); + checkUnusedIdentifiersDeferred(node); } function checkForOfStatement(node: ForOfStatement): void { From 4789ff0316f7a19e53fda55f07a54ff3aedaa26d Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 13:34:41 -0700 Subject: [PATCH 075/103] Do not check ambients, and overloads --- src/compiler/checker.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06813b82557..d1c3a88c85e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14532,8 +14532,11 @@ namespace ts { case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - checkUnusedIdentifiers(node); - + if ((node).body) { + checkUnusedIdentifiers(node); + } + checkUnusedTypeParameters(node); + break; case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: @@ -17029,7 +17032,9 @@ namespace ts { checkUnusedIdentifiersDeferred(node); } - checkUnusedIdentifiersDeferredNodes(); + if (!node.isDeclarationFile) { + checkUnusedIdentifiersDeferredNodes(); + } deferredNodes = undefined; deferredUnusedIdentifierNodes = undefined; From 62f47fe995acec622aa88afa19e933b94ee94e3d Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 13:35:10 -0700 Subject: [PATCH 076/103] Add tests --- .../unusedLocalsAndParameters.errors.txt | 159 +++++++++ .../reference/unusedLocalsAndParameters.js | 168 +++++++++ ...usedLocalsAndParametersDeferred.errors.txt | 172 +++++++++ .../unusedLocalsAndParametersDeferred.js | 325 ++++++++++++++++++ ...edLocalsAndParametersOverloadSignatures.js | 45 +++ ...alsAndParametersOverloadSignatures.symbols | 70 ++++ ...ocalsAndParametersOverloadSignatures.types | 74 ++++ .../compiler/unusedLocalsAndParameters.ts | 86 +++++ .../unusedLocalsAndParametersDeferred.ts | 162 +++++++++ ...edLocalsAndParametersOverloadSignatures.ts | 25 ++ 10 files changed, 1286 insertions(+) create mode 100644 tests/baselines/reference/unusedLocalsAndParameters.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsAndParameters.js create mode 100644 tests/baselines/reference/unusedLocalsAndParametersDeferred.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsAndParametersDeferred.js create mode 100644 tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.js create mode 100644 tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.symbols create mode 100644 tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.types create mode 100644 tests/cases/compiler/unusedLocalsAndParameters.ts create mode 100644 tests/cases/compiler/unusedLocalsAndParametersDeferred.ts create mode 100644 tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts diff --git a/tests/baselines/reference/unusedLocalsAndParameters.errors.txt b/tests/baselines/reference/unusedLocalsAndParameters.errors.txt new file mode 100644 index 00000000000..a7b1d1b37f4 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParameters.errors.txt @@ -0,0 +1,159 @@ +tests/cases/compiler/unusedLocalsAndParameters.ts(5,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(10,22): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(16,5): error TS6133: 'farrow' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(16,15): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(19,7): error TS6133: 'C' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(21,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/unusedLocalsAndParameters.ts(24,11): error TS6133: 'v' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(28,5): error TS6133: 'E' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(30,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(33,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/unusedLocalsAndParameters.ts(33,11): error TS6133: 'v' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(39,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(42,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/unusedLocalsAndParameters.ts(42,11): error TS6133: 'v' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(49,10): error TS6133: 'i' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(53,10): error TS6133: 'i' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(57,17): error TS6133: 'n' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(64,11): error TS6133: 'c' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(69,11): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(72,11): error TS6133: 'c' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(75,11): error TS6133: 'c' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(80,11): error TS6133: 'N' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(81,9): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsAndParameters.ts (24 errors) ==== + + export { }; + + // function declaration paramter + function f(a) { + ~ +!!! error TS6133: 'a' is declared but never used. + } + f(0); + + // function expression paramter + var fexp = function (a) { + ~ +!!! error TS6133: 'a' is declared but never used. + }; + + fexp(0); + + // arrow function paramter + var farrow = (a) => { + ~~~~~~ +!!! error TS6133: 'farrow' is declared but never used. + ~ +!!! error TS6133: 'a' is declared but never used. + }; + + class C { + ~ +!!! error TS6133: 'C' is declared but never used. + // Method declaration paramter + method(a) { + ~ +!!! error TS6133: 'a' is declared but never used. + } + // Accessor declaration paramter + set x(v: number) { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS6133: 'v' is declared but never used. + } + } + + var E = class { + ~ +!!! error TS6133: 'E' is declared but never used. + // Method declaration paramter + method(a) { + ~ +!!! error TS6133: 'a' is declared but never used. + } + // Accessor declaration paramter + set x(v: number) { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS6133: 'v' is declared but never used. + } + } + + var o = { + // Object literal method declaration paramter + method(a) { + ~ +!!! error TS6133: 'a' is declared but never used. + }, + // Accessor declaration paramter + set x(v: number) { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS6133: 'v' is declared but never used. + } + }; + + o; + + // in a for..in statment + for (let i in o) { + ~ +!!! error TS6133: 'i' is declared but never used. + } + + // in a for..of statment + for (let i of [1, 2, 3]) { + ~ +!!! error TS6133: 'i' is declared but never used. + } + + // in a for. statment + for (let i = 0, n; i < 10; i++) { + ~ +!!! error TS6133: 'n' is declared but never used. + } + + // in a block + + const condition = false; + if (condition) { + const c = 0; + ~ +!!! error TS6133: 'c' is declared but never used. + } + + // in try/catch/finally + try { + const a = 0; + ~ +!!! error TS6133: 'a' is declared but never used. + } + catch (e) { + const c = 1; + ~ +!!! error TS6133: 'c' is declared but never used. + } + finally { + const c = 0; + ~ +!!! error TS6133: 'c' is declared but never used. + } + + + // in a namespace + namespace N { + ~ +!!! error TS6133: 'N' is declared but never used. + var x; + ~ +!!! error TS6133: 'x' is declared but never used. + } + + \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndParameters.js b/tests/baselines/reference/unusedLocalsAndParameters.js new file mode 100644 index 00000000000..64ff373db4a --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParameters.js @@ -0,0 +1,168 @@ +//// [unusedLocalsAndParameters.ts] + +export { }; + +// function declaration paramter +function f(a) { +} +f(0); + +// function expression paramter +var fexp = function (a) { +}; + +fexp(0); + +// arrow function paramter +var farrow = (a) => { +}; + +class C { + // Method declaration paramter + method(a) { + } + // Accessor declaration paramter + set x(v: number) { + } +} + +var E = class { + // Method declaration paramter + method(a) { + } + // Accessor declaration paramter + set x(v: number) { + } +} + +var o = { + // Object literal method declaration paramter + method(a) { + }, + // Accessor declaration paramter + set x(v: number) { + } +}; + +o; + +// in a for..in statment +for (let i in o) { +} + +// in a for..of statment +for (let i of [1, 2, 3]) { +} + +// in a for. statment +for (let i = 0, n; i < 10; i++) { +} + +// in a block + +const condition = false; +if (condition) { + const c = 0; +} + +// in try/catch/finally +try { + const a = 0; +} +catch (e) { + const c = 1; +} +finally { + const c = 0; +} + + +// in a namespace +namespace N { + var x; +} + + + +//// [unusedLocalsAndParameters.js] +"use strict"; +// function declaration paramter +function f(a) { +} +f(0); +// function expression paramter +var fexp = function (a) { +}; +fexp(0); +// arrow function paramter +var farrow = function (a) { +}; +var C = (function () { + function C() { + } + // Method declaration paramter + C.prototype.method = function (a) { + }; + Object.defineProperty(C.prototype, "x", { + // Accessor declaration paramter + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +}()); +var E = (function () { + function class_1() { + } + // Method declaration paramter + class_1.prototype.method = function (a) { + }; + Object.defineProperty(class_1.prototype, "x", { + // Accessor declaration paramter + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return class_1; +}()); +var o = { + // Object literal method declaration paramter + method: function (a) { + }, + // Accessor declaration paramter + set x(v) { + } +}; +o; +// in a for..in statment +for (var i in o) { +} +// in a for..of statment +for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) { + var i = _a[_i]; +} +// in a for. statment +for (var i = 0, n = void 0; i < 10; i++) { +} +// in a block +var condition = false; +if (condition) { + var c = 0; +} +// in try/catch/finally +try { + var a = 0; +} +catch (e) { + var c = 1; +} +finally { + var c = 0; +} +// in a namespace +var N; +(function (N) { + var x; +})(N || (N = {})); diff --git a/tests/baselines/reference/unusedLocalsAndParametersDeferred.errors.txt b/tests/baselines/reference/unusedLocalsAndParametersDeferred.errors.txt new file mode 100644 index 00000000000..63afd213f1c --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersDeferred.errors.txt @@ -0,0 +1,172 @@ +tests/cases/compiler/unusedLocalsAndParametersDeferred.ts(42,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/unusedLocalsAndParametersDeferred.ts(65,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/unusedLocalsAndParametersDeferred.ts(87,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + + +==== tests/cases/compiler/unusedLocalsAndParametersDeferred.ts (3 errors) ==== + + export { }; + + function defered(a: () => T): T { + return a(); + } + + // function declaration paramter + function f(a) { + defered(() => { + a; + }); + } + f(0); + + // function expression paramter + var fexp = function (a) { + defered(() => { + a; + }); + }; + fexp(1); + + // arrow function paramter + var farrow = (a) => { + defered(() => { + a; + }); + }; + farrow(2); + + let prop1; + + class C { + // Method declaration paramter + method(a) { + defered(() => { + a; + }); + } + // Accessor declaration paramter + set x(v: number) { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + defered(() => { + v; + }); + } + // in a property initalizer + p = defered(() => { + prop1; + }); + } + + new C(); + + let prop2; + + var E = class { + // Method declaration paramter + method(a) { + defered(() => { + a; + }); + } + // Accessor declaration paramter + set x(v: number) { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + defered(() => { + v; + }); + } + // in a property initalizer + p = defered(() => { + prop2; + }); + } + + new E(); + + + var o = { + // Object literal method declaration paramter + method(a) { + defered(() => { + a; + }); + }, + // Accessor declaration paramter + set x(v: number) { + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + defered(() => { + v; + }); + }, + // in a property initalizer + p: defered(() => { + prop1; + }) + }; + + o; + + // in a for..in statment + for (let i in o) { + defered(() => { + i; + }); + } + + // in a for..of statment + for (let i of [1,2,3]) { + defered(() => { + i; + }); + } + + // in a for. statment + for (let i = 0; i < 10; i++) { + defered(() => { + i; + }); + } + + // in a block + + const condition = false; + if (condition) { + const c = 0; + defered(() => { + c; + }); + } + + // in try/catch/finally + try { + const a = 0; + defered(() => { + a; + }); + } + catch (e) { + const c = 1; + defered(() => { + c; + }); + } + finally { + const c = 0; + defered(() => { + c; + }); + } + + + // in a namespace + namespace N { + var x; + defered(() => { + x; + }); + } + N; + \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndParametersDeferred.js b/tests/baselines/reference/unusedLocalsAndParametersDeferred.js new file mode 100644 index 00000000000..7fbfd15c526 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersDeferred.js @@ -0,0 +1,325 @@ +//// [unusedLocalsAndParametersDeferred.ts] + +export { }; + +function defered(a: () => T): T { + return a(); +} + +// function declaration paramter +function f(a) { + defered(() => { + a; + }); +} +f(0); + +// function expression paramter +var fexp = function (a) { + defered(() => { + a; + }); +}; +fexp(1); + +// arrow function paramter +var farrow = (a) => { + defered(() => { + a; + }); +}; +farrow(2); + +let prop1; + +class C { + // Method declaration paramter + method(a) { + defered(() => { + a; + }); + } + // Accessor declaration paramter + set x(v: number) { + defered(() => { + v; + }); + } + // in a property initalizer + p = defered(() => { + prop1; + }); +} + +new C(); + +let prop2; + +var E = class { + // Method declaration paramter + method(a) { + defered(() => { + a; + }); + } + // Accessor declaration paramter + set x(v: number) { + defered(() => { + v; + }); + } + // in a property initalizer + p = defered(() => { + prop2; + }); +} + +new E(); + + +var o = { + // Object literal method declaration paramter + method(a) { + defered(() => { + a; + }); + }, + // Accessor declaration paramter + set x(v: number) { + defered(() => { + v; + }); + }, + // in a property initalizer + p: defered(() => { + prop1; + }) +}; + +o; + +// in a for..in statment +for (let i in o) { + defered(() => { + i; + }); +} + +// in a for..of statment +for (let i of [1,2,3]) { + defered(() => { + i; + }); +} + +// in a for. statment +for (let i = 0; i < 10; i++) { + defered(() => { + i; + }); +} + +// in a block + +const condition = false; +if (condition) { + const c = 0; + defered(() => { + c; + }); +} + +// in try/catch/finally +try { + const a = 0; + defered(() => { + a; + }); +} +catch (e) { + const c = 1; + defered(() => { + c; + }); +} +finally { + const c = 0; + defered(() => { + c; + }); +} + + +// in a namespace +namespace N { + var x; + defered(() => { + x; + }); +} +N; + + +//// [unusedLocalsAndParametersDeferred.js] +"use strict"; +function defered(a) { + return a(); +} +// function declaration paramter +function f(a) { + defered(function () { + a; + }); +} +f(0); +// function expression paramter +var fexp = function (a) { + defered(function () { + a; + }); +}; +fexp(1); +// arrow function paramter +var farrow = function (a) { + defered(function () { + a; + }); +}; +farrow(2); +var prop1; +var C = (function () { + function C() { + // in a property initalizer + this.p = defered(function () { + prop1; + }); + } + // Method declaration paramter + C.prototype.method = function (a) { + defered(function () { + a; + }); + }; + Object.defineProperty(C.prototype, "x", { + // Accessor declaration paramter + set: function (v) { + defered(function () { + v; + }); + }, + enumerable: true, + configurable: true + }); + return C; +}()); +new C(); +var prop2; +var E = (function () { + function class_1() { + // in a property initalizer + this.p = defered(function () { + prop2; + }); + } + // Method declaration paramter + class_1.prototype.method = function (a) { + defered(function () { + a; + }); + }; + Object.defineProperty(class_1.prototype, "x", { + // Accessor declaration paramter + set: function (v) { + defered(function () { + v; + }); + }, + enumerable: true, + configurable: true + }); + return class_1; +}()); +new E(); +var o = { + // Object literal method declaration paramter + method: function (a) { + defered(function () { + a; + }); + }, + // Accessor declaration paramter + set x(v) { + defered(function () { + v; + }); + }, + // in a property initalizer + p: defered(function () { + prop1; + }) +}; +o; +// in a for..in statment +var _loop_1 = function(i) { + defered(function () { + i; + }); +}; +for (var i in o) { + _loop_1(i); +} +// in a for..of statment +var _loop_2 = function(i) { + defered(function () { + i; + }); +}; +for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) { + var i = _a[_i]; + _loop_2(i); +} +// in a for. statment +var _loop_3 = function(i) { + defered(function () { + i; + }); +}; +for (var i = 0; i < 10; i++) { + _loop_3(i); +} +// in a block +var condition = false; +if (condition) { + var c_1 = 0; + defered(function () { + c_1; + }); +} +// in try/catch/finally +try { + var a_1 = 0; + defered(function () { + a_1; + }); +} +catch (e) { + var c_2 = 1; + defered(function () { + c_2; + }); +} +finally { + var c_3 = 0; + defered(function () { + c_3; + }); +} +// in a namespace +var N; +(function (N) { + var x; + defered(function () { + x; + }); +})(N || (N = {})); +N; diff --git a/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.js b/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.js new file mode 100644 index 00000000000..221d49a0fdf --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.js @@ -0,0 +1,45 @@ +//// [unusedLocalsAndParametersOverloadSignatures.ts] + +export function func(details: number, message: string, ...args: any[]): void; +export function func(details: number, message: string): any { + return details + message; +} + +export class C { + constructor(details: number, message: string, ...args: any[]); + constructor(details: number, message: string) { + details + message; + } + + method(details: number, message: string, ...args: any[]): void; + method(details: number, message: string): any { + return details + message; + } +} + + +export function genericFunc(details: number, message: T, ...args: any[]): void; +export function genericFunc(details: number, message: any): any { + return details + message; +} + +//// [unusedLocalsAndParametersOverloadSignatures.js] +"use strict"; +function func(details, message) { + return details + message; +} +exports.func = func; +var C = (function () { + function C(details, message) { + details + message; + } + C.prototype.method = function (details, message) { + return details + message; + }; + return C; +}()); +exports.C = C; +function genericFunc(details, message) { + return details + message; +} +exports.genericFunc = genericFunc; diff --git a/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.symbols b/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.symbols new file mode 100644 index 00000000000..da3c47f2e42 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.symbols @@ -0,0 +1,70 @@ +=== tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts === + +export function func(details: number, message: string, ...args: any[]): void; +>func : Symbol(func, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 0, 0), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 77)) +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 21)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 37)) +>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 54)) + +export function func(details: number, message: string): any { +>func : Symbol(func, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 0, 0), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 77)) +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 21)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 37)) + + return details + message; +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 21)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 37)) +} + +export class C { +>C : Symbol(C, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 4, 1)) + + constructor(details: number, message: string, ...args: any[]); +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 7, 16)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 7, 32)) +>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 7, 49)) + + constructor(details: number, message: string) { +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 16)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 32)) + + details + message; +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 16)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 32)) + } + + method(details: number, message: string, ...args: any[]): void; +>method : Symbol(C.method, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 10, 5), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 67)) +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 11)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 27)) +>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 44)) + + method(details: number, message: string): any { +>method : Symbol(C.method, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 10, 5), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 67)) +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 11)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 27)) + + return details + message; +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 11)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 27)) + } +} + + +export function genericFunc(details: number, message: T, ...args: any[]): void; +>genericFunc : Symbol(genericFunc, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 16, 1), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 82)) +>T : Symbol(T, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 28)) +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 31)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 47)) +>T : Symbol(T, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 28)) +>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 59)) + +export function genericFunc(details: number, message: any): any { +>genericFunc : Symbol(genericFunc, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 16, 1), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 82)) +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 28)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 44)) + + return details + message; +>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 28)) +>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 44)) +} diff --git a/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.types b/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.types new file mode 100644 index 00000000000..2a216c8acd2 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersOverloadSignatures.types @@ -0,0 +1,74 @@ +=== tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts === + +export function func(details: number, message: string, ...args: any[]): void; +>func : (details: number, message: string, ...args: any[]) => void +>details : number +>message : string +>args : any[] + +export function func(details: number, message: string): any { +>func : (details: number, message: string, ...args: any[]) => void +>details : number +>message : string + + return details + message; +>details + message : string +>details : number +>message : string +} + +export class C { +>C : C + + constructor(details: number, message: string, ...args: any[]); +>details : number +>message : string +>args : any[] + + constructor(details: number, message: string) { +>details : number +>message : string + + details + message; +>details + message : string +>details : number +>message : string + } + + method(details: number, message: string, ...args: any[]): void; +>method : (details: number, message: string, ...args: any[]) => void +>details : number +>message : string +>args : any[] + + method(details: number, message: string): any { +>method : (details: number, message: string, ...args: any[]) => void +>details : number +>message : string + + return details + message; +>details + message : string +>details : number +>message : string + } +} + + +export function genericFunc(details: number, message: T, ...args: any[]): void; +>genericFunc : (details: number, message: T, ...args: any[]) => void +>T : T +>details : number +>message : T +>T : T +>args : any[] + +export function genericFunc(details: number, message: any): any { +>genericFunc : (details: number, message: T, ...args: any[]) => void +>details : number +>message : any + + return details + message; +>details + message : any +>details : number +>message : any +} diff --git a/tests/cases/compiler/unusedLocalsAndParameters.ts b/tests/cases/compiler/unusedLocalsAndParameters.ts new file mode 100644 index 00000000000..1f4fc944ff4 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsAndParameters.ts @@ -0,0 +1,86 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +export { }; + +// function declaration paramter +function f(a) { +} +f(0); + +// function expression paramter +var fexp = function (a) { +}; + +fexp(0); + +// arrow function paramter +var farrow = (a) => { +}; + +class C { + // Method declaration paramter + method(a) { + } + // Accessor declaration paramter + set x(v: number) { + } +} + +var E = class { + // Method declaration paramter + method(a) { + } + // Accessor declaration paramter + set x(v: number) { + } +} + +var o = { + // Object literal method declaration paramter + method(a) { + }, + // Accessor declaration paramter + set x(v: number) { + } +}; + +o; + +// in a for..in statment +for (let i in o) { +} + +// in a for..of statment +for (let i of [1, 2, 3]) { +} + +// in a for. statment +for (let i = 0, n; i < 10; i++) { +} + +// in a block + +const condition = false; +if (condition) { + const c = 0; +} + +// in try/catch/finally +try { + const a = 0; +} +catch (e) { + const c = 1; +} +finally { + const c = 0; +} + + +// in a namespace +namespace N { + var x; +} + + \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsAndParametersDeferred.ts b/tests/cases/compiler/unusedLocalsAndParametersDeferred.ts new file mode 100644 index 00000000000..75b98308199 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsAndParametersDeferred.ts @@ -0,0 +1,162 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +export { }; + +function defered(a: () => T): T { + return a(); +} + +// function declaration paramter +function f(a) { + defered(() => { + a; + }); +} +f(0); + +// function expression paramter +var fexp = function (a) { + defered(() => { + a; + }); +}; +fexp(1); + +// arrow function paramter +var farrow = (a) => { + defered(() => { + a; + }); +}; +farrow(2); + +let prop1; + +class C { + // Method declaration paramter + method(a) { + defered(() => { + a; + }); + } + // Accessor declaration paramter + set x(v: number) { + defered(() => { + v; + }); + } + // in a property initalizer + p = defered(() => { + prop1; + }); +} + +new C(); + +let prop2; + +var E = class { + // Method declaration paramter + method(a) { + defered(() => { + a; + }); + } + // Accessor declaration paramter + set x(v: number) { + defered(() => { + v; + }); + } + // in a property initalizer + p = defered(() => { + prop2; + }); +} + +new E(); + + +var o = { + // Object literal method declaration paramter + method(a) { + defered(() => { + a; + }); + }, + // Accessor declaration paramter + set x(v: number) { + defered(() => { + v; + }); + }, + // in a property initalizer + p: defered(() => { + prop1; + }) +}; + +o; + +// in a for..in statment +for (let i in o) { + defered(() => { + i; + }); +} + +// in a for..of statment +for (let i of [1,2,3]) { + defered(() => { + i; + }); +} + +// in a for. statment +for (let i = 0; i < 10; i++) { + defered(() => { + i; + }); +} + +// in a block + +const condition = false; +if (condition) { + const c = 0; + defered(() => { + c; + }); +} + +// in try/catch/finally +try { + const a = 0; + defered(() => { + a; + }); +} +catch (e) { + const c = 1; + defered(() => { + c; + }); +} +finally { + const c = 0; + defered(() => { + c; + }); +} + + +// in a namespace +namespace N { + var x; + defered(() => { + x; + }); +} +N; + \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts b/tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts new file mode 100644 index 00000000000..32affb28be3 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts @@ -0,0 +1,25 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +export function func(details: number, message: string, ...args: any[]): void; +export function func(details: number, message: string): any { + return details + message; +} + +export class C { + constructor(details: number, message: string, ...args: any[]); + constructor(details: number, message: string) { + details + message; + } + + method(details: number, message: string, ...args: any[]): void; + method(details: number, message: string): any { + return details + message; + } +} + + +export function genericFunc(details: number, message: T, ...args: any[]): void; +export function genericFunc(details: number, message: any): any { + return details + message; +} \ No newline at end of file From d4513c8affcd1e127b72e6f03d03a9ef073da031 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 14:07:42 -0700 Subject: [PATCH 077/103] Consolidate type reference marking in getTypeFromTypeReference --- src/compiler/checker.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d1c3a88c85e..26b94358f36 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4961,6 +4961,10 @@ namespace ts { // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; links.resolvedType = type; + + if (noUnusedIdentifiers && symbol !== unknownSymbol && !isInAmbientContext(node)) { + symbol.hasReference = true; + } } return links.resolvedType; } @@ -8321,16 +8325,6 @@ namespace ts { return container === declarationContainer; } - function updateReferencesForInterfaceHeritiageClauseTargets(node: InterfaceDeclaration): void { - const extendedTypeNode = getClassExtendsHeritageClauseElement(node); - if (extendedTypeNode) { - const t = getTypeFromTypeNode(extendedTypeNode); - if (t !== unknownType && t.symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { - t.symbol.hasReference = true; - } - } - } - function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); if (symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { @@ -13620,9 +13614,6 @@ namespace ts { checkGrammarTypeArguments(node, node.typeArguments); const type = getTypeFromTypeReference(node); if (type !== unknownType) { - if (type.symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { - type.symbol.hasReference = true; - } if (node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved forEach(node.typeArguments, checkSourceElement); @@ -16099,7 +16090,6 @@ namespace ts { if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); - updateReferencesForInterfaceHeritiageClauseTargets(node); checkUnusedTypeParameters(node); } } From 97aa9879784c4b4720099fd12a902341ab0838aa Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 14:07:55 -0700 Subject: [PATCH 078/103] Handel type aliases --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 26b94358f36..b715310ad02 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14546,15 +14546,15 @@ namespace ts { for (const key in node.locals) { if (hasProperty(node.locals, key)) { const local = node.locals[key]; - if (!local.hasReference && local.valueDeclaration) { - if (local.valueDeclaration.kind !== SyntaxKind.Parameter && compilerOptions.noUnusedLocals) { - error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); - } - else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) { - if (!isParameterPropertyDeclaration(local.valueDeclaration)) { + if (!local.hasReference) { + if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { + if (compilerOptions.noUnusedParameters && !isParameterPropertyDeclaration(local.valueDeclaration)) { error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } + else if (compilerOptions.noUnusedLocals) { + forEach(local.declarations, d => error(d.name || d, Diagnostics._0_is_declared_but_never_used, local.name)); + } } } } From f81a8e7382820ec94815ee2dbbb94818b052c1b0 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 14:08:20 -0700 Subject: [PATCH 079/103] Add tests --- .../unusedLocalsAndParametersTypeAliases.js | 35 +++++++++++ ...usedLocalsAndParametersTypeAliases.symbols | 59 +++++++++++++++++ ...unusedLocalsAndParametersTypeAliases.types | 63 +++++++++++++++++++ ...LocalsAndParametersTypeAliases2.errors.txt | 20 ++++++ .../unusedLocalsAndParametersTypeAliases2.js | 18 ++++++ .../unusedLocalsAndParametersTypeAliases.ts | 29 +++++++++ .../unusedLocalsAndParametersTypeAliases2.ts | 13 ++++ 7 files changed, 237 insertions(+) create mode 100644 tests/baselines/reference/unusedLocalsAndParametersTypeAliases.js create mode 100644 tests/baselines/reference/unusedLocalsAndParametersTypeAliases.symbols create mode 100644 tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types create mode 100644 tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.js create mode 100644 tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts create mode 100644 tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.js b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.js new file mode 100644 index 00000000000..b854278a3e3 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.js @@ -0,0 +1,35 @@ +//// [unusedLocalsAndParametersTypeAliases.ts] + +// used in a declaration +type handler1 = () => void; +export interface I1 { + getHandler: handler1; +} + +// exported +export type handler2 = () => void; + +// used in extends clause +type handler3 = () => void; +export interface I3 { + getHandler: T; +} + +// used in another type alias declaration +type handler4 = () => void; +type handler5 = handler4 | (()=>number); +var x: handler5; +x(); + +// used as type argument +type handler6 = () => void; +var y: Array; +y[0](); + + +//// [unusedLocalsAndParametersTypeAliases.js] +"use strict"; +var x; +x(); +var y; +y[0](); diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.symbols b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.symbols new file mode 100644 index 00000000000..9f9004d7a28 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.symbols @@ -0,0 +1,59 @@ +=== tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts === + +// used in a declaration +type handler1 = () => void; +>handler1 : Symbol(handler1, Decl(unusedLocalsAndParametersTypeAliases.ts, 0, 0)) + +export interface I1 { +>I1 : Symbol(I1, Decl(unusedLocalsAndParametersTypeAliases.ts, 2, 27)) + + getHandler: handler1; +>getHandler : Symbol(I1.getHandler, Decl(unusedLocalsAndParametersTypeAliases.ts, 3, 21)) +>handler1 : Symbol(handler1, Decl(unusedLocalsAndParametersTypeAliases.ts, 0, 0)) +} + +// exported +export type handler2 = () => void; +>handler2 : Symbol(handler2, Decl(unusedLocalsAndParametersTypeAliases.ts, 5, 1)) + +// used in extends clause +type handler3 = () => void; +>handler3 : Symbol(handler3, Decl(unusedLocalsAndParametersTypeAliases.ts, 8, 34)) + +export interface I3 { +>I3 : Symbol(I3, Decl(unusedLocalsAndParametersTypeAliases.ts, 11, 27)) +>T : Symbol(T, Decl(unusedLocalsAndParametersTypeAliases.ts, 12, 20)) +>handler3 : Symbol(handler3, Decl(unusedLocalsAndParametersTypeAliases.ts, 8, 34)) + + getHandler: T; +>getHandler : Symbol(I3.getHandler, Decl(unusedLocalsAndParametersTypeAliases.ts, 12, 41)) +>T : Symbol(T, Decl(unusedLocalsAndParametersTypeAliases.ts, 12, 20)) +} + +// used in another type alias declaration +type handler4 = () => void; +>handler4 : Symbol(handler4, Decl(unusedLocalsAndParametersTypeAliases.ts, 14, 1)) + +type handler5 = handler4 | (()=>number); +>handler5 : Symbol(handler5, Decl(unusedLocalsAndParametersTypeAliases.ts, 17, 27)) +>handler4 : Symbol(handler4, Decl(unusedLocalsAndParametersTypeAliases.ts, 14, 1)) + +var x: handler5; +>x : Symbol(x, Decl(unusedLocalsAndParametersTypeAliases.ts, 19, 3)) +>handler5 : Symbol(handler5, Decl(unusedLocalsAndParametersTypeAliases.ts, 17, 27)) + +x(); +>x : Symbol(x, Decl(unusedLocalsAndParametersTypeAliases.ts, 19, 3)) + +// used as type argument +type handler6 = () => void; +>handler6 : Symbol(handler6, Decl(unusedLocalsAndParametersTypeAliases.ts, 20, 4)) + +var y: Array; +>y : Symbol(y, Decl(unusedLocalsAndParametersTypeAliases.ts, 24, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>handler6 : Symbol(handler6, Decl(unusedLocalsAndParametersTypeAliases.ts, 20, 4)) + +y[0](); +>y : Symbol(y, Decl(unusedLocalsAndParametersTypeAliases.ts, 24, 3)) + diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types new file mode 100644 index 00000000000..82c87deb7d0 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases.types @@ -0,0 +1,63 @@ +=== tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts === + +// used in a declaration +type handler1 = () => void; +>handler1 : () => void + +export interface I1 { +>I1 : I1 + + getHandler: handler1; +>getHandler : () => void +>handler1 : () => void +} + +// exported +export type handler2 = () => void; +>handler2 : () => void + +// used in extends clause +type handler3 = () => void; +>handler3 : () => void + +export interface I3 { +>I3 : I3 +>T : T +>handler3 : () => void + + getHandler: T; +>getHandler : T +>T : T +} + +// used in another type alias declaration +type handler4 = () => void; +>handler4 : () => void + +type handler5 = handler4 | (()=>number); +>handler5 : (() => void) | (() => number) +>handler4 : () => void + +var x: handler5; +>x : (() => void) | (() => number) +>handler5 : (() => void) | (() => number) + +x(); +>x() : void | number +>x : (() => void) | (() => number) + +// used as type argument +type handler6 = () => void; +>handler6 : () => void + +var y: Array; +>y : (() => void)[] +>Array : T[] +>handler6 : () => void + +y[0](); +>y[0]() : void +>y[0] : () => void +>y : (() => void)[] +>0 : number + diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt new file mode 100644 index 00000000000..d6abf6f2f3f --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(3,6): error TS6133: 'handler1' is declared but never used. +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(7,10): error TS6133: 'handler2' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts (2 errors) ==== + + // unused + type handler1 = () => void; + ~~~~~~~~ +!!! error TS6133: 'handler1' is declared but never used. + + + function foo() { + type handler2 = () => void; + ~~~~~~~~ +!!! error TS6133: 'handler2' is declared but never used. + foo(); + } + + export {} \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.js b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.js new file mode 100644 index 00000000000..7da916370ca --- /dev/null +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.js @@ -0,0 +1,18 @@ +//// [unusedLocalsAndParametersTypeAliases2.ts] + +// unused +type handler1 = () => void; + + +function foo() { + type handler2 = () => void; + foo(); +} + +export {} + +//// [unusedLocalsAndParametersTypeAliases2.js] +"use strict"; +function foo() { + foo(); +} diff --git a/tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts b/tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts new file mode 100644 index 00000000000..b94f88845bc --- /dev/null +++ b/tests/cases/compiler/unusedLocalsAndParametersTypeAliases.ts @@ -0,0 +1,29 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// used in a declaration +type handler1 = () => void; +export interface I1 { + getHandler: handler1; +} + +// exported +export type handler2 = () => void; + +// used in extends clause +type handler3 = () => void; +export interface I3 { + getHandler: T; +} + +// used in another type alias declaration +type handler4 = () => void; +type handler5 = handler4 | (()=>number); +var x: handler5; +x(); + +// used as type argument +type handler6 = () => void; +var y: Array; +y[0](); + \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts b/tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts new file mode 100644 index 00000000000..23d23a5bc18 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// unused +type handler1 = () => void; + + +function foo() { + type handler2 = () => void; + foo(); +} + +export {} \ No newline at end of file From adca77003e2229b9d0ad7170676fd2b121efefc3 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 29 Jun 2016 16:00:11 -0700 Subject: [PATCH 080/103] Add test --- .../formattingIllegalImportClause.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/cases/fourslash/formattingIllegalImportClause.ts diff --git a/tests/cases/fourslash/formattingIllegalImportClause.ts b/tests/cases/fourslash/formattingIllegalImportClause.ts new file mode 100644 index 00000000000..9e97087c000 --- /dev/null +++ b/tests/cases/fourslash/formattingIllegalImportClause.ts @@ -0,0 +1,26 @@ +/// + +//// var expect = require('expect.js'); +//// import React from 'react'/*1*/; +//// import { mount } from 'enzyme'; +//// require('../setup'); +//// var Amount = require('../../src/js/components/amount'); + +//// describe('', () => { +//// var history +//// beforeEach(() => { +//// history = createMemoryHistory(); +//// sinon.spy(history, 'pushState'); +//// }); + +//// afterEach(() => { +//// }) + +//// it('redirects to order summary', () => { + +//// }); +//// }); + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("import React from 'react';") \ No newline at end of file From 5a45c44eb789f52ceb1aa0e23a230ecb599bfb08 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Wed, 29 Jun 2016 17:04:42 -0700 Subject: [PATCH 081/103] Dont load JavaScript if types packages are present --- src/compiler/program.ts | 19 ++++++++++++------- .../amd/maxDepthIncreased/root.js | 6 ++++-- .../nodeModulesMaxDepthIncreased.errors.txt | 18 +++++++++++++++--- .../amd/nodeModulesMaxDepthIncreased.json | 1 + .../node/maxDepthIncreased/root.js | 5 ++++- .../nodeModulesMaxDepthIncreased.errors.txt | 18 +++++++++++++++--- .../node/nodeModulesMaxDepthIncreased.json | 1 + .../node_modules/@types/m4/entry.d.ts | 1 + .../node_modules/@types/m4/package.json | 5 +++++ .../node_modules/m4/entry.js | 1 + .../node_modules/m4/package.json | 5 +++++ .../maxDepthIncreased/root.ts | 8 +++++++- 12 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5cb3b8dad7e..c56debdf251 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -779,13 +779,18 @@ namespace ts { while (true) { const baseName = getBaseFileName(directory); if (baseName !== "node_modules") { - const result = - // first: try to load module as-is - loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) || - // second: try to load module from the scope '@types' - loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (result) { - return result; + // Try to load source from the package + const packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && hasTypeScriptFileExtension(packageResult)) { + // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package + return packageResult; + } + else { + // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) + const typesResult = loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } } } diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js index 77951a4889d..0024891fbe3 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -1,6 +1,8 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { +define(["require", "exports", "m1", "m4"], function (require, exports, m1, m4) { "use strict"; m1.f1("test"); m1.f2.a = 10; - m1.f2.person.age = "10"; // Error: Should be number + m1.f2.person.age = "10"; // Should error if loaded the .js files correctly + var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file }); diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt index f63c2a789e8..473d69bc526 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt @@ -1,4 +1,5 @@ -maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -28,11 +29,22 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to exports.f2 = m2; -==== maxDepthIncreased/root.ts (1 errors) ==== +==== entry.d.ts (0 errors) ==== + export declare var foo: number; + +==== maxDepthIncreased/root.ts (2 errors) ==== import * as m1 from "m1"; + import * as m4 from "m4"; + m1.f1("test"); m1.f2.a = 10; - m1.f2.person.age = "10"; // Error: Should be number + + m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. + let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + ~~~~ +!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. + + let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json index 1350bf6441e..bb3234f1db2 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json @@ -10,6 +10,7 @@ "maxDepthIncreased/node_modules/m2/node_modules/m3/index.js", "maxDepthIncreased/node_modules/m2/entry.js", "maxDepthIncreased/node_modules/m1/index.js", + "maxDepthIncreased/node_modules/@types/m4/entry.d.ts", "maxDepthIncreased/root.ts" ], "emittedFiles": [ diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index 3a0a96991b0..ba6d7e96241 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -1,5 +1,8 @@ "use strict"; var m1 = require("m1"); +var m4 = require("m4"); m1.f1("test"); m1.f2.a = 10; -m1.f2.person.age = "10"; // Error: Should be number +m1.f2.person.age = "10"; // Should error if loaded the .js files correctly +var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info +var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt index f63c2a789e8..473d69bc526 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt @@ -1,4 +1,5 @@ -maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -28,11 +29,22 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to exports.f2 = m2; -==== maxDepthIncreased/root.ts (1 errors) ==== +==== entry.d.ts (0 errors) ==== + export declare var foo: number; + +==== maxDepthIncreased/root.ts (2 errors) ==== import * as m1 from "m1"; + import * as m4 from "m4"; + m1.f1("test"); m1.f2.a = 10; - m1.f2.person.age = "10"; // Error: Should be number + + m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. + let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + ~~~~ +!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. + + let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json index 1350bf6441e..bb3234f1db2 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json @@ -10,6 +10,7 @@ "maxDepthIncreased/node_modules/m2/node_modules/m3/index.js", "maxDepthIncreased/node_modules/m2/entry.js", "maxDepthIncreased/node_modules/m1/index.js", + "maxDepthIncreased/node_modules/@types/m4/entry.d.ts", "maxDepthIncreased/root.ts" ], "emittedFiles": [ diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts new file mode 100644 index 00000000000..f0fc245910a --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts @@ -0,0 +1 @@ +export declare var foo: number; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json new file mode 100644 index 00000000000..53ac1558a23 --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json @@ -0,0 +1,5 @@ +{ + "types": "entry.d.ts", + "name": "m4", + "version": "1.0.0" +} \ No newline at end of file diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js new file mode 100644 index 00000000000..a1cb557b18d --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js @@ -0,0 +1 @@ +exports.test = "hello, world"; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json new file mode 100644 index 00000000000..4ae99f312fc --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json @@ -0,0 +1,5 @@ +{ + "name": "m4", + "version": "1.0.0", + "main": "entry.js" +} \ No newline at end of file diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts index 9ed943bebba..5d9f331b249 100644 --- a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts @@ -1,4 +1,10 @@ import * as m1 from "m1"; +import * as m4 from "m4"; + m1.f1("test"); m1.f2.a = 10; -m1.f2.person.age = "10"; // Error: Should be number + +m1.f2.person.age = "10"; // Should error if loaded the .js files correctly +let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + +let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file From d8047b607f11cdf319284bb344282582c7c0aea0 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Wed, 29 Jun 2016 17:05:55 -0700 Subject: [PATCH 082/103] Renamed API --- src/compiler/program.ts | 2 +- src/compiler/utilities.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c56debdf251..2e4492efa7b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1383,7 +1383,7 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromNodeModules: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), + isSourceFileFromExternalLibrary: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e4111e3f925..7892af6624f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -36,7 +36,7 @@ namespace ts { getSourceFiles(): SourceFile[]; /* @internal */ - isSourceFileFromNodeModules(file: SourceFile): boolean; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; getCommonSourceDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -2279,7 +2279,7 @@ namespace ts { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; for (const sourceFile of sourceFiles) { // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromNodeModules(sourceFile)) { + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { onSingleFileEmit(host, sourceFile); } } @@ -2315,7 +2315,7 @@ namespace ts { // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. const bundledSources = filter(host.getSourceFiles(), sourceFile => !isDeclarationFile(sourceFile) && - !host.isSourceFileFromNodeModules(sourceFile) && + !host.isSourceFileFromExternalLibrary(sourceFile) && (!isExternalModule(sourceFile) || !!getEmitModuleKind(options))); if (bundledSources.length) { From 5f6e25c8d2994694cefc907e50d7ba19f1e07722 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 29 Jun 2016 18:47:10 -0700 Subject: [PATCH 083/103] Use checkExpression, not checkExpressionCached --- 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 9ec2ec3309b..0aad4f61960 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12547,7 +12547,7 @@ namespace ts { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getCombinedTypeFlags(checkExpressionCached(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) { + !(getCombinedTypeFlags(checkExpression(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) { sourceType = getTypeWithFacts(sourceType, TypeFacts.NEUndefined); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); From dc5cf3386182233e135d31b222b1683a963f9718 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 22:54:18 -0700 Subject: [PATCH 084/103] Do not report unused errors for module augmentations --- src/compiler/checker.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b715310ad02..d593683a2a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14604,7 +14604,11 @@ namespace ts { if (hasProperty(node.locals, key)) { const local = node.locals[key]; if (!local.hasReference && !local.exportSymbol) { - forEach(local.declarations, d => error(d.name, Diagnostics._0_is_declared_but_never_used, local.name)); + for (const declaration of local.declarations) { + if (!isAmbientModule(declaration)) { + error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name); + } + } } } } @@ -16487,7 +16491,9 @@ namespace ts { if (node.body) { checkSourceElement(node.body); - checkUnusedIdentifiersDeferred(node); + if (!isGlobalScopeAugmentation(node)) { + checkUnusedIdentifiersDeferred(node); + } } } From f751901eee100fea85bf17917700e4d465e50ede Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 23:46:41 -0700 Subject: [PATCH 085/103] Consolidate refernce marking in resolveName to allow marking aliases correctelly --- src/compiler/checker.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d593683a2a9..40ff595b0ad 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -899,6 +899,10 @@ namespace ts { error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name); } } + + if (result && noUnusedIdentifiers && !isInAmbientContext(location)) { + result.hasReference = true; + } } return result; } @@ -4961,10 +4965,6 @@ namespace ts { // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; links.resolvedType = type; - - if (noUnusedIdentifiers && symbol !== unknownSymbol && !isInAmbientContext(node)) { - symbol.hasReference = true; - } } return links.resolvedType; } @@ -8327,9 +8327,6 @@ namespace ts { function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); - if (symbol && noUnusedIdentifiers && !isInAmbientContext(node)) { - symbol.hasReference = true; - } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -16674,9 +16671,6 @@ namespace ts { if (target.flags & SymbolFlags.Type) { checkTypeNameIsReserved(node.name, Diagnostics.Import_name_cannot_be_0); } - if (noUnusedIdentifiers && !isInAmbientContext(node)) { - target.hasReference = true; - } } } else { From 8fb3b25c1e3874334c668a9b82165316a3ad223b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Jun 2016 23:46:50 -0700 Subject: [PATCH 086/103] add tests --- tests/baselines/reference/unusedImports11.js | 41 ++++++++++++++++ .../reference/unusedImports11.symbols | 43 +++++++++++++++++ .../baselines/reference/unusedImports11.types | 48 +++++++++++++++++++ .../reference/unusedImports12.errors.txt | 29 +++++++++++ tests/baselines/reference/unusedImports12.js | 27 +++++++++++ tests/cases/compiler/unusedImports11.ts | 19 ++++++++ tests/cases/compiler/unusedImports12.ts | 13 +++++ 7 files changed, 220 insertions(+) create mode 100644 tests/baselines/reference/unusedImports11.js create mode 100644 tests/baselines/reference/unusedImports11.symbols create mode 100644 tests/baselines/reference/unusedImports11.types create mode 100644 tests/baselines/reference/unusedImports12.errors.txt create mode 100644 tests/baselines/reference/unusedImports12.js create mode 100644 tests/cases/compiler/unusedImports11.ts create mode 100644 tests/cases/compiler/unusedImports12.ts diff --git a/tests/baselines/reference/unusedImports11.js b/tests/baselines/reference/unusedImports11.js new file mode 100644 index 00000000000..86561e1021e --- /dev/null +++ b/tests/baselines/reference/unusedImports11.js @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/unusedImports11.ts] //// + +//// [b.ts] + +export class Member {} +export default Member; + + +//// [a.ts] +import { Member } from './b'; +import d, { Member as M } from './b'; +import * as ns from './b'; +import r = require("./b"); + +new Member(); +new d(); +new M(); +new ns.Member(); +new r.Member(); + +//// [b.js] +"use strict"; +var Member = (function () { + function Member() { + } + return Member; +}()); +exports.Member = Member; +exports.__esModule = true; +exports["default"] = Member; +//// [a.js] +"use strict"; +var b_1 = require('./b'); +var b_2 = require('./b'); +var ns = require('./b'); +var r = require("./b"); +new b_1.Member(); +new b_2["default"](); +new b_2.Member(); +new ns.Member(); +new r.Member(); diff --git a/tests/baselines/reference/unusedImports11.symbols b/tests/baselines/reference/unusedImports11.symbols new file mode 100644 index 00000000000..995b4a40c2a --- /dev/null +++ b/tests/baselines/reference/unusedImports11.symbols @@ -0,0 +1,43 @@ +=== tests/cases/compiler/a.ts === +import { Member } from './b'; +>Member : Symbol(Member, Decl(a.ts, 0, 8)) + +import d, { Member as M } from './b'; +>d : Symbol(d, Decl(a.ts, 1, 6)) +>Member : Symbol(M, Decl(a.ts, 1, 11)) +>M : Symbol(M, Decl(a.ts, 1, 11)) + +import * as ns from './b'; +>ns : Symbol(ns, Decl(a.ts, 2, 6)) + +import r = require("./b"); +>r : Symbol(r, Decl(a.ts, 2, 26)) + +new Member(); +>Member : Symbol(Member, Decl(a.ts, 0, 8)) + +new d(); +>d : Symbol(d, Decl(a.ts, 1, 6)) + +new M(); +>M : Symbol(M, Decl(a.ts, 1, 11)) + +new ns.Member(); +>ns.Member : Symbol(Member, Decl(b.ts, 0, 0)) +>ns : Symbol(ns, Decl(a.ts, 2, 6)) +>Member : Symbol(Member, Decl(b.ts, 0, 0)) + +new r.Member(); +>r.Member : Symbol(Member, Decl(b.ts, 0, 0)) +>r : Symbol(r, Decl(a.ts, 2, 26)) +>Member : Symbol(Member, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === + +export class Member {} +>Member : Symbol(Member, Decl(b.ts, 0, 0)) + +export default Member; +>Member : Symbol(Member, Decl(b.ts, 0, 0)) + + diff --git a/tests/baselines/reference/unusedImports11.types b/tests/baselines/reference/unusedImports11.types new file mode 100644 index 00000000000..1d71a0226b6 --- /dev/null +++ b/tests/baselines/reference/unusedImports11.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/a.ts === +import { Member } from './b'; +>Member : typeof Member + +import d, { Member as M } from './b'; +>d : typeof Member +>Member : typeof Member +>M : typeof Member + +import * as ns from './b'; +>ns : typeof ns + +import r = require("./b"); +>r : typeof ns + +new Member(); +>new Member() : Member +>Member : typeof Member + +new d(); +>new d() : Member +>d : typeof Member + +new M(); +>new M() : Member +>M : typeof Member + +new ns.Member(); +>new ns.Member() : Member +>ns.Member : typeof Member +>ns : typeof ns +>Member : typeof Member + +new r.Member(); +>new r.Member() : Member +>r.Member : typeof Member +>r : typeof ns +>Member : typeof Member + +=== tests/cases/compiler/b.ts === + +export class Member {} +>Member : Member + +export default Member; +>Member : Member + + diff --git a/tests/baselines/reference/unusedImports12.errors.txt b/tests/baselines/reference/unusedImports12.errors.txt new file mode 100644 index 00000000000..89b0687317b --- /dev/null +++ b/tests/baselines/reference/unusedImports12.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/a.ts(1,10): error TS6133: 'Member' is declared but never used. +tests/cases/compiler/a.ts(2,8): error TS6133: 'd' is declared but never used. +tests/cases/compiler/a.ts(2,23): error TS6133: 'M' is declared but never used. +tests/cases/compiler/a.ts(3,13): error TS6133: 'ns' is declared but never used. +tests/cases/compiler/a.ts(4,8): error TS6133: 'r' is declared but never used. + + +==== tests/cases/compiler/a.ts (5 errors) ==== + import { Member } from './b'; + ~~~~~~ +!!! error TS6133: 'Member' is declared but never used. + import d, { Member as M } from './b'; + ~ +!!! error TS6133: 'd' is declared but never used. + ~ +!!! error TS6133: 'M' is declared but never used. + import * as ns from './b'; + ~~ +!!! error TS6133: 'ns' is declared but never used. + import r = require("./b"); + ~ +!!! error TS6133: 'r' is declared but never used. + +==== tests/cases/compiler/b.ts (0 errors) ==== + + export class Member {} + export default Member; + + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports12.js b/tests/baselines/reference/unusedImports12.js new file mode 100644 index 00000000000..ece9b105bc9 --- /dev/null +++ b/tests/baselines/reference/unusedImports12.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/unusedImports12.ts] //// + +//// [b.ts] + +export class Member {} +export default Member; + + +//// [a.ts] +import { Member } from './b'; +import d, { Member as M } from './b'; +import * as ns from './b'; +import r = require("./b"); + + +//// [b.js] +"use strict"; +var Member = (function () { + function Member() { + } + return Member; +}()); +exports.Member = Member; +exports.__esModule = true; +exports["default"] = Member; +//// [a.js] +"use strict"; diff --git a/tests/cases/compiler/unusedImports11.ts b/tests/cases/compiler/unusedImports11.ts new file mode 100644 index 00000000000..4f2fed649d1 --- /dev/null +++ b/tests/cases/compiler/unusedImports11.ts @@ -0,0 +1,19 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @filename: b.ts +export class Member {} +export default Member; + + +// @filename: a.ts +import { Member } from './b'; +import d, { Member as M } from './b'; +import * as ns from './b'; +import r = require("./b"); + +new Member(); +new d(); +new M(); +new ns.Member(); +new r.Member(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports12.ts b/tests/cases/compiler/unusedImports12.ts new file mode 100644 index 00000000000..14206284b64 --- /dev/null +++ b/tests/cases/compiler/unusedImports12.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @filename: b.ts +export class Member {} +export default Member; + + +// @filename: a.ts +import { Member } from './b'; +import d, { Member as M } from './b'; +import * as ns from './b'; +import r = require("./b"); From 3d9c9206e437542ffce326b7d9820ec98613fead Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 30 Jun 2016 00:03:54 -0700 Subject: [PATCH 087/103] Code review comments --- src/compiler/checker.ts | 60 ++++++++++++++++++++--------------------- src/compiler/types.ts | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 40ff595b0ad..f42ca9ffe34 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -901,7 +901,7 @@ namespace ts { } if (result && noUnusedIdentifiers && !isInAmbientContext(location)) { - result.hasReference = true; + result.isReferenced = true; } } return result; @@ -10242,7 +10242,7 @@ namespace ts { } if (noUnusedIdentifiers && !isInAmbientContext(node)) { - prop.hasReference = true; + prop.isReferenced = true; } getNodeLinks(node).resolvedSymbol = prop; @@ -12187,7 +12187,7 @@ namespace ts { } } } - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } } @@ -13415,7 +13415,7 @@ namespace ts { checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); const symbol = getSymbolOfNode(node); const firstDeclaration = getDeclarationOfKind(symbol, node.kind); @@ -13561,7 +13561,7 @@ namespace ts { } if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) { checkSourceElement(node.body); - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } else { checkNodeDeferred(node); @@ -13578,7 +13578,7 @@ namespace ts { function checkAccessorDeferred(node: AccessorDeclaration) { checkSourceElement(node.body); - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } function checkMissingDeclaration(node: Node) { @@ -14482,26 +14482,26 @@ namespace ts { } } - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } - function checkUnusedIdentifiersDeferred(node: Node) { + function registerForUnusedIdentifiersCheck(node: Node) { if (deferredUnusedIdentifierNodes) { deferredUnusedIdentifierNodes.push(node); } } - function checkUnusedIdentifiersDeferredNodes() { + function checkUnusedIdentifiers() { if (deferredUnusedIdentifierNodes) { for (const node of deferredUnusedIdentifierNodes) { switch (node.kind) { case SyntaxKind.SourceFile: case SyntaxKind.ModuleDeclaration: - checkUnusedModuleLocals(node); + checkUnusedModuleMembers(node); break; case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: - checkUnusedClassLocals(node); + checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; case SyntaxKind.InterfaceDeclaration: @@ -14511,7 +14511,7 @@ namespace ts { case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: - checkUnusedIdentifiers(node); + checkUnusedLocalsAndParameters(node); break; case SyntaxKind.Constructor: case SyntaxKind.FunctionExpression: @@ -14521,7 +14521,7 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: if ((node).body) { - checkUnusedIdentifiers(node); + checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; @@ -14538,12 +14538,12 @@ namespace ts { } } - function checkUnusedIdentifiers(node: FunctionLikeDeclaration | ForStatement | Block): void { + function checkUnusedLocalsAndParameters(node: FunctionLikeDeclaration | ForStatement | Block): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { const local = node.locals[key]; - if (!local.hasReference) { + if (!local.isReferenced) { if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { if (compilerOptions.noUnusedParameters && !isParameterPropertyDeclaration(local.valueDeclaration)) { error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); @@ -14558,18 +14558,18 @@ namespace ts { } } - function checkUnusedClassLocals(node: ClassDeclaration | ClassExpression): void { + function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.members) { for (const member of node.members) { if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { - if (isPrivateNode(member) && !member.symbol.hasReference) { + if (isPrivateNode(member) && !member.symbol.isReferenced) { error(member.name, Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } else if (member.kind === SyntaxKind.Constructor) { for (const parameter of (member).parameters) { - if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + if (isPrivateNode(parameter) && !parameter.symbol.isReferenced) { error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); } } @@ -14583,7 +14583,7 @@ namespace ts { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.typeParameters) { for (const typeParameter of node.typeParameters) { - if (!typeParameter.symbol.hasReference) { + if (!typeParameter.symbol.isReferenced) { error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); } } @@ -14595,12 +14595,12 @@ namespace ts { return (node.flags & NodeFlags.Private) !== 0; } - function checkUnusedModuleLocals(node: ModuleDeclaration | SourceFile): void { + function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { const local = node.locals[key]; - if (!local.hasReference && !local.exportSymbol) { + if (!local.isReferenced && !local.exportSymbol) { for (const declaration of local.declarations) { if (!isAmbientModule(declaration)) { error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name); @@ -14619,7 +14619,7 @@ namespace ts { } forEach(node.statements, checkSourceElement); if (node.locals) { - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } } @@ -15085,7 +15085,7 @@ namespace ts { if (node.condition) checkExpression(node.condition); if (node.incrementor) checkExpression(node.incrementor); checkSourceElement(node.statement); - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } function checkForOfStatement(node: ForOfStatement): void { @@ -15127,7 +15127,7 @@ namespace ts { checkSourceElement(node.statement); if (node.locals) { - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } } @@ -15177,7 +15177,7 @@ namespace ts { checkSourceElement(node.statement); if (node.locals) { - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } } @@ -15771,7 +15771,7 @@ namespace ts { function checkClassExpressionDeferred(node: ClassExpression) { forEach(node.members, checkSourceElement); - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node: ClassDeclaration) { @@ -15781,7 +15781,7 @@ namespace ts { checkClassLikeDeclaration(node); forEach(node.members, checkSourceElement); - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { @@ -16489,7 +16489,7 @@ namespace ts { if (node.body) { checkSourceElement(node.body); if (!isGlobalScopeAugmentation(node)) { - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } } } @@ -17019,11 +17019,11 @@ namespace ts { checkDeferredNodes(); if (isExternalModule(node)) { - checkUnusedIdentifiersDeferred(node); + registerForUnusedIdentifiersCheck(node); } if (!node.isDeclarationFile) { - checkUnusedIdentifiersDeferredNodes(); + checkUnusedIdentifiers(); } deferredNodes = undefined; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 56029fd316c..a3d7fd4823d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2128,7 +2128,7 @@ namespace ts { /* @internal */ parent?: Symbol; // Parent symbol /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums - /* @internal */ hasReference?: boolean; // True if the symbol is referenced elsewhere + /* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere } /* @internal */ From b40512d8a21f5dd66df4b4c5a4940b68509effb9 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 30 Jun 2016 01:00:53 -0700 Subject: [PATCH 088/103] Only mark symbols found in a local symbol table --- src/compiler/checker.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f42ca9ffe34..0bedc9f404a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -51,7 +51,7 @@ namespace ts { const compilerOptions = host.getCompilerOptions(); const languageVersion = compilerOptions.target || ScriptTarget.ES3; const modulekind = getEmitModuleKind(compilerOptions); - const noUnusedIdentifiers = compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters; + const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System; const strictNullChecks = compilerOptions.strictNullChecks; @@ -849,6 +849,10 @@ namespace ts { location = location.parent; } + if (result && nameNotFoundMessage && noUnusedIdentifiers) { + result.isReferenced = true; + } + if (!result) { result = getSymbol(globals, name, meaning); } @@ -899,10 +903,6 @@ namespace ts { error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name); } } - - if (result && noUnusedIdentifiers && !isInAmbientContext(location)) { - result.isReferenced = true; - } } return result; } From 0535d55a9775c83e5c70a30fae5192561546bb90 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 30 Jun 2016 06:38:18 -0700 Subject: [PATCH 089/103] Show "" if the name of a declaration is unavailable --- src/services/navigationBar.ts | 3 +-- .../navigationBarNamespaceImportWithNoName.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index bfbaf5a6287..022c538e762 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -412,8 +412,7 @@ namespace ts.NavigationBar { case SyntaxKind.JSDocTypedefTag: return getJSDocTypedefTagName(node); default: - Debug.fail(); - return ""; + return ""; } } diff --git a/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts b/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts new file mode 100644 index 00000000000..732e2deb1dd --- /dev/null +++ b/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts @@ -0,0 +1,13 @@ +////import *{} from 'foo'; +verify.navigationBar([ + { + "text": "\"navigationBarNamespaceImportWithNoName\"", + "kind": "module", + "childItems": [ + { + "text": "", + "kind": "alias" + } + ] + } +]); From 4195eb3670cfe784995828e97758d93a600838cd Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 29 Jun 2016 13:29:54 -0700 Subject: [PATCH 090/103] Parse `export default async function` as a declaration --- src/compiler/parser.ts | 10 +++++----- src/compiler/types.ts | 2 +- .../reference/exportDefaultAsyncFunction.js | 18 ++++++++++++++++++ .../exportDefaultAsyncFunction.symbols | 8 ++++++++ .../reference/exportDefaultAsyncFunction.types | 9 +++++++++ .../compiler/exportDefaultAsyncFunction.ts | 3 +++ 6 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/exportDefaultAsyncFunction.js create mode 100644 tests/baselines/reference/exportDefaultAsyncFunction.symbols create mode 100644 tests/baselines/reference/exportDefaultAsyncFunction.types create mode 100644 tests/cases/compiler/exportDefaultAsyncFunction.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9f02e8c2926..d720cd0648f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1155,12 +1155,12 @@ namespace ts { if (token === SyntaxKind.ExportKeyword) { nextToken(); if (token === SyntaxKind.DefaultKeyword) { - return lookAhead(nextTokenIsClassOrFunction); + return lookAhead(nextTokenIsClassOrFunctionOrAsync); } return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.AsKeyword && token !== SyntaxKind.OpenBraceToken && canFollowModifier(); } if (token === SyntaxKind.DefaultKeyword) { - return nextTokenIsClassOrFunction(); + return nextTokenIsClassOrFunctionOrAsync(); } if (token === SyntaxKind.StaticKeyword) { nextToken(); @@ -1182,9 +1182,9 @@ namespace ts { || isLiteralPropertyName(); } - function nextTokenIsClassOrFunction(): boolean { + function nextTokenIsClassOrFunctionOrAsync(): boolean { nextToken(); - return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword; + return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword || token === SyntaxKind.AsyncKeyword; } // True if positioned at the start of a list element @@ -5070,7 +5070,7 @@ namespace ts { * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray { - let flags = 0; + let flags: NodeFlags = 0; let modifiers: ModifiersArray; while (true) { const modifierStart = scanner.getStartPos(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 56029fd316c..0110fda4e41 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -469,7 +469,7 @@ namespace ts { } export interface ModifiersArray extends NodeArray { - flags: number; + flags: NodeFlags; } // @kind(SyntaxKind.AbstractKeyword) diff --git a/tests/baselines/reference/exportDefaultAsyncFunction.js b/tests/baselines/reference/exportDefaultAsyncFunction.js new file mode 100644 index 00000000000..a06b41b5e73 --- /dev/null +++ b/tests/baselines/reference/exportDefaultAsyncFunction.js @@ -0,0 +1,18 @@ +//// [exportDefaultAsyncFunction.ts] +export default async function foo(): Promise {} +foo(); + + +//// [exportDefaultAsyncFunction.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +export default function foo() { + return __awaiter(this, void 0, void 0, function* () { }); +} +foo(); diff --git a/tests/baselines/reference/exportDefaultAsyncFunction.symbols b/tests/baselines/reference/exportDefaultAsyncFunction.symbols new file mode 100644 index 00000000000..47178519558 --- /dev/null +++ b/tests/baselines/reference/exportDefaultAsyncFunction.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/exportDefaultAsyncFunction.ts === +export default async function foo(): Promise {} +>foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +foo(); +>foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0)) + diff --git a/tests/baselines/reference/exportDefaultAsyncFunction.types b/tests/baselines/reference/exportDefaultAsyncFunction.types new file mode 100644 index 00000000000..7258c6fcf0c --- /dev/null +++ b/tests/baselines/reference/exportDefaultAsyncFunction.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/exportDefaultAsyncFunction.ts === +export default async function foo(): Promise {} +>foo : () => Promise +>Promise : Promise + +foo(); +>foo() : Promise +>foo : () => Promise + diff --git a/tests/cases/compiler/exportDefaultAsyncFunction.ts b/tests/cases/compiler/exportDefaultAsyncFunction.ts new file mode 100644 index 00000000000..c05296711ec --- /dev/null +++ b/tests/cases/compiler/exportDefaultAsyncFunction.ts @@ -0,0 +1,3 @@ +// @target: es6 +export default async function foo(): Promise {} +foo(); From 1fa69caf13ddb9474bb4231d02268701ddbbf67f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 30 Jun 2016 10:38:59 -0700 Subject: [PATCH 091/103] handel private properties correctelly --- src/compiler/checker.ts | 9 +- src/compiler/types.ts | 2 + .../reference/unusedPrivateMembers.js | 114 +++++++++++++++++ .../reference/unusedPrivateMembers.symbols | 113 ++++++++++++++++ .../reference/unusedPrivateMembers.types | 121 ++++++++++++++++++ tests/cases/compiler/unusedPrivateMembers.ts | 51 ++++++++ 6 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/unusedPrivateMembers.js create mode 100644 tests/baselines/reference/unusedPrivateMembers.symbols create mode 100644 tests/baselines/reference/unusedPrivateMembers.types create mode 100644 tests/cases/compiler/unusedPrivateMembers.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0bedc9f404a..33ff04697f9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10241,8 +10241,13 @@ namespace ts { return unknownType; } - if (noUnusedIdentifiers && !isInAmbientContext(node)) { - prop.isReferenced = true; + if (noUnusedIdentifiers && (prop.flags & SymbolFlags.ClassMember)) { + if (prop.flags & SymbolFlags.Instantiated) { + getSymbolLinks(prop).target.isReferenced = true; + } + else { + prop.isReferenced = true; + } } getNodeLinks(node).resolvedSymbol = prop; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a3d7fd4823d..7d7e92f27c3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2107,6 +2107,8 @@ namespace ts { PropertyOrAccessor = Property | Accessor, Export = ExportNamespace | ExportType | ExportValue, + ClassMember = Method | Accessor | Property, + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. diff --git a/tests/baselines/reference/unusedPrivateMembers.js b/tests/baselines/reference/unusedPrivateMembers.js new file mode 100644 index 00000000000..cdb540349c3 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMembers.js @@ -0,0 +1,114 @@ +//// [unusedPrivateMembers.ts] + +class Test1 { + private initializeInternal() { + } + + public test() { + var x = new Test1(); + x.initializeInternal(); + } +} + +class Test2 { + private p = 0; + public test() { + var x = new Test2(); + x.p; + } +} + +class Test3 { + private get x () { + return 0; + } + + public test() { + var x = new Test3(); + x.x; + } +} + +class Test4 { + private set x(v) { + v; + } + + public test() { + var x = new Test4(); + x.x; + } +} + +class Test5 { + private p: T; + public test() { + var x = new Test5(); + x.p; + } +} + + +//// [unusedPrivateMembers.js] +var Test1 = (function () { + function Test1() { + } + Test1.prototype.initializeInternal = function () { + }; + Test1.prototype.test = function () { + var x = new Test1(); + x.initializeInternal(); + }; + return Test1; +}()); +var Test2 = (function () { + function Test2() { + this.p = 0; + } + Test2.prototype.test = function () { + var x = new Test2(); + x.p; + }; + return Test2; +}()); +var Test3 = (function () { + function Test3() { + } + Object.defineProperty(Test3.prototype, "x", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Test3.prototype.test = function () { + var x = new Test3(); + x.x; + }; + return Test3; +}()); +var Test4 = (function () { + function Test4() { + } + Object.defineProperty(Test4.prototype, "x", { + set: function (v) { + v; + }, + enumerable: true, + configurable: true + }); + Test4.prototype.test = function () { + var x = new Test4(); + x.x; + }; + return Test4; +}()); +var Test5 = (function () { + function Test5() { + } + Test5.prototype.test = function () { + var x = new Test5(); + x.p; + }; + return Test5; +}()); diff --git a/tests/baselines/reference/unusedPrivateMembers.symbols b/tests/baselines/reference/unusedPrivateMembers.symbols new file mode 100644 index 00000000000..0d4426a594a --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMembers.symbols @@ -0,0 +1,113 @@ +=== tests/cases/compiler/unusedPrivateMembers.ts === + +class Test1 { +>Test1 : Symbol(Test1, Decl(unusedPrivateMembers.ts, 0, 0)) + + private initializeInternal() { +>initializeInternal : Symbol(Test1.initializeInternal, Decl(unusedPrivateMembers.ts, 1, 13)) + } + + public test() { +>test : Symbol(Test1.test, Decl(unusedPrivateMembers.ts, 3, 5)) + + var x = new Test1(); +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 6, 11)) +>Test1 : Symbol(Test1, Decl(unusedPrivateMembers.ts, 0, 0)) + + x.initializeInternal(); +>x.initializeInternal : Symbol(Test1.initializeInternal, Decl(unusedPrivateMembers.ts, 1, 13)) +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 6, 11)) +>initializeInternal : Symbol(Test1.initializeInternal, Decl(unusedPrivateMembers.ts, 1, 13)) + } +} + +class Test2 { +>Test2 : Symbol(Test2, Decl(unusedPrivateMembers.ts, 9, 1)) + + private p = 0; +>p : Symbol(Test2.p, Decl(unusedPrivateMembers.ts, 11, 13)) + + public test() { +>test : Symbol(Test2.test, Decl(unusedPrivateMembers.ts, 12, 18)) + + var x = new Test2(); +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 14, 11)) +>Test2 : Symbol(Test2, Decl(unusedPrivateMembers.ts, 9, 1)) + + x.p; +>x.p : Symbol(Test2.p, Decl(unusedPrivateMembers.ts, 11, 13)) +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 14, 11)) +>p : Symbol(Test2.p, Decl(unusedPrivateMembers.ts, 11, 13)) + } +} + +class Test3 { +>Test3 : Symbol(Test3, Decl(unusedPrivateMembers.ts, 17, 1)) + + private get x () { +>x : Symbol(Test3.x, Decl(unusedPrivateMembers.ts, 19, 13)) + + return 0; + } + + public test() { +>test : Symbol(Test3.test, Decl(unusedPrivateMembers.ts, 22, 5)) + + var x = new Test3(); +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 25, 11)) +>Test3 : Symbol(Test3, Decl(unusedPrivateMembers.ts, 17, 1)) + + x.x; +>x.x : Symbol(Test3.x, Decl(unusedPrivateMembers.ts, 19, 13)) +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 25, 11)) +>x : Symbol(Test3.x, Decl(unusedPrivateMembers.ts, 19, 13)) + } +} + +class Test4 { +>Test4 : Symbol(Test4, Decl(unusedPrivateMembers.ts, 28, 1)) + + private set x(v) { +>x : Symbol(Test4.x, Decl(unusedPrivateMembers.ts, 30, 13)) +>v : Symbol(v, Decl(unusedPrivateMembers.ts, 31, 18)) + + v; +>v : Symbol(v, Decl(unusedPrivateMembers.ts, 31, 18)) + } + + public test() { +>test : Symbol(Test4.test, Decl(unusedPrivateMembers.ts, 33, 5)) + + var x = new Test4(); +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 36, 11)) +>Test4 : Symbol(Test4, Decl(unusedPrivateMembers.ts, 28, 1)) + + x.x; +>x.x : Symbol(Test4.x, Decl(unusedPrivateMembers.ts, 30, 13)) +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 36, 11)) +>x : Symbol(Test4.x, Decl(unusedPrivateMembers.ts, 30, 13)) + } +} + +class Test5 { +>Test5 : Symbol(Test5, Decl(unusedPrivateMembers.ts, 39, 1)) +>T : Symbol(T, Decl(unusedPrivateMembers.ts, 41, 12)) + + private p: T; +>p : Symbol(Test5.p, Decl(unusedPrivateMembers.ts, 41, 16)) +>T : Symbol(T, Decl(unusedPrivateMembers.ts, 41, 12)) + + public test() { +>test : Symbol(Test5.test, Decl(unusedPrivateMembers.ts, 42, 17)) + + var x = new Test5(); +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 44, 11)) +>Test5 : Symbol(Test5, Decl(unusedPrivateMembers.ts, 39, 1)) + + x.p; +>x.p : Symbol(Test5.p, Decl(unusedPrivateMembers.ts, 41, 16)) +>x : Symbol(x, Decl(unusedPrivateMembers.ts, 44, 11)) +>p : Symbol(Test5.p, Decl(unusedPrivateMembers.ts, 41, 16)) + } +} + diff --git a/tests/baselines/reference/unusedPrivateMembers.types b/tests/baselines/reference/unusedPrivateMembers.types new file mode 100644 index 00000000000..1d303068f24 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMembers.types @@ -0,0 +1,121 @@ +=== tests/cases/compiler/unusedPrivateMembers.ts === + +class Test1 { +>Test1 : Test1 + + private initializeInternal() { +>initializeInternal : () => void + } + + public test() { +>test : () => void + + var x = new Test1(); +>x : Test1 +>new Test1() : Test1 +>Test1 : typeof Test1 + + x.initializeInternal(); +>x.initializeInternal() : void +>x.initializeInternal : () => void +>x : Test1 +>initializeInternal : () => void + } +} + +class Test2 { +>Test2 : Test2 + + private p = 0; +>p : number +>0 : number + + public test() { +>test : () => void + + var x = new Test2(); +>x : Test2 +>new Test2() : Test2 +>Test2 : typeof Test2 + + x.p; +>x.p : number +>x : Test2 +>p : number + } +} + +class Test3 { +>Test3 : Test3 + + private get x () { +>x : number + + return 0; +>0 : number + } + + public test() { +>test : () => void + + var x = new Test3(); +>x : Test3 +>new Test3() : Test3 +>Test3 : typeof Test3 + + x.x; +>x.x : number +>x : Test3 +>x : number + } +} + +class Test4 { +>Test4 : Test4 + + private set x(v) { +>x : any +>v : any + + v; +>v : any + } + + public test() { +>test : () => void + + var x = new Test4(); +>x : Test4 +>new Test4() : Test4 +>Test4 : typeof Test4 + + x.x; +>x.x : any +>x : Test4 +>x : any + } +} + +class Test5 { +>Test5 : Test5 +>T : T + + private p: T; +>p : T +>T : T + + public test() { +>test : () => void + + var x = new Test5(); +>x : Test5 +>new Test5() : Test5 +>Test5 : typeof Test5 + + x.p; +>x.p : number +>x : Test5 +>p : number + } +} + diff --git a/tests/cases/compiler/unusedPrivateMembers.ts b/tests/cases/compiler/unusedPrivateMembers.ts new file mode 100644 index 00000000000..ab4e5ba9bca --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMembers.ts @@ -0,0 +1,51 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true +//@target:ES5 + +class Test1 { + private initializeInternal() { + } + + public test() { + var x = new Test1(); + x.initializeInternal(); + } +} + +class Test2 { + private p = 0; + public test() { + var x = new Test2(); + x.p; + } +} + +class Test3 { + private get x () { + return 0; + } + + public test() { + var x = new Test3(); + x.x; + } +} + +class Test4 { + private set x(v) { + v; + } + + public test() { + var x = new Test4(); + x.x; + } +} + +class Test5 { + private p: T; + public test() { + var x = new Test5(); + x.p; + } +} From b8486906264bb7228c363a3b2e8be36ab9dbdef4 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Thu, 30 Jun 2016 14:26:07 -0700 Subject: [PATCH 092/103] Port 9426 to release 2.0 --- src/services/formatting/smartIndenter.ts | 2 +- .../formattingIllegalImportClause.ts | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/formattingIllegalImportClause.ts diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 120a5be6e4e..4eebf4b9431 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -497,7 +497,7 @@ namespace ts.formatting { return childKind !== SyntaxKind.NamedExports; case SyntaxKind.ImportDeclaration: return childKind !== SyntaxKind.ImportClause || - (child).namedBindings.kind !== SyntaxKind.NamedImports; + ((child).namedBindings && (child).namedBindings.kind !== SyntaxKind.NamedImports); case SyntaxKind.JsxElement: return childKind !== SyntaxKind.JsxClosingElement; } diff --git a/tests/cases/fourslash/formattingIllegalImportClause.ts b/tests/cases/fourslash/formattingIllegalImportClause.ts new file mode 100644 index 00000000000..9e97087c000 --- /dev/null +++ b/tests/cases/fourslash/formattingIllegalImportClause.ts @@ -0,0 +1,26 @@ +/// + +//// var expect = require('expect.js'); +//// import React from 'react'/*1*/; +//// import { mount } from 'enzyme'; +//// require('../setup'); +//// var Amount = require('../../src/js/components/amount'); + +//// describe('', () => { +//// var history +//// beforeEach(() => { +//// history = createMemoryHistory(); +//// sinon.spy(history, 'pushState'); +//// }); + +//// afterEach(() => { +//// }) + +//// it('redirects to order summary', () => { + +//// }); +//// }); + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("import React from 'react';") \ No newline at end of file From 54b4bef8c8eea59c56c0d2a1b5ffa19cd03a3316 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 30 Jun 2016 15:18:17 -0700 Subject: [PATCH 093/103] Handel Swtich statements check for locals on for statments only mark private properties --- src/compiler/checker.ts | 25 +++++++----- .../reference/unusedSwitchStatment.errors.txt | 31 +++++++++++++++ .../reference/unusedSwitchStatment.js | 38 +++++++++++++++++++ tests/cases/compiler/unusedSwitchStatment.ts | 21 ++++++++++ 4 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/unusedSwitchStatment.errors.txt create mode 100644 tests/baselines/reference/unusedSwitchStatment.js create mode 100644 tests/cases/compiler/unusedSwitchStatment.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 33ff04697f9..be94a7ce4e3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10241,9 +10241,12 @@ namespace ts { return unknownType; } - if (noUnusedIdentifiers && (prop.flags & SymbolFlags.ClassMember)) { + if (noUnusedIdentifiers && + (prop.flags & SymbolFlags.ClassMember) && + prop.valueDeclaration && (prop.valueDeclaration.flags & NodeFlags.Private)) { if (prop.flags & SymbolFlags.Instantiated) { getSymbolLinks(prop).target.isReferenced = true; + } else { prop.isReferenced = true; @@ -14513,10 +14516,11 @@ namespace ts { checkUnusedTypeParameters(node); break; case SyntaxKind.Block: + case SyntaxKind.CaseBlock: case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: - checkUnusedLocalsAndParameters(node); + checkUnusedLocalsAndParameters(node); break; case SyntaxKind.Constructor: case SyntaxKind.FunctionExpression: @@ -14543,7 +14547,7 @@ namespace ts { } } - function checkUnusedLocalsAndParameters(node: FunctionLikeDeclaration | ForStatement | Block): void { + function checkUnusedLocalsAndParameters(node: Node): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { @@ -14568,13 +14572,13 @@ namespace ts { if (node.members) { for (const member of node.members) { if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { - if (isPrivateNode(member) && !member.symbol.isReferenced) { + if (!member.symbol.isReferenced && member.flags & NodeFlags.Private) { error(member.name, Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } else if (member.kind === SyntaxKind.Constructor) { for (const parameter of (member).parameters) { - if (isPrivateNode(parameter) && !parameter.symbol.isReferenced) { + if (!parameter.symbol.isReferenced && parameter.flags & NodeFlags.Private) { error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); } } @@ -14596,10 +14600,6 @@ namespace ts { } } - function isPrivateNode(node: Node): boolean { - return (node.flags & NodeFlags.Private) !== 0; - } - function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { @@ -15090,7 +15090,9 @@ namespace ts { if (node.condition) checkExpression(node.condition); if (node.incrementor) checkExpression(node.incrementor); checkSourceElement(node.statement); - registerForUnusedIdentifiersCheck(node); + if (node.locals) { + registerForUnusedIdentifiersCheck(node); + } } function checkForOfStatement(node: ForOfStatement): void { @@ -15556,6 +15558,9 @@ namespace ts { } forEach(clause.statements, checkSourceElement); }); + if (node.caseBlock.locals) { + registerForUnusedIdentifiersCheck(node.caseBlock); + } } function checkLabeledStatement(node: LabeledStatement) { diff --git a/tests/baselines/reference/unusedSwitchStatment.errors.txt b/tests/baselines/reference/unusedSwitchStatment.errors.txt new file mode 100644 index 00000000000..58359eed90d --- /dev/null +++ b/tests/baselines/reference/unusedSwitchStatment.errors.txt @@ -0,0 +1,31 @@ +tests/cases/compiler/unusedSwitchStatment.ts(4,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedSwitchStatment.ts(7,15): error TS6133: 'c' is declared but never used. +tests/cases/compiler/unusedSwitchStatment.ts(10,13): error TS6133: 'z' is declared but never used. + + +==== tests/cases/compiler/unusedSwitchStatment.ts (3 errors) ==== + + switch (1) { + case 0: + let x; + ~ +!!! error TS6133: 'x' is declared but never used. + break; + case 1: + const c = 1; + ~ +!!! error TS6133: 'c' is declared but never used. + break; + default: + let z = 2; + ~ +!!! error TS6133: 'z' is declared but never used. + } + + + switch (2) { + case 0: + let x; + case 1: + x++; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSwitchStatment.js b/tests/baselines/reference/unusedSwitchStatment.js new file mode 100644 index 00000000000..2fd0d1fc49e --- /dev/null +++ b/tests/baselines/reference/unusedSwitchStatment.js @@ -0,0 +1,38 @@ +//// [unusedSwitchStatment.ts] + +switch (1) { + case 0: + let x; + break; + case 1: + const c = 1; + break; + default: + let z = 2; +} + + +switch (2) { + case 0: + let x; + case 1: + x++; +} + +//// [unusedSwitchStatment.js] +switch (1) { + case 0: + var x = void 0; + break; + case 1: + var c = 1; + break; + default: + var z = 2; +} +switch (2) { + case 0: + var x = void 0; + case 1: + x++; +} diff --git a/tests/cases/compiler/unusedSwitchStatment.ts b/tests/cases/compiler/unusedSwitchStatment.ts new file mode 100644 index 00000000000..53f93b913aa --- /dev/null +++ b/tests/cases/compiler/unusedSwitchStatment.ts @@ -0,0 +1,21 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +switch (1) { + case 0: + let x; + break; + case 1: + const c = 1; + break; + default: + let z = 2; +} + + +switch (2) { + case 0: + let x; + case 1: + x++; +} \ No newline at end of file From 5e4f13f342a75ec8f7cf65cb669bec9d6e6c5581 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Thu, 30 Jun 2016 16:36:39 -0700 Subject: [PATCH 094/103] Removed one error to avoid full path issues --- .../amd/maxDepthIncreased/root.js | 1 - .../amd/nodeModulesMaxDepthIncreased.errors.txt | 6 +----- .../node/maxDepthIncreased/root.js | 1 - .../node/nodeModulesMaxDepthIncreased.errors.txt | 6 +----- .../projects/NodeModulesSearch/maxDepthIncreased/root.ts | 1 - 5 files changed, 2 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js index 0024891fbe3..9ef3915c851 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -3,6 +3,5 @@ define(["require", "exports", "m1", "m4"], function (require, exports, m1, m4) { m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly - var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file }); diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt index 473d69bc526..f511000d5ac 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt @@ -1,5 +1,4 @@ maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. -maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -32,7 +31,7 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on ==== entry.d.ts (0 errors) ==== export declare var foo: number; -==== maxDepthIncreased/root.ts (2 errors) ==== +==== maxDepthIncreased/root.ts (1 errors) ==== import * as m1 from "m1"; import * as m4 from "m4"; @@ -42,9 +41,6 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. - let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index ba6d7e96241..f6783cda79b 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -4,5 +4,4 @@ var m4 = require("m4"); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly -var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt index 473d69bc526..f511000d5ac 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt @@ -1,5 +1,4 @@ maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. -maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -32,7 +31,7 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on ==== entry.d.ts (0 errors) ==== export declare var foo: number; -==== maxDepthIncreased/root.ts (2 errors) ==== +==== maxDepthIncreased/root.ts (1 errors) ==== import * as m1 from "m1"; import * as m4 from "m4"; @@ -42,9 +41,6 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. - let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts index 5d9f331b249..2b80564ae26 100644 --- a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts @@ -5,6 +5,5 @@ m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly -let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file From d64ab2f9ad798c55e6121fb75ae7b1fa76d71a79 Mon Sep 17 00:00:00 2001 From: Doug Ilijev Date: Thu, 30 Jun 2016 18:33:32 -0700 Subject: [PATCH 095/103] Fix incorrectly-saved quote symbols in ThirdPartyNoticeText.txt --- ThirdPartyNoticeText.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdPartyNoticeText.txt b/ThirdPartyNoticeText.txt index 6fbb7e4a0ce..a9ffbddbd89 100644 --- a/ThirdPartyNoticeText.txt +++ b/ThirdPartyNoticeText.txt @@ -21,7 +21,7 @@ Third Party Code Components -------------------------------------------- ------------------- DefinitelyTyped -------------------- -This file is based on or incorporates material from the projects listed below (collectively ?Third Party Code?). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise. +This file is based on or incorporates material from the projects listed below (collectively "Third Party Code"). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise. DefinitelyTyped This project is licensed under the MIT license. Copyrights are respective of each contributor listed at the beginning of each definition file. From 5de7ca2cb182ef6e88d700991e7b95c753a1bdfe Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 30 Jun 2016 19:35:30 -0700 Subject: [PATCH 096/103] Fix #9458: exclude parameters starting with underscore from unusedParamter checks --- src/compiler/checker.ts | 9 ++- .../unusedParametersWithUnderscore.errors.txt | 56 +++++++++++++++++++ .../unusedParametersWithUnderscore.js | 50 +++++++++++++++++ .../unusedParametersWithUnderscore.ts | 25 +++++++++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/unusedParametersWithUnderscore.errors.txt create mode 100644 tests/baselines/reference/unusedParametersWithUnderscore.js create mode 100644 tests/cases/compiler/unusedParametersWithUnderscore.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index be94a7ce4e3..c62277fc346 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14554,7 +14554,10 @@ namespace ts { const local = node.locals[key]; if (!local.isReferenced) { if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { - if (compilerOptions.noUnusedParameters && !isParameterPropertyDeclaration(local.valueDeclaration)) { + const parameter = local.valueDeclaration; + if (compilerOptions.noUnusedParameters && + !isParameterPropertyDeclaration(parameter) && + !parameterNameStartsWithUnderscore(parameter)) { error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } @@ -14567,6 +14570,10 @@ namespace ts { } } + function parameterNameStartsWithUnderscore(parameter: ParameterDeclaration) { + return parameter.name && parameter.name.kind === SyntaxKind.Identifier && (parameter.name).text.charCodeAt(0) === CharacterCodes._; + } + function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.members) { diff --git a/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt new file mode 100644 index 00000000000..adfe7bb9bc1 --- /dev/null +++ b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt @@ -0,0 +1,56 @@ +tests/cases/compiler/unusedParametersWithUnderscore.ts(2,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(2,19): error TS6133: 'c' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(2,27): error TS6133: 'd' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(2,29): error TS6133: 'e___' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(6,14): error TS6133: '_a' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(6,18): error TS6133: '___b' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(9,14): error TS6133: '_a' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(9,19): error TS6133: '___b' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(12,16): error TS6133: 'arg' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(18,13): error TS6133: 'arg' is declared but never used. + + +==== tests/cases/compiler/unusedParametersWithUnderscore.ts (10 errors) ==== + + function f(a, _b, c, ___, d,e___, _f) { + ~ +!!! error TS6133: 'a' is declared but never used. + ~ +!!! error TS6133: 'c' is declared but never used. + ~ +!!! error TS6133: 'd' is declared but never used. + ~~~~ +!!! error TS6133: 'e___' is declared but never used. + } + + + function f2({_a, __b}) { + ~~ +!!! error TS6133: '_a' is declared but never used. + ~~~ +!!! error TS6133: '___b' is declared but never used. + } + + function f3([_a, ,__b]) { + ~~ +!!! error TS6133: '_a' is declared but never used. + ~~~ +!!! error TS6133: '___b' is declared but never used. + } + + function f4(...arg) { + ~~~ +!!! error TS6133: 'arg' is declared but never used. + } + + function f5(..._arg) { + } + + function f6(arg?, _arg?) { + ~~~ +!!! error TS6133: 'arg' is declared but never used. + } + + var f7 = _ => undefined; + + var f8 = function (_) { }; \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersWithUnderscore.js b/tests/baselines/reference/unusedParametersWithUnderscore.js new file mode 100644 index 00000000000..2899d347c66 --- /dev/null +++ b/tests/baselines/reference/unusedParametersWithUnderscore.js @@ -0,0 +1,50 @@ +//// [unusedParametersWithUnderscore.ts] + +function f(a, _b, c, ___, d,e___, _f) { +} + + +function f2({_a, __b}) { +} + +function f3([_a, ,__b]) { +} + +function f4(...arg) { +} + +function f5(..._arg) { +} + +function f6(arg?, _arg?) { +} + +var f7 = _ => undefined; + +var f8 = function (_) { }; + +//// [unusedParametersWithUnderscore.js] +function f(a, _b, c, ___, d, e___, _f) { +} +function f2(_c) { + var _a = _c._a, __b = _c.__b; +} +function f3(_c) { + var _a = _c[0], __b = _c[2]; +} +function f4() { + var arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + arg[_i - 0] = arguments[_i]; + } +} +function f5() { + var _arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + _arg[_i - 0] = arguments[_i]; + } +} +function f6(arg, _arg) { +} +var f7 = function (_) { return undefined; }; +var f8 = function (_) { }; diff --git a/tests/cases/compiler/unusedParametersWithUnderscore.ts b/tests/cases/compiler/unusedParametersWithUnderscore.ts new file mode 100644 index 00000000000..e7382e5c2af --- /dev/null +++ b/tests/cases/compiler/unusedParametersWithUnderscore.ts @@ -0,0 +1,25 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f(a, _b, c, ___, d,e___, _f) { +} + + +function f2({_a, __b}) { +} + +function f3([_a, ,__b]) { +} + +function f4(...arg) { +} + +function f5(..._arg) { +} + +function f6(arg?, _arg?) { +} + +var f7 = _ => undefined; + +var f8 = function (_) { }; \ No newline at end of file From d63ef2c9f5af1870cd0ebe336bbe87fc3842a7ba Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Sat, 2 Jul 2016 00:15:06 +0800 Subject: [PATCH 097/103] change variable name for strict mode --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0181c8c78f6..085749892be 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13294,8 +13294,8 @@ namespace ts { } } else { - const static = forEach(member.modifiers, m => m.kind === SyntaxKind.StaticKeyword); - const names = static ? staticNames : instanceNames; + const isStatic = forEach(member.modifiers, m => m.kind === SyntaxKind.StaticKeyword); + const names = isStatic ? staticNames : instanceNames; const memberName = member.name && getPropertyNameForPropertyNameNode(member.name); if (memberName) { From a591d40584ec610a60c57141bb7f0f33db99f666 Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 1 Jul 2016 09:59:30 -0700 Subject: [PATCH 098/103] Increase timeout from running RWC. As UWDWeb takes slightly longer now (#9454) --- Gulpfile.ts | 2 +- Jakefile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 74113b4b0c7..3f9b2a66caa 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -650,7 +650,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } if (tests && tests.toLocaleLowerCase() === "rwc") { - testTimeout = 100000; + testTimeout = 400000; } const colors = cmdLineOptions["colors"]; diff --git a/Jakefile.js b/Jakefile.js index 7db91abcfcc..828f4b084d1 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -750,7 +750,7 @@ function runConsoleTests(defaultReporter, runInParallel) { } if (tests && tests.toLocaleLowerCase() === "rwc") { - testTimeout = 100000; + testTimeout = 400000; } colors = process.env.colors || process.env.color; From 9eba8d751d55a4a2915b7c843912f6d35336940d Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 1 Jul 2016 09:59:07 -0700 Subject: [PATCH 099/103] Handle relative paths in tsconfig exclude and include globs --- src/compiler/commandLineParser.ts | 20 ++- src/compiler/core.ts | 18 +-- src/compiler/diagnosticMessages.json | 4 + tests/cases/unittests/matchFiles.ts | 198 ++++++++++++++++++++++++++- 4 files changed, 229 insertions(+), 11 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index aa85c32f6cd..7b2aedb5d3d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -891,6 +891,21 @@ namespace ts { */ const invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + /** + * Tests for a path where .. appears after a recursive directory wildcard. + * Matches **\..\*, **\a\..\*, and **\.., but not ..\**\* + * + * NOTE: used \ in place of / above to avoid issues with multiline comments. + * + * Breakdown: + * (^|\/) # matches either the beginning of the string or a directory separator. + * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator. + * (.*\/)? # optionally matches any number of characters followed by a directory separator. + * \.\. # matches a parent directory path component ".." + * ($|\/) # matches either the end of the string or a directory separator. + */ + const invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + /** * Tests for a path containing a wildcard character in a directory component of the path. * Matches \*\, \?\, and \a*b\, but not \a\ or \a\*. @@ -1023,6 +1038,9 @@ namespace ts { else if (invalidMultipleRecursionPatterns.test(spec)) { errors.push(createCompilerDiagnostic(Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(createCompilerDiagnostic(Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } else { validSpecs.push(spec); } @@ -1052,7 +1070,7 @@ namespace ts { if (include !== undefined) { const recursiveKeys: string[] = []; for (const file of include) { - const name = combinePaths(path, file); + const name = normalizePath(combinePaths(path, file)); if (excludeRegex && excludeRegex.test(name)) { continue; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4aba46c7839..fe4731a1c91 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1072,15 +1072,17 @@ namespace ts { // Storage for literal base paths amongst the include patterns. const includeBasePaths: string[] = []; for (const include of includes) { - if (isRootedDiskPath(include)) { - const wildcardOffset = indexOfAnyCharCode(include, wildcardCharCodes); - const includeBasePath = wildcardOffset < 0 - ? removeTrailingDirectorySeparator(getDirectoryPath(include)) - : include.substring(0, include.lastIndexOf(directorySeparator, wildcardOffset)); + // We also need to check the relative paths by converting them to absolute and normalizing + // in case they escape the base path (e.g "..\somedirectory") + const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include)); - // Append the literal and canonical candidate base paths. - includeBasePaths.push(includeBasePath); - } + const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); + const includeBasePath = wildcardOffset < 0 + ? removeTrailingDirectorySeparator(getDirectoryPath(absolute)) + : absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset)); + + // Append the literal and canonical candidate base paths. + includeBasePaths.push(includeBasePath); } // Sort the offsets array using either the literal or canonical path representations. diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0ee1818ee57..7996f80bd91 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2332,6 +2332,10 @@ "category": "Error", "code": 5064 }, + "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'.": { + "category": "Error", + "code": 5065 + }, "Concatenate and emit output to single file.": { "category": "Message", "code": 6001 diff --git a/tests/cases/unittests/matchFiles.ts b/tests/cases/unittests/matchFiles.ts index b9c538a9e14..d68fb9b2a7f 100644 --- a/tests/cases/unittests/matchFiles.ts +++ b/tests/cases/unittests/matchFiles.ts @@ -24,7 +24,8 @@ namespace ts { "c:/dev/x/y/b.ts", "c:/dev/js/a.js", "c:/dev/js/b.js", - "c:/ext/ext.ts" + "c:/ext/ext.ts", + "c:/ext/b/a..b.ts" ]); const caseSensitiveBasePath = "/dev/"; @@ -740,7 +741,7 @@ namespace ts { "c:/dev/a.ts", "c:/dev/b.ts", "c:/dev/c.d.ts", - "c:/ext/ext.ts", + "c:/ext/ext.ts" ], wildcardDirectories: { "c:/dev": ts.WatchDirectoryFlags.None, @@ -752,6 +753,97 @@ namespace ts { assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); }); + it("include paths outside of the project using relative paths", () => { + const json = { + include: [ + "*", + "../ext/*" + ], + exclude: [ + "**" + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [], + fileNames: [ + "c:/ext/ext.ts" + ], + wildcardDirectories: { + "c:/ext": ts.WatchDirectoryFlags.None + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + it("exclude paths outside of the project using relative paths", () => { + const json = { + include: [ + "c:/**/*" + ], + exclude: [ + "../**" + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [], + fileNames: [], + wildcardDirectories: {} + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + it("include files with .. in their name", () => { + const json = { + include: [ + "c:/ext/b/a..b.ts" + ], + exclude: [ + "**" + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [], + fileNames: [ + "c:/ext/b/a..b.ts" + ], + wildcardDirectories: {} + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + it("exclude files with .. in their name", () => { + const json = { + include: [ + "c:/ext/**/*" + ], + exclude: [ + "c:/ext/b/a..b.ts" + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [], + fileNames: [ + "c:/ext/ext.ts", + ], + wildcardDirectories: { + "c:/ext": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); it("with jsx=none, allowJs=false", () => { const json = { compilerOptions: { @@ -951,6 +1043,108 @@ namespace ts { assert.deepEqual(actual.errors, expected.errors); }); }); + + describe("with parent directory symbols after a recursive directory pattern", () => { + it("in includes immediately after", () => { + const json = { + include: [ + "**/../*" + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*") + ], + fileNames: [], + wildcardDirectories: {} + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + + it("in includes after a subdirectory", () => { + const json = { + include: [ + "**/y/../*" + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*") + ], + fileNames: [], + wildcardDirectories: {} + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + + it("in excludes immediately after", () => { + const json = { + include: [ + "**/a.ts" + ], + exclude: [ + "**/.." + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/..") + ], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/x/a.ts", + "c:/dev/x/y/a.ts", + "c:/dev/z/a.ts" + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + + it("in excludes after a subdirectory", () => { + const json = { + include: [ + "**/a.ts" + ], + exclude: [ + "**/y/.." + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/..") + ], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/x/a.ts", + "c:/dev/x/y/a.ts", + "c:/dev/z/a.ts" + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + }); }); }); } \ No newline at end of file From f7c4281f6b0c59e62b77f9cbbf9647a7b6e25e2e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 1 Jul 2016 17:35:12 -0700 Subject: [PATCH 100/103] add new method getEmitOutputObject to return result of the emit as object with properties instead of json string --- src/services/shims.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index e0f7cc6dc76..e53203c211f 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -231,6 +231,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; getEmitOutput(fileName: string): string; + getEmitOutputObject(fileName: string): EmitOutput; } export interface ClassifierShim extends Shim { @@ -518,9 +519,13 @@ namespace ts { } function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): string { + return forwardCall(logger, actionDescription, /*returnJson*/ true, action, logPerformance); + } + + function forwardCall(logger: Logger, actionDescription: string, returnJson: boolean, action: () => T, logPerformance: boolean): T | string { try { const result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return JSON.stringify({ result }); + return returnJson ? JSON.stringify({ result }) : result; } catch (err) { if (err instanceof OperationCanceledException) { @@ -532,6 +537,7 @@ namespace ts { } } + class ShimBase implements Shim { constructor(private factory: ShimFactory) { factory.registerShim(this); @@ -918,6 +924,15 @@ namespace ts { () => this.languageService.getEmitOutput(fileName) ); } + + public getEmitOutputObject(fileName: string): any { + return forwardCall( + this.logger, + `getEmitOutput('${fileName}')`, + /*returnJson*/ false, + () => this.languageService.getEmitOutput(fileName), + this.logPerformance); + } } function convertClassifications(classifications: Classifications): { spans: string, endOfLineState: EndOfLineState } { From f9a5593f6a2570691d4030c8497ae9c5bc771214 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 1 Jul 2016 20:30:08 -0700 Subject: [PATCH 101/103] fix linter --- src/services/shims.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index e53203c211f..a233f99d03f 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -927,7 +927,7 @@ namespace ts { public getEmitOutputObject(fileName: string): any { return forwardCall( - this.logger, + this.logger, `getEmitOutput('${fileName}')`, /*returnJson*/ false, () => this.languageService.getEmitOutput(fileName), From 19c141aefed7920291a11398daca4d076f862e67 Mon Sep 17 00:00:00 2001 From: Yui Date: Sat, 2 Jul 2016 21:50:13 -0700 Subject: [PATCH 102/103] Fix PromiseLike to be compatible with es6-promise (#9484) --- src/lib/es5.d.ts | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 4f657d4b52b..54ae1209cb3 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1255,33 +1255,13 @@ declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | P interface PromiseLike { /** - * 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) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; - - /** - * 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 | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: (value: T) => TResult | PromiseLike): PromiseLike; - - /** - * Creates a new Promise with the same internal state of this Promise. - * @returns A Promise. - */ - then(): PromiseLike; + * 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 | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } interface ArrayLike { From c2730ce659733b89b8599440837a3046ca734a75 Mon Sep 17 00:00:00 2001 From: Yui Date: Sun, 3 Jul 2016 05:59:44 -0700 Subject: [PATCH 103/103] Fix reading files from IOLog because previous our API captures (#9483) * Fix reading files from IOLog because previous our API captures * Refactoring the ioLog --- src/harness/loggedIO.ts | 62 ++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 81b5e4a672d..25e982cf680 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -8,7 +8,12 @@ interface FileInformation { } interface FindFileResult { +} +interface IOLogFile { + path: string; + codepage: number; + result?: FileInformation; } interface IOLog { @@ -17,11 +22,7 @@ interface IOLog { executingPath: string; currentDirectory: string; useCustomLibraryFile?: boolean; - filesRead: { - path: string; - codepage: number; - result?: FileInformation; - }[]; + filesRead: IOLogFile[]; filesWritten: { path: string; contents: string; @@ -61,7 +62,7 @@ interface IOLog { }[]; directoriesRead: { path: string, - extension: string[], + extensions: string[], exclude: string[], include: string[], result: string[] @@ -170,8 +171,7 @@ namespace Playback { path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }), memoize(path => { // If we read from the file, it must exist - const noResult = {}; - if (findResultByPath(wrapper, replayLog.filesRead, path, noResult) !== noResult) { + if (findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) { return true; } else { @@ -215,16 +215,30 @@ namespace Playback { recordLog.filesRead.push(logEntry); return result; }, - memoize(path => findResultByPath(wrapper, replayLog.filesRead, path).contents)); + memoize(path => findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents)); wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)( - (path, extension, exclude, include) => { - const result = (underlying).readDirectory(path, extension, exclude, include); - const logEntry = { path, extension, exclude, include, result }; + (path, extensions, exclude, include) => { + const result = (underlying).readDirectory(path, extensions, exclude, include); + const logEntry = { path, extensions, exclude, include, result }; recordLog.directoriesRead.push(logEntry); return result; }, - (path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead, path)); + (path, extensions, exclude) => { + // Because extensions is an array of all allowed extension, we will want to merge each of the replayLog.directoriesRead into one + // if each of the directoriesRead has matched path with the given path (directory with same path but different extension will considered + // different entry). + // TODO (yuisu): We can certainly remove these once we recapture the RWC using new API + const normalizedPath = ts.normalizePath(path).toLowerCase(); + const result: string[] = []; + for (const directory of replayLog.directoriesRead) { + if (ts.normalizeSlashes(directory.path).toLowerCase() === normalizedPath) { + result.push(...directory.result); + } + } + + return result; + }); wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( (path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), @@ -279,30 +293,22 @@ namespace Playback { return results[0].result; } - function findResultByPath(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T { + function findFileByPath(wrapper: { resolvePath(s: string): string }, logArray: IOLogFile[], + expectedPath: string, throwFileNotFoundError: boolean): FileInformation { const normalizedName = ts.normalizePath(expectedPath).toLowerCase(); // Try to find the result through normal fileName - for (let i = 0; i < logArray.length; i++) { - if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) { - return logArray[i].result; - } - } - // Fallback, try to resolve the target paths as well - if (replayLog.pathsResolved.length > 0) { - const normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase(); - for (let i = 0; i < logArray.length; i++) { - if (wrapper.resolvePath(logArray[i].path).toLowerCase() === normalizedResolvedName) { - return logArray[i].result; - } + for (const log of logArray) { + if (ts.normalizeSlashes(log.path).toLowerCase() === normalizedName) { + return log.result; } } // If we got here, we didn't find a match - if (defaultValue === undefined) { + if (throwFileNotFoundError) { throw new Error("No matching result in log array for path: " + expectedPath); } else { - return defaultValue; + return undefined; } }