mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
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:
@@ -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;
|
||||
|
||||
12
tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts
Normal file
12
tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts
Normal 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 doesn’t crash
|
||||
verify.not.quickInfoExists();
|
||||
});
|
||||
11
tests/cases/fourslash/jsxExpressionWithCommaExpression.ts
Normal file
11
tests/cases/fourslash/jsxExpressionWithCommaExpression.ts
Normal 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));
|
||||
Reference in New Issue
Block a user