TypeScript: Forbid invalid tuple label (#14256)

This commit is contained in:
fisker Cheung authored and GitHub committed 2023-02-06 10:44:46 +08:00
1 parent ac91baff0e
commit 5d4380372e
5 files changed
+37 -28

No files matched your search

-1
View File
@@ -189,7 +189,6 @@ const allowedMessageCodes = new Set([
"UnsupportedParameterPropertyKind",
"MixedLabeledAndUnlabeledElements",
"InvalidTupleMemberLabel",
"DuplicateAccessibilityModifier",
"IndexSignatureHasDeclare",
@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`snippet: #0 [babel-ts] format 1`] = `
"Tuple members must be labeled with a simple identifier. (1:11)
> 1 | type T = [x.y: A];
| ^"
`;
exports[`snippet: #0 [typescript] format 1`] = `
"',' expected. (1:14)
> 1 | type T = [x.y: A];
| ^"
`;
exports[`snippet: #1 [babel-ts] format 1`] = `
"Tuple members must be labeled with a simple identifier. (1:11)
> 1 | type T = [x<y>: A];
| ^"
`;
exports[`snippet: #1 [typescript] format 1`] = `
"',' expected. (1:15)
> 1 | type T = [x<y>: A];
| ^"
`;
@@ -0,0 +1,12 @@
run_spec(
{
importMeta: import.meta,
snippets: [
// Invalid label 1
"type T = [x.y: A];",
// Invalid label 2
"type T = [x<y>: A];",
],
},
["babel-ts", "typescript"]
);
@@ -183,25 +183,3 @@ type Foo =
================================================================================
`;
exports[`tuple-labeled-ts.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
printWidth: 80
| printWidth
=====================================input======================================
// Invalid label 1
type T = [x.y: A];
// Invalid label 2
type T = [x<y>: A];
=====================================output=====================================
// Invalid label 1
type T = [x.y: A];
// Invalid label 2
type T = [x<y>: A];
================================================================================
`;
@@ -1,5 +0,0 @@
// Invalid label 1
type T = [x.y: A];
// Invalid label 2
type T = [x<y>: A];