Print ObjectTypeInternalSlot with both flow/babel parsers (#4869)
* Print ObjectTypeInternalSlot with both flow/babel parsers * chore: update to flow-parser@0.78.0 * test: update snapshotmaster
parent
418a04bf2b
commit
1391891ef6
|
@ -32,7 +32,7 @@
|
||||||
"esutils": "2.0.2",
|
"esutils": "2.0.2",
|
||||||
"find-parent-dir": "0.3.0",
|
"find-parent-dir": "0.3.0",
|
||||||
"find-project-root": "1.1.1",
|
"find-project-root": "1.1.1",
|
||||||
"flow-parser": "0.75.0",
|
"flow-parser": "0.78.0",
|
||||||
"get-stream": "3.0.0",
|
"get-stream": "3.0.0",
|
||||||
"globby": "6.1.0",
|
"globby": "6.1.0",
|
||||||
"graphql": "0.13.2",
|
"graphql": "0.13.2",
|
||||||
|
|
|
@ -1086,6 +1086,18 @@ function printPathNoParens(path, options, print, args) {
|
||||||
parts.push(path.call(print, "body"));
|
parts.push(path.call(print, "body"));
|
||||||
|
|
||||||
return concat(parts);
|
return concat(parts);
|
||||||
|
|
||||||
|
case "ObjectTypeInternalSlot":
|
||||||
|
return concat([
|
||||||
|
n.static ? "static " : "",
|
||||||
|
"[[",
|
||||||
|
path.call(print, "id"),
|
||||||
|
"]]",
|
||||||
|
printOptionalToken(path),
|
||||||
|
n.method ? "" : ": ",
|
||||||
|
path.call(print, "value")
|
||||||
|
]);
|
||||||
|
|
||||||
case "ObjectExpression":
|
case "ObjectExpression":
|
||||||
case "ObjectPattern":
|
case "ObjectPattern":
|
||||||
case "ObjectTypeAnnotation":
|
case "ObjectTypeAnnotation":
|
||||||
|
@ -1140,7 +1152,7 @@ function printPathNoParens(path, options, print, args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTypeAnnotation) {
|
if (isTypeAnnotation) {
|
||||||
fields.push("indexers", "callProperties");
|
fields.push("indexers", "callProperties", "internalSlots");
|
||||||
}
|
}
|
||||||
fields.push(propertiesField);
|
fields.push(propertiesField);
|
||||||
|
|
||||||
|
@ -2414,7 +2426,8 @@ function printPathNoParens(path, options, print, args) {
|
||||||
let isArrowFunctionTypeAnnotation =
|
let isArrowFunctionTypeAnnotation =
|
||||||
n.type === "TSFunctionType" ||
|
n.type === "TSFunctionType" ||
|
||||||
!(
|
!(
|
||||||
(parent.type === "ObjectTypeProperty" &&
|
((parent.type === "ObjectTypeProperty" ||
|
||||||
|
parent.type === "ObjectTypeInternalSlot") &&
|
||||||
!getFlowVariance(parent) &&
|
!getFlowVariance(parent) &&
|
||||||
!parent.optional &&
|
!parent.optional &&
|
||||||
options.locStart(parent) === options.locStart(n)) ||
|
options.locStart(parent) === options.locStart(n)) ||
|
||||||
|
@ -5553,7 +5566,8 @@ function isMemberExpressionChain(node) {
|
||||||
// type T = { method(): void };
|
// type T = { method(): void };
|
||||||
function isObjectTypePropertyAFunction(node, options) {
|
function isObjectTypePropertyAFunction(node, options) {
|
||||||
return (
|
return (
|
||||||
node.type === "ObjectTypeProperty" &&
|
(node.type === "ObjectTypeProperty" ||
|
||||||
|
node.type === "ObjectTypeInternalSlot") &&
|
||||||
node.value.type === "FunctionTypeAnnotation" &&
|
node.value.type === "FunctionTypeAnnotation" &&
|
||||||
!node.static &&
|
!node.static &&
|
||||||
!isFunctionNotation(node, options)
|
!isFunctionNotation(node, options)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`internal_slot.js - flow-verify 1`] = `
|
||||||
|
declare class C { static [[foo]]: T }
|
||||||
|
declare class C { [[foo]]: T }
|
||||||
|
interface T { [[foo]]: X }
|
||||||
|
interface T { [[foo]](): X }
|
||||||
|
type T = { [[foo]]: X }
|
||||||
|
type T = { [[foo]](): X }
|
||||||
|
type T = { [[foo]]?: X }
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
declare class C { static [[foo]]: T }
|
||||||
|
declare class C { [[foo]]: T }
|
||||||
|
interface T { [[foo]]: X }
|
||||||
|
interface T { [[foo]](): X }
|
||||||
|
type T = { [[foo]]: X };
|
||||||
|
type T = { [[foo]](): X };
|
||||||
|
type T = { [[foo]]?: X };
|
||||||
|
|
||||||
|
`;
|
|
@ -0,0 +1,7 @@
|
||||||
|
declare class C { static [[foo]]: T }
|
||||||
|
declare class C { [[foo]]: T }
|
||||||
|
interface T { [[foo]]: X }
|
||||||
|
interface T { [[foo]](): X }
|
||||||
|
type T = { [[foo]]: X }
|
||||||
|
type T = { [[foo]](): X }
|
||||||
|
type T = { [[foo]]?: X }
|
|
@ -0,0 +1 @@
|
||||||
|
run_spec(__dirname, ["flow", "babylon"]);
|
|
@ -2377,9 +2377,9 @@ flatten@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
||||||
|
|
||||||
flow-parser@0.75.0:
|
flow-parser@0.78.0:
|
||||||
version "0.75.0"
|
version "0.78.0"
|
||||||
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.75.0.tgz#9a1891c48051c73017b6b5cc07b3681fda3fdfb0"
|
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.78.0.tgz#4ec829a97fa68cff6e97691dfff7b6ddebbc187c"
|
||||||
|
|
||||||
for-in@^1.0.1, for-in@^1.0.2:
|
for-in@^1.0.1, for-in@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
|
|
Loading…
Reference in New Issue