Fix flow and TS types of babel-types is* type checks to accept null | undefined (#9539)
* babel-types is* type checks accept null | undefiend as value TS type * Use | null | undefined instead of any, make Flow type nullable * Also change flow types of generated src
This commit is contained in:
committed by
Daniel Tschinder
parent
b8d045f5cf
commit
417e72ebfd
@@ -105,7 +105,7 @@ for (const type in t.NODE_FIELDS) {
|
||||
for (let i = 0; i < t.TYPES.length; i++) {
|
||||
let decl = `declare function is${
|
||||
t.TYPES[i]
|
||||
}(node: Object, opts?: ?Object): boolean`;
|
||||
}(node: ?Object, opts?: ?Object): boolean`;
|
||||
|
||||
if (t.NODE_FIELDS[t.TYPES[i]]) {
|
||||
decl += ` %checks (node instanceof ${NODE_PREFIX}${t.TYPES[i]})`;
|
||||
|
||||
@@ -11,7 +11,7 @@ function addIsHelper(type, aliasKeys, deprecated) {
|
||||
" === nodeType";
|
||||
}
|
||||
|
||||
return `export function is${type}(node: Object, opts?: Object): boolean {
|
||||
return `export function is${type}(node: ?Object, opts?: Object): boolean {
|
||||
${deprecated || ""}
|
||||
if (!node) return false;
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ for (const type in t.NODE_FIELDS) {
|
||||
for (let i = 0; i < t.TYPES.length; i++) {
|
||||
let decl = `export function is${
|
||||
t.TYPES[i]
|
||||
}(node: object, opts?: object | null): `;
|
||||
}(node: object | null | undefined, opts?: object | null): `;
|
||||
|
||||
if (t.NODE_FIELDS[t.TYPES[i]]) {
|
||||
decl += `node is ${t.TYPES[i]};`;
|
||||
|
||||
Reference in New Issue
Block a user