Add TS support to @babel/parser's Scope (#9766)

* [parser] Allow plugins to extend ScopeHandler

* Directly extend Scope

* Don't use new.target to get the ScopeHandler

* [parser] Add TS enum  support to the Scope

* Remove duplicated options in tests

* Fix

* Fix flow

* Rename tests

* Add tests

* Full typescript support in scope

* Remove BIND_SIMPLE_CATCH

SCOPE_SIMPLE_CATCH was used instead

* Export TS types

* Register function declarations

* Fix body-less functions and namespaces

1) Move this.scope.exit() for functions from parseFunctionBody to the callers.
    Otherwise the scope of body-less functions was never closed.
    Also, it is easier to track scope.exit() if it is near to scope.enter()
2) Register namespace ids for export

* Disallow redeclaration of enum with const enum
This commit is contained in:
Nicolò Ribaudo
2019-04-26 14:19:53 +02:00
committed by GitHub
parent 293f3c98d2
commit 30d507c915
108 changed files with 3974 additions and 98 deletions

View File

@@ -2,6 +2,6 @@ type Foo = false;
type Foo2 = true;
type Foo3 = "string";
type Foo4 = 123;
type Foo4 = 123.4;
type Foo5 = -123;
type Foo5 = -123.5;
type Foo5 = 123.4;
type Foo6 = -123;
type Foo7 = -123.5;

View File

@@ -312,9 +312,9 @@
"line": 5,
"column": 9
},
"identifierName": "Foo4"
"identifierName": "Foo5"
},
"name": "Foo4"
"name": "Foo5"
},
"typeAnnotation": {
"type": "TSLiteralType",
@@ -376,9 +376,9 @@
"line": 6,
"column": 9
},
"identifierName": "Foo5"
"identifierName": "Foo6"
},
"name": "Foo5"
"name": "Foo6"
},
"typeAnnotation": {
"type": "TSLiteralType",
@@ -457,9 +457,9 @@
"line": 7,
"column": 9
},
"identifierName": "Foo5"
"identifierName": "Foo7"
},
"name": "Foo5"
"name": "Foo7"
},
"typeAnnotation": {
"type": "TSLiteralType",

View File

@@ -0,0 +1,2 @@
{ enum Foo {} }
let Foo;

View File

@@ -0,0 +1,137 @@
{
"type": "File",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "BlockStatement",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"body": [
{
"type": "TSEnumDeclaration",
"start": 2,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 13
}
},
"id": {
"type": "Identifier",
"start": 7,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "Foo"
},
"name": "Foo"
},
"members": []
}
],
"directives": []
},
{
"type": "VariableDeclaration",
"start": 16,
"end": 24,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 20,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 7
}
},
"id": {
"type": "Identifier",
"start": 20,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "Foo"
},
"name": "Foo"
},
"init": null
}
],
"kind": "let"
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
declare function foo(): void;
export { foo };

View File

@@ -0,0 +1,169 @@
{
"type": "File",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 15
}
},
"program": {
"type": "Program",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 15
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSDeclareFunction",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 29
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "foo"
},
"name": "foo"
},
"generator": false,
"async": false,
"params": [],
"returnType": {
"type": "TSTypeAnnotation",
"start": 22,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 28
}
},
"typeAnnotation": {
"type": "TSVoidKeyword",
"start": 24,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 28
}
}
}
},
"declare": true
},
{
"type": "ExportNamedDeclaration",
"start": 31,
"end": 46,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 15
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 40,
"end": 43,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 40,
"end": 43,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"exported": {
"type": "Identifier",
"start": 40,
"end": 43,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
}
}
],
"source": null,
"declaration": null
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
export { foo };
declare function foo(): void;

View File

@@ -0,0 +1,169 @@
{
"type": "File",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 29
}
},
"program": {
"type": "Program",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 29
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"exported": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
}
}
],
"source": null,
"declaration": null
},
{
"type": "TSDeclareFunction",
"start": 17,
"end": 46,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 29
}
},
"id": {
"type": "Identifier",
"start": 34,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 17
},
"end": {
"line": 3,
"column": 20
},
"identifierName": "foo"
},
"name": "foo"
},
"generator": false,
"async": false,
"params": [],
"returnType": {
"type": "TSTypeAnnotation",
"start": 39,
"end": 45,
"loc": {
"start": {
"line": 3,
"column": 22
},
"end": {
"line": 3,
"column": 28
}
},
"typeAnnotation": {
"type": "TSVoidKeyword",
"start": 41,
"end": 45,
"loc": {
"start": {
"line": 3,
"column": 24
},
"end": {
"line": 3,
"column": 28
}
}
}
},
"declare": true
}
],
"directives": []
}
}

View File

@@ -0,0 +1,5 @@
// https://github.com/babel/babel/issues/9763
enum Test {}
export { Test as default }

View File

@@ -0,0 +1,172 @@
{
"type": "File",
"start": 0,
"end": 87,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 87,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 26
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSEnumDeclaration",
"start": 47,
"end": 59,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 52,
"end": 56,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 9
},
"identifierName": "Test"
},
"name": "Test"
},
"members": [],
"leadingComments": [
{
"type": "CommentLine",
"value": " https://github.com/babel/babel/issues/9763",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 45
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 61,
"end": 87,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 26
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 70,
"end": 85,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 24
}
},
"local": {
"type": "Identifier",
"start": 70,
"end": 74,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 13
},
"identifierName": "Test"
},
"name": "Test"
},
"exported": {
"type": "Identifier",
"start": 78,
"end": 85,
"loc": {
"start": {
"line": 5,
"column": 17
},
"end": {
"line": 5,
"column": 24
},
"identifierName": "default"
},
"name": "default"
}
}
],
"source": null,
"declaration": null
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " https://github.com/babel/babel/issues/9763",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 45
}
}
}
]
}

View File

@@ -0,0 +1,3 @@
export { Test as default }
enum Test {}

View File

@@ -0,0 +1,136 @@
{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 12
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 12
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 9,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 24
}
},
"local": {
"type": "Identifier",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 13
},
"identifierName": "Test"
},
"name": "Test"
},
"exported": {
"type": "Identifier",
"start": 17,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 24
},
"identifierName": "default"
},
"name": "default"
}
}
],
"source": null,
"declaration": null
},
{
"type": "TSEnumDeclaration",
"start": 28,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 33,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 9
},
"identifierName": "Test"
},
"name": "Test"
},
"members": []
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
interface A {}
export { A };

View File

@@ -0,0 +1,151 @@
{
"type": "File",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSInterfaceDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": []
}
},
{
"type": "ExportNamedDeclaration",
"start": 15,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
}
},
"local": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"exported": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "A"
},
"name": "A"
}
}
],
"source": null,
"declaration": null
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
export { A };
interface A {}

View File

@@ -0,0 +1,151 @@
{
"type": "File",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"local": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"exported": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "A"
},
"name": "A"
}
}
],
"source": null,
"declaration": null
},
{
"type": "TSInterfaceDeclaration",
"start": 14,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
namespace N {}
export { N };

View File

@@ -0,0 +1,151 @@
{
"type": "File",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 13
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSModuleDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "N"
},
"name": "N"
},
"body": {
"type": "TSModuleBlock",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": []
}
},
{
"type": "ExportNamedDeclaration",
"start": 16,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 13
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 10
}
},
"local": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 10
},
"identifierName": "N"
},
"name": "N"
},
"exported": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 10
},
"identifierName": "N"
},
"name": "N"
}
}
],
"source": null,
"declaration": null
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
type A = number;
export { A };

View File

@@ -0,0 +1,150 @@
{
"type": "File",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSTypeAliasDeclaration",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "A"
},
"name": "A"
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}
}
},
{
"type": "ExportNamedDeclaration",
"start": 17,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
}
},
"local": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"exported": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "A"
},
"name": "A"
}
}
],
"source": null,
"declaration": null
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
export { A };
type A = number;

View File

@@ -0,0 +1,150 @@
{
"type": "File",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"program": {
"type": "Program",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"local": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"exported": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "A"
},
"name": "A"
}
}
],
"source": null,
"declaration": null
},
{
"type": "TSTypeAliasDeclaration",
"start": 14,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "A"
},
"name": "A"
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 23,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
}
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,4 @@
function f(): void;
function f() {}
export { f };

View File

@@ -0,0 +1,2 @@
class A {}
class A {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'A' has already been declared (2:6)"
}

View File

@@ -0,0 +1,2 @@
class A {}
enum A {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'A' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
class A {}
interface A {}

View File

@@ -0,0 +1,132 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 10
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 10
}
},
"body": []
}
},
{
"type": "TSInterfaceDeclaration",
"start": 11,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 23,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
class A {}
type A = number;

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'A' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
const enum Foo {}
const enum Foo {}

View File

@@ -0,0 +1,103 @@
{
"type": "File",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"program": {
"type": "Program",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSEnumDeclaration",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"const": true,
"id": {
"type": "Identifier",
"start": 11,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "Foo"
},
"name": "Foo"
},
"members": []
},
{
"type": "TSEnumDeclaration",
"start": 18,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"const": true,
"id": {
"type": "Identifier",
"start": 29,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 14
},
"identifierName": "Foo"
},
"name": "Foo"
},
"members": []
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
const enum X {}
enum X {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'X' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
enum X {}
class X {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'X' has already been declared (2:6)"
}

View File

@@ -0,0 +1,2 @@
enum X {}
const enum X {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'X' has already been declared (2:11)"
}

View File

@@ -0,0 +1,2 @@
enum Foo {}
enum Foo {}

View File

@@ -0,0 +1,101 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSEnumDeclaration",
"start": 0,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 5,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 8
},
"identifierName": "Foo"
},
"name": "Foo"
},
"members": []
},
{
"type": "TSEnumDeclaration",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "Foo"
},
"name": "Foo"
},
"members": []
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
enum Foo {}
function Foo() {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'Foo' has already been declared (2:9)"
}

View File

@@ -0,0 +1,2 @@
enum X {}
interface X {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'X' has already been declared (2:10)"
}

View File

@@ -0,0 +1,2 @@
enum Foo {}
let Foo;

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'Foo' has already been declared (2:4)"
}

View File

@@ -0,0 +1,2 @@
enum X {}
type X = number;

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'X' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
enum Foo {}
let Foo;

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'Foo' has already been declared (2:4)"
}

View File

@@ -0,0 +1,2 @@
function Foo() {}
enum Foo {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'Foo' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
function A() {}
interface A {}

View File

@@ -0,0 +1,135 @@
{
"type": "File",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 13,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 15
}
},
"body": [],
"directives": []
}
},
{
"type": "TSInterfaceDeclaration",
"start": 16,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 28,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
function A() {}
type A = number;

View File

@@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 13,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 15
}
},
"body": [],
"directives": []
}
},
{
"type": "TSTypeAliasDeclaration",
"start": 16,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "A"
},
"name": "A"
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 25,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
}
}
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
interface A {}
class A {}

View File

@@ -0,0 +1,132 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSInterfaceDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": []
}
},
{
"type": "ClassDeclaration",
"start": 15,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 23,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 10
}
},
"body": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
interface X {}
enum X {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'X' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
interface A {}
function A() {}

View File

@@ -0,0 +1,135 @@
{
"type": "File",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"program": {
"type": "Program",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSInterfaceDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": []
}
},
{
"type": "FunctionDeclaration",
"start": 15,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 28,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 15
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
interface A {}
interface A {}

View File

@@ -0,0 +1,131 @@
{
"type": "File",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSInterfaceDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": []
}
},
{
"type": "TSInterfaceDeclaration",
"start": 15,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 27,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
interface A {}
let A;

View File

@@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSInterfaceDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": []
}
},
{
"type": "VariableDeclaration",
"start": 15,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "A"
},
"name": "A"
},
"init": null
}
],
"kind": "let"
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
interface A {}
var A;

View File

@@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSInterfaceDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 12,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 14
}
},
"body": []
}
},
{
"type": "VariableDeclaration",
"start": 15,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "A"
},
"name": "A"
},
"init": null
}
],
"kind": "var"
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
let Foo;
enum Foo {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'Foo' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
let A;
interface A {}

View File

@@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 6
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "A"
},
"name": "A"
},
"init": null
}
],
"kind": "let"
},
{
"type": "TSInterfaceDeclaration",
"start": 7,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 19,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
type A = number;
class A {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'A' has already been declared (2:6)"
}

View File

@@ -0,0 +1,2 @@
type A = number;
enum A {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'A' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
type A = number;
function A() {}

View File

@@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSTypeAliasDeclaration",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "A"
},
"name": "A"
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}
}
},
{
"type": "FunctionDeclaration",
"start": 17,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "A"
},
"name": "A"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 30,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 15
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
type A = number;
interface A {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'A' has already been declared (2:10)"
}

View File

@@ -0,0 +1,2 @@
type A = number;
let A;

View File

@@ -0,0 +1,133 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSTypeAliasDeclaration",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "A"
},
"name": "A"
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}
}
},
{
"type": "VariableDeclaration",
"start": 17,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "A"
},
"name": "A"
},
"init": null
}
],
"kind": "let"
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
type A = number;
type A = string;

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'A' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
type A = number;
var A;

View File

@@ -0,0 +1,133 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSTypeAliasDeclaration",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "A"
},
"name": "A"
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}
}
},
{
"type": "VariableDeclaration",
"start": 17,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "A"
},
"name": "A"
},
"init": null
}
],
"kind": "var"
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
let Foo;
enum Foo {}

View File

@@ -0,0 +1,3 @@
{
"throws": "Identifier 'Foo' has already been declared (2:5)"
}

View File

@@ -0,0 +1,2 @@
var A;
interface A {}

View File

@@ -0,0 +1,134 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 6
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "A"
},
"name": "A"
},
"init": null
}
],
"kind": "var"
},
{
"type": "TSInterfaceDeclaration",
"start": 7,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 19,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 14
}
},
"body": []
}
}
],
"directives": []
}
}