From 422b5414f1961be252fc7f705b6e2be8143c313f Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 20 May 2019 12:02:52 -0700 Subject: [PATCH 1/8] Allow synthetic identifiers to exist and give them escapedText --- src/services/services.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 9637b3c5321..6e4889e330e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -172,10 +172,11 @@ namespace ts { const token = scanner.scan(); const textPos = scanner.getTextPos(); if (textPos <= end) { - if (token === SyntaxKind.Identifier) { - Debug.fail(`Did not expect ${Debug.showSyntaxKind(parent)} to have an Identifier in its trivia`); + const node = createNode(token, pos, textPos, parent); + nodes.push(node); + if (isIdentifier(node)) { + node.escapedText = escapeLeadingUnderscores(scanner.getTokenValue()); } - nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; if (token === SyntaxKind.EndOfFileToken) { From 0a3c755fc207d8d5843db4f5e059235b0e6dc67a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 20 May 2019 12:26:12 -0700 Subject: [PATCH 2/8] Add test --- .../jsxExpressionFollowedByIdentifier.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts diff --git a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts new file mode 100644 index 00000000000..8d93244e01e --- /dev/null +++ b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts @@ -0,0 +1,18 @@ +/// + +//@Filename: jsxExpressionFollowedByIdentifier.tsx +////declare var React: any; +////declare var x: string; +////const a =
{
/*1*/x/*2*/}
+ +goTo.marker('1'); +verify.getSyntacticDiagnostics([{ + code: 1005, + message: "'}' expected.", + range: { + fileName: test.marker('1').fileName, + pos: test.marker('1').position, + end: test.marker('2').position, + } +}]); +verify.quickInfoIs('var x: string'); \ No newline at end of file From 897e10a81e3495c7749977a51cc4b82602f9ba03 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 20 May 2019 14:58:25 -0700 Subject: [PATCH 3/8] Use range instead of two markers --- .../fourslash/jsxExpressionFollowedByIdentifier.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts index 8d93244e01e..3231ed9cf62 100644 --- a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts +++ b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts @@ -3,16 +3,12 @@ //@Filename: jsxExpressionFollowedByIdentifier.tsx ////declare var React: any; ////declare var x: string; -////const a =
{
/*1*/x/*2*/}
+////const a =
{
[|x|]}
-goTo.marker('1'); +const range = test.ranges()[0]; verify.getSyntacticDiagnostics([{ code: 1005, message: "'}' expected.", - range: { - fileName: test.marker('1').fileName, - pos: test.marker('1').position, - end: test.marker('2').position, - } + range, }]); -verify.quickInfoIs('var x: string'); \ No newline at end of file +verify.quickInfoAt(range, 'var x: string'); \ No newline at end of file From 77a76c157bf65a7589791ebd689f695172f04f4c Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 21 May 2019 09:45:08 -0700 Subject: [PATCH 4/8] Revert "Allow synthetic identifiers to exist and give them escapedText" This reverts commit 422b5414f1961be252fc7f705b6e2be8143c313f. --- src/services/services.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 6e4889e330e..9637b3c5321 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -172,11 +172,10 @@ namespace ts { const token = scanner.scan(); const textPos = scanner.getTextPos(); if (textPos <= end) { - const node = createNode(token, pos, textPos, parent); - nodes.push(node); - if (isIdentifier(node)) { - node.escapedText = escapeLeadingUnderscores(scanner.getTokenValue()); + if (token === SyntaxKind.Identifier) { + Debug.fail(`Did not expect ${Debug.showSyntaxKind(parent)} to have an Identifier in its trivia`); } + nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; if (token === SyntaxKind.EndOfFileToken) { From feaef9c8297e89a0df44f4e0e2d3d5e5aa9fead2 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 21 May 2019 14:21:44 -0700 Subject: [PATCH 5/8] Improve error message for JSXExpressions that are comma expressions --- src/compiler/checker.ts | 7 +++++++ src/compiler/diagnosticMessages.json | 4 ++++ src/compiler/parser.ts | 5 ++++- src/harness/fourslash.ts | 18 ++++++++++++++++++ tests/cases/fourslash/fourslash.ts | 1 + .../jsxExpressionFollowedByIdentifier.ts | 1 + .../jsxExpressionWithCommaExpression.ts | 11 +++++++++++ 7 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/jsxExpressionWithCommaExpression.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 18c1f42f838..d0efd490816 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19850,6 +19850,7 @@ namespace ts { } function checkJsxExpression(node: JsxExpression, checkMode?: CheckMode) { + checkGrammarJsxExpression(node); if (node.expression) { const type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { @@ -31658,6 +31659,12 @@ namespace ts { } } + function checkGrammarJsxExpression(node: JsxExpression) { + if (node.expression && isCommaSequence(node.expression)) { + return grammarErrorOnNode(node.expression, Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); + } + } + function checkGrammarForInOrForOfStatement(forInOrOfStatement: ForInOrOfStatement): boolean { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 87101781ead..97e80f69b11 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4986,5 +4986,9 @@ "Classes may not have a field named 'constructor'.": { "category": "Error", "code": 18006 + }, + "JSX expressions may not use the comma operator. Did you mean to write an array?": { + "category": "Error", + "code": 18007 } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c38e4f67fe2..f3b0c2c06e6 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4430,7 +4430,10 @@ namespace ts { if (token() !== SyntaxKind.CloseBraceToken) { node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - node.expression = parseAssignmentExpressionOrHigher(); + // Only an AssignmentExpression is valid here per the JSX spec, + // but we can unambiguously parse a comma sequence and provide + // a better error message in grammar checking. + node.expression = parseExpression(); } if (inExpressionContext) { parseExpected(SyntaxKind.CloseBraceToken); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index df7f0051f3f..a2e2c0f29af 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -582,6 +582,20 @@ namespace FourSlash { }); } + public verifyErrorExistsAtRange(range: Range, code: number) { + const span = ts.createTextSpanFromRange(range); + const hasMatchingError = ts.some( + this.getDiagnostics(range.fileName), + ({ code, start, length }) => + code === code && + ts.isNumber(start) && ts.isNumber(length) && + ts.textSpansEqual(span, { start, length })); + + if (!hasMatchingError) { + this.raiseError(`No error with code ${code} found at provided range.`); + } + } + public verifyNumberOfErrorsInCurrentFile(expected: number) { const errors = this.getDiagnostics(this.activeFile.fileName); const actual = errors.length; @@ -3968,6 +3982,10 @@ namespace FourSlashInterface { this.state.verifyNoErrors(); } + public errorExistsAtRange(range: FourSlash.Range, code: number) { + this.state.verifyErrorExistsAtRange(range, code); + } + public numberOfErrorsInCurrentFile(expected: number) { this.state.verifyNumberOfErrorsInCurrentFile(expected); } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 4252296d5da..427a3558b31 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -238,6 +238,7 @@ declare namespace FourSlashInterface { signatureHelp(...options: VerifySignatureHelpOptions[], ): void; // Checks that there are no compile errors. noErrors(): void; + errorExistsAtRange(range: Range, code: number): void; numberOfErrorsInCurrentFile(expected: number): void; baselineCurrentFileBreakpointLocations(): void; baselineCurrentFileNameOrDottedNameSpans(): void; diff --git a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts index 3231ed9cf62..d040bacd546 100644 --- a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts +++ b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts @@ -4,6 +4,7 @@ ////declare var React: any; ////declare var x: string; ////const a =
{
[|x|]}
+////const b =
[|x|]} /> const range = test.ranges()[0]; verify.getSyntacticDiagnostics([{ diff --git a/tests/cases/fourslash/jsxExpressionWithCommaExpression.ts b/tests/cases/fourslash/jsxExpressionWithCommaExpression.ts new file mode 100644 index 00000000000..829a2172364 --- /dev/null +++ b/tests/cases/fourslash/jsxExpressionWithCommaExpression.ts @@ -0,0 +1,11 @@ +/// + +//@Filename: jsxExpressionWithCommaExpression.tsx +//@jsx: react +////declare var React: any; +////declare var x: string; +////const a =
+////const b =
{[|x, x|]}
+ +verify.getSyntacticDiagnostics([]); +test.ranges().forEach(range => verify.errorExistsAtRange(range, 18006)); From 2856aabd70463e320ccc0afc9a0d813187d17d9d Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 21 May 2019 15:28:16 -0700 Subject: [PATCH 6/8] Parse stray identifier-ish as JSXText instead of trivia --- src/compiler/parser.ts | 5 +++-- src/harness/fourslash.ts | 9 +++++---- tests/cases/fourslash/fourslash.ts | 2 +- .../fourslash/jsxExpressionFollowedByIdentifier.ts | 13 +++++-------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f3b0c2c06e6..e56ff98846e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4439,8 +4439,9 @@ namespace ts { parseExpected(SyntaxKind.CloseBraceToken); } else { - parseExpected(SyntaxKind.CloseBraceToken, /*message*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(SyntaxKind.CloseBraceToken, /*message*/ undefined, /*shouldAdvance*/ false)) { + scanJsxText(); + } } return finishNode(node); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a2e2c0f29af..5d0725ea106 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -582,12 +582,13 @@ namespace FourSlash { }); } - public verifyErrorExistsAtRange(range: Range, code: number) { + public verifyErrorExistsAtRange(range: Range, code: number, expectedMessage?: string) { const span = ts.createTextSpanFromRange(range); const hasMatchingError = ts.some( this.getDiagnostics(range.fileName), - ({ code, start, length }) => + ({ code, messageText, start, length }) => code === code && + (!expectedMessage || expectedMessage === messageText) && ts.isNumber(start) && ts.isNumber(length) && ts.textSpansEqual(span, { start, length })); @@ -3982,8 +3983,8 @@ namespace FourSlashInterface { this.state.verifyNoErrors(); } - public errorExistsAtRange(range: FourSlash.Range, code: number) { - this.state.verifyErrorExistsAtRange(range, code); + public errorExistsAtRange(range: FourSlash.Range, code: number, message?: string) { + this.state.verifyErrorExistsAtRange(range, code, message); } public numberOfErrorsInCurrentFile(expected: number) { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 427a3558b31..e6f2a08f002 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -238,7 +238,7 @@ declare namespace FourSlashInterface { signatureHelp(...options: VerifySignatureHelpOptions[], ): void; // Checks that there are no compile errors. noErrors(): void; - errorExistsAtRange(range: Range, code: number): void; + errorExistsAtRange(range: Range, code: number, message?: string): void; numberOfErrorsInCurrentFile(expected: number): void; baselineCurrentFileBreakpointLocations(): void; baselineCurrentFileNameOrDottedNameSpans(): void; diff --git a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts index d040bacd546..501a325b989 100644 --- a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts +++ b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts @@ -2,14 +2,11 @@ //@Filename: jsxExpressionFollowedByIdentifier.tsx ////declare var React: any; -////declare var x: string; ////const a =
{
[|x|]}
////const b =
[|x|]} /> -const range = test.ranges()[0]; -verify.getSyntacticDiagnostics([{ - code: 1005, - message: "'}' expected.", - range, -}]); -verify.quickInfoAt(range, 'var x: string'); \ No newline at end of file +test.ranges().forEach(range => { + verify.errorExistsAtRange(range, 1005, "'}' expected."); + // This is just to ensure getting quick info doesn’t crash + verify.not.quickInfoExists(); +}); From 52894cf8500ec9b1b864d2118bb79d7b86cfe772 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 21 May 2019 15:39:07 -0700 Subject: [PATCH 7/8] Accept baselines, I guess --- .../baselines/reference/jsxAndTypeAssertion.js | 11 +++++++---- .../reference/jsxInvalidEsprimaTestSuite.js | 2 +- .../reference/jsxParsingError1.errors.txt | 17 +++++++---------- tests/baselines/reference/jsxParsingError1.js | 3 +-- .../reference/jsxParsingError1.symbols | 2 +- .../baselines/reference/jsxParsingError1.types | 6 +++--- .../reference/tsxErrorRecovery1.errors.txt | 16 ++-------------- tests/baselines/reference/tsxErrorRecovery1.js | 8 +++----- .../reference/tsxErrorRecovery1.symbols | 2 ++ .../baselines/reference/tsxErrorRecovery1.types | 10 ++++++---- 10 files changed, 33 insertions(+), 44 deletions(-) diff --git a/tests/baselines/reference/jsxAndTypeAssertion.js b/tests/baselines/reference/jsxAndTypeAssertion.js index cf4033f4c57..fb51acd6fd4 100644 --- a/tests/baselines/reference/jsxAndTypeAssertion.js +++ b/tests/baselines/reference/jsxAndTypeAssertion.js @@ -28,18 +28,21 @@ var foo = /** @class */ (function () { return foo; }()); var x; -x = {test} }; +x = {test}: }; x = ; -x = hello {} } +x = hello {} }; x = }>hello}/> -x = }>hello{}} +x = }>hello{}}; x = x, x = ; {{/foo/.test(x) ? : }} : -}}}/>; +} + + +}}/>; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index bf17ca57c0d..b04a03079b7 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -123,7 +123,7 @@ var x =
one
,
two
; var x =
one
/* intervening comment */, /* intervening comment */
two
; ; //// [20.jsx] -{"str"}}; +{"str"};}; //// [21.jsx] ; //// [22.jsx] diff --git a/tests/baselines/reference/jsxParsingError1.errors.txt b/tests/baselines/reference/jsxParsingError1.errors.txt index dec1228fd72..a3e4e0b4f25 100644 --- a/tests/baselines/reference/jsxParsingError1.errors.txt +++ b/tests/baselines/reference/jsxParsingError1.errors.txt @@ -1,9 +1,8 @@ -tests/cases/conformance/jsx/file.tsx(11,36): error TS1005: '}' expected. -tests/cases/conformance/jsx/file.tsx(11,44): error TS1003: Identifier expected. -tests/cases/conformance/jsx/file.tsx(11,46): error TS1161: Unterminated regular expression literal. +tests/cases/conformance/jsx/file.tsx(11,30): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/conformance/jsx/file.tsx(11,30): error TS18007: JSX expressions may not use the comma operator. Did you mean to write an array? -==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { @@ -15,10 +14,8 @@ tests/cases/conformance/jsx/file.tsx(11,46): error TS1161: Unterminated regular const class1 = "foo"; const class2 = "bar"; const elem =
; - ~ -!!! error TS1005: '}' expected. - ~ -!!! error TS1003: Identifier expected. - -!!! error TS1161: Unterminated regular expression literal. + ~~~~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~~~~~~~~~~~~~~ +!!! error TS18007: JSX expressions may not use the comma operator. Did you mean to write an array? \ No newline at end of file diff --git a/tests/baselines/reference/jsxParsingError1.js b/tests/baselines/reference/jsxParsingError1.js index bf2d48b0491..09bb9c113c1 100644 --- a/tests/baselines/reference/jsxParsingError1.js +++ b/tests/baselines/reference/jsxParsingError1.js @@ -16,5 +16,4 @@ const elem =
; // This should be a parse error var class1 = "foo"; var class2 = "bar"; -var elem =
; -/>;; +var elem =
; diff --git a/tests/baselines/reference/jsxParsingError1.symbols b/tests/baselines/reference/jsxParsingError1.symbols index 35d1ba6c290..535f39f5927 100644 --- a/tests/baselines/reference/jsxParsingError1.symbols +++ b/tests/baselines/reference/jsxParsingError1.symbols @@ -25,5 +25,5 @@ const elem =
; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) >className : Symbol(className, Decl(file.tsx, 10, 17)) >class1 : Symbol(class1, Decl(file.tsx, 8, 5)) ->class2 : Symbol(class2, Decl(file.tsx, 10, 36)) +>class2 : Symbol(class2, Decl(file.tsx, 9, 5)) diff --git a/tests/baselines/reference/jsxParsingError1.types b/tests/baselines/reference/jsxParsingError1.types index 3278c28c724..2d4c65b91d0 100644 --- a/tests/baselines/reference/jsxParsingError1.types +++ b/tests/baselines/reference/jsxParsingError1.types @@ -18,10 +18,10 @@ const class2 = "bar"; const elem =
; >elem : JSX.Element ->
: JSX.Element >div : any >className : string +>class1, class2 : "bar" >class1 : "foo" ->class2 : true ->/>; : RegExp +>class2 : "bar" diff --git a/tests/baselines/reference/tsxErrorRecovery1.errors.txt b/tests/baselines/reference/tsxErrorRecovery1.errors.txt index d7e4f5c55df..34c2a3fc879 100644 --- a/tests/baselines/reference/tsxErrorRecovery1.errors.txt +++ b/tests/baselines/reference/tsxErrorRecovery1.errors.txt @@ -1,26 +1,14 @@ -tests/cases/conformance/jsx/file.tsx(4,11): error TS17008: JSX element 'div' has no corresponding closing tag. tests/cases/conformance/jsx/file.tsx(4,19): error TS1109: Expression expected. -tests/cases/conformance/jsx/file.tsx(7,11): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/file.tsx(7,12): error TS1005: '}' expected. -tests/cases/conformance/jsx/file.tsx(8,1): error TS1005: ' {
- ~~~ -!!! error TS17008: JSX element 'div' has no corresponding closing tag. ~~ !!! error TS1109: Expression expected. } // Shouldn't see any errors down here var y = { a: 1 }; - ~ -!!! error TS2304: Cannot find name 'a'. - ~ -!!! error TS1005: '}' expected. - - -!!! error TS1005: ' {}div> -} -// Shouldn't see any errors down here -var y = {a} 1 }; - ; + var x =
{}
; } +// Shouldn't see any errors down here +var y = { a: 1 }; diff --git a/tests/baselines/reference/tsxErrorRecovery1.symbols b/tests/baselines/reference/tsxErrorRecovery1.symbols index de6bce7d278..2b39f9bbce7 100644 --- a/tests/baselines/reference/tsxErrorRecovery1.symbols +++ b/tests/baselines/reference/tsxErrorRecovery1.symbols @@ -11,4 +11,6 @@ function foo() { } // Shouldn't see any errors down here var y = { a: 1 }; +>y : Symbol(y, Decl(file.tsx, 6, 3)) +>a : Symbol(a, Decl(file.tsx, 6, 9)) diff --git a/tests/baselines/reference/tsxErrorRecovery1.types b/tests/baselines/reference/tsxErrorRecovery1.types index d75b4ab89ae..010097d4166 100644 --- a/tests/baselines/reference/tsxErrorRecovery1.types +++ b/tests/baselines/reference/tsxErrorRecovery1.types @@ -6,13 +6,15 @@ function foo() { var x =
{
>x : JSX.Element ->
{
}// Shouldn't see any errors down herevar y = { a: 1 }; : JSX.Element +>
{
: JSX.Element >div : any > : any +>div : any } // Shouldn't see any errors down here var y = { a: 1 }; ->a : any - -> : any +>y : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 From ad9c36e0ecae1be0532b1e87db59ecc4f80c96bc Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 22 May 2019 10:00:09 -0700 Subject: [PATCH 8/8] Expose ts.Diagnostics to fourslash --- tests/cases/fourslash/fourslash.ts | 17 +++++++++++++++++ .../jsxExpressionFollowedByIdentifier.ts | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index e6f2a08f002..29bfe9acade 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -42,6 +42,8 @@ // // TODO: figure out a better solution to the API exposure problem. +/// + declare module ts { export type MapKey = string | number; export interface Map { @@ -70,6 +72,21 @@ declare module ts { text: string; } + enum DiagnosticCategory { + Warning, + Error, + Suggestion, + Message + } + + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + message: string; + reportsUnnecessary?: {}; + } + function flatMap(array: ReadonlyArray, mapfn: (x: T, i: number) => U | ReadonlyArray | undefined): U[]; } diff --git a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts index 501a325b989..16dcb7f6560 100644 --- a/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts +++ b/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts @@ -6,7 +6,7 @@ ////const b =
[|x|]} /> test.ranges().forEach(range => { - verify.errorExistsAtRange(range, 1005, "'}' expected."); + verify.errorExistsAtRange(range, ts.Diagnostics._0_expected.code, "'}' expected."); // This is just to ensure getting quick info doesn’t crash verify.not.quickInfoExists(); });