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

master
Ika 2018-05-21 18:57:30 +08:00 committed by GitHub
parent 3fc4c527d3
commit 553e9bb1ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

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(

View File

@ -171,3 +171,14 @@ class X {
}
`;
exports[`quoted-property.ts 1`] = `
class User {
"username": string;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class User {
"username": string;
}
`;

View File

@ -0,0 +1,3 @@
class User {
"username": string;
}