Skip to content

Commit

Permalink
fix(types): correct typescript function headers (#10404)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matt-forster authored and nicolo-ribaudo committed Sep 6, 2019
1 parent fc8e142 commit 15b63bc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/babel-types/scripts/generators/flow.js
Expand Up @@ -146,7 +146,7 @@ lines.push(
`declare function isLet(node: BabelNode): boolean`,
`declare function isNode(node: ?Object): boolean`,
`declare function isNodesEquivalent(a: any, b: any): boolean`,
`declare function isPlaceholderType(placeholderType: ?string, targetType: string): boolean`,
`declare function isPlaceholderType(placeholderType: string, targetType: string): boolean`,
`declare function isReferenced(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
`declare function isScope(node: BabelNode, parent: BabelNode): boolean`,
`declare function isSpecifierDefault(specifier: BabelNodeModuleSpecifier): boolean`,
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-types/scripts/generators/typescript.js
Expand Up @@ -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, 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`,
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-types/src/validators/isPlaceholderType.js
Expand Up @@ -5,7 +5,7 @@ import { PLACEHOLDERS_ALIAS } from "../definitions";
* Test if a `placeholderType` is a `targetType` or if `targetType` is an alias of `placeholderType`.
*/
export default function isPlaceholderType(
placeholderType: ?string,
placeholderType: string,
targetType: string,
): boolean {
if (placeholderType === targetType) return true;
Expand Down

0 comments on commit 15b63bc

Please sign in to comment.