benjamn / benjamn/ast-types

should all `namedTypes` `let`-exports be `PredicateType`s?

Open
#604 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

It appears that all the values exported through `namedTypes` are `PredicateType`s

```
$ _ = 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 `Type`s

https://github.com/benjamn/ast-types/blob/53123a2be5e03e9b58d72e5e16503cb42628a8eb/gen/namedTypes.ts#L1617-L1619

and that's specified here

https://github.com/benjamn/ast-types/blob/53123a2be5e03e9b58d72e5e16503cb42628a8eb/script/gen-types.ts#L149

and it is of course technically true

https://github.com/benjamn/ast-types/blob/53123a2be5e03e9b58d72e5e16503cb42628a8eb/lib/types.ts#L11-L16

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'.
// Property 'name' does not exist on type 'ArrayType'
```

Would it be correct to change the type generator to state that these are all `PredicateType`s?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.