-
Notifications
You must be signed in to change notification settings - Fork 356
Open
Description
Hello! 👋
Thanks for the amazing library.
From the readme:
the following identity is guaranteed:
recast.print(recast.parse(source)).code === source
I assumed that this should be true for different parsers too? I noticed a case where this is not true, hopefully this helps debugging the issue:
Original Source:
const a = <Text>
{slice.length >= 2 ? (
// 2-n followers, including blocks
serverCount > 2 ? (
<Trans>
Followed by{' '}
<Text emoji key={aaa.profile.did} style={textStyle}>
{bbb.profile.displayName}
</Text>
,{' '}
<Text emoji key={ccc.profile.did} style={textStyle}>
{ddd.profile.displayName}
</Text>
, and{' '}
<Plural
value={serverCount - 2}
one="# other"
other="# others"
/>
</Trans>
) : (
// only 2
<Trans>
Followed by{' '}
<Text emoji key={eee.profile.did} style={textStyle}>
{fff.profile.displayName}
</Text>{' '}
and{' '}
<Text emoji key={ggg.profile.did} style={textStyle}>
{hhh.profile.displayName}
</Text>
</Trans>
)
) : serverCount > 1 ? (
// 1-n followers, including blocks
<Trans>
Followed by{' '}
<Text emoji key={iii.profile.did} style={textStyle}>
{jjj.profile.displayName}
</Text>{' '}
and{' '}
<Plural
value={serverCount - 1}
one="# other"
other="# others"
/>
</Trans>
) : (
// only 1
<Trans>
Followed by{' '}
<Text emoji key={lll.profile.did} style={textStyle}>
{mmm.profile.displayName}
</Text>
</Trans>
)}
</Text>recast.print(recast.parse(source), { parser: require('recast/parsers/babel-ts') }).code
const a = <Text>
{slice.length >= 2 ? (
// 2-n followers, including blocks
serverCount > 2 ? (
<Trans>
Followed by{' '}
<Text emoji key={aaa.profile.did} style={textStyle}>
{bbb.profile.displayName}
</Text>
,{' '}
<Text emoji key={ccc.profile.did} style={textStyle}>
{ddd.profile.displayName}
</Text>
, and{' '}
<Plural
value={serverCount - 2}
one="# other"
other="# others"
/>
</Trans>
) : (
// only 2
<Trans>
Followed by{' '}
<Text emoji key={eee.profile.did} style={textStyle}>
{fff.profile.displayName}
</Text>{' '}
and{' '}
<Text emoji key={ggg.profile.did} style={textStyle}>
{hhh.profile.displayName}
</Text>
</Trans>
)
) : serverCount > 1 ? (
// 1-n followers, including blocks
<Trans>
Followed by{' '}
<Text emoji key={iii.profile.did} style={textStyle}>
{jjj.profile.displayName}
</Text>{' '}
and{' '}
<Plural
value={serverCount - 1}
one="# other"
other="# others"
/>
</Trans>
) : (
// only 1
<Trans>
Followed by{' '}
<Text emoji key={lll.profile.did} style={textStyle}>
{mmm.profile.displayName}
</Text>
</Trans>
)}
</Text>Here's the diff:
4,6c4
< serverCount > 2 ? (
< <Trans>
< Followed by{' '}
---
> (serverCount > 2 ? (<Trans>Followed by{' '}
9,10c7
< </Text>
< ,{' '}
---
> </Text>,{' '}
13,14c10
< </Text>
< , and{' '}
---
> </Text>, and{' '}
20,24c16,17
< </Trans>
< ) : (
< // only 2
< <Trans>
< Followed by{' '}
---
> </Trans>) : // only 2
> (<Trans>Followed by{' '}
27,28c20
< </Text>{' '}
< and{' '}
---
> </Text>{' '}and{' '}
32,33c24
< </Trans>
< )
---
> </Trans>))
36,37c27
< <Trans>
< Followed by{' '}
---
> (<Trans>Followed by{' '}
40,41c30
< </Text>{' '}
< and{' '}
---
> </Text>{' '}and{' '}
47c36
< </Trans>
---
> </Trans>)
50,51c39
< <Trans>
< Followed by{' '}
---
> (<Trans>Followed by{' '}
55c43
< </Trans>
---
> </Trans>)Thank you!!
Metadata
Metadata
Assignees
Labels
No labels