From deabbfdfdb9d9077e67f345f76565c7a62e0844c Mon Sep 17 00:00:00 2001 From: Aakash Patel Date: Wed, 19 Jan 2022 18:35:21 -0800 Subject: [PATCH] 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 --- unsupported/juno/crates/juno/src/gen_js.rs | 9 +++++---- unsupported/juno/crates/juno/tests/gen_js/mod.rs | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/unsupported/juno/crates/juno/src/gen_js.rs b/unsupported/juno/crates/juno/src/gen_js.rs index 0679b2a14cd..b3a4ffd84b6 100644 --- a/unsupported/juno/crates/juno/src/gen_js.rs +++ b/unsupported/juno/crates/juno/src/gen_js.rs @@ -2011,11 +2011,12 @@ impl GenJS { Node::StringLiteralTypeAnnotation(StringLiteralTypeAnnotation { metadata: _, value, - raw: _, + raw, }) => { - out_token!(self, node, "\""); - self.print_escaped_string_literal(value, '"'); - out!(self, "\""); + let quote = raw.str[0] as u8 as char; + out_token!(self, node, "{}", quote); + self.print_escaped_string_literal(value, quote); + out!(self, "{}", quote); } Node::NumberLiteralTypeAnnotation(NumberLiteralTypeAnnotation { metadata: _, diff --git a/unsupported/juno/crates/juno/tests/gen_js/mod.rs b/unsupported/juno/crates/juno/tests/gen_js/mod.rs index 749ba0b2148..61b645c2389 100644 --- a/unsupported/juno/crates/juno/tests/gen_js/mod.rs +++ b/unsupported/juno/crates/juno/tests/gen_js/mod.rs @@ -474,6 +474,7 @@ fn test_types() { test_roundtrip_flow("type A = ?(number | string)"); test_roundtrip_flow("type A = string"); test_roundtrip_flow("type A = \"foo\""); + test_roundtrip_flow("type A = 'foo'"); test_roundtrip_flow("type A = 3"); test_roundtrip_flow("type A = boolean"); test_roundtrip_flow("type A = true | false");