flow-remove-types 2.248.1 → 2.249.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.
Files changed (2) hide show
  1. package/index.js +9 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -156,7 +156,6 @@ var removeFlowVisitor = {
156
156
  TypeAnnotation: removeNodeIfNotCommentType,
157
157
  TypePredicate: removeNodeIfNotCommentType,
158
158
  TypeParameterDeclaration: removeNode,
159
- TypeParameterInstantiation: removeNode,
160
159
  InferredPredicate: removeInferredPredicateNode,
161
160
  OpaqueType: removeNode,
162
161
  DeclareOpaqueType: removeNode,
@@ -168,11 +167,7 @@ var removeFlowVisitor = {
168
167
  AsExpression: function (context, node, ast) {
169
168
  var typeIdx = findTokenIndexAtStartOfNode(ast.tokens, node.typeAnnotation);
170
169
  removeNode(context, ast.tokens[typeIdx - 1]); // `as` token
171
- if (node.typeAnnotation.type === 'GenericTypeAnnotation') {
172
- removeNode(context, ast.tokens[typeIdx]);
173
- } else {
174
- removeNode(context, node.typeAnnotation);
175
- }
170
+ removeNode(context, node.typeAnnotation);
176
171
  },
177
172
 
178
173
  AsConstExpression: function (context, node, ast) {
@@ -311,6 +306,13 @@ var removeFlowVisitor = {
311
306
  }
312
307
  }
313
308
  },
309
+
310
+ TypeParameterInstantiation: function (context, node, ast, parent) {
311
+ // prevent interference with asExpression removal
312
+ if (parent.type !== 'GenericTypeAnnotation') {
313
+ removeNode(context, node);
314
+ }
315
+ },
314
316
  };
315
317
 
316
318
  // If this class declaration or expression implements interfaces, remove
@@ -561,7 +563,7 @@ function visit(ast, context, visitor) {
561
563
  if (node && typeof node === 'object' && (node.type || node.length)) {
562
564
  if (node.type) {
563
565
  var visitFn = visitor[node.type];
564
- if (visitFn && visitFn(context, node, ast) === false) {
566
+ if (visitFn && visitFn(context, node, ast, parent) === false) {
565
567
  continue;
566
568
  }
567
569
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-remove-types",
3
- "version": "2.248.1",
3
+ "version": "2.249.0",
4
4
  "description": "Removes Flow type annotations from JavaScript files with speed and simplicity.",
5
5
  "author": {
6
6
  "name": "Flow Team",