From 2ed2374026a3443888f0a05c4580273dc394c715 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sun, 8 May 2022 22:47:20 -0700 Subject: [PATCH 1/2] flow: Add getter/setter "kind" on ObjectTypeProperty These are already emitted by the Babel parser. --- def/flow.ts | 1 + gen/builders.ts | 1 + gen/namedTypes.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/def/flow.ts b/def/flow.ts index 7df97cf8..ba13ff39 100644 --- a/def/flow.ts +++ b/def/flow.ts @@ -171,6 +171,7 @@ export default function (fork: Fork) { .field("key", or(def("Literal"), def("Identifier"))) .field("value", def("FlowType")) .field("optional", Boolean) + .field("kind", or("init", "get", "set")) .field("variance", LegacyVariance, defaults["null"]); def("ObjectTypeIndexer") diff --git a/gen/builders.ts b/gen/builders.ts index 3f5254ba..c4005a09 100644 --- a/gen/builders.ts +++ b/gen/builders.ts @@ -1906,6 +1906,7 @@ export interface ObjectTypePropertyBuilder { params: { comments?: K.CommentKind[] | null, key: K.LiteralKind | K.IdentifierKind, + kind: "init" | "get" | "set", loc?: K.SourceLocationKind | null, optional: boolean, value: K.FlowTypeKind, diff --git a/gen/namedTypes.ts b/gen/namedTypes.ts index a520ef45..c50caa68 100644 --- a/gen/namedTypes.ts +++ b/gen/namedTypes.ts @@ -890,6 +890,7 @@ export namespace namedTypes { key: K.LiteralKind | K.IdentifierKind; value: K.FlowTypeKind; optional: boolean; + kind: "init" | "get" | "set"; variance?: K.VarianceKind | "plus" | "minus" | null; } From 1b7f07f8e7b331ce35e4a6d29ea89310dba50321 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sun, 8 May 2022 23:14:56 -0700 Subject: [PATCH 2/2] flow: Make "kind" optional on ObjectTypeProperty It'd really be a pain to have to specify this every time -- the case where it's anything other than "init" is a bit of an esoteric feature. --- def/flow.ts | 2 +- gen/builders.ts | 2 +- gen/namedTypes.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/def/flow.ts b/def/flow.ts index ba13ff39..dd5dc2a5 100644 --- a/def/flow.ts +++ b/def/flow.ts @@ -171,7 +171,7 @@ export default function (fork: Fork) { .field("key", or(def("Literal"), def("Identifier"))) .field("value", def("FlowType")) .field("optional", Boolean) - .field("kind", or("init", "get", "set")) + .field("kind", or("init", "get", "set"), () => "init") .field("variance", LegacyVariance, defaults["null"]); def("ObjectTypeIndexer") diff --git a/gen/builders.ts b/gen/builders.ts index c4005a09..e22db325 100644 --- a/gen/builders.ts +++ b/gen/builders.ts @@ -1906,7 +1906,7 @@ export interface ObjectTypePropertyBuilder { params: { comments?: K.CommentKind[] | null, key: K.LiteralKind | K.IdentifierKind, - kind: "init" | "get" | "set", + kind?: "init" | "get" | "set", loc?: K.SourceLocationKind | null, optional: boolean, value: K.FlowTypeKind, diff --git a/gen/namedTypes.ts b/gen/namedTypes.ts index c50caa68..f1691498 100644 --- a/gen/namedTypes.ts +++ b/gen/namedTypes.ts @@ -890,7 +890,7 @@ export namespace namedTypes { key: K.LiteralKind | K.IdentifierKind; value: K.FlowTypeKind; optional: boolean; - kind: "init" | "get" | "set"; + kind?: "init" | "get" | "set"; variance?: K.VarianceKind | "plus" | "minus" | null; }