forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw a syntax error for empty type parameter/argument (babel#12088)
- Loading branch information
1 parent
cb4e436
commit a4a14ca
Showing
23 changed files
with
438 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/class/empty-type-parameters/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class C<> {} |
36 changes: 36 additions & 0 deletions
36
packages/babel-parser/test/fixtures/typescript/class/empty-type-parameters/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/function/empty-type-parameters/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function foo<>() {} |
39 changes: 39 additions & 0 deletions
39
packages/babel-parser/test/fixtures/typescript/function/empty-type-parameters/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} | ||
} |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...pescript/type-arguments/empty/output.json → ...type-arguments/empty-function/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ges/babel-parser/test/fixtures/typescript/type-arguments/empty-interface-extends/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
interface A extends B<> {} |
46 changes: 46 additions & 0 deletions
46
.../babel-parser/test/fixtures/typescript/type-arguments/empty-interface-extends/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../babel-parser/test/fixtures/typescript/type-arguments/empty-interface-implements/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class A implements B<> {} |
47 changes: 47 additions & 0 deletions
47
...bel-parser/test/fixtures/typescript/type-arguments/empty-interface-implements/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-new/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
new A<>(); |
35 changes: 35 additions & 0 deletions
35
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-new/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-superclass/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class A extends B<> {} |
40 changes: 40 additions & 0 deletions
40
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-superclass/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var a = <Comp<>></Comp> |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["jsx", "typescript"] | ||
} |
62 changes: 62 additions & 0 deletions
62
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-tsx/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/type-arguments/empty-type-import/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let a: import("")<>; |
Oops, something went wrong.