TypeScript definitions for babel-types is* checks should accept any type, not just object #9538
Labels
i: bug
i: needs triage
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
Bug Report
Current Behavior
Let's use
t.isIdentifier
as an example.Current definition generated in
packages\babel-types\lib\index.d.ts
:Input Code
Expected behavior/code
This code runs perfectly fine, and if
func.id === 'foo'
the// Do something
will be called.However, in TypeScript with
strictNullChecks
you get a type error on compile becausefunc.id
has typeIdentifier | null | undefined
, and the argument type isobject
which does not acceptnull | undefined
.In actual fact, all the
is*
validate the value passed to it properly, so there is no need to restrict the type.Babel Configuration (.babelrc, package.json, cli command)
N/A
Environment
Possible Solution
Change from
object
toany
type for value of allis*
type declarationsI'm happy to submit a PR, should be a very small isolated fix.
The text was updated successfully, but these errors were encountered: