From 6be4ccc88efd5976fd31bad1bec07d304b6f27c5 Mon Sep 17 00:00:00 2001 From: Matt Forster Date: Fri, 6 Sep 2019 12:54:03 -0600 Subject: [PATCH 1/2] fix(types): correct typescript function headers Flow maybe types state; > Maybe types accept the provided type as well as null or undefined. So ?number would mean number, null, or undefined. So in this case, explicitly allow the type, null, or undefined in the typescript definition. Fixes #10403 --- packages/babel-types/scripts/generators/typescript.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/babel-types/scripts/generators/typescript.js b/packages/babel-types/scripts/generators/typescript.js index 35696923e1ae..3bc269b0340c 100644 --- a/packages/babel-types/scripts/generators/typescript.js +++ b/packages/babel-types/scripts/generators/typescript.js @@ -153,13 +153,13 @@ lines.push( `export function isBlockScoped(node: Node): boolean`, `export function isImmutable(node: Node): boolean`, `export function isLet(node: Node): boolean`, - `export function isNode(node: ?object): boolean`, + `export function isNode(node: object | null | undefined): boolean`, `export function isNodesEquivalent(a: any, b: any): boolean`, - `export function isPlaceholderType(placeholderType: ?string, targetType: string): boolean`, + `export function isPlaceholderType(placeholderType: string | null | undefined, targetType: string): boolean`, `export function isReferenced(node: Node, parent: Node, grandparent?: Node): boolean`, `export function isScope(node: Node, parent: Node): boolean`, `export function isSpecifierDefault(specifier: ModuleSpecifier): boolean`, - `export function isType(nodetype: ?string, targetType: string): boolean`, + `export function isType(nodetype: string | null | undefined, targetType: string): boolean`, `export function isValidES3Identifier(name: string): boolean`, `export function isValidES3Identifier(name: string): boolean`, `export function isValidIdentifier(name: string): boolean`, From e72d9b151c3ef3e65df8fbb0cd35c3475e6dffd0 Mon Sep 17 00:00:00 2001 From: Matt Forster Date: Fri, 6 Sep 2019 13:19:24 -0600 Subject: [PATCH 2/2] chore(types): disable eslint on function definition precedent found on L149 --- packages/babel-types/scripts/generators/typescript.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/babel-types/scripts/generators/typescript.js b/packages/babel-types/scripts/generators/typescript.js index 3bc269b0340c..ca6d609bdd9b 100644 --- a/packages/babel-types/scripts/generators/typescript.js +++ b/packages/babel-types/scripts/generators/typescript.js @@ -155,6 +155,7 @@ lines.push( `export function isLet(node: Node): boolean`, `export function isNode(node: object | null | undefined): boolean`, `export function isNodesEquivalent(a: any, b: any): boolean`, + // eslint-disable-next-line `export function isPlaceholderType(placeholderType: string | null | undefined, targetType: string): boolean`, `export function isReferenced(node: Node, parent: Node, grandparent?: Node): boolean`, `export function isScope(node: Node, parent: Node): boolean`,