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

190 lines
4.0 KiB
JSON

{
"type": "File",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 10
}
},
"program": {
"type": "Program",
"start": 0,
"end": 53,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 10
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "DeclareModule",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "BlockStatement",
"start": 17,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "DeclareClass",
"start": 21,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 20
}
},
"id": {
"type": "Identifier",
"start": 35,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 16
},
"end": {
"line": 2,
"column": 17
},
"identifierName": "X"
},
"name": "X"
},
"typeParameters": null,
"extends": [],
"implements": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 37,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 20
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}
]
},
"kind": "CommonJS"
},
{
"type": "ClassDeclaration",
"start": 43,
"end": 53,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 10
}
},
"id": {
"type": "Identifier",
"start": 49,
"end": 50,
"loc": {
"start": {
"line": 5,
"column": 6
},
"end": {
"line": 5,
"column": 7
},
"identifierName": "X"
},
"name": "X"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 51,
"end": 53,
"loc": {
"start": {
"line": 5,
"column": 8
},
"end": {
"line": 5,
"column": 10
}
},
"body": []
}
}
],
"directives": []
}
}