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:
Ian Craig
2019-02-22 01:48:27 -08:00
committed by Daniel Tschinder
parent b8d045f5cf
commit 417e72ebfd
4 changed files with 303 additions and 270 deletions

View File

@@ -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]})`;

View File

@@ -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;

View File

@@ -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]};`;

File diff suppressed because it is too large Load Diff