Upgrading @babel/types to 7.10.0+ breaks typings. For example:
function foo(path: NodePath) {
if (nodePath.isMemberExpression()) {
// nodePath used to be of type "NodePath<MemberExpression>" here.
// But now is "NodePath<Node> & NodePath<MemberExpression>".
// As a result, obj has a loose type: "NodePath<Node> | NodePath<Node>[]"
// Used to be "NodePath<Expression>".
const obj = path.get('object');
// And then this breaks:
obj.isIdentifier();
}
}
Hard to figure out a proper fix and understand why this happens. The only workaround I found so far is too cumbersome to be acceptable:
function foo(path: NodePath) {
if (nodePath.isMemberExpression()) {
const obj = (path as NodePath<MemberExpression>).get('object');
// now obj has expected type, we can do:
obj.isIdentifier();
}
}
Another problem:
function foo(path: NodePath<Node>) {}
function bar(expr: NodePath<CallExpression>) {
// fails here
// ↓↓↓↓
foo(expr);
}
Now fails with the following error:
Argument of type 'NodePath<CallExpression>' is not assignable to parameter of type 'NodePath<Node>'.
Type 'Node' is not assignable to type 'CallExpression'.
Type 'AnyTypeAnnotation' is missing the following properties from type 'CallExpression': callee, arguments, optional, typeArguments, typeParametersts(2345)
Waiting for a proper fix, #170 pinned @babel/types to the latest version that works: 7.9.6. Starting at 7.10.0 the breaking change occurs :man_shrugging: .
How to reproduce
remove yarn.lock and node_modules
upgrade all the dependencies
yarn run types
Expected behavior
Types should be strong and not break.
What actually happens
Lot of typing errors, mostly related to the aforementioned issue. For example:
src/extractors/withTranslationHOC.ts:293:62 - error TS2345: Argument of type 'NodePath<Node> | NodePath<Node>[]' is not assignable to parameter of type 'NodePath<Node>'.
Type 'NodePath<Node>[]' is not assignable to type 'NodePath<Node>'.
293 result.push(...findTFunctionCallsFromPropsAssignment(id));
~~
Describe the bug
Upgrading @babel/types to 7.10.0+ breaks typings. For example:
Hard to figure out a proper fix and understand why this happens. The only workaround I found so far is too cumbersome to be acceptable:
Another problem:
Now fails with the following error:
Waiting for a proper fix, #170 pinned
@babel/types
to the latest version that works: 7.9.6. Starting at 7.10.0 the breaking change occurs :man_shrugging: .How to reproduce
yarn.lock
andnode_modules
yarn run types
Expected behavior
Types should be strong and not break.
What actually happens
Lot of typing errors, mostly related to the aforementioned issue. For example:
Your environment
irrelevant
Additional context
None