forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync prettier v3.0.3 and add support for AsExpression and rendersType…
… changes Summary: Sync changes from hermes-v2-backport: https://github.com/pieterv/prettier/commits/hermes-v2-backport This includes: - Rebase to Prettier v3.0.3 prettier/prettier@d5f3171 - Patch in AsExpression logic from prettier/prettier@675490a - Update printing logic to support `rendersType` AST structure change. - Add tweaks to wrap-paren.js logic to ensure renders types and components correctly get wrapped. pieterv/prettier@7c7635c Reviewed By: SamChou19815 Differential Revision: D50248021 fbshipit-source-id: 097cfe0b435f45c7cf25c03bab0f89a7e2bbf38f
- Loading branch information
1 parent
9651515
commit 0aac412
Showing
10 changed files
with
936 additions
and
109 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
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
56 changes: 56 additions & 0 deletions
56
tools/hermes-parser/js/hermes-parser/__tests__/MappedType-test.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,56 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
import { | ||
printForSnapshotESTree, | ||
parseForSnapshotESTree, | ||
printForSnapshotBabel, | ||
parseForSnapshotBabel, | ||
} from '../__test_utils__/parse'; | ||
|
||
describe('MappedType', () => { | ||
describe('Basic', () => { | ||
const code = ` | ||
type Mapped = {[key in keyof O]: O[key]}; | ||
`; | ||
|
||
test('ESTree', async () => { | ||
expect(await parseForSnapshotESTree(code)).toMatchSnapshot(); | ||
expect(await printForSnapshotESTree(code)).toBe(code.trim()); | ||
}); | ||
|
||
test('Babel', async () => { | ||
expect(await parseForSnapshotBabel(code)).toMatchSnapshot(); | ||
expect(await printForSnapshotBabel(code)).toMatchInlineSnapshot(` | ||
"type Mapped = { any | ||
};" | ||
`); | ||
}); | ||
}); | ||
|
||
describe('Union', () => { | ||
const code = ` | ||
type Mapped = {[key in keyof (O | Z)]: O[key]}; | ||
`; | ||
|
||
test('ESTree', async () => { | ||
expect(await parseForSnapshotESTree(code)).toMatchSnapshot(); | ||
expect(await printForSnapshotESTree(code)).toBe(code.trim()); | ||
}); | ||
|
||
test('Babel', async () => { | ||
expect(await parseForSnapshotBabel(code)).toMatchSnapshot(); | ||
expect(await printForSnapshotBabel(code)).toMatchInlineSnapshot(` | ||
"type Mapped = { any | ||
};" | ||
`); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.