Do not register ambient classes to the TS scope (#10352)

This commit is contained in:
Nicolò Ribaudo
2019-08-21 00:22:47 +02:00
committed by Brian Ng
parent 11ed2e2bf5
commit 15aa511b8e
10 changed files with 468 additions and 8 deletions

View File

@@ -0,0 +1,2 @@
declare class C { }
declare function C(): void;

View File

@@ -0,0 +1,151 @@
{
"type": "File",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 27
}
},
"program": {
"type": "Program",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 27
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "C"
},
"name": "C"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 16,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 19
}
},
"body": []
},
"declare": true
},
{
"type": "TSDeclareFunction",
"start": 20,
"end": 47,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 27
}
},
"id": {
"type": "Identifier",
"start": 37,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 17
},
"end": {
"line": 2,
"column": 18
},
"identifierName": "C"
},
"name": "C"
},
"generator": false,
"async": false,
"params": [],
"returnType": {
"type": "TSTypeAnnotation",
"start": 40,
"end": 46,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 26
}
},
"typeAnnotation": {
"type": "TSVoidKeyword",
"start": 42,
"end": 46,
"loc": {
"start": {
"line": 2,
"column": 22
},
"end": {
"line": 2,
"column": 26
}
}
}
},
"declare": true
}
],
"directives": []
}
}

View File

@@ -0,0 +1,2 @@
declare class C { }
function C() { }

View File

@@ -0,0 +1,137 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"declare": true,
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "C"
},
"name": "C"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 16,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 19
}
},
"body": []
}
},
{
"type": "FunctionDeclaration",
"start": 20,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 16
}
},
"id": {
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "C"
},
"name": "C"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 33,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 16
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
import Something from './somewhere.js'
declare class Something {}

View File

@@ -0,0 +1,154 @@
{
"type": "File",
"start": 0,
"end": 66,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 66,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 26
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 16
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 16
},
"identifierName": "Something"
},
"name": "Something"
}
}
],
"source": {
"type": "StringLiteral",
"start": 22,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 38
}
},
"extra": {
"rawValue": "./somewhere.js",
"raw": "'./somewhere.js'"
},
"value": "./somewhere.js"
}
},
{
"type": "ClassDeclaration",
"start": 40,
"end": 66,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 26
}
},
"declare": true,
"id": {
"type": "Identifier",
"start": 54,
"end": 63,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 23
},
"identifierName": "Something"
},
"name": "Something"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 64,
"end": 66,
"loc": {
"start": {
"line": 3,
"column": 24
},
"end": {
"line": 3,
"column": 26
}
},
"body": []
}
}
],
"directives": []
}
}