Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should all namedTypes let-exports be PredicateTypes? #604

Open
seansfkelley opened this issue Aug 14, 2021 · 0 comments
Open

should all namedTypes let-exports be PredicateTypes? #604

seansfkelley opened this issue Aug 14, 2021 · 0 comments

Comments

@seansfkelley
Copy link

seansfkelley commented Aug 14, 2021

It appears that all the values exported through namedTypes are PredicateTypes

$ _ = require('lodash')
$ astTypes = require('ast-types') // version 0.14.2
$ _.uniq(Object.values(astTypes.namedTypes).map(t => t.kind))
[ 'PredicateType' ]

but all of the let declarations in namedTypes.ts state that they are Types

ast-types/gen/namedTypes.ts

Lines 1617 to 1619 in 53123a2

export let Printable: Type<Printable>;
export let SourceLocation: Type<SourceLocation>;
export let Node: Type<Node>;

and that's specified here

b.identifier("Type"),

and it is of course technically true

ast-types/lib/types.ts

Lines 11 to 16 in 53123a2

export type Type<T> =
| ArrayType<T>
| IdentityType<T>
| ObjectType<T>
| OrType<T>
| PredicateType<T>;

but means that when I use these types through jscodeshift, the compiler gets mad:

j.MemberExpression.name

// Property 'name' does not exist on type 'Type<MemberExpression>'.
//  Property 'name' does not exist on type 'ArrayType<MemberExpression>'

Would it be correct to change the type generator to state that these are all PredicateTypes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant