fix(typescript): preserve quoted class property (#4517)
parent
3fc4c527d3
commit
553e9bb1ac
|
@ -3247,7 +3247,8 @@ function printPropertyKey(path, options, print) {
|
||||||
isStringLiteral(key) &&
|
isStringLiteral(key) &&
|
||||||
isIdentifierName(key.value) &&
|
isIdentifierName(key.value) &&
|
||||||
!node.computed &&
|
!node.computed &&
|
||||||
options.parser !== "json"
|
options.parser !== "json" &&
|
||||||
|
!(options.parser === "typescript" && node.type === "ClassProperty")
|
||||||
) {
|
) {
|
||||||
// 'a' -> a
|
// 'a' -> a
|
||||||
return path.call(
|
return path.call(
|
||||||
|
|
|
@ -171,3 +171,14 @@ class X {
|
||||||
}
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`quoted-property.ts 1`] = `
|
||||||
|
class User {
|
||||||
|
"username": string;
|
||||||
|
}
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
class User {
|
||||||
|
"username": string;
|
||||||
|
}
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
class User {
|
||||||
|
"username": string;
|
||||||
|
}
|
Loading…
Reference in New Issue