fix(typescript): preserve quoted class property (#4517)

This commit is contained in:
Ika authored and GitHub committed 2018-05-21 18:57:30 +08:00
1 parent 3fc4c527d3
commit 553e9bb1ac
3 files changed
+16 -1

No files matched your search

+2 -1
View File
@@ -3247,7 +3247,8 @@ function printPropertyKey(path, options, print) {
isStringLiteral(key) &&
isIdentifierName(key.value) &&
!node.computed &&
options.parser !== "json"
options.parser !== "json" &&
!(options.parser === "typescript" && node.type === "ClassProperty")
) {
// 'a' -> a
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;
}