facebook / jscodeshift

A JavaScript codemod toolkit.
https://jscodeshift.com
MIT License
9.26k stars 477 forks source link

Find does not traverse ClassDeclarations superTypeParameters #34

Open kyldvs opened 9 years ago

kyldvs commented 9 years ago

When I'm searching for all GenericTypeAnnotationss find does not traverse the generics on a super class that a class extends.

class Foo extends Bar<Baz> {}

It would not find Baz for example, even though it is a GenericTypeAnnotation.

Here's an example that highlights this, http://felix-kling.de/esprima_ast_explorer/#/odivoefENV/16

fkling commented 9 years ago

Since jscodeshift is really a thin wrapper around ast-types / recast, I suspect the issue may be there. Will investigate.

fkling commented 9 years ago

It appears the issue is that ast-types doesn't actually extend the core node types to include type fields.

E.g. the definition for ClassDeclaration does not specify a superTypeParameters field, hence it is not traversed.

I'm happy to add some of them, presumably in def/fb-harmony.js. What do you think @benjamn?