|
| 1 | +/* |
| 2 | + * Copyright (c) 2015, Facebook, Inc. |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * This source code is licensed under the BSD-style license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. An additional grant |
| 7 | + * of patent rights can be found in the PATENTS file in the same directory. |
| 8 | + * |
| 9 | + */ |
| 10 | + |
| 11 | +import type Documentation from './Documentation'; |
| 12 | + |
| 13 | +export type PropTypeDescriptor = { |
| 14 | + name: |
| 15 | + | 'arrayOf' |
| 16 | + | 'custom' |
| 17 | + | 'enum' |
| 18 | + | 'array' |
| 19 | + | 'bool' |
| 20 | + | 'func' |
| 21 | + | 'number' |
| 22 | + | 'object' |
| 23 | + | 'string' |
| 24 | + | 'any' |
| 25 | + | 'element' |
| 26 | + | 'node' |
| 27 | + | 'symbol' |
| 28 | + | 'objectOf' |
| 29 | + | 'shape' |
| 30 | + | 'union', |
| 31 | + value?: any, |
| 32 | + raw?: string, |
| 33 | + computed?: boolean, |
| 34 | + // These are only needed for shape types. |
| 35 | + // Consider consolidating PropTypeDescriptor and PropDescriptor |
| 36 | + description?: string, |
| 37 | + required?: boolean, |
| 38 | +}; |
| 39 | + |
| 40 | +export type FlowBaseType = { |
| 41 | + required?: boolean, |
| 42 | + nullable?: boolean, |
| 43 | + alias?: string, |
| 44 | +}; |
| 45 | + |
| 46 | +export type FlowSimpleType = FlowBaseType & {| |
| 47 | + name: string, |
| 48 | + raw?: string, |
| 49 | +|}; |
| 50 | + |
| 51 | +export type FlowLiteralType = FlowBaseType & { |
| 52 | + name: 'literal', |
| 53 | + value: string, |
| 54 | +}; |
| 55 | + |
| 56 | +export type FlowElementsType = FlowBaseType & { |
| 57 | + name: string, |
| 58 | + raw: string, |
| 59 | + elements: Array<FlowTypeDescriptor>, |
| 60 | +}; |
| 61 | + |
| 62 | +export type FlowFunctionSignatureType = FlowBaseType & { |
| 63 | + name: 'signature', |
| 64 | + type: 'function', |
| 65 | + raw: string, |
| 66 | + signature: { |
| 67 | + arguments: Array<{ name: string, type: FlowTypeDescriptor }>, |
| 68 | + return: FlowTypeDescriptor, |
| 69 | + }, |
| 70 | +}; |
| 71 | + |
| 72 | +export type FlowObjectSignatureType = FlowBaseType & { |
| 73 | + name: 'signature', |
| 74 | + type: 'object', |
| 75 | + raw: string, |
| 76 | + signature: { |
| 77 | + properties: Array<{ |
| 78 | + key: string | FlowTypeDescriptor, |
| 79 | + value: FlowTypeDescriptor, |
| 80 | + }>, |
| 81 | + constructor?: FlowTypeDescriptor, |
| 82 | + }, |
| 83 | +}; |
| 84 | + |
| 85 | +export type FlowTypeDescriptor = |
| 86 | + | FlowSimpleType |
| 87 | + | FlowLiteralType |
| 88 | + | FlowElementsType |
| 89 | + | FlowFunctionSignatureType |
| 90 | + | FlowObjectSignatureType; |
| 91 | + |
| 92 | +export type PropDescriptor = { |
| 93 | + type?: PropTypeDescriptor, |
| 94 | + flowType?: FlowTypeDescriptor, |
| 95 | + required?: boolean, |
| 96 | + defaultValue?: any, |
| 97 | + description?: string, |
| 98 | +}; |
| 99 | + |
| 100 | +export type Handler = (documentation: Documentation, path: NodePath) => void; |
| 101 | +export type Resolver = ( |
| 102 | + node: ASTNode, |
| 103 | + recast: Recast, |
| 104 | +) => ?NodePath | ?Array<NodePath>; |
0 commit comments