Merge pull request #31480 from andrewbranch/bug/25487

Fix invalid JSXExpressions having identifier-ish things in their trivia, improve error messages for comma expressions in JSX
This commit is contained in:
Andrew Branch
2019-06-26 10:13:42 -07:00
committed by GitHub
17 changed files with 111 additions and 47 deletions

View File

@@ -42,6 +42,8 @@
//
// TODO: figure out a better solution to the API exposure problem.
/// <reference path="../../../src/compiler/diagnosticInformationMap.generated.ts" />
declare module ts {
export type MapKey = string | number;
export interface Map<T> {
@@ -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<T, U>(array: ReadonlyArray<T>, mapfn: (x: T, i: number) => U | ReadonlyArray<U> | undefined): U[];
}
@@ -238,6 +255,7 @@ declare namespace FourSlashInterface {
signatureHelp(...options: VerifySignatureHelpOptions[], ): void;
// Checks that there are no compile errors.
noErrors(): void;
errorExistsAtRange(range: Range, code: number, message?: string): void;
numberOfErrorsInCurrentFile(expected: number): void;
baselineCurrentFileBreakpointLocations(): void;
baselineCurrentFileNameOrDottedNameSpans(): void;

View File

@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />
//@Filename: jsxExpressionFollowedByIdentifier.tsx
////declare var React: any;
////const a = <div>{<div />[|x|]}</div>
////const b = <div x={<div />[|x|]} />
test.ranges().forEach(range => {
verify.errorExistsAtRange(range, ts.Diagnostics._0_expected.code, "'}' expected.");
// This is just to ensure getting quick info doesnt crash
verify.not.quickInfoExists();
});

View File

@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />
//@Filename: jsxExpressionWithCommaExpression.tsx
//@jsx: react
////declare var React: any;
////declare var x: string;
////const a = <div x={[|x, x|]} />
////const b = <div>{[|x, x|]}</div>
verify.getSyntacticDiagnostics([]);
test.ranges().forEach(range => verify.errorExistsAtRange(range, 18006));