facebook / facebook/jscodeshift

Why can't I specify `typeParameters` to a `CallExpression`?

Open
#330 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
10k
Forks
498
PR merge metrics
No merged PRs in 30d

Description

I can't get the following code to add type parameters to my `CallExpression` in any of the parsers I've tried (flow and babylon7):

```javascript
const myExpression = j.callExpression(
j.identifier('withTheme'),
[j.identifier('Thing')],
j.typeParameterInstantiation([
j.genericTypeAnnotation(j.identifier('Props'), null),
])
);
```

[AST Explorer](https://astexplorer.net/#/gist/c9f1b34d7a46dad1f96c87ef41631754/40ba0271d09ad80d6fa837f65eb5612da3e2bf16)

Forgive me if I've entered this issue in the wrong place, I don't yet really follow how the jscodeshift ecosystem fits together.

[Here](https://github.com/benjamn/ast-types/blob/0b6bc6dec16203076e3a0ffca0157c9215ec14f9/def/flow.ts#L384-L388) it looks like the `callExpression` builder function is being decorated with a third argument for type parameters, but if I just pass junk into that argument there is no type error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.