Commit Graph
162 Commits
Author SHA1 Message Date
fisker Cheung 24d39a9068 Throw errors for invalid left-hand side assignment (#10416)
* Throw errors for invalid left-hand side assignment

* Fix tests

* FIx tests

* Add tests from https://github.com/babel/babel/pull/12933
2021-03-30 01:40:42 +03:00
Sosuke Suzuki f0a612a302 Update @typescript-eslint/typescript-estree (#10589) 2021-03-24 19:39:00 +09:00
dependabot[bot] 72fcf45df3 Build(deps): Bump @babel/parser from 7.13.9 to 7.13.10 (#10523) 2021-03-16 04:07:53 +00:00
046ffb11f9 Support better formatting for curried arrow functions (#9992)
* Support formatting for curried arrow functions

* Fix test file name

* Fix threshold

* Add changelog

* Fix operator for comparing

* Fix return pos

* Fix eslint

* level 2

* Refactor for level2

* Update tests

* Remove concat

* If it fits on one line, print on one line

* Indent second level arg

* Break before last return value

* Use isCallLikeExpression

* Improve printing

* Add tests

* Remove unnecesary condition

* Fix lint problems

* Update src/language-js/utils.js

Co-authored-by: Chris Brody <chris.brody+brodybits@gmail.com>

* Update changelog

* Add ImportExpression

* Add ImportExpression to isCallLikeExpression

* Resolve conflicts

* Address reviews

* Fix ESLint problem

* Fix changelog

* Add tests

* More tests

* Print simple arrow chains on one line

* Don't forcibly break chain when a segment has a return type but no params

* Prevent excessive wrapping in assignments

* Simplify

* Format object bodies like blocks

* Update changelog

* Fix last arg expansion

* Simplify

* Fix arrow chains in assignment chains

Co-authored-by: Chris Brody <chris.brody+brodybits@gmail.com>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-03-08 23:18:53 +02:00
Sosuke Suzuki c9144daf47 Support TS 4.2 abstract construct types via ts-estree (#10466) 2021-03-06 19:16:51 +02:00
Georgii Dolzhykov 37aa31e929 Remove hacks for single-element unions/intersections (#10457)
* Remove hacks for degenerate unions/intersection

* Add changelog
2021-03-04 01:21:03 +02:00
fisker CheungandGeorgii Dolzhykov 383e17665e Refactor decorators print (#10296)
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-03-01 02:58:43 +08:00
Sosuke Suzuki feacf82892 Update babel/parser to v7.12.17 (#10345) 2021-02-25 18:28:06 +08:00
Georgii Dolzhykov ec27ade49b Heuristic for grouping parameters in method signatures (#10357)
* Heuristic for grouping parameters in method signatures
* Apply the same logic to function declaration and Flow types
* Group only if there is only one parameter
* Don't group if type param has constraints/default or >1 type param
2021-02-23 16:38:56 +02:00
Sosuke Suzuki b0d66bb3c6 Support TS 4.1 intrinsic keyword (#10390) 2021-02-22 13:49:49 +02:00
Georgii Dolzhykov 42f8271a1e Indent type assertions in heads of call and member expressions (#10341) 2021-02-20 14:37:08 +02:00
Georgii Dolzhykov aef9277ada Print trailing comma for TS type parameters but not type arguments (#10353) 2021-02-20 12:47:56 +02:00
Georgii Dolzhykov 3950ce194d Correct parentheses for non-null assertions (#10337) 2021-02-18 01:52:24 +02:00
Georgii Dolzhykov 0a647a0d31 Format assignments more consistently (#10222) 2021-02-16 21:25:11 +02:00
Georgii Dolzhykov 81e6208e63 Allow arg hugging for non-concise arrow functions with return type (#10316) 2021-02-15 19:13:09 +02:00
Sosuke Suzuki 2d97df8ec7 Fix unnecessary line breaks in method type declaration parameters (#10024) 2021-02-11 09:49:38 +02:00
Sosuke Suzuki cc1f0543e6 Consistent indentations for conditional operators (#10187) 2021-02-07 16:53:05 +02:00
dependabot[bot]andfisker Cheung d0942b8fae Build(deps): Bump @babel/code-frame from 7.12.11 to 7.12.13 (#10226)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2021-02-04 09:42:00 +08:00
Sosuke SuzukiandGeorgii Dolzhykov 53a7e9782b Print trailing comma for type parameters (#10109)
* Print type parameters for TypeScript

* Add more tests

* Add changelog

* Avoid duplicates printing trailing-commas

* Fix changelog

* Address review

* Update src/language-js/print/type-parameters.js

* Update 10109.md

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-01-28 23:03:16 +09:00
Sosuke Suzuki c7a3c16f7d Improve visual separation between header and body in classes with multiline headers (#10085)
* Add hardline for a class whose extends part is broken

refactor

Use groupId

Remove isPreviousLineEmpty

* Avoid leading comments

* Rename to heritage

* Add heuristic for implements

* Fix lint problems

* Fix

Fix

Fix

* Extract getGroupId patterns

* Adopots solution 2

* Fix

* Fix lint problem

* Add changelog

* Address reviews

* Update tests

* Rename to createGroupIdMapper

* Split files

* Add tests for complex extends

* Fix changelog
2021-01-20 15:01:16 +09:00
fisker Cheung 099ba04327 TypeScript: Fix missing comments in MethodDefinition (#9872) 2020-12-15 12:22:56 +08:00
dependabot[bot]andfisker 82603f2609 Build(deps): Bump @babel/parser from 7.12.5 to 7.12.7 (#9748)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
2020-11-24 14:24:30 +08:00
Sosuke Suzukiandfisker Cheung 4cc149248a Support TypeScript 4.1 via typescript-estree (#9636)
* Update typescript and typescript-estree

* Add AST transformation for TSTemplateLiteralType

* Update tests for template-literal-types

* Fix transformChainExpression

* Update tests for key-remapping-in-mapped-types

* Implement recoverInvalidDecorators

* Update changelog

* Avoid typecheck error

* Add os.platform() shim

* Update config.js

* Update config.js

* Shim os.cpus

* Update `process.versions.node`

* Attempt to fix build

* Update ts parserOptions

* Fix code style

* Remove `errorOnUnknownASTType`, fix code style

* Use `[] ||` instead of `[] //`

* Fix hack

* Add invalid tests

* checkMissingDecorators

* Update tests

* Fix tests

* Add comment

* Revert "Implement recoverInvalidDecorators"

This reverts commit 27e7b46ed41df36fb585791117c85e1b2dab932c.

* Add ref pr link

* Simplify logic

* Don't transform `TSTemplateLiteralType`

* Add `TSTemplateLiteralType` as simple type

* Fix tests

* Update comments

* Add comment

* Fix logic

* Minor tweak

* use multiple parsers

* Update @typescript-eslint/typescript-estree to v4.8.0

* Switch to `parseWithNodeMaps`

* Rename `esNode` -> `esTreeNode`

* Update @typescript-eslint/typescript-estree to 4.8.1-alpha.1

* Use @typescript-eslint/typescript-estree 4.8.1

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2020-11-18 10:59:58 +09:00
fisker CheungandGeorgii Dolzhykov 2a9d0f66d5 Typescript: Fix prettier-ignored mapped types (#9551)
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-11-13 09:06:02 +08:00
c91914e610 Build(deps): Bump @babel/parser from 7.12.3 to 7.12.5 (#9597)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sosukesuzuki <aosukeke@gmail.com>
Co-authored-by: fisker <lionkay@gmail.com>
2020-11-06 19:30:42 +08:00
fisker Cheung 7836466d67 Test: snapshot parse errors (#9467) 2020-11-06 15:27:04 +08:00
fisker Cheung 3f4c8c1df0 Treat more types as simple type (#9543) 2020-10-31 21:15:35 +08:00
fisker Cheung d2ce7d44d5 Refactor: Improve readability (#9539) 2020-10-30 16:52:17 +08:00
fisker Cheung eabceb2dcb Consistent type print (#9521) 2020-10-30 09:56:47 +08:00
Sosuke Suzuki 56e9602a28 Support TypeScript 4.1 via Babel (#9473)
* Support Key Remapping In Mapped Types

* Fix by Prettier

* Add changelog

* Fix jsfmt.spec.js

* Update cspell.json
2020-10-22 21:12:24 +09:00
Sosuke Suzuki 3b7a7ba3c9 Update @babel/parser to 7.12 (#9408)
* Install babel/parser 7.12

* Add tests for babel/babel#12161

* Add test for babel/babel#12076

* Add test for babel/babel#12085

* Add test for babel/babel#12108

* Add test for babel/babel#12120

* Add test for babel/babel#12054

* Add test for babel/babel#12061

* Add test babel/babel#12093

* Add test for babel/babel#12065

* Add test for babel/babel#12111

* Add test for babel/babel#12072

* Switch syntax-module-attributes to syntax-import-assertion

* Support "String import/export specifier"

* Remove tests for module-attributes

* Add changelog

* Update to 7.12.3

* Fix by linter

* Fix by spellchecker

* Add tests for module attributes to errors

* Add error test for module string name with import

* Remove TSTypeCastExpression

* Add tests for funny import-assertions

* Update snapshots|

* Add more tests
2020-10-20 19:01:30 +09:00
fisker Cheung 1005954c75 Test: use errors options instead of disableBabelTS (#9387) 2020-10-13 17:16:40 +08:00
Sosuke Suzuki e1eecfd7eb TypeScript: Preserve a last separator for ignored object and interface types (#9318)
* Preserve ignored TypeScript signature

* Add Changelog
2020-10-06 15:09:22 +09:00
fisker Cheung 94ef5f5683 Test: Fix indexes calculation (#9152)
* Test: Fix indexes calculation

* Simplify logic

* Update snapshots
2020-09-17 07:31:29 +08:00
golergka 7131347cde Typescript tagged template literal test (#9195) 2020-09-14 14:20:24 +03:00
Chris Brody 77c8da7691 test(TypeScript): test ...infer type with parens (#9056) 2020-08-26 09:02:58 +08:00
fisker Cheung 9a9dcbe12b Fix broken format for ...infer T (#9044) 2020-08-25 12:36:54 +03:00
fisker Cheung 08e8b40ac6 Move non-js syntax test out of tests/js/ dir (#9023) 2020-08-22 14:50:54 +08:00
Sosuke SuzukiandChristopher J. Brody 751f67af1f Upgrade to TypeScript 4.0 (#8982)
* Upgrade to TypeScript 4.0

* Update tests

* Fix changelog

* Revert invalid label tests

* Set loggerFn to false

* Use TS 4.0

* Apply logical assginment test for TypeScript

* Remove hack for NamedTupleMember

* workaround for TypeScript 4.0 in src/language-js/utils.js

Co-authored-by: Christopher J. Brody <chris.brody+brodybits@gmail.com>
2020-08-21 16:09:28 +09:00
Sosuke Suzukiandfisker Cheung 6dbef8681e Fix interface extends with long type parameters (#8981)
* Try the same way as #8967

* Update src/language-js/printer-estree.js

Co-authored-by: fisker Cheung <lionkay@gmail.com>

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2020-08-19 23:51:49 +09:00
Sosuke Suzuki 36c35be210 Fix class implements with long type parameters (#8967)
* Fix class implements

* Extract extendsParts and indent

* Refactor

* Refactor

* Fix by Prettier

* Refactor

* Refactor getTypeParametersGroupId with WeakMap
2020-08-19 20:21:52 +09:00
dependabot[bot]andfisker e2e0ddf08c Build(deps): Bump @babel/parser from 7.11.0 to 7.11.1 (#8914)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
2020-08-06 10:40:49 +08:00
dependabot[bot]andfisker 8f58bffecf Build(deps): Bump @babel/parser from 7.10.5 to 7.11.0 (#8869)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
2020-08-03 21:13:19 +08:00
fisker Cheung 170033f3f8 Update @typescript-eslint/typescript-estree to v3.7.1 (#8805) 2020-08-02 07:03:20 +08:00
Sosuke Suzuki 02137069a7 JavaScript: Break ternary expressions containing a multi-line block comment (#8592)
* Break ternary expression when there is multiline block comment

* Add changelog
2020-06-21 17:02:58 +09:00
Sosuke Suzuki 29959103a9 TypeScript: Prefer leading comment when there is a comment on after "?" in conditional types (#8557)
* Fix #8555

* Add changelog
2020-06-15 20:08:43 +09:00
fisker Cheung db05f0f36f Add tests for issue 6678 (#8513) 2020-06-08 16:17:04 +03:00
Sosuke Suzuki 3fc75799ee TypeScript: Support a TS 3.9 breaking change for Optional Chaining and Non-Null Assertions (#8450)
* Suuport improvement optional chaining ergonomics

* Add changelog

* Fix reviewed points
2020-05-31 09:17:39 +09:00
Georgii Dolzhykov 5a0e33cc84 fix(range): improve detection of JS source elements (#8419)
* fix(range): improve detection of JS source elements

* Add changelog entry

* Remove unneeded comment

* Add more types and update snapshots
2020-05-29 07:29:09 +03:00
fisker Cheung 12d379d29d Test: visualize the range (#8420) 2020-05-28 01:16:52 +08:00