Daniel Tschinder a7391144b3
Introduce scope tracking in the parser (#9493)
* Introduce scope tracking

* Fix tests

* Add new tests

* Remove constructor-super check from transform as it is now in parser

* Correctly handle class properties and class scope

* Fix duplicate name check

* Convert scope identifier storage to array

* Enter a new scope in typescript module blocks

* Add test for duplicate declaration

* Rename error for duplicate exports

* Treat class declarations as lexical declaration

* Update whitelist

* Add tests

* Fix scope tracking for function declarations

* Migrate try-catch duplicate error

* Fix test

* More tests

* One more test

* Make scope a separate class and fix review comments

* Do not allow new.target in top scope arrow function

* Correctly enter new scope for declare module and treat type aliases as lexical declarations

* Tests for typescript scope tracking to not mark type aliases as duplicate

* Fix flow scope tracking

* Remove ident from test names as redundant

* Add test case for var and function

* Improve error messages

* Improve literal regex
2019-02-25 11:04:52 -08:00

171 lines
3.9 KiB
JSON

{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"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": 40,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 40
}
},
"body": [
{
"type": "ReturnStatement",
"start": 15,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 38
}
},
"argument": {
"type": "ArrowFunctionExpression",
"start": 22,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 38
}
},
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "MetaProperty",
"start": 28,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 38
}
},
"meta": {
"type": "Identifier",
"start": 28,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 31
},
"identifierName": "new"
},
"name": "new"
},
"property": {
"type": "Identifier",
"start": 32,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 32
},
"end": {
"line": 1,
"column": 38
},
"identifierName": "target"
},
"name": "target"
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}