Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support type annotations on auto accessors via
babel-ts
(#14049)
* Update `@babel/parser` * Move tests to `/format/typescript` * Update tests * Add changelog * Dedupe Co-authored-by: fisker <lionkay@gmail.com>
- Loading branch information
1 parent
57a109a
commit 7564339
Showing
8 changed files
with
47 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#### Support type annotations on auto accessors via `babel-ts` (#14049 by @sosukesuzuki) | ||
|
||
[The bug that `@babel/parser` cannot parse auto accessors with type annotations](https://github.com/babel/babel/issues/15205) has been fixed. So we now support it via `babel-ts` parser. | ||
|
||
<!-- prettier-ignore --> | ||
```tsx | ||
class Foo { | ||
accessor prop: number; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/format/typescript/decorator-auto-accessors/__snapshots__/jsfmt.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`decorator-auto-accessors-type-annotations.ts format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
abstract class Foo { | ||
accessor prop: number = 1; | ||
static accessor prop2: number = 1; | ||
accessor #prop3: number = 1; | ||
accessor [prop4]: number = 1; | ||
private accessor prop5: number = 1; | ||
abstract accessor prop6: number; | ||
} | ||
=====================================output===================================== | ||
abstract class Foo { | ||
accessor prop: number = 1; | ||
static accessor prop2: number = 1; | ||
accessor #prop3: number = 1; | ||
accessor [prop4]: number = 1; | ||
private accessor prop5: number = 1; | ||
abstract accessor prop6: number; | ||
} | ||
================================================================================ | ||
`; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run_spec(__dirname, ["typescript"]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters