Skip to content

Commit d7a4d74

Browse files
authored
fix: quote props consistent (#546)
1 parent 2bbcc4f commit d7a4d74

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/generation/context.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ impl<'a> Context<'a> {
173173
) -> TReturn {
174174
if self.config.quote_props == QuoteProps::Consistent {
175175
self.consistent_quote_props_stack.push((use_consistent_quotes)(&state));
176+
let result = action(self, state);
177+
self.consistent_quote_props_stack.pop();
178+
result
179+
} else {
180+
action(self, state)
176181
}
177-
let is_consistent = self.consistent_quote_props_stack.peek().copied().unwrap_or(true);
178-
self.consistent_quote_props_stack.push(is_consistent);
179-
let result = action(self, state);
180-
self.consistent_quote_props_stack.pop();
181-
result
182182
}
183183

184184
// do any assertions for how the state of this context should be at the end of the file

tests/specs/literals/StringLiteral/StringLiteral_QuoteProps_Consistent.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,19 @@ type Type = {
158158
set foo3(v: string);
159159
foo4: "literal";
160160
};
161+
162+
== should not remove in this scenario ==
163+
const x = {
164+
"/src/shared/tsconfig-base.json": JSON.stringify({
165+
include: ["./typings-base/"],
166+
}),
167+
"/src/shared/index.ts": `export const a: Unrestricted = 1;`,
168+
}
169+
170+
[expect]
171+
const x = {
172+
"/src/shared/tsconfig-base.json": JSON.stringify({
173+
include: ["./typings-base/"],
174+
}),
175+
"/src/shared/index.ts": `export const a: Unrestricted = 1;`,
176+
};

0 commit comments

Comments
 (0)