Generate types with %checks annotations.

This commit is contained in:
Logan Smyth
2017-10-11 23:06:41 -04:00
parent e6beb7cb61
commit ad05c9935e
2 changed files with 250 additions and 244 deletions

View File

@@ -124,9 +124,15 @@ for (const type in t.NODE_FIELDS) {
}
for (let i = 0; i < t.TYPES.length; i++) {
lines.push(
`declare function is${t.TYPES[i]}(node: Object, opts?: Object): boolean;`
);
let decl = `declare function is${t.TYPES[
i
]}(node: Object, opts?: ?Object): boolean`;
if (t.NODE_FIELDS[t.TYPES[i]]) {
decl += ` %checks (node instanceof ${NODE_PREFIX}${t.TYPES[i]})`;
}
lines.push(decl);
}
lines.push(