flow-parser 0.325.0 → 0.327.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,9 +12,9 @@
12
12
 
13
13
  export type HermesPosition = {
14
14
  /** >= 1 */
15
- +line: number,
15
+ readonly line: number,
16
16
  /** >= 0 */
17
- +column: number,
17
+ readonly column: number,
18
18
  };
19
19
  export type HermesSourceLocation = {
20
20
  start?: HermesPosition,
@@ -31,9 +31,9 @@ export type ParserOptions = {
31
31
  throwOnParseErrors?: boolean,
32
32
  tokens?: boolean,
33
33
  transformOptions?: {
34
- +TransformEnumSyntax?: {
35
- +enable: boolean,
36
- +getRuntime?: () => Expression,
34
+ readonly TransformEnumSyntax?: {
35
+ readonly enable: boolean,
36
+ readonly getRuntime?: () => Expression,
37
37
  },
38
38
  },
39
39
  };
@@ -96,7 +96,7 @@ const FlowESTreeAndBabelVisitorKeys: VisitorKeys = {
96
96
  CommentLine: [],
97
97
  };
98
98
 
99
- function nodeWith<T: ESNode>(node: T, overrideProps: Partial<T>): T {
99
+ function nodeWith<T extends ESNode>(node: T, overrideProps: Partial<T>): T {
100
100
  return SimpleTransform.nodeWith(
101
101
  node,
102
102
  overrideProps,
@@ -110,33 +110,33 @@ function nodeWith<T: ESNode>(node: T, overrideProps: Partial<T>): T {
110
110
  * Copied from: https://github.com/babel/babel/blob/main/packages/babel-types/src/ast-types/generated/index.ts
111
111
  */
112
112
  export interface BabelFile extends BaseNode {
113
- +type: 'File';
114
- +program: Program;
115
- +comments: ReadonlyArray<BabelComment>;
113
+ readonly type: 'File';
114
+ readonly program: Program;
115
+ readonly comments: ReadonlyArray<BabelComment>;
116
116
  }
117
117
 
118
118
  interface BabelCommentBlock extends BaseToken {
119
- +type: 'CommentBlock';
120
- +value: string;
119
+ readonly type: 'CommentBlock';
120
+ readonly value: string;
121
121
  }
122
122
  interface BabelCommentLine extends BaseToken {
123
- +type: 'CommentLine';
124
- +value: string;
123
+ readonly type: 'CommentLine';
124
+ readonly value: string;
125
125
  }
126
126
  type BabelComment = BabelCommentBlock | BabelCommentLine;
127
127
 
128
128
  interface BabelObjectMethod extends BaseNode {
129
- +type: 'ObjectMethod';
130
- +kind: 'method' | 'get' | 'set';
131
- +key: Expression;
132
- +params: ReadonlyArray<FunctionParameter>;
133
- +body: BlockStatement;
134
- +computed: boolean;
135
- +generator: boolean;
136
- +async: boolean;
137
- +returnType?: TypeAnnotation | null;
138
- +typeParameters?: TypeParameterDeclaration | null;
139
- +variance?: boolean | null;
129
+ readonly type: 'ObjectMethod';
130
+ readonly kind: 'method' | 'get' | 'set';
131
+ readonly key: Expression;
132
+ readonly params: ReadonlyArray<FunctionParameter>;
133
+ readonly body: BlockStatement;
134
+ readonly computed: boolean;
135
+ readonly generator: boolean;
136
+ readonly async: boolean;
137
+ readonly returnType?: TypeAnnotation | null;
138
+ readonly typeParameters?: TypeParameterDeclaration | null;
139
+ readonly variance?: boolean | null;
140
140
 
141
141
  // TODO: Should these exist?
142
142
  // +id: ...,
@@ -146,146 +146,146 @@ interface BabelObjectMethod extends BaseNode {
146
146
  }
147
147
 
148
148
  interface BabelObjectProperty extends BaseNode {
149
- +type: 'ObjectProperty';
150
- +computed: boolean;
151
- +key: Expression;
152
- +value: Expression;
153
- +method: boolean;
154
- +shorthand: boolean;
149
+ readonly type: 'ObjectProperty';
150
+ readonly computed: boolean;
151
+ readonly key: Expression;
152
+ readonly value: Expression;
153
+ readonly method: boolean;
154
+ readonly shorthand: boolean;
155
155
  }
156
156
 
157
157
  interface BabelClassMethodBase extends BaseNode {
158
- +kind: 'get' | 'set' | 'method' | 'constructor';
159
- +computed: boolean;
160
- +static: boolean;
161
- +key:
158
+ readonly kind: 'get' | 'set' | 'method' | 'constructor';
159
+ readonly computed: boolean;
160
+ readonly static: boolean;
161
+ readonly key:
162
162
  | Identifier
163
163
  | StringLiteral
164
164
  | ClassPropertyNameComputed
165
165
  | ClassPropertyNameNonComputed;
166
- +id: null;
167
- +params: ReadonlyArray<FunctionParameter>;
168
- +body: BlockStatement;
169
- +async: boolean;
170
- +generator: boolean;
171
- +returnType?: TypeAnnotation | null;
172
- +typeParameters?: TypeParameterDeclaration | null;
173
- +predicate: null;
166
+ readonly id: null;
167
+ readonly params: ReadonlyArray<FunctionParameter>;
168
+ readonly body: BlockStatement;
169
+ readonly async: boolean;
170
+ readonly generator: boolean;
171
+ readonly returnType?: TypeAnnotation | null;
172
+ readonly typeParameters?: TypeParameterDeclaration | null;
173
+ readonly predicate: null;
174
174
  }
175
175
 
176
176
  interface BabelClassPrivateMethod extends BabelClassMethodBase {
177
- +type: 'ClassPrivateMethod';
177
+ readonly type: 'ClassPrivateMethod';
178
178
  }
179
179
  interface BabelClassMethod extends BabelClassMethodBase {
180
- +type: 'ClassMethod';
180
+ readonly type: 'ClassMethod';
181
181
  }
182
182
 
183
183
  interface BabelClassProperty extends BaseNode {
184
- +type: 'ClassProperty';
185
- +key: Expression;
186
- +value: null | Expression;
187
- +typeAnnotation: null | TypeAnnotation;
188
- +static: boolean;
189
- +variance: null | Variance;
190
- +declare: boolean;
191
- +optional: null | boolean;
192
- +computed: boolean;
184
+ readonly type: 'ClassProperty';
185
+ readonly key: Expression;
186
+ readonly value: null | Expression;
187
+ readonly typeAnnotation: null | TypeAnnotation;
188
+ readonly static: boolean;
189
+ readonly variance: null | Variance;
190
+ readonly declare: boolean;
191
+ readonly optional: null | boolean;
192
+ readonly computed: boolean;
193
193
  }
194
194
 
195
195
  interface BabelClassPrivateProperty extends BaseNode {
196
- +type: 'ClassPrivateProperty';
197
- +key: BabelPrivateName;
198
- +value: null | Expression;
199
- +typeAnnotation: null | TypeAnnotation;
200
- +static: boolean;
201
- +variance: null | Variance;
196
+ readonly type: 'ClassPrivateProperty';
197
+ readonly key: BabelPrivateName;
198
+ readonly value: null | Expression;
199
+ readonly typeAnnotation: null | TypeAnnotation;
200
+ readonly static: boolean;
201
+ readonly variance: null | Variance;
202
202
  }
203
203
 
204
204
  interface BabelExportNamespaceSpecifier extends BaseNode {
205
- +type: 'ExportNamespaceSpecifier';
206
- +exported: Identifier;
205
+ readonly type: 'ExportNamespaceSpecifier';
206
+ readonly exported: Identifier;
207
207
  }
208
208
 
209
209
  interface BabelExportNamedDeclaration extends BaseNode {
210
- +type: 'ExportNamedDeclaration';
211
- +declaration?: null;
212
- +specifiers: ReadonlyArray<BabelExportNamespaceSpecifier>;
213
- +source?: StringLiteral | null;
214
- +exportKind: 'value' | 'type';
210
+ readonly type: 'ExportNamedDeclaration';
211
+ readonly declaration?: null;
212
+ readonly specifiers: ReadonlyArray<BabelExportNamespaceSpecifier>;
213
+ readonly source?: StringLiteral | null;
214
+ readonly exportKind: 'value' | 'type';
215
215
  }
216
216
 
217
217
  interface BabelPrivateName extends BaseNode {
218
- +type: 'PrivateName';
219
- +id: Identifier;
218
+ readonly type: 'PrivateName';
219
+ readonly id: Identifier;
220
220
  }
221
221
 
222
222
  interface BabelOptionalMemberExpression extends BaseNode {
223
- +type: 'OptionalMemberExpression';
224
- +object:
223
+ readonly type: 'OptionalMemberExpression';
224
+ readonly object:
225
225
  | Expression
226
226
  | Super
227
227
  | BabelOptionalMemberExpression
228
228
  | BabelOptionalCallExpression;
229
- +property: Expression | Identifier | PrivateIdentifier;
230
- +computed: boolean;
231
- +optional: boolean;
229
+ readonly property: Expression | Identifier | PrivateIdentifier;
230
+ readonly computed: boolean;
231
+ readonly optional: boolean;
232
232
  }
233
233
 
234
234
  interface BabelOptionalCallExpression extends BaseNode {
235
- +type: 'OptionalCallExpression';
236
- +callee:
235
+ readonly type: 'OptionalCallExpression';
236
+ readonly callee:
237
237
  | Expression
238
238
  | Super
239
239
  | BabelOptionalMemberExpression
240
240
  | BabelOptionalCallExpression;
241
- +arguments: ReadonlyArray<Expression | SpreadElement>;
242
- +optional: boolean;
243
- +typeArguments?: TypeParameterInstantiation | null;
241
+ readonly arguments: ReadonlyArray<Expression | SpreadElement>;
242
+ readonly optional: boolean;
243
+ readonly typeArguments?: TypeParameterInstantiation | null;
244
244
  }
245
245
 
246
246
  interface BabelStringLiteral extends BaseNode {
247
- +type: 'StringLiteral';
248
- +value: string;
249
- +extra: Readonly<{
250
- +rawValue: string,
251
- +raw: string,
247
+ readonly type: 'StringLiteral';
248
+ readonly value: string;
249
+ readonly extra: Readonly<{
250
+ readonly rawValue: string,
251
+ readonly raw: string,
252
252
  }>;
253
253
  }
254
254
 
255
255
  interface BabelNumericLiteral extends BaseNode {
256
- +type: 'NumericLiteral';
257
- +value: number;
258
- +extra: Readonly<{
259
- +rawValue: number,
260
- +raw: string,
256
+ readonly type: 'NumericLiteral';
257
+ readonly value: number;
258
+ readonly extra: Readonly<{
259
+ readonly rawValue: number,
260
+ readonly raw: string,
261
261
  }>;
262
262
  }
263
263
 
264
264
  interface BabelBigIntLiteral extends BaseNode {
265
- +type: 'BigIntLiteral';
266
- +value: string;
267
- +extra: Readonly<{
268
- +rawValue: string,
269
- +raw: string,
265
+ readonly type: 'BigIntLiteral';
266
+ readonly value: string;
267
+ readonly extra: Readonly<{
268
+ readonly rawValue: string,
269
+ readonly raw: string,
270
270
  }>;
271
271
  }
272
272
 
273
273
  interface BabelBooleanLiteral extends BaseNode {
274
- +type: 'BooleanLiteral';
275
- +value: boolean;
274
+ readonly type: 'BooleanLiteral';
275
+ readonly value: boolean;
276
276
  }
277
277
 
278
278
  interface BabelNullLiteral extends BaseNode {
279
- +type: 'NullLiteral';
279
+ readonly type: 'NullLiteral';
280
280
  }
281
281
 
282
282
  interface BabelRegExpLiteral extends BaseNode {
283
- +type: 'RegExpLiteral';
284
- +extra: Readonly<{
285
- +raw: string,
283
+ readonly type: 'RegExpLiteral';
284
+ readonly extra: Readonly<{
285
+ readonly raw: string,
286
286
  }>;
287
- +pattern: string;
288
- +flags: string;
287
+ readonly pattern: string;
288
+ readonly flags: string;
289
289
  }
290
290
 
291
291
  type BabelLiteral =
@@ -346,7 +346,7 @@ function fixSourceLocation(
346
346
  delete node.parent;
347
347
  }
348
348
 
349
- function mapNodeWithDirectives<T: Program | BlockStatement>(node: T): T {
349
+ function mapNodeWithDirectives<T extends Program | BlockStatement>(node: T): T {
350
350
  // $FlowExpectedError[prop-missing]
351
351
  if (node.directives != null) {
352
352
  return node;
@@ -726,16 +726,16 @@ function calculateSimpleArgument(node: Expression | Super): boolean {
726
726
  * Analyze the match cases and return information we will use to build the result.
727
727
  */
728
728
  type CaseAnalysis<T> = {
729
- +conditions: Array<Condition>,
730
- +bindings: Array<Binding>,
731
- +guard: Expression | null,
732
- +body: T,
729
+ readonly conditions: Array<Condition>,
730
+ readonly bindings: Array<Binding>,
731
+ readonly guard: Expression | null,
732
+ readonly body: T,
733
733
  };
734
734
 
735
735
  interface MatchCase<T> {
736
- +pattern: MatchPattern;
737
- +guard: Expression | null;
738
- +body: T;
736
+ readonly pattern: MatchPattern;
737
+ readonly guard: Expression | null;
738
+ readonly body: T;
739
739
  }
740
740
 
741
741
  function analyzeCases<T>(cases: ReadonlyArray<MatchCase<T>>): {
@@ -158,7 +158,7 @@ export class SimpleTransform {
158
158
  * @return Either the orginal node if the properties matched the existing node or a new node with
159
159
  * the new properties.
160
160
  */
161
- static nodeWith<T: ESNode>(
161
+ static nodeWith<T extends ESNode>(
162
162
  node: T,
163
163
  overrideProps: Partial<T>,
164
164
  visitorKeys?: VisitorKeysType,
@@ -179,7 +179,7 @@ export function updateAllParentPointers(
179
179
  *
180
180
  * This will only create a new object if the overrides actually result in a change.
181
181
  */
182
- export function nodeWith<T: ESNode>(
182
+ export function nodeWith<T extends ESNode>(
183
183
  node: T,
184
184
  overrideProps: Partial<T>,
185
185
  visitorKeys?: ?VisitorKeysType,
@@ -216,7 +216,7 @@ export function nodeWith<T: ESNode>(
216
216
  /**
217
217
  * Shallow clones node, providing a new reference for an existing node.
218
218
  */
219
- export function shallowCloneNode<T: ESNode>(
219
+ export function shallowCloneNode<T extends ESNode>(
220
220
  node: T,
221
221
  visitorKeys?: ?VisitorKeysType,
222
222
  ): T {
@@ -232,7 +232,7 @@ export function shallowCloneNode<T: ESNode>(
232
232
  /**
233
233
  * Deeply clones node and its entire tree.
234
234
  */
235
- export function deepCloneNode<T: ESNode>(
235
+ export function deepCloneNode<T extends ESNode>(
236
236
  node: T,
237
237
  visitorKeys?: ?VisitorKeysType,
238
238
  ): T {
@@ -15,14 +15,14 @@ import type {VisitorKeys as VisitorKeysType} from '../generated/ESTreeVisitorKey
15
15
 
16
16
  import FlowVisitorKeys from '../generated/ESTreeVisitorKeys';
17
17
 
18
- export function isNode(thing: unknown) /*: implies thing is {+[string]: unknown} */ {
18
+ export function isNode(thing: unknown) /*: implies thing is {readonly [string]: unknown} */ {
19
19
  return (
20
20
  typeof thing === 'object' && thing != null && typeof thing.type === 'string'
21
21
  );
22
22
  }
23
23
 
24
24
  export type {VisitorKeysType};
25
- export function getVisitorKeys<T: ESNode>(
25
+ export function getVisitorKeys<T extends ESNode>(
26
26
  node: T,
27
27
  visitorKeys?: ?VisitorKeysType,
28
28
  ) /*: ReadonlyArray<keyof T> */ {
@@ -14,8 +14,8 @@ const genPrefix = '$$gen$';
14
14
 
15
15
  export default class GenID {
16
16
  genN: number = 0;
17
- +used: Set<string> = new Set();
18
- +prefix: string;
17
+ readonly used: Set<string> = new Set();
18
+ readonly prefix: string;
19
19
 
20
20
  constructor(uniqueTransformPrefix: string) {
21
21
  this.prefix = `${genPrefix}${uniqueTransformPrefix}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-parser",
3
- "version": "0.325.0",
3
+ "version": "0.327.0",
4
4
  "description": "JavaScript parser written in OCaml. Produces ESTree AST",
5
5
  "homepage": "https://flow.org",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "test": "node test/run_tests.js"
24
24
  },
25
25
  "dependencies": {
26
- "flow-estree": "0.325.0"
26
+ "flow-estree": "0.327.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/generator": "7.7.4",