Throw a syntax error for empty type parameter/argument (#12088)
This commit is contained in:
parent
cb4e436018
commit
a4a14caee7
@ -73,6 +73,8 @@ const TSErrors = Object.freeze({
|
|||||||
"An implementation cannot be declared in ambient contexts.",
|
"An implementation cannot be declared in ambient contexts.",
|
||||||
DuplicateModifier: "Duplicate modifier: '%0'",
|
DuplicateModifier: "Duplicate modifier: '%0'",
|
||||||
EmptyHeritageClauseType: "'%0' list cannot be empty.",
|
EmptyHeritageClauseType: "'%0' list cannot be empty.",
|
||||||
|
EmptyTypeArguments: "Type argument list cannot be empty.",
|
||||||
|
EmptyTypeParameters: "Type parameter list cannot be empty.",
|
||||||
IndexSignatureHasAbstract:
|
IndexSignatureHasAbstract:
|
||||||
"Index signatures cannot have the 'abstract' modifier",
|
"Index signatures cannot have the 'abstract' modifier",
|
||||||
IndexSignatureHasAccessibility:
|
IndexSignatureHasAccessibility:
|
||||||
@ -403,6 +405,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
/* bracket */ false,
|
/* bracket */ false,
|
||||||
/* skipFirstToken */ true,
|
/* skipFirstToken */ true,
|
||||||
);
|
);
|
||||||
|
if (node.params.length === 0) {
|
||||||
|
this.raise(node.start, TSErrors.EmptyTypeParameters);
|
||||||
|
}
|
||||||
return this.finishNode(node, "TSTypeParameterDeclaration");
|
return this.finishNode(node, "TSTypeParameterDeclaration");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1680,6 +1685,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
if (node.params.length === 0) {
|
||||||
|
this.raise(node.start, TSErrors.EmptyTypeArguments);
|
||||||
|
}
|
||||||
// This reads the next token after the `>` too, so do this in the enclosing context.
|
// This reads the next token after the `>` too, so do this in the enclosing context.
|
||||||
// But be sure not to parse a regex in the jsx expression `<C<number> />`, so set exprAllowed = false
|
// But be sure not to parse a regex in the jsx expression `<C<number> />`, so set exprAllowed = false
|
||||||
this.state.exprAllowed = false;
|
this.state.exprAllowed = false;
|
||||||
|
|||||||
1
packages/babel-parser/test/fixtures/typescript/class/empty-type-parameters/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/class/empty-type-parameters/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class C<> {}
|
||||||
36
packages/babel-parser/test/fixtures/typescript/class/empty-type-parameters/output.json
vendored
Normal file
36
packages/babel-parser/test/fixtures/typescript/class/empty-type-parameters/output.json
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type parameter list cannot be empty. (1:7)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"C"},
|
||||||
|
"name": "C"
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterDeclaration",
|
||||||
|
"start":7,"end":9,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":9}},
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start":10,"end":12,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":12}},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/typescript/function/empty-type-parameters/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/function/empty-type-parameters/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
function foo<>() {}
|
||||||
39
packages/babel-parser/test/fixtures/typescript/function/empty-type-parameters/output.json
vendored
Normal file
39
packages/babel-parser/test/fixtures/typescript/function/empty-type-parameters/output.json
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type parameter list cannot be empty. (1:12)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterDeclaration",
|
||||||
|
"start":12,"end":14,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":14}},
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":17,"end":19,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}},
|
||||||
|
"body": [],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"type": "File",
|
"type": "File",
|
||||||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
|
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:3)"
|
||||||
|
],
|
||||||
"program": {
|
"program": {
|
||||||
"type": "Program",
|
"type": "Program",
|
||||||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
|
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}},
|
||||||
@ -0,0 +1 @@
|
|||||||
|
interface A extends B<> {}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:21)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TSInterfaceDeclaration",
|
||||||
|
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"A"},
|
||||||
|
"name": "A"
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
{
|
||||||
|
"type": "TSExpressionWithTypeArguments",
|
||||||
|
"start":20,"end":23,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":23}},
|
||||||
|
"expression": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"B"},
|
||||||
|
"name": "B"
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterInstantiation",
|
||||||
|
"start":21,"end":23,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":23}},
|
||||||
|
"params": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"type": "TSInterfaceBody",
|
||||||
|
"start":24,"end":26,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":26}},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
class A implements B<> {}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:20)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"A"},
|
||||||
|
"name": "A"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"implements": [
|
||||||
|
{
|
||||||
|
"type": "TSExpressionWithTypeArguments",
|
||||||
|
"start":19,"end":22,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":22}},
|
||||||
|
"expression": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"B"},
|
||||||
|
"name": "B"
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterInstantiation",
|
||||||
|
"start":20,"end":22,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":22}},
|
||||||
|
"params": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start":23,"end":25,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":25}},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-new/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-new/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
new A<>();
|
||||||
35
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-new/output.json
vendored
Normal file
35
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-new/output.json
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:5)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
|
||||||
|
"expression": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"A"},
|
||||||
|
"name": "A"
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterInstantiation",
|
||||||
|
"start":5,"end":7,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":7}},
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-superclass/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-superclass/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class A extends B<> {}
|
||||||
40
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-superclass/output.json
vendored
Normal file
40
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-superclass/output.json
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:17)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"A"},
|
||||||
|
"name": "A"
|
||||||
|
},
|
||||||
|
"superClass": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17},"identifierName":"B"},
|
||||||
|
"name": "B"
|
||||||
|
},
|
||||||
|
"superTypeParameters": {
|
||||||
|
"type": "TSTypeParameterInstantiation",
|
||||||
|
"start":17,"end":19,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}},
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start":20,"end":22,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":22}},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
var a = <Comp<>></Comp>
|
||||||
3
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["jsx", "typescript"]
|
||||||
|
}
|
||||||
62
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/output.json
vendored
Normal file
62
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/output.json
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:13)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":4,"end":23,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":23}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"a"},
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "JSXElement",
|
||||||
|
"start":8,"end":23,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":23}},
|
||||||
|
"openingElement": {
|
||||||
|
"type": "JSXOpeningElement",
|
||||||
|
"start":8,"end":16,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":16}},
|
||||||
|
"name": {
|
||||||
|
"type": "JSXIdentifier",
|
||||||
|
"start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13}},
|
||||||
|
"name": "Comp"
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterInstantiation",
|
||||||
|
"start":13,"end":15,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":15}},
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
"attributes": [],
|
||||||
|
"selfClosing": false
|
||||||
|
},
|
||||||
|
"closingElement": {
|
||||||
|
"type": "JSXClosingElement",
|
||||||
|
"start":16,"end":23,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":23}},
|
||||||
|
"name": {
|
||||||
|
"type": "JSXIdentifier",
|
||||||
|
"start":18,"end":22,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":22}},
|
||||||
|
"name": "Comp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "var"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-import/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-import/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
let a: import("")<>;
|
||||||
55
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-import/output.json
vendored
Normal file
55
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-import/output.json
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:17)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":4,"end":19,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":19}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":4,"end":19,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":19},"identifierName":"a"},
|
||||||
|
"name": "a",
|
||||||
|
"typeAnnotation": {
|
||||||
|
"type": "TSTypeAnnotation",
|
||||||
|
"start":5,"end":19,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":19}},
|
||||||
|
"typeAnnotation": {
|
||||||
|
"type": "TSImportType",
|
||||||
|
"start":7,"end":19,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":19}},
|
||||||
|
"argument": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "",
|
||||||
|
"raw": "\"\""
|
||||||
|
},
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterInstantiation",
|
||||||
|
"start":17,"end":19,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}},
|
||||||
|
"params": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"init": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "let"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-ref/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-ref/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
let a: Foo<>;
|
||||||
51
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-ref/output.json
vendored
Normal file
51
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-ref/output.json
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Type argument list cannot be empty. (1:10)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":4,"end":12,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":12}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":4,"end":12,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":12},"identifierName":"a"},
|
||||||
|
"name": "a",
|
||||||
|
"typeAnnotation": {
|
||||||
|
"type": "TSTypeAnnotation",
|
||||||
|
"start":5,"end":12,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":12}},
|
||||||
|
"typeAnnotation": {
|
||||||
|
"type": "TSTypeReference",
|
||||||
|
"start":7,"end":12,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":12}},
|
||||||
|
"typeName": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10},"identifierName":"Foo"},
|
||||||
|
"name": "Foo"
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterInstantiation",
|
||||||
|
"start":10,"end":12,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":12}},
|
||||||
|
"params": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"init": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "let"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -69,6 +69,7 @@ classExtendsAcrossFiles.ts
|
|||||||
classExtendsMultipleBaseClasses.ts
|
classExtendsMultipleBaseClasses.ts
|
||||||
classIndexer5.ts
|
classIndexer5.ts
|
||||||
classOverloadForFunction.ts
|
classOverloadForFunction.ts
|
||||||
|
classWithEmptyTypeParameter.ts
|
||||||
collisionExportsRequireAndClass.ts
|
collisionExportsRequireAndClass.ts
|
||||||
commonSourceDir5.ts
|
commonSourceDir5.ts
|
||||||
commonSourceDir6.ts
|
commonSourceDir6.ts
|
||||||
@ -147,6 +148,9 @@ emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts
|
|||||||
emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts
|
emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts
|
||||||
emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts
|
emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts
|
||||||
emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts
|
emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts
|
||||||
|
emptyGenericParamList.ts
|
||||||
|
emptyTypeArgumentList.ts
|
||||||
|
emptyTypeArgumentListWithNew.ts
|
||||||
enumGenericTypeClash.ts
|
enumGenericTypeClash.ts
|
||||||
es3-oldStyleOctalLiteralTypes.ts
|
es3-oldStyleOctalLiteralTypes.ts
|
||||||
es3defaultAliasIsQuoted.ts
|
es3defaultAliasIsQuoted.ts
|
||||||
@ -278,7 +282,6 @@ jsdocAccessEnumType.ts
|
|||||||
jsdocPropertyTagInvalid.ts
|
jsdocPropertyTagInvalid.ts
|
||||||
jsxAttributeWithoutExpressionReact.tsx
|
jsxAttributeWithoutExpressionReact.tsx
|
||||||
jsxIntrinsicElementsExtendsRecord.tsx
|
jsxIntrinsicElementsExtendsRecord.tsx
|
||||||
jsxIntrinsicElementsTypeArgumentErrors.tsx
|
|
||||||
letAndVarRedeclaration.ts
|
letAndVarRedeclaration.ts
|
||||||
letAsIdentifier.ts
|
letAsIdentifier.ts
|
||||||
letAsIdentifierInStrictMode.ts
|
letAsIdentifierInStrictMode.ts
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user