diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f4c45a856ee..4f1b797e58a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14890,6 +14890,10 @@ namespace ts { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type!); } } + const thisTag = getJSDocThisTag(node); + if (thisTag && thisTag.typeExpression) { + return getTypeFromTypeNode(thisTag.typeExpression); + } } function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean { diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index de96a342067..5f7122bd70c 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -486,12 +486,18 @@ + + + + + + @@ -960,6 +966,15 @@ + + + + + + + + + @@ -1029,6 +1044,15 @@ + + + + + + + + + @@ -1773,18 +1797,27 @@ + + + + + + + + + @@ -2865,6 +2898,9 @@ + + + @@ -3327,6 +3363,9 @@ + + + @@ -5760,6 +5799,9 @@ + + + @@ -5802,6 +5844,9 @@ + + + @@ -6240,42 +6285,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6291,6 +6357,9 @@ + + + @@ -6756,6 +6825,15 @@ + + + + + + + + + @@ -7332,6 +7410,9 @@ + + + @@ -7356,12 +7437,18 @@ + + + + + + @@ -8976,6 +9063,9 @@ + + + @@ -9531,6 +9621,9 @@ + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index f723f786b33..ea5d75fe447 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -495,12 +495,18 @@ + + + + + + @@ -969,6 +975,15 @@ + + + + + + + + + @@ -1041,6 +1056,15 @@ + + + + + + + + + @@ -1791,12 +1815,18 @@ + + + + + + @@ -2877,6 +2907,9 @@ + + + @@ -3339,6 +3372,9 @@ + + + @@ -5772,6 +5808,9 @@ + + + @@ -5814,6 +5853,9 @@ + + + @@ -6252,24 +6294,36 @@ + + + + + + + + + + + + @@ -6282,12 +6336,18 @@ + + + + + + @@ -6303,6 +6363,9 @@ + + + @@ -6768,6 +6831,15 @@ + + + + + + + + + @@ -7344,6 +7416,9 @@ + + + @@ -7368,12 +7443,18 @@ + + + + + + @@ -8988,6 +9069,9 @@ + + + @@ -9543,6 +9627,9 @@ + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8abfd535e1c..2b22cc304dd 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -495,12 +495,18 @@ + + + + + + @@ -969,6 +975,15 @@ + + + + + + + + + @@ -1041,6 +1056,15 @@ + + + + + + + + + @@ -1785,18 +1809,27 @@ + + + + + + + + + @@ -2877,6 +2910,9 @@ + + + @@ -3339,6 +3375,9 @@ + + + @@ -5772,6 +5811,9 @@ + + + @@ -5814,6 +5856,9 @@ + + + @@ -6252,42 +6297,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6303,6 +6369,9 @@ + + + @@ -6768,6 +6837,15 @@ + + + + + + + + + @@ -7344,6 +7422,9 @@ + + + @@ -7368,12 +7449,18 @@ + + + + + + @@ -8988,6 +9075,9 @@ + + + diff --git a/src/parser/parser.ts b/src/parser/parser.ts index 591cb900a7f..c7b01b9b804 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -491,6 +491,8 @@ namespace ts { case SyntaxKind.JSDocCallbackTag: return visitNode(cbNode, (node as JSDocCallbackTag).fullName) || visitNode(cbNode, (node as JSDocCallbackTag).typeExpression); + case SyntaxKind.JSDocThisTag: + return visitNode(cbNode, (node as JSDocThisTag).typeExpression); case SyntaxKind.JSDocSignature: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || @@ -6497,6 +6499,9 @@ namespace ts { case "constructor": tag = parseClassTag(atToken, tagName); break; + case "this": + tag = parseThisTag(atToken, tagName); + break; case "arg": case "argument": case "param": @@ -6768,6 +6773,15 @@ namespace ts { return finishNode(tag); } + function parseThisTag(atToken: AtToken, tagName: Identifier): JSDocThisTag { + const tag = createNode(SyntaxKind.JSDocThisTag, atToken.pos); + tag.atToken = atToken; + tag.tagName = tagName; + tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); + skipWhitespace(); + return finishNode(tag); + } + function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); skipWhitespace(); diff --git a/src/parser/types.ts b/src/parser/types.ts index c79976091fe..29a7e3d8842 100644 --- a/src/parser/types.ts +++ b/src/parser/types.ts @@ -371,6 +371,7 @@ namespace ts { JSDocCallbackTag, JSDocParameterTag, JSDocReturnTag, + JSDocThisTag, JSDocTypeTag, JSDocTemplateTag, JSDocTypedefTag, @@ -2323,6 +2324,11 @@ namespace ts { kind: SyntaxKind.JSDocClassTag; } + export interface JSDocThisTag extends JSDocTag { + kind: SyntaxKind.JSDocThisTag; + typeExpression?: JSDocTypeExpression; + } + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; typeParameters: NodeArray; diff --git a/src/parser/utilities.ts b/src/parser/utilities.ts index e67ea3e743f..7602e01f9c2 100644 --- a/src/parser/utilities.ts +++ b/src/parser/utilities.ts @@ -4970,6 +4970,11 @@ namespace ts { return getFirstJSDocTag(node, isJSDocClassTag); } + /** Gets the JSDoc this tag for the node if present */ + export function getJSDocThisTag(node: Node): JSDocThisTag | undefined { + return getFirstJSDocTag(node, isJSDocThisTag); + } + /** Gets the JSDoc return tag for the node if present */ export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { return getFirstJSDocTag(node, isJSDocReturnTag); @@ -5701,6 +5706,10 @@ namespace ts { return node.kind === SyntaxKind.JSDocClassTag; } + export function isJSDocThisTag(node: Node): node is JSDocThisTag { + return node.kind === SyntaxKind.JSDocThisTag; + } + export function isJSDocParameterTag(node: Node): node is JSDocParameterTag { return node.kind === SyntaxKind.JSDocParameterTag; } diff --git a/tests/baselines/reference/APISample_Watch.errors.txt b/tests/baselines/reference/APISample_Watch.errors.txt new file mode 100644 index 00000000000..d4f7638416b --- /dev/null +++ b/tests/baselines/reference/APISample_Watch.errors.txt @@ -0,0 +1,208 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_Watch.ts (0 errors) ==== + /* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript-wiki/blob/master/Using-the-Compiler-API.md#writing-an-incremental-program-watcher + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var process: any; + declare var console: any; + declare var os: any; + + import ts = require("typescript"); + + const formatHost: ts.FormatDiagnosticsHost = { + getCanonicalFileName: path => path, + getCurrentDirectory: ts.sys.getCurrentDirectory, + getNewLine: () => ts.sys.newLine, + } + + function watchMain() { + const configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json"); + if (!configPath) { + throw new Error("Could not find a valid 'tsconfig.json'."); + } + + // TypeScript can use several different program creation "strategies": + // * ts.createEmitAndSemanticDiagnosticsBuilderProgram, + // * ts.createSemanticDiagnosticsBuilderProgram + // * ts.createAbstractBuilder + // The first two produce "builder programs". These use an incremental strategy to only re-check and emit files whose + // contents may have changed, or whose dependencies may have changes which may impact change the result of prior type-check and emit. + // The last uses an ordinary program which does a full type check after every change. + // Between `createEmitAndSemanticDiagnosticsBuilderProgram` and `createSemanticDiagnosticsBuilderProgram`, the only difference is emit. + // For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable. + + // Note that there is another overload for `createWatchCompilerHost` that takes a set of root files. + const host = ts.createWatchCompilerHost(configPath, {}, ts.sys, + ts.createSemanticDiagnosticsBuilderProgram, + reportDiagnostic, + reportWatchStatusChanged, + ); + + // You can technically override any given hook on the host, though you probably don't need to. + // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. + const origCreateProgram = host.createProgram; + host.createProgram = (rootNames: ReadonlyArray, options, host, oldProgram) => { + console.log("** We're about to create the program! **"); + return origCreateProgram(rootNames, options, host, oldProgram); + } + const origPostProgramCreate = host.afterProgramCreate; + + host.afterProgramCreate = program => { + console.log("** We finished making the program! **"); + origPostProgramCreate!(program); + }; + + // `createWatchProgram` creates an initial program, watches files, and updates the program over time. + ts.createWatchProgram(host); + } + + function reportDiagnostic(diagnostic: ts.Diagnostic) { + console.error("Error", diagnostic.code, ":", + ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()) + ); + } + + /** + * Prints a diagnostic every time the watch status changes. + * This is mainly for messages like "Starting compilation" or "Compilation completed". + */ + function reportWatchStatusChanged(diagnostic: ts.Diagnostic) { + console.info(ts.formatDiagnostic(diagnostic, formatHost)); + } + + watchMain(); + \ No newline at end of file diff --git a/tests/baselines/reference/APISample_WatchWithDefaults.errors.txt b/tests/baselines/reference/APISample_WatchWithDefaults.errors.txt new file mode 100644 index 00000000000..52755e8fe21 --- /dev/null +++ b/tests/baselines/reference/APISample_WatchWithDefaults.errors.txt @@ -0,0 +1,181 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_WatchWithDefaults.ts (0 errors) ==== + /* + * Note: This test is a public API sample. This uses default sys interface without having to pass anything + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var console: any; + + import ts = require("typescript"); + + function watchMain() { + const configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json"); + if (!configPath) { + throw new Error("Could not find a valid 'tsconfig.json'."); + } + + // TypeScript can use several different program creation "strategies": + // * ts.createEmitAndSemanticDiagnosticsBuilderProgram, + // * ts.createSemanticDiagnosticsBuilderProgram + // * ts.createAbstractBuilder + // The first two produce "builder programs". These use an incremental strategy to only re-check and emit files whose + // contents may have changed, or whose dependencies may have changes which may impact change the result of prior type-check and emit. + // The last uses an ordinary program which does a full type check after every change. + // Between `createEmitAndSemanticDiagnosticsBuilderProgram` and `createSemanticDiagnosticsBuilderProgram`, the only difference is emit. + // For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable. + + // Note that there is another overload for `createWatchCompilerHost` that takes a set of root files. + const host = ts.createWatchCompilerHost(configPath, {}, ts.sys); + + // You can technically override any given hook on the host, though you probably don't need to. + // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. + const origCreateProgram = host.createProgram; + host.createProgram = (rootNames, options, host, oldProgram) => { + console.log("** We're about to create the program! **"); + return origCreateProgram(rootNames, options, host, oldProgram); + } + const origPostProgramCreate = host.afterProgramCreate; + + host.afterProgramCreate = program => { + console.log("** We finished making the program! **"); + origPostProgramCreate!(program); + }; + + // `createWatchProgram` creates an initial program, watches files, and updates the program over time. + ts.createWatchProgram(host); + } + + watchMain(); + \ No newline at end of file diff --git a/tests/baselines/reference/APISample_WatchWithOwnWatchHost.errors.txt b/tests/baselines/reference/APISample_WatchWithOwnWatchHost.errors.txt new file mode 100644 index 00000000000..1275cf337b0 --- /dev/null +++ b/tests/baselines/reference/APISample_WatchWithOwnWatchHost.errors.txt @@ -0,0 +1,188 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts (0 errors) ==== + /* + * Note: This test is a public API sample. This sample verifies creating abstract builder to watch list of root files + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var console: any; + + import ts = require("typescript"); + + function watchMain() { + // get list of files and compiler options somehow + const files: string[] = []; + const options: ts.CompilerOptions = {}; + + const host: ts.WatchCompilerHostOfFilesAndCompilerOptions = { + rootFiles: files, + options, + + useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, + getNewLine: () => ts.sys.newLine, + getCurrentDirectory: ts.sys.getCurrentDirectory, + getDefaultLibFileName: options => ts.getDefaultLibFilePath(options), + + fileExists: ts.sys.fileExists, + readFile: ts.sys.readFile, + directoryExists: ts.sys.directoryExists, + getDirectories: ts.sys.getDirectories, + readDirectory: ts.sys.readDirectory, + realpath: ts.sys.realpath, + + watchFile: ts.sys.watchFile!, + watchDirectory: ts.sys.watchDirectory!, + createProgram: ts.createAbstractBuilder + }; + + // You can technically override any given hook on the host, though you probably don't need to. + // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. + const origCreateProgram = host.createProgram; + host.createProgram = (rootNames, options, host, oldProgram) => { + console.log("** We're about to create the program! **"); + return origCreateProgram(rootNames, options, host, oldProgram); + } + const origPostProgramCreate = host.afterProgramCreate; + + host.afterProgramCreate = program => { + console.log("** We finished making the program! **"); + origPostProgramCreate!(program); + }; + + // `createWatchProgram` creates an initial program, watches files, and updates the program over time. + ts.createWatchProgram(host); + } + + watchMain(); + \ No newline at end of file diff --git a/tests/baselines/reference/APISample_compile.errors.txt b/tests/baselines/reference/APISample_compile.errors.txt new file mode 100644 index 00000000000..4af4a173002 --- /dev/null +++ b/tests/baselines/reference/APISample_compile.errors.txt @@ -0,0 +1,171 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_compile.ts (0 errors) ==== + /* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var process: any; + declare var console: any; + declare var os: any; + + import ts = require("typescript"); + + export function compile(fileNames: string[], options: ts.CompilerOptions): void { + var program = ts.createProgram(fileNames, options); + var emitResult = program.emit(); + + var allDiagnostics = ts.getPreEmitDiagnostics(program); + + allDiagnostics.forEach(diagnostic => { + var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + if (!diagnostic.file) { + console.log(message); + return; + } + var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); + console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + }); + + var exitCode = emitResult.emitSkipped ? 1 : 0; + console.log(`Process exiting with code '${exitCode}'.`); + process.exit(exitCode); + } + + compile(process.argv.slice(2), { + noEmitOnError: true, noImplicitAny: true, + target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS + }); + \ No newline at end of file diff --git a/tests/baselines/reference/APISample_jsdoc.errors.txt b/tests/baselines/reference/APISample_jsdoc.errors.txt new file mode 100644 index 00000000000..b80bb027663 --- /dev/null +++ b/tests/baselines/reference/APISample_jsdoc.errors.txt @@ -0,0 +1,246 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_jsdoc.ts (0 errors) ==== + /* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var console: any; + + import * as ts from "typescript"; + + // excerpted from https://github.com/YousefED/typescript-json-schema + // (converted from a method and modified; for example, `this: any` to compensate, among other changes) + function parseCommentsIntoDefinition(this: any, + symbol: ts.Symbol, + definition: {description?: string, [s: string]: string | undefined}, + otherAnnotations: { [s: string]: true}): void { + if (!symbol) { + return; + } + + // the comments for a symbol + let comments = symbol.getDocumentationComment(undefined); + + if (comments.length) { + definition.description = comments.map(comment => comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n")).join(""); + } + + // jsdocs are separate from comments + const jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(doc => { + // if we have @TJS-... annotations, we have to parse them + const { name, text } = doc; + if (this.userValidationKeywords[name]) { + definition[name] = this.parseValue(text); + } else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); + } + + + // excerpted from https://github.com/vega/ts-json-schema-generator + export interface Annotations { + [name: string]: any; + } + function getAnnotations(this: any, node: ts.Node): Annotations | undefined { + const symbol: ts.Symbol = (node as any).symbol; + if (!symbol) { + return undefined; + } + + const jsDocTags: ts.JSDocTagInfo[] = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + + const annotations: Annotations = jsDocTags.reduce((result: Annotations, jsDocTag: ts.JSDocTagInfo) => { + const value = this.parseJsDocTag(jsDocTag); + if (value !== undefined) { + result[jsDocTag.name] = value; + } + + return result; + }, {}); + return Object.keys(annotations).length ? annotations : undefined; + } + + // these examples are artificial and mostly nonsensical + function parseSpecificTags(node: ts.Node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node as ts.ParameterDeclaration); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + const func = node as ts.FunctionDeclaration; + if (ts.hasJSDocParameterTags(func)) { + const flat: ts.JSDocTag[] = []; + for (const tags of func.parameters.map(ts.getJSDocParameterTags)) { + if (tags) flat.push(...tags); + } + return flat; + } + } + } + + function getReturnTypeFromJSDoc(node: ts.Node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + let type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return (type as ts.FunctionTypeNode).type; + } + } + + function getAllTags(node: ts.Node) { + ts.getJSDocTags(node); + } + + function getSomeOtherTags(node: ts.Node) { + const tags: (ts.JSDocTag | undefined)[] = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + const type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; + } + \ No newline at end of file diff --git a/tests/baselines/reference/APISample_linter.errors.txt b/tests/baselines/reference/APISample_linter.errors.txt new file mode 100644 index 00000000000..51a0140cf04 --- /dev/null +++ b/tests/baselines/reference/APISample_linter.errors.txt @@ -0,0 +1,196 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_linter.ts (0 errors) ==== + /* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var process: any; + declare var console: any; + declare var readFileSync: any; + + import * as ts from "typescript"; + + export function delint(sourceFile: ts.SourceFile) { + delintNode(sourceFile); + + function delintNode(node: ts.Node) { + switch (node.kind) { + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.DoStatement: + if ((node).statement.kind !== ts.SyntaxKind.Block) { + report(node, "A looping statement's contents should be wrapped in a block body."); + } + break; + + case ts.SyntaxKind.IfStatement: + let ifStatement = (node); + if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { + report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); + } + if (ifStatement.elseStatement && + ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && + ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) { + report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); + } + break; + + case ts.SyntaxKind.BinaryExpression: + let op = (node).operatorToken.kind; + if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { + report(node, "Use '===' and '!=='.") + } + break; + } + + ts.forEachChild(node, delintNode); + } + + function report(node: ts.Node, message: string) { + let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); + console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`); + } + } + + const fileNames: string[] = process.argv.slice(2); + fileNames.forEach(fileName => { + // Parse a file + let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); + + // delint it + delint(sourceFile); + }); \ No newline at end of file diff --git a/tests/baselines/reference/APISample_parseConfig.errors.txt b/tests/baselines/reference/APISample_parseConfig.errors.txt new file mode 100644 index 00000000000..f2ccfacdc9f --- /dev/null +++ b/tests/baselines/reference/APISample_parseConfig.errors.txt @@ -0,0 +1,168 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_parseConfig.ts (0 errors) ==== + /* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var process: any; + declare var console: any; + declare var os: any; + + import ts = require("typescript"); + + function printError(error: ts.Diagnostic): void { + if (!error) { + return; + } + console.log(`${error.file && error.file.fileName}: ${error.messageText}`); + } + + export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program | undefined { + const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson) + if (error) { + printError(error); + return undefined; + } + const basePath: string = process.cwd(); + const settings = ts.convertCompilerOptionsFromJson(config.config["compilerOptions"], basePath); + if (!settings.options) { + for (const err of settings.errors) { + printError(err); + } + return undefined; + } + return ts.createProgram(rootFiles, settings.options); + } \ No newline at end of file diff --git a/tests/baselines/reference/APISample_transform.errors.txt b/tests/baselines/reference/APISample_transform.errors.txt new file mode 100644 index 00000000000..1680cd61511 --- /dev/null +++ b/tests/baselines/reference/APISample_transform.errors.txt @@ -0,0 +1,148 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_transform.ts (0 errors) ==== + /* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var console: any; + + import * as ts from "typescript"; + + const source = "let x: string = 'string'"; + + let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); + + console.log(JSON.stringify(result)); \ No newline at end of file diff --git a/tests/baselines/reference/APISample_watcher.errors.txt b/tests/baselines/reference/APISample_watcher.errors.txt new file mode 100644 index 00000000000..1041d8495bb --- /dev/null +++ b/tests/baselines/reference/APISample_watcher.errors.txt @@ -0,0 +1,242 @@ +typescript_standalone.d.ts(21,28): error TS1005: ';' expected. +typescript_standalone.d.ts(21,41): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,28): error TS1005: ';' expected. +typescript_standalone.d.ts(8921,42): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9181,46): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9531,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9555,36): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,28): error TS1005: ';' expected. +typescript_standalone.d.ts(9642,38): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10807,57): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10818,41): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10828,48): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10903,47): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,28): error TS1005: ';' expected. +typescript_standalone.d.ts(10960,47): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11014,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11034,44): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11044,35): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11078,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11081,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11085,45): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11103,56): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11129,36): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11132,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11144,43): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11174,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11208,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11219,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11243,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11251,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11255,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11285,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11328,41): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11515,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11517,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11521,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11523,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11525,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11527,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11529,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11538,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11540,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11542,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11544,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11546,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11548,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11550,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11552,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11554,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11556,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11558,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11560,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11562,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11564,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11566,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11576,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11578,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11580,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11582,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11584,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11586,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11588,37): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11590,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11592,52): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11664,72): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11666,38): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11668,71): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11670,40): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,28): error TS1005: ';' expected. +typescript_standalone.d.ts(11746,48): error TS1005: ';' expected. + + +==== tests/cases/compiler/APISample_watcher.ts (0 errors) ==== + /* + * Note: This test is a public API sample. The sample sources can be found + at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + + declare var process: any; + declare var console: any; + declare var fs: { + existsSync(path: string): boolean; + readdirSync(path: string): string[]; + readFileSync(filename: string, encoding?: string): string; + writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; } | string): void; + watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void; + }; + declare var path: any; + + import * as ts from "typescript"; + + function watch(rootFileNames: string[], options: ts.CompilerOptions) { + const files: ts.MapLike<{ version: number }> = {}; + + // initialize the list of files + rootFileNames.forEach(fileName => { + files[fileName] = { version: 0 }; + }); + + // Create the language service host to allow the LS to communicate with the host + const servicesHost: ts.LanguageServiceHost = { + getScriptFileNames: () => rootFileNames, + getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(), + getScriptSnapshot: (fileName) => { + if (!fs.existsSync(fileName)) { + return undefined; + } + + return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); + }, + getCurrentDirectory: () => process.cwd(), + getCompilationSettings: () => options, + getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), + }; + + // Create the language service files + const services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry()) + + // Now let's watch the files + rootFileNames.forEach(fileName => { + // First time around, emit all files + emitFile(fileName); + + // Add a watch on the file to handle next change + fs.watchFile(fileName, + { persistent: true, interval: 250 }, + (curr, prev) => { + // Check timestamp + if (+curr.mtime <= +prev.mtime) { + return; + } + + // Update the version to signal a change in the file + files[fileName].version++; + + // write the changes to disk + emitFile(fileName); + }); + }); + + function emitFile(fileName: string) { + let output = services.getEmitOutput(fileName); + + if (!output.emitSkipped) { + console.log(`Emitting ${fileName}`); + } + else { + console.log(`Emitting ${fileName} failed`); + logErrors(fileName); + } + + output.outputFiles.forEach(o => { + fs.writeFileSync(o.name, o.text, "utf8"); + }); + } + + function logErrors(fileName: string) { + let allDiagnostics = services.getCompilerOptionsDiagnostics() + .concat(services.getSyntacticDiagnostics(fileName)) + .concat(services.getSemanticDiagnostics(fileName)); + + allDiagnostics.forEach(diagnostic => { + let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); + if (diagnostic.file) { + let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); + console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + } + else { + console.log(` Error: ${message}`); + } + }); + } + } + + // Initialize files constituting the program as all .ts files in the current directory + const currentDirectoryFiles = fs.readdirSync(process.cwd()). + filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"); + + // Start the watcher + watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); + \ No newline at end of file diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index c09fab01201..a4597e9997d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -888,17 +888,18 @@ declare namespace ts { JSDocCallbackTag = 292, JSDocParameterTag = 293, JSDocReturnTag = 294, - JSDocTypeTag = 295, - JSDocTemplateTag = 296, - JSDocTypedefTag = 297, - JSDocPropertyTag = 298, - SyntaxList = 299, - NotEmittedStatement = 300, - PartiallyEmittedExpression = 301, - CommaListExpression = 302, - MergeDeclarationMarker = 303, - EndOfDeclarationMarker = 304, - Count = 305, + JSDocThisTag = 295, + JSDocTypeTag = 296, + JSDocTemplateTag = 297, + JSDocTypedefTag = 298, + JSDocPropertyTag = 299, + SyntaxList = 300, + NotEmittedStatement = 301, + PartiallyEmittedExpression = 302, + CommaListExpression = 303, + MergeDeclarationMarker = 304, + EndOfDeclarationMarker = 305, + Count = 306, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -925,9 +926,9 @@ declare namespace ts { LastBinaryOperator = 70, FirstNode = 146, FirstJSDocNode = 278, - LastJSDocNode = 298, + LastJSDocNode = 299, FirstJSDocTagNode = 289, - LastJSDocTagNode = 298, + LastJSDocTagNode = 299, FirstContextualKeyword = 117, LastContextualKeyword = 145 } @@ -2163,6 +2164,10 @@ declare namespace ts { interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } + interface JSDocThisTag extends JSDocTag { + kind: SyntaxKind.JSDocThisTag; + typeExpression?: JSDocTypeExpression; + } interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; typeParameters: NodeArray; @@ -6361,7 +6366,7 @@ declare namespace ts { function getExpressionAssociativity(expression: Expression): Associativity; function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; function getExpressionPrecedence(expression: Expression): number; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.InferKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ConditionalType | SyntaxKind.InferType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ImportType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.MetaProperty | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxFragment | SyntaxKind.JsxOpeningFragment | SyntaxKind.JsxClosingFragment | SyntaxKind.JsxAttribute | SyntaxKind.JsxAttributes | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.Bundle | SyntaxKind.UnparsedSource | SyntaxKind.InputFiles | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocSignature | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocClassTag | SyntaxKind.JSDocCallbackTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.CommaListExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; + function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.InferKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ConditionalType | SyntaxKind.InferType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ImportType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.MetaProperty | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxFragment | SyntaxKind.JsxOpeningFragment | SyntaxKind.JsxClosingFragment | SyntaxKind.JsxAttribute | SyntaxKind.JsxAttributes | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.Bundle | SyntaxKind.UnparsedSource | SyntaxKind.InputFiles | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocSignature | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocClassTag | SyntaxKind.JSDocCallbackTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocThisTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.CommaListExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): number; function getBinaryOperatorPrecedence(kind: SyntaxKind): number; function createDiagnosticCollection(): DiagnosticCollection; @@ -6714,6 +6719,8 @@ declare namespace ts { function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined; /** Gets the JSDoc class tag for the node if present */ function getJSDocClassTag(node: Node): JSDocClassTag | undefined; + /** Gets the JSDoc this tag for the node if present */ + function getJSDocThisTag(node: Node): JSDocThisTag | undefined; /** Gets the JSDoc return tag for the node if present */ function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined; /** Gets the JSDoc template tag for the node if present */ @@ -6900,6 +6907,7 @@ declare namespace ts { function isJSDoc(node: Node): node is JSDoc; function isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag; function isJSDocClassTag(node: Node): node is JSDocClassTag; + function isJSDocThisTag(node: Node): node is JSDocThisTag; function isJSDocParameterTag(node: Node): node is JSDocParameterTag; function isJSDocReturnTag(node: Node): node is JSDocReturnTag; function isJSDocTypeTag(node: Node): node is JSDocTypeTag; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 4df56662501..872799f1b25 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -888,17 +888,18 @@ declare namespace ts { JSDocCallbackTag = 292, JSDocParameterTag = 293, JSDocReturnTag = 294, - JSDocTypeTag = 295, - JSDocTemplateTag = 296, - JSDocTypedefTag = 297, - JSDocPropertyTag = 298, - SyntaxList = 299, - NotEmittedStatement = 300, - PartiallyEmittedExpression = 301, - CommaListExpression = 302, - MergeDeclarationMarker = 303, - EndOfDeclarationMarker = 304, - Count = 305, + JSDocThisTag = 295, + JSDocTypeTag = 296, + JSDocTemplateTag = 297, + JSDocTypedefTag = 298, + JSDocPropertyTag = 299, + SyntaxList = 300, + NotEmittedStatement = 301, + PartiallyEmittedExpression = 302, + CommaListExpression = 303, + MergeDeclarationMarker = 304, + EndOfDeclarationMarker = 305, + Count = 306, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -925,9 +926,9 @@ declare namespace ts { LastBinaryOperator = 70, FirstNode = 146, FirstJSDocNode = 278, - LastJSDocNode = 298, + LastJSDocNode = 299, FirstJSDocTagNode = 289, - LastJSDocTagNode = 298, + LastJSDocTagNode = 299, FirstContextualKeyword = 117, LastContextualKeyword = 145 } @@ -2163,6 +2164,10 @@ declare namespace ts { interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } + interface JSDocThisTag extends JSDocTag { + kind: SyntaxKind.JSDocThisTag; + typeExpression?: JSDocTypeExpression; + } interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; typeParameters: NodeArray; @@ -6361,7 +6366,7 @@ declare namespace ts { function getExpressionAssociativity(expression: Expression): Associativity; function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; function getExpressionPrecedence(expression: Expression): number; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.InferKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ConditionalType | SyntaxKind.InferType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ImportType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.MetaProperty | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxFragment | SyntaxKind.JsxOpeningFragment | SyntaxKind.JsxClosingFragment | SyntaxKind.JsxAttribute | SyntaxKind.JsxAttributes | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.Bundle | SyntaxKind.UnparsedSource | SyntaxKind.InputFiles | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocSignature | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocClassTag | SyntaxKind.JSDocCallbackTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.CommaListExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; + function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.InferKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ConditionalType | SyntaxKind.InferType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ImportType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.MetaProperty | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxFragment | SyntaxKind.JsxOpeningFragment | SyntaxKind.JsxClosingFragment | SyntaxKind.JsxAttribute | SyntaxKind.JsxAttributes | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.Bundle | SyntaxKind.UnparsedSource | SyntaxKind.InputFiles | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocSignature | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocClassTag | SyntaxKind.JSDocCallbackTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocThisTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.CommaListExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): number; function getBinaryOperatorPrecedence(kind: SyntaxKind): number; function createDiagnosticCollection(): DiagnosticCollection; @@ -6714,6 +6719,8 @@ declare namespace ts { function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined; /** Gets the JSDoc class tag for the node if present */ function getJSDocClassTag(node: Node): JSDocClassTag | undefined; + /** Gets the JSDoc this tag for the node if present */ + function getJSDocThisTag(node: Node): JSDocThisTag | undefined; /** Gets the JSDoc return tag for the node if present */ function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined; /** Gets the JSDoc template tag for the node if present */ @@ -6900,6 +6907,7 @@ declare namespace ts { function isJSDoc(node: Node): node is JSDoc; function isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag; function isJSDocClassTag(node: Node): node is JSDocClassTag; + function isJSDocThisTag(node: Node): node is JSDocThisTag; function isJSDocParameterTag(node: Node): node is JSDocParameterTag; function isJSDocReturnTag(node: Node): node is JSDocReturnTag; function isJSDocTypeTag(node: Node): node is JSDocTypeTag; diff --git a/tests/baselines/reference/thisTag1.symbols b/tests/baselines/reference/thisTag1.symbols new file mode 100644 index 00000000000..473a80be70f --- /dev/null +++ b/tests/baselines/reference/thisTag1.symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/jsdoc/a.js === +/** @this {{ n: number }} Mount Holyoke Preparatory School + * @param {string} s + * @return {number} + */ +function f(s) { +>f : Symbol(f, Decl(a.js, 0, 0)) +>s : Symbol(s, Decl(a.js, 4, 11)) + + return this.n + s.length +>this.n : Symbol(n, Decl(a.js, 0, 12)) +>this : Symbol(__type, Decl(a.js, 0, 11)) +>n : Symbol(n, Decl(a.js, 0, 12)) +>s.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(a.js, 4, 11)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +} + +const o = { +>o : Symbol(o, Decl(a.js, 8, 5)) + + f, +>f : Symbol(f, Decl(a.js, 8, 11)) + + n: 1 +>n : Symbol(n, Decl(a.js, 9, 6)) +} +o.f('hi') +>o.f : Symbol(f, Decl(a.js, 8, 11)) +>o : Symbol(o, Decl(a.js, 8, 5)) +>f : Symbol(f, Decl(a.js, 8, 11)) + diff --git a/tests/baselines/reference/thisTag1.types b/tests/baselines/reference/thisTag1.types new file mode 100644 index 00000000000..1ef6ae8d28f --- /dev/null +++ b/tests/baselines/reference/thisTag1.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsdoc/a.js === +/** @this {{ n: number }} Mount Holyoke Preparatory School + * @param {string} s + * @return {number} + */ +function f(s) { +>f : (s: string) => number +>s : string + + return this.n + s.length +>this.n + s.length : number +>this.n : number +>this : { n: number; } +>n : number +>s.length : number +>s : string +>length : number +} + +const o = { +>o : { [x: string]: any; f: (s: string) => number; n: number; } +>{ f, n: 1} : { [x: string]: any; f: (s: string) => number; n: number; } + + f, +>f : (s: string) => number + + n: 1 +>n : number +>1 : 1 +} +o.f('hi') +>o.f('hi') : number +>o.f : (s: string) => number +>o : { [x: string]: any; f: (s: string) => number; n: number; } +>f : (s: string) => number +>'hi' : "hi" + diff --git a/tests/cases/conformance/jsdoc/thisTag1.ts b/tests/cases/conformance/jsdoc/thisTag1.ts new file mode 100644 index 00000000000..62416b78d16 --- /dev/null +++ b/tests/cases/conformance/jsdoc/thisTag1.ts @@ -0,0 +1,19 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @strict: true +// @Filename: a.js + +/** @this {{ n: number }} Mount Holyoke Preparatory School + * @param {string} s + * @return {number} + */ +function f(s) { + return this.n + s.length +} + +const o = { + f, + n: 1 +} +o.f('hi')