Fix key quotes omission for flow parser (#203)
```js echo 'var { "key": val } = 1;' | ./bin/prettier.js --stdin --flow-parser var { key: val } = 1; ```master
parent
fe959631c1
commit
15cc3bb778
|
@ -1587,7 +1587,11 @@ function printStatementSequence(path, options, print) {
|
||||||
|
|
||||||
function printPropertyKey(path, print) {
|
function printPropertyKey(path, print) {
|
||||||
var node = path.getNode().key;
|
var node = path.getNode().key;
|
||||||
if (node.type === "StringLiteral" && isIdentifierName(node.value)) {
|
if (
|
||||||
|
(node.type === "StringLiteral" ||
|
||||||
|
node.type === "Literal" && typeof node.value === "string") &&
|
||||||
|
isIdentifierName(node.value)
|
||||||
|
) {
|
||||||
// 'a' -> a
|
// 'a' -> a
|
||||||
return node.value;
|
return node.value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -555,7 +555,7 @@ exports[`test string_lit.js 1`] = `
|
||||||
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
||||||
(with_dash: \"motivating example\"); // ok
|
(with_dash: \"motivating example\"); // ok
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var { \"key\": val } = { key: \"val\" };
|
var { key: val } = { key: \"val\" };
|
||||||
(val: void);
|
(val: void);
|
||||||
// error: string ~> void
|
// error: string ~> void
|
||||||
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
||||||
|
|
|
@ -161,7 +161,7 @@ var f: typeof numberAlias = 42;
|
||||||
* These provoke a specific error, not just the generic
|
* These provoke a specific error, not just the generic
|
||||||
* \"type is incompatible\"
|
* \"type is incompatible\"
|
||||||
*/
|
*/
|
||||||
var Map = { \"A\": \"this is A\", \"B\": \"this is B\", \"C\": \"this is C\" };
|
var Map = { A: \"this is A\", B: \"this is B\", C: \"this is C\" };
|
||||||
var keys: $Keys<Map> = \"A\"; // Error: ineligible value used in type anno
|
var keys: $Keys<Map> = \"A\"; // Error: ineligible value used in type anno
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
Loading…
Reference in New Issue