-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add conversion of the iterator from Flow to TS (#1604)
Summary: Pull Request resolved: #1604 `@iterator` and `@asyncIterator` are valid syntaxes for Flow but not for TS which accepts [Symbol.iterator] and [Symbol.asyncIterator]. According to flow lexer these are the only valid syntaxes in this form so checking for other cases prefixed with `@@` should not be required. Changelog: [flow-api-translator] - Added conversion of the iterator and asyncIterator from Flow to TS Reviewed By: pieterv Differential Revision: D68776171 fbshipit-source-id: 9532eb287755aa3b384c4743a1b942bbde08bc55
- Loading branch information
1 parent
89fe002
commit ede7def
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...ow-api-translator/__tests__/flowDefToTSDef/fixtures/class/members/method/iterator/spec.js
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,14 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
declare class Foo { | ||
@@iterator(): Iterator<string>; | ||
@@asyncIterator(): AsyncIterator<string>; | ||
} |
19 changes: 19 additions & 0 deletions
19
...tor/__tests__/flowDefToTSDef/fixtures/class/members/method/iterator/translate-result.shot
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,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`flowDefToTSDef class/members/method/iterator 1`] = ` | ||
"/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
* @format | ||
*/ | ||
|
||
declare class Foo { | ||
[Symbol.iterator](): Iterator<string>; | ||
[Symbol.asyncIterator](): AsyncIterator<string>; | ||
} | ||
" | ||
`; |
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