221 Commits

Author SHA1 Message Date
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
Nicolò Ribaudo
1f6454cc90
v7.3.4 2019-02-25 19:29:12 +01:00
Justin Ridgewell
fc1ea7f496 Revert "Parenthesized expressions (#8025)"
This reverts commit dd8b700a2c4c975584c7b2ea43023aa275c16167.
2019-02-25 19:03:00 +01:00
Barthélémy Ledoux
9f3457797f Fix TypeScript parsers missing token check (#9571) (#9572)
* Fix TypeScript parsers missing token check (#9571)

* fix unit test
2019-02-24 13:34:38 +01:00
Erik Arvidsson
dd8b700a2c Parenthesized expressions (#8025)
* Add parser createParenthesizedExpressions option  …

When set to `true` we create `ParenthesizedExpression` nodes instead of
setting `extra.parenthesized`.

* Also update babel-parser.d.ts
2019-02-23 02:45:25 -05:00
Daniel Tschinder
a1ea765b95
Make tests spec compliant and avoid duplicate declarations in input files (#9522) 2019-02-18 16:14:35 -08:00
Daniel Tschinder
058f057426
Also check AssignmentPatterns for export name (#9521) 2019-02-15 22:55:03 -08:00
Nicolò Ribaudo
d1fe2d05f4 v7.3.3 2019-02-15 22:06:01 +01:00
Daniel Tschinder
4ba998c5db Add importKind to spec 2019-02-14 21:53:29 +01:00
Daniel Tschinder
d349b74a4f
Better error output in parser tests (#9491) 2019-02-11 02:13:24 -08:00
Daniel Tschinder
2817844e89
Fix regression with let (#9477)
* Fix corner cases with let

* Handle generators correctly

* Fix flow plugin

* Fix typescript plugin
2019-02-08 13:36:37 -08:00
Downpooooour
d1514f57bd Typescript function destructured params (#9431)
* fix typescript funtion destructured params for array

* update type name
2019-02-07 22:59:50 +01:00
Brian Ng
07b0f22a3f
Fix range for TypeScript optional parameter in arrow function (#9463) 2019-02-06 08:17:32 -06:00
Yifei Fu
e03e5ba01d Add TypeScript definitions for parser plugin options. (#9457) 2019-02-06 10:03:54 +01:00
Nicolò Ribaudo
d896ce2b53 v7.3.2 2019-02-04 23:20:05 +01:00
Daniel Tschinder
344d35bbe9 Simplify await and yield tracking in params (#9405) 2019-02-04 22:01:17 +01:00
Daniel Tschinder
9eb010da50
Unify reserved word checking and update error messages (#9402)
* Unify reserved word checking and update error messages

* Fix test
2019-01-31 19:02:32 -08:00
Galymzhan Abdugalimov
00c3e3c8e0 Fixed link to @babel/parser's issues in README (#9427) 2019-01-30 08:18:43 -06:00
Nicolò Ribaudo
4c4c22a316 Run prettier 2019-01-30 11:30:31 +01:00
Daniel Tschinder
828169e611
Fix line continuation with Unicode line terminators (#9403) 2019-01-28 13:35:35 -08:00
Brian Ng
7dc157f9be
Fix location/range on TypeScript ExportNamedDeclarations (#9406) 2019-01-24 19:44:22 -06:00
Daniel Tschinder
46ba5940c2
Make yield a contextual keyword (#9400) 2019-01-23 14:33:23 -08:00
Daniel Tschinder
42c5d3fc4b
Correctly fail for invalid yield in for (#9398) 2019-01-23 13:39:30 -08:00
Daniel Tschinder
8bc9f9a05f
fix: Allow toplevel await when option true and correctly mark await keyword as unexpected (#9371) 2019-01-22 14:56:30 -08:00
Daniel Tschinder
4f69699b71 Fix parsing in non-declaration places 2019-01-22 13:12:03 -08:00
Daniel Tschinder
f4f5ca2aaa Parse class name in strict mode
The specification defines that the whole class declaration is parsed in strict mode
2019-01-22 13:12:03 -08:00
Daniel Tschinder
8071dca9ad Disallow const let or let let 2019-01-22 13:12:02 -08:00
Daniel Tschinder
178f2d7949 Make let a contextual keyword 2019-01-22 13:12:02 -08:00
Nicolò Ribaudo
65febdd13a
Refactor import and export parsing (#9326)
* [parser] Refactor import parsing

* [parser] Refactor export parsing

* Fix types
2019-01-22 19:52:56 +01:00
Brian Ng
f77c450cda
Bump prettier (#9373) 2019-01-22 09:16:32 -06:00
Nicolò Ribaudo
f2af6c1170 v7.3.1 2019-01-22 08:07:23 +01:00
Daniel Tschinder
af88e63dff
fix new keyword broken by recent refactoring (#9377) 2019-01-21 22:25:37 -08:00
Nicolò Ribaudo
f6ee26c3da v7.3.0 2019-01-21 22:22:39 +01:00
Daniel Tschinder
96a7343142
Merge pull request #9348 from danez/perf
Parser Performance Collection
2019-01-21 02:27:42 -08:00
Armano
a2e6d8e968 Disallow usage of invalid keyword after export abstract statement in Typescript (#9336) 2019-01-19 15:48:05 -06:00
Daniel Tschinder
4e5e319d5b perf: remove double check for keywords in readWord
Instead of calling isKeyword we simple check directly if the keyword token is available
2019-01-17 16:16:31 -08:00
Daniel Tschinder
b66d921053 perf: Use === or Set.has instead of array.indexOf for keyword checks 2019-01-17 16:16:30 -08:00
Daniel Tschinder
f12905b531 perf: Use for loops while cloning classes 2019-01-17 16:16:29 -08:00
Daniel Tschinder
f216975378 perf: call isLineTerminator as last check 2019-01-17 16:16:28 -08:00
Daniel Tschinder
3a3d5cbe9c perf: Check for plugin only once before looping 2019-01-17 16:16:28 -08:00
Daniel Tschinder
58768072ef perf: Ensure canInsertSemicolon is always called last
It does a lot of checks and a regex test
2019-01-17 16:16:26 -08:00
Daniel Tschinder
455e003567 perf: Optimize regex
This saves some steps, as the regex parser does not have to backtrack for character classes, but is has to for alternates
2019-01-17 16:15:07 -08:00
Daniel Tschinder
49f7bcf271 perf: Remove unnecessary check for flow plugin inside of flow plugin 2019-01-17 16:15:07 -08:00
Daniel Tschinder
c2e41588aa perf: run flow code in flow plugin 2019-01-17 16:15:05 -08:00
Daniel Tschinder
a1eac37bd2 Generate prettier comments 2019-01-17 16:15:04 -08:00
Daniel Tschinder
0370af58f1 perf: Use strict equals 2019-01-17 16:15:03 -08:00
Daniel Tschinder
8df0500f55 perf: Simplify reading of tokens.
This avoids checking isIdentifierStart for every single token
2019-01-17 16:15:01 -08:00
Daniel Tschinder
e4b8cfc768 perf: use Set instead of string indexOf 2019-01-17 16:15:00 -08:00
Daniel Tschinder
a7757ec4d0 perf: Use increment operator 2019-01-17 16:14:58 -08:00
Daniel Tschinder
25a8db2a29 perf: use normal equality check in stead of indexOf 2019-01-17 16:14:57 -08:00