Skip to content

Commit deabbfd

Browse files
avpfacebook-github-bot
authored andcommitted
Use proper quotes in string literal type annotation
Summary: This stores `raw` now so use it. Reviewed By: tmikov Differential Revision: D33072071 fbshipit-source-id: d35aeacf81848625aea7c17ef85e0b3cd0dc6cb8
1 parent ae61d74 commit deabbfd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

unsupported/juno/crates/juno/src/gen_js.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2011,11 +2011,12 @@ impl<W: Write> GenJS<W> {
20112011
Node::StringLiteralTypeAnnotation(StringLiteralTypeAnnotation {
20122012
metadata: _,
20132013
value,
2014-
raw: _,
2014+
raw,
20152015
}) => {
2016-
out_token!(self, node, "\"");
2017-
self.print_escaped_string_literal(value, '"');
2018-
out!(self, "\"");
2016+
let quote = raw.str[0] as u8 as char;
2017+
out_token!(self, node, "{}", quote);
2018+
self.print_escaped_string_literal(value, quote);
2019+
out!(self, "{}", quote);
20192020
}
20202021
Node::NumberLiteralTypeAnnotation(NumberLiteralTypeAnnotation {
20212022
metadata: _,

unsupported/juno/crates/juno/tests/gen_js/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ fn test_types() {
474474
test_roundtrip_flow("type A = ?(number | string)");
475475
test_roundtrip_flow("type A = string");
476476
test_roundtrip_flow("type A = \"foo\"");
477+
test_roundtrip_flow("type A = 'foo'");
477478
test_roundtrip_flow("type A = 3");
478479
test_roundtrip_flow("type A = boolean");
479480
test_roundtrip_flow("type A = true | false");

0 commit comments

Comments
 (0)