diff --git a/cli/src/commands/__tests__/runTests-test.js b/cli/src/commands/__tests__/runTests-test.js index b58db78177..5a49b0917b 100644 --- a/cli/src/commands/__tests__/runTests-test.js +++ b/cli/src/commands/__tests__/runTests-test.js @@ -26,7 +26,7 @@ describe('run-tests (command)', () => { it('console logs about unused suppression', async () => { const expectedError = `Unused suppression`; - const calls = ((console.log: any): JestMockFn<*, *>).mock.calls; + const calls = ((console.log: any): JestMockFn).mock.calls; const lastErrorMsg = calls[calls.length - 1][1]; expect(lastErrorMsg).toContain(expectedError); }); diff --git a/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-/react-components_v3.x.x.js b/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-v.200.x/react-components_v3.x.x.js similarity index 100% rename from definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-/react-components_v3.x.x.js rename to definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-v.200.x/react-components_v3.x.x.js diff --git a/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-/test_react-components_v3.x.x.js b/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-v.200.x/test_react-components_v3.x.x.js similarity index 100% rename from definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-/test_react-components_v3.x.x.js rename to definitions/npm/@apollo/react-components_v3.x.x/flow_v0.104.x-v.200.x/test_react-components_v3.x.x.js diff --git a/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.201.x-/react-components_v3.x.x.js b/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.201.x-/react-components_v3.x.x.js new file mode 100644 index 0000000000..bbd729967d --- /dev/null +++ b/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.201.x-/react-components_v3.x.x.js @@ -0,0 +1,1050 @@ +declare module '@apollo/react-components' { + import type { ComponentType, Element, Node } from 'react'; + + declare export type MakeOptional = (V) => ?V; + declare export type MakeDataOptional = $ObjMap< + TData, + MakeOptional + > | void; + + declare export type Record = { + [key: T]: U, + ..., + }; + + declare export type Dict = Record; + /** + * Copied types from Apollo Client libdef + * Please update apollo-client libdef as well if updating these types + */ + declare class ObservableQuery< + T, + V = { [key: string]: any, ... } + > extends Observable> { + options: WatchQueryOptions; + queryId: string; + variables: V; + isCurrentlyPolling: boolean; + shouldSubscribe: boolean; + isTornDown: boolean; + scheduler: QueryScheduler; + queryManager: QueryManager; + observers: Observer>[]; + subscriptionHandles: SubscriptionLINK[]; + lastResult: ApolloQueryResult; + lastError: ApolloError; + lastVariables: V; + + constructor(data: { + scheduler: QueryScheduler, + options: WatchQueryOptions, + shouldSubscribe?: boolean, + ... + }): this; + result(): Promise>; + currentResult(): ApolloCurrentResult; + getLastResult(): ApolloQueryResult; + getLastError(): ApolloError; + resetLastResults(): void; + refetch(variables?: V): Promise>; + fetchMore( + fetchMoreOptions: FetchMoreQueryOptions & FetchMoreOptions + ): Promise>; + subscribeToMore(options: SubscribeToMoreOptions): () => void; + setOptions( + opts: ModifiableWatchQueryOptions + ): Promise>; + setVariables( + variables: V, + tryFetch?: boolean, + fetchResults?: boolean + ): Promise>; + updateQuery( + mapFn: (previousQueryResult: any, options: UpdateQueryOptions) => mixed + ): void; + stopPolling(): void; + startPolling(pollInterval: number): void; + } + + declare class QueryManager { + scheduler: QueryScheduler; + link: ApolloLink; + mutationStore: MutationStore; + queryStore: QueryStore; + dataStore: DataStore; + + constructor({ + link: ApolloLink, + queryDeduplication?: boolean, + store: DataStore, + onBroadcast?: () => mixed, + ssrMode?: boolean, + ... + }): this; + + mutate(options: MutationOptions<>): Promise>; + fetchQuery( + queryId: string, + options: WatchQueryOptions, + fetchType?: FetchType, + fetchMoreForQueryId?: string + ): Promise>; + queryListenerForObserver( + queryId: string, + options: WatchQueryOptions, + observer: Observer> + ): QueryListener; + watchQuery( + options: WatchQueryOptions, + shouldSubscribe?: boolean + ): ObservableQuery; + query(options: WatchQueryOptions): Promise>; + generateQueryId(): string; + stopQueryInStore(queryId: string): void; + addQueryListener(queryId: string, listener: QueryListener): void; + updateQueryWatch( + queryId: string, + document: DocumentNode, + options: WatchQueryOptions + ): void; + addFetchQueryPromise( + requestId: number, + promise: Promise>, + resolve: (result: ApolloQueryResult) => void, + reject: (error: Error) => void + ): void; + removeFetchQueryPromise(requestId: number): void; + addObservableQuery( + queryId: string, + observableQuery: ObservableQuery + ): void; + removeObservableQuery(queryId: string): void; + clearStore(): Promise; + resetStore(): Promise[]>; + } + + declare class QueryStore { + getStore(): { [queryId: string]: QueryStoreValue, ... }; + get(queryId: string): QueryStoreValue; + initQuery(query: { + queryId: string, + document: DocumentNode, + storePreviousVariables: boolean, + variables: any, + isPoll: boolean, + isRefetch: boolean, + metadata: any, + fetchMoreForQueryId: string | void, + ... + }): void; + markQueryResult( + queryId: string, + result: ExecutionResult<>, + fetchMoreForQueryId: string | void + ): void; + markQueryError( + queryId: string, + error: Error, + fetchMoreForQueryId: string | void + ): void; + markQueryResultClient(queryId: string, complete: boolean): void; + stopQuery(queryId: string): void; + reset(observableQueryIds: string[]): void; + } + + declare class QueryScheduler { + inFlightQueries: { [queryId: string]: WatchQueryOptions, ... }; + registeredQueries: { [queryId: string]: WatchQueryOptions, ... }; + intervalQueries: { [interval: number]: string[], ... }; + queryManager: QueryManager; + constructor({ + queryManager: QueryManager, + ssrMode?: boolean, + ... + }): this; + checkInFlight(queryId: string): ?boolean; + fetchQuery( + queryId: string, + options: WatchQueryOptions, + fetchType: FetchType + ): Promise>; + startPollingQuery( + options: WatchQueryOptions, + queryId: string, + listener?: QueryListener + ): string; + stopPollingQuery(queryId: string): void; + fetchQueriesOnInterval(interval: number): void; + addQueryOnInterval( + queryId: string, + queryOptions: WatchQueryOptions + ): void; + registerPollingQuery( + queryOptions: WatchQueryOptions + ): ObservableQuery; + markMutationError(mutationId: string, error: Error): void; + reset(): void; + } + + declare class DataStore { + constructor(initialCache: ApolloCache): this; + getCache(): ApolloCache; + markQueryResult( + result: ExecutionResult<>, + document: DocumentNode, + variables: any, + fetchMoreForQueryId: string | void, + ignoreErrors?: boolean + ): void; + markSubscriptionResult( + result: ExecutionResult<>, + document: DocumentNode, + variables: any + ): void; + markMutationInit(mutation: { + mutationId: string, + document: DocumentNode, + variables: any, + updateQueries: { [queryId: string]: QueryWithUpdater, ... }, + update: ((proxy: DataProxy, mutationResult: any) => mixed) | void, + optimisticResponse: Dict, + ... + }): void; + markMutationResult(mutation: { + mutationId: string, + result: ExecutionResult<>, + document: DocumentNode, + variables: any, + updateQueries: { [queryId: string]: QueryWithUpdater, ... }, + update: ((proxy: DataProxy, mutationResult: any) => mixed) | void, + ... + }): void; + markMutationComplete({ + mutationId: string, + optimisticResponse?: Dict, + ... + }): void; + markUpdateQueryResult( + document: DocumentNode, + variables: any, + newResult: any + ): void; + reset(): Promise; + } + + declare export type QueryWithUpdater = { + updater: MutationQueryReducer, + query: QueryStoreValue, + ... + }; + + declare export interface MutationStoreValue { + mutationString: string; + variables: any; + loading: boolean; + error: Error | null; + } + + declare class MutationStore { + getStore(): { [mutationId: string]: MutationStoreValue, ... }; + get(mutationId: string): MutationStoreValue; + initMutation( + mutationId: string, + mutationString: string, + variables: any + ): void; + } + + declare export interface FetchMoreOptions { + updateQuery: ( + previousQueryResult: TData, + options: { + fetchMoreResult?: TData, + variables: TVariables, + ... + } + ) => TData; + } + + declare export interface UpdateQueryOptions { + variables?: any; + } + + declare export type ApolloCurrentResult = { + data: T | { ... }, + errors?: Array, + loading: boolean, + networkStatus: NetworkStatus, + error?: ApolloError, + partial?: boolean, + ... + }; + + declare export interface ModifiableWatchQueryOptions { + variables?: Dict; + pollInterval?: number; + fetchPolicy?: FetchPolicy; + errorPolicy?: ErrorPolicy; + fetchResults?: boolean; + notifyOnNetworkStatusChange?: boolean; + } + + declare export interface WatchQueryOptions + extends ModifiableWatchQueryOptions { + query: DocumentNode; + metadata?: any; + context?: any; + } + + declare export type RefetchQueryDescription = $ReadOnlyArray< + string | PureQueryOptions + >; + + declare export interface MutationBaseOptions { + optimisticResponse?: Dict; + updateQueries?: MutationQueryReducersMap; + refetchQueries?: + | ((result: ExecutionResult<>) => RefetchQueryDescription) + | RefetchQueryDescription; + update?: MutationUpdaterFn; + errorPolicy?: ErrorPolicy; + variables?: any; + } + + declare export interface MutationOptions + extends MutationBaseOptions { + mutation: DocumentNode; + context?: any; + fetchPolicy?: FetchPolicy; + } + + declare export interface SubscriptionOptions { + query: DocumentNode; + variables?: Dict; + } + + declare export type FetchPolicy = + | 'cache-first' + | 'cache-and-network' + | 'network-only' + | 'cache-only' + | 'no-cache' + | 'standby'; + + declare export type ErrorPolicy = 'none' | 'ignore' | 'all'; + + declare export interface FetchMoreQueryOptions { + variables: $Shape; + } + + declare export type SubscribeToMoreOptions< + TData, + TSubscriptionData, + TSubscriptionVariables = void + > = { + document?: DocumentNode, + variables?: TSubscriptionVariables, + updateQuery?: ( + previousResult: TData, + result: { + subscriptionData: { data?: TSubscriptionData, ... }, + variables: TSubscriptionVariables, + ... + } + ) => TData, + onError?: (error: Error) => mixed, + ... + }; + + declare export type MutationUpdaterFn = ( + proxy: DataProxy, + mutationResult: FetchResult + ) => mixed; + + declare export type NetworkStatus = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; + + declare export type QueryListener = ( + queryStoreValue: QueryStoreValue, + newData?: any + ) => mixed; + + declare export type QueryStoreValue = { + document: DocumentNode, + variables: any, + previousVariables: any, + networkStatus: NetworkStatus, + networkError: Error | null, + graphQLErrors: GraphQLError[], + metadata: any, + ... + }; + + declare export type PureQueryOptions = { + query: DocumentNode, + variables?: Dict, + ... + }; + + declare export type ApolloQueryResult = { + data: T, + errors?: Array, + loading: boolean, + networkStatus: NetworkStatus, + stale: boolean, + ... + }; + + declare export type FetchType = 1 | 2 | 3; + + declare export type MutationQueryReducer = ( + previousResult: Dict, + options: { + mutationResult: FetchResult, + queryName: string | void, + queryVariables: Dict, + ... + } + ) => Dict; + + declare export type MutationQueryReducersMap = { + [queryName: string]: MutationQueryReducer, + ..., + }; + + declare class $ApolloError extends Error { + message: string; + graphQLErrors: Array; + networkError: Error | null; + extraInfo: any; + constructor(info: ErrorConstructor): this; + } + declare export type ApolloError = $ApolloError; + + declare export interface ErrorConstructor { + graphQLErrors?: Array; + networkError?: Error | null; + errorMessage?: string; + extraInfo?: any; + } + + declare export interface DefaultOptions { + +watchQuery?: ModifiableWatchQueryOptions; + +query?: ModifiableWatchQueryOptions; + +mutate?: MutationBaseOptions<>; + } + + declare export type ApolloClientOptions = { + link: ApolloLink, + cache: ApolloCache, + ssrMode?: boolean, + ssrForceFetchDelay?: number, + connectToDevTools?: boolean, + queryDeduplication?: boolean, + defaultOptions?: DefaultOptions, + ... + }; + + declare export class ApolloClient { + link: ApolloLink; + store: DataStore; + cache: ApolloCache; + queryManager: QueryManager; + disableNetworkFetches: boolean; + version: string; + queryDeduplication: boolean; + defaultOptions: DefaultOptions; + devToolsHookCb: any; + proxy: ApolloCache | void; + ssrMode: boolean; + resetStoreCallbacks: Array<() => Promise>; + + constructor(options: ApolloClientOptions): this; + watchQuery(options: WatchQueryOptions): ObservableQuery; + query(options: WatchQueryOptions): Promise>; + mutate(options: MutationOptions): Promise>; + subscribe(options: SubscriptionOptions): Observable; + readQuery(options: DataProxyReadQueryOptions): T | null; + readFragment(options: DataProxyReadFragmentOptions): T | null; + writeQuery(options: DataProxyWriteQueryOptions): void; + writeFragment(options: DataProxyWriteFragmentOptions): void; + writeData(options: DataProxyWriteDataOptions): void; + __actionHookForDevTools(cb: () => mixed): void; + __requestRaw(payload: GraphQLRequest): Observable>; + initQueryManager(): void; + clearStore(): Promise; + resetStore(): Promise> | null>; + onResetStore(cb: () => Promise): () => void; + reFetchObservableQueries( + includeStandby?: boolean + ): Promise[]> | Promise; + extract(optimistic?: boolean): TCacheShape; + restore(serializedState: TCacheShape): ApolloCache; + } + + /* apollo-link types */ + declare class ApolloLink { + constructor(request?: RequestHandler): this; + + static empty(): ApolloLink; + static from(links: Array): ApolloLink; + static split( + test: (op: Operation) => boolean, + left: ApolloLink | RequestHandler, + right: ApolloLink | RequestHandler + ): ApolloLink; + static execute( + link: ApolloLink, + operation: GraphQLRequest + ): Observable>; + + split( + test: (op: Operation) => boolean, + left: ApolloLink | RequestHandler, + right: ApolloLink | RequestHandler + ): ApolloLink; + + concat(next: ApolloLink | RequestHandler): ApolloLink; + + request( + operation: Operation, + forward?: NextLink + ): Observable> | null; + } + + declare export interface GraphQLRequest { + query: DocumentNode; + variables?: Dict; + operationName?: string; + context?: Dict; + extensions?: Dict; + } + + declare export interface Operation { + query: DocumentNode; + variables: Dict; + operationName: string; + extensions: Dict; + setContext: (context: Dict) => Dict; + getContext: () => Dict; + toKey: () => string; + } + + declare export type FetchResult = ExecutionResult & { + extension?: E, + context?: C, + ... + }; + + declare export type NextLink = ( + operation: Operation + ) => Observable>; + + declare export type RequestHandler = ( + operation: Operation, + forward?: NextLink + ) => Observable> | null; + + declare class Observable { + subscribe( + observerOrNext: ((value: T) => mixed) | ZenObservableObserver, + error?: (error: any) => mixed, + complete?: () => mixed + ): ZenObservableSubscription; + + forEach(fn: (value: T) => mixed): Promise; + + map(fn: (value: T) => R): Observable; + + filter(fn: (value: T) => boolean): Observable; + + reduce( + fn: (previousValue: R | T, currentValue: T) => R | T, + initialValue?: R | T + ): Observable; + + flatMap(fn: (value: T) => ZenObservableObservableLike): Observable; + + from( + observable: Observable | ZenObservableObservableLike | Array + ): Observable; + + of(...args: Array): Observable; + } + + declare export interface Observer { + start?: (subscription: SubscriptionLINK) => any; + next?: (value: T) => void; + error?: (errorValue: any) => void; + complete?: () => void; + } + + declare export interface SubscriptionLINK { + closed: boolean; + unsubscribe(): void; + } + + declare export interface ZenObservableSubscriptionObserver { + closed: boolean; + next(value: T): void; + error(errorValue: any): void; + complete(): void; + } + + declare export interface ZenObservableSubscription { + closed: boolean; + unsubscribe(): void; + } + + declare export interface ZenObservableObserver { + start?: (subscription: ZenObservableSubscription) => mixed; + next?: (value: T) => mixed; + error?: (errorValue: any) => mixed; + complete?: () => mixed; + } + + declare export type ZenObservableSubscriber = ( + observer: ZenObservableSubscriptionObserver + ) => mixed | (() => mixed) | SubscriptionLINK; + + declare export interface ZenObservableObservableLike { + subscribe?: ZenObservableSubscriber; + } + /* apollo-link types */ + + /* apollo-cache types */ + declare class ApolloCache { + read(query: CacheReadOptions): T | null; + write(write: CacheWriteOptions): void; + diff(query: CacheDiffOptions): CacheDiffResult; + watch(watch: CacheWatchOptions): () => void; + evict(query: CacheEvictOptions): CacheEvictionResult; + reset(): Promise; + + restore(serializedState: TSerialized): ApolloCache; + extract(optimistic?: boolean): TSerialized; + + removeOptimistic(id: string): void; + + performTransaction(transaction: Transaction): void; + recordOptimisticTransaction( + transaction: Transaction, + id: string + ): void; + + transformDocument(document: DocumentNode): DocumentNode; + transformForLink(document: DocumentNode): DocumentNode; + + readQuery( + options: DataProxyReadQueryOptions, + optimistic?: boolean + ): QueryType | null; + readFragment( + options: DataProxyReadFragmentOptions, + optimistic?: boolean + ): FragmentType | null; + writeQuery(options: CacheWriteQueryOptions): void; + writeFragment(options: CacheWriteFragmentOptions): void; + writeData(options: CacheWriteDataOptions): void; + } + + declare export type Transaction = (c: ApolloCache) => mixed; + + declare export type CacheWatchCallback = (newData: any) => mixed; + + declare export interface CacheEvictionResult { + success: boolean; + } + + declare export interface CacheReadOptions extends DataProxyReadQueryOptions { + rootId?: string; + previousResult?: any; + optimistic: boolean; + } + + declare export interface CacheWriteOptions extends DataProxyReadQueryOptions { + dataId: string; + result: any; + } + + declare export interface CacheDiffOptions extends CacheReadOptions { + returnPartialData?: boolean; + } + + declare export interface CacheWatchOptions extends CacheReadOptions { + callback: CacheWatchCallback; + } + + declare export interface CacheEvictOptions extends DataProxyReadQueryOptions { + rootId?: string; + } + + declare export type CacheDiffResult = DataProxyDiffResult; + declare export type CacheWriteQueryOptions = DataProxyWriteQueryOptions; + declare export type CacheWriteFragmentOptions = DataProxyWriteFragmentOptions; + declare export type CacheWriteDataOptions = DataProxyWriteDataOptions; + + declare export interface DataProxyReadQueryOptions { + query: DocumentNode; + variables?: any; + } + + declare export interface DataProxyReadFragmentOptions { + id: string; + fragment: DocumentNode; + fragmentName?: string; + variables?: any; + } + + declare export interface DataProxyWriteQueryOptions { + data: any; + query: DocumentNode; + variables?: any; + } + + declare export interface DataProxyWriteFragmentOptions { + data: any; + id: string; + fragment: DocumentNode; + fragmentName?: string; + variables?: any; + } + + declare export interface DataProxyWriteDataOptions { + data: any; + id?: string; + } + + declare export type DataProxyDiffResult = { + result?: T, + complete?: boolean, + ... + }; + + declare export interface DataProxy { + readQuery( + options: DataProxyReadQueryOptions, + optimistic?: boolean + ): QueryType | null; + readFragment( + options: DataProxyReadFragmentOptions, + optimistic?: boolean + ): FragmentType | null; + writeQuery(options: DataProxyWriteQueryOptions): void; + writeFragment(options: DataProxyWriteFragmentOptions): void; + writeData(options: DataProxyWriteDataOptions): void; + } + /* End apollo-cache types */ + + /** End from Apollo Client */ + + /** + * Types From graphql + * graphql types are maintained in the graphql-js repo + */ + declare export type DocumentNode = any; + declare export type ExecutionResult = { + data?: T, + extensions?: { [string]: any, ... }, + errors?: any[], + ... + }; + declare export type GraphQLError = any; + declare export type VariableDefinitionNode = any; + /** End From graphql */ + + declare export interface ApolloProviderProps { + client: any; // ApolloClient; + children: Node; + } + + declare export interface ApolloConsumerProps { + children: (client: ApolloClient) => Node; + } + + declare export class ApolloConsumer extends React$Component {} + + declare export class ApolloProvider extends React$Component< + ApolloProviderProps + > { + childContextTypes: { + client: ApolloClient, + operations: Map< + string, + { + query: DocumentNode, + variables: any, + ... + } + >, + ... + }; + + getChildContext(): { + client: ApolloClient, + operations: Map< + string, + { + query: DocumentNode, + variables: any, + ... + } + >, + ... + }; + } + + declare export type MutationFunc = ( + opts: MutationOpts + ) => Promise>; + + declare export type GraphqlData = TResult & + GraphqlQueryControls & { + variables: TVariables, + refetch: (variables?: TVariables) => Promise>, + ... + }; + + declare export type ChildProps = { + data: GraphqlData, + mutate: MutationFunc, + ... + } & TOwnProps; + + declare export type RefetchQueriesProviderFn = ( + ...args: any[] + ) => RefetchQueryDescription; + + declare export type MutationOpts = {| + variables?: TVariables, + optimisticResponse?: Dict, + refetchQueries?: RefetchQueryDescription | RefetchQueriesProviderFn, + update?: MutationUpdaterFn, + errorPolicy?: ErrorPolicy, + |}; + + declare export type QueryOpts = {| + ssr?: boolean, + variables?: TVariables, + fetchPolicy?: FetchPolicy, + pollInterval?: number, + skip?: boolean, + errorPolicy?: ErrorPolicy, + context?: Dict, + |}; + + declare export interface GraphqlQueryControls< + TGraphQLVariables = OperationVariables + > { + error?: ApolloError | any; // Added optional `any` to satisfy Flow < 0.62 + networkStatus: NetworkStatus; + loading: boolean; + variables: TGraphQLVariables; + fetchMore: ( + fetchMoreOptions: FetchMoreQueryOptions & + FetchMoreOptions + ) => Promise>; + refetch: (variables?: TGraphQLVariables) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: ( + mapFn: (previousQueryResult: any, options: UpdateQueryOptions) => mixed + ) => void; + } + + declare export interface OptionProps { + ownProps: TProps; + data?: GraphqlData; + mutate: MutationFunc; + } + + declare export type OptionDescription = + | QueryOpts + | MutationOpts + | ((props: TProps) => QueryOpts | MutationOpts); + + declare export type NamedProps = P & { ownProps: R, ... }; + + declare export interface OperationOption< + TResult: { ... }, + TProps: { ... }, + TChildProps: { ... }, + TVariables: { ... } + > { + +options?: OptionDescription; + props?: ( + props: OptionProps + ) => TChildProps | ChildProps; + +skip?: boolean | ((props: any) => boolean); + name?: string; + withRef?: boolean; + shouldResubscribe?: (props: TProps, nextProps: TProps) => boolean; + alias?: string; + } + + declare export interface OperationComponent< + TResult: { ... }, + TOwnProps: { ... }, + TVariables: { ... }, + TMergedProps: ChildProps + > { + (component: ComponentType): ComponentType; + } + + declare export interface IDocumentDefinition { + type: DocumentType; + name: string; + variables: VariableDefinitionNode[]; + } + + declare export interface Context { + [key: string]: any; + } + + declare export interface QueryResult { + query: Promise>; + element: Element; + context: Context; + } + + declare export type QueryRenderProps< + TData = any, + TVariables = OperationVariables + > = { + data: MakeDataOptional, + loading: boolean, + error?: ApolloError, + variables: TVariables, + networkStatus: NetworkStatus, + refetch: (variables?: TVariables) => Promise>, + fetchMore: (( + options: FetchMoreOptions & + FetchMoreQueryOptions + ) => Promise>) & + (( + options: { + query: DocumentNode, + ... + } & FetchMoreQueryOptions & + FetchMoreOptions + ) => Promise>), + load: () => void, + startPolling: (interval: number) => void, + stopPolling: () => void, + subscribeToMore: ( + options: SubscribeToMoreOptions + ) => () => void, + updateQuery: ( + mapFn: ( + previousResult: TData, + options: { variables: TVariables, ... } + ) => TData + ) => mixed, + client: ApolloClient, + ... + }; + + declare export type QueryRenderPropFunction = ( + QueryRenderProps + ) => Node; + + declare export class Query extends React$Component<{ + query: DocumentNode, + children: QueryRenderPropFunction, + variables?: TVariables, + pollInterval?: number, + notifyOnNetworkStatusChange?: boolean, + fetchPolicy?: FetchPolicy, + errorPolicy?: ErrorPolicy, + ssr?: boolean, + displayName?: string, + delay?: boolean, + context?: { [string]: any, ... }, + ... + }> {} + + declare export type SubscriptionResult< + TData, + TVariables = OperationVariables + > = { + loading: boolean, + data?: MakeDataOptional, + error?: ApolloError, + ... + }; + + declare export type SubscriptionRenderPropFunction = ( + result: SubscriptionResult + ) => Node; + + declare export type OnSubscriptionDataOptions = { + client: ApolloClient, + subscriptionData: SubscriptionResult, + ... + }; + + declare export type SubscriptionProps< + TData, + TVariables = OperationVariables + > = { + subscription: DocumentNode, + variables?: TVariables, + shouldResubscribe?: + | boolean + | (( + SubscriptionProps, + SubscriptionProps + ) => boolean), + onSubscriptionData?: (OnSubscriptionDataOptions) => any, + children?: SubscriptionRenderPropFunction, + ... + }; + + declare export class Subscription extends React$Component< + SubscriptionProps + > {} + + declare export type OperationVariables = Dict; + + declare export type MutationFunction< + TData = any, + TVariables = OperationVariables + > = (options?: { + variables?: TVariables, + optimisticResponse?: Dict, + refetchQueries?: RefetchQueryDescription | RefetchQueriesProviderFn, + update?: MutationUpdaterFn, + ... + }) => Promise>; + + declare export type MutationResult = { + loading: boolean, + error?: ApolloError, + data?: TData, + called: boolean, + client: ApolloClient, + ... + }; + + declare export type MutationRenderPropFunction = ( + mutate: MutationFunction, + result: MutationResult + ) => Node; + + declare export class Mutation< + TData, + TVariables = void + > extends React$Component<{ + mutation: DocumentNode, + children: MutationRenderPropFunction, + variables?: TVariables, + update?: MutationUpdaterFn, + ignoreResults?: boolean, + optimisticResponse?: Dict, + refetchQueries?: RefetchQueryDescription | RefetchQueriesProviderFn, + onCompleted?: (data: TData) => mixed, + onError?: (error: ApolloError) => mixed, + context?: { [string]: any, ... }, + ... + }> {} +} diff --git a/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.201.x-/test_react-components_v3.x.x.js b/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.201.x-/test_react-components_v3.x.x.js new file mode 100644 index 0000000000..6d05627b21 --- /dev/null +++ b/definitions/npm/@apollo/react-components_v3.x.x/flow_v0.201.x-/test_react-components_v3.x.x.js @@ -0,0 +1,682 @@ +// @flow +import * as React from 'react'; +import { it, describe } from 'flow-typed-test'; +import { + ApolloProvider, + ApolloConsumer, + Query, + Mutation, + Subscription, + type ApolloClient, + type MutationFunction, + type MutationResult, + type QueryRenderProps, + type PureQueryOptions, + type SubscriptionResult, + type RefetchQueryDescription, +} from '@apollo/react-components'; + +const gql = (strings, ...args) => {}; // graphql-tag stub + +const query = gql` + { + foo + } +`; +const mutation = gql` + mutation { + foo + } +`; + +type Hero = { + name: string, + id: string, + appearsIn: string[], + friends: Hero[], + ... +}; + +type IQuery = { + foo: string, + bar: string, + ... +}; + +const HERO_QUERY = gql` + query GetCharacter($episode: String!, $offset: Int) { + hero(episode: $episode, offset: $offset) { + name + id + friends { + name + id + appearsIn + } + } + } +`; + +const OTHER_QUERY = gql` + query GetOther($other: String!) { + other(other: $other) { + name + } + } +`; + +const HERO_MUTATION = gql` + mutation UpdateHero($input: HeroInput!) { + updateHero(input: $input) { + hero { + name + id + } + } + } +`; + +const HERO_SUBSCRIPTION = gql` + mutation onHeroUpdate($heroId: ID!) { + heroUpdated(heroId: $heroId) { + hero { + name + id + } + } + } +`; + +type HeroQueryVariables = { + episode: string, + offset?: ?number, + ... +}; +class HeroQueryComp extends Query< + { hero: ?Hero, ... }, + { episode: string, offset?: ?number, ... } +> {} + +describe('', () => { + it('works', () => { + type Vars = {| foo: string |}; + type Res = {| res: string |}; + const vars: Vars = { foo: 'bar' }; + const q = ( + + {({ data }: QueryRenderProps) => { + // $FlowExpectedError Cannot get `data.res` + data.res; + if (!data) { + return
; + } + // $FlowExpectedError Cannot get `data.res` because property `res` is missing in object type + const s: string = data.res; + if (data.res) { + const _s: string = data.res; + } + return
; + }} + + ); + }); + + it('works when extending Query with types', () => { + + {({ data, loading, error }) => { + if (loading) return 'Loading....'; + if (error) return 'Error!'; + // $FlowExpectedError Cannot get `data.hero`. data may be undefined + data.hero; + if (!data || !data.hero) { + return
; + } + const hero = data.hero; + + const nameAgain: string = hero.name; + // $FlowExpectedError unknown is not a property on Hero + const unknown = hero.unknown; + + return
{nameAgain}
; + }} + ; + }); + + it('raises an error if accessing a prop in children function that doesnt exist', () => { + + {// $FlowExpectedError cannot render HeroQueryComp becuase errors is missing in children function (should be error instead of errors) + ({ data, loading, errors }) => { + if (loading) return 'Loading....'; + if (errors) return 'Error!'; + return String(data); + }} + ; + }); + + describe('refetch', () => { + it('works if passed variablees that match the query', () => { + + {({ data, refetch }) => { + const onClick = () => { + refetch(); + refetch({ episode: 'otherEpisode' }); + // $FlowExpectedError refetch variables do not match variables for query + refetch({ notEpisode: 'otherEpisode' }); + }; + return ; + }} + ; + }); + }); + + describe('fetchMore', () => { + it('works when passed valid options', () => { + + {({ data, fetchMore }) => { + const onClick = () => { + fetchMore({ + variables: { episode: 'episode2' }, + updateQuery: (prev, options) => { + if (!options.fetchMoreResult) return prev; + return { + hero: options.fetchMoreResult.hero, + }; + }, + }); + + const variables: $Shape = { offset: 1 }; + fetchMore({ + variables: variables, + updateQuery: (prev, options) => { + if (!options.fetchMoreResult) return prev; + return { + hero: options.fetchMoreResult.hero, + }; + }, + }); + + const otherVariables = { other: '1234' }; + fetchMore({ + query: OTHER_QUERY, + variables: otherVariables, + updateQuery: (prev, options) => { + if (!options.fetchMoreResult) return prev; + return { + other: options.fetchMoreResult.other, + }; + }, + }); + }; + return ; + }} + ; + }); + + it('raises an error when passed invalid options', () => { + + {({ data, fetchMore }) => { + const onClick = () => { + // $FlowExpectedError variables must match $Shape of query variables + fetchMore({ + variables: { other: 'hello' }, + updateQuery: (prev, options) => { + if (!options.fetchMoreResult) return prev; + return { + hero: options.fetchMoreResult.hero, + }; + }, + }); + + // $FlowExpectedError must pass query option if passing different variables than query + fetchMore({ + variables: { other: '1234' }, + updateQuery: (prev, options) => { + if (!options.fetchMoreResult) return prev; + return { + other: options.fetchMoreResult.other, + }; + }, + }); + + fetchMore({ + variables: { episode: 'episode2' }, + updateQuery: (prev, options) => { + if (!options.fetchMoreResult) return prev; + // $FlowExpectedError updateQuery return type must match query response type + return { + other: options.fetchMoreResult.hero, + }; + }, + }); + }; + return ; + }} + ; + }); + }); + + describe('updateQuery', () => { + it('works', () => { + + {({ updateQuery }) => { + // $FlowExpectedError updateQuery return type must match previous result type + updateQuery((previousResult, options) => ({ hello: 'flow' })); + const renameHero = (newName: string) => + updateQuery((previousResult, options) => { + // $FlowExpectedError Cannot get `options.unknownProperty` because property `unknownProperty` is missing in options + const a = options.unknownProperty; + const { variables } = options; + return { ...previousResult, name: newName }; + }); + return
; + }} + ; + }); + }); +}); + +type HeroSubcriptionVariables = { + heroId: string, + ... +}; +class HeroSubscriptionComp extends Subscription< + { hero: ?Hero, ... }, + HeroSubcriptionVariables +> {} + +describe('', () => { + it('works', () => { + type Vars = {| foo: string |}; + type Res = {| res: string |}; + const vars: Vars = { foo: '1' }; + const q = ( + + {({ data }: SubscriptionResult) => { + // $FlowExpectedError Cannot get `data.res` + data.res; + if (!data) { + return
; + } + // $FlowExpectedError Cannot get `data.res` because property `res` is missing in object type + const s: string = data.res; + const _s: ?string = data.res; + return
; + }} + + ); + }); + it('works when extending Subscription with types', () => { + + {({ data, loading, error }) => { + if (loading) return 'Loading....'; + if (error) return 'Error!'; + // $FlowExpectedError Cannot get `data.hero`. data may be undefined + data.hero; + if (!data || !data.hero) { + return
; + } + const hero = data.hero; + + const nameAgain: string = hero.name; + // $FlowExpectedError unknown is not a property on Hero + const unknown = hero.unknown; + + return
{nameAgain}
; + }} + ; + }); + it('errors if wrong variables passed', () => { + type Vars = {| foo: string |}; + type Res = {| res: string |}; + const q = ( + // $FlowExpectedError variables must match shape of query variables + + {// $FlowExpectedError variables must match shape of query variables + ({ data }: SubscriptionResult) => {}} + + ); + }); + it('supports onSubscriptionData prop', function() { + const q = ( + , + subscriptionData: SubscriptionResult<{ hero: ?Hero, ... }>, + ... + }) => { + const hero: ?Hero = + subscriptionData.data && subscriptionData.data.hero + ? subscriptionData.data.hero + : null; + }} + /> + ); + }); +}); + +type UpdateHeroMutationVariables = { + input: { id: string, name: string, ... }, + ... +}; +class UpdateHeroMutationComp extends Mutation< + { updateHero?: ?{ hero: ?Hero, ... }, ... }, + UpdateHeroMutationVariables +> {} + +describe('', () => { + it('mutate() args are optional', () => { + type Vars = {| foo: string |}; + type Res = {| res: string |}; + const vars: Vars = { foo: 'bar' }; + const q = ( + + {mutate => { + mutate(); + return
; + }} + + ); + }); + + it('works', () => { + type Vars = {| foo: string |}; + type Res = {| res: string |}; + const vars: Vars = { foo: 'bar' }; + const q = ( + + {( + update: MutationFunction, + { data, client }: MutationResult + ) => { + // $FlowExpectedError Cannot get `data.res` + data.res; + if (!data) { + return
; + } + const d1: Res = data; + const s: string = data.res; + client; + return
; + }} + + ); + }); + + it('works when extending Mutation with types', () => { + + {(updateHero, { loading, error, data, called }) => { + const onClick = () => { + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + }); + // $FlowExpectedError variables must match Mutation variables + updateHero({ + variables: { id: '1', name: 'hero1' }, + }); + }; + return ( +
+ + {error && error.message} +
+ ); + }} +
; + }); + + describe('optimisticResponse', () => { + it('works when passed an optimisticResponse object', () => { + + {updateHero => { + const optimisticResponse = { + updateHero: { + __typename: 'UpdateHeroPayload', + hero: { + __typename: 'Hero', + name: 'Hero1', + id: '1', + }, + }, + }; + const onClick = () => { + updateHero({ + optimisticResponse, + variables: { input: { id: '1', name: 'hero1' } }, + }); + + // $FlowExpectedError optimisticResponse must be an object + updateHero({ + optimisticResponse: 'optimisticResponse', + variables: { input: { id: '1', name: 'hero1' } }, + }); + }; + return ; + }} + ; + }); + }); + + describe('refetchQueries', () => { + it('works when passed refetchQueries to Mutation component', () => { + const queryOption = { + query: HERO_QUERY, + variables: { episode: 'episode' }, + }; + const refetchQueries: RefetchQueryDescription = [queryOption, 'foo']; + + + {updateHero => { + const onClick = () => { + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + }); + }; + return ; + }} + ; + + // $FlowExpectedError refetchQueries must be an array of queries or a function that returns an array of queries + + {updateHero => { + const onClick = () => { + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + }); + }; + return ; + }} + ; + }); + + it('works when passed refetchQueries to mutation function', () => { + + {updateHero => { + const onClick = () => { + const queryOption = { + query: HERO_QUERY, + variables: { episode: 'episode' }, + }; + const refetchQueries: PureQueryOptions[] = [queryOption]; + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + refetchQueries, + }); + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + refetchQueries: () => refetchQueries, + }); + + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + // $FlowExpectedError refetchQueries must be an array of queries or a function that returns an array of queries + refetchQueries: () => queryOption, + }); + // $FlowExpectedError refetchQueries must be an array of queries or a function that returns an array of queries + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + refetchQueries: queryOption, + }); + }; + return ; + }} + ; + }); + }); + + describe('update', () => { + it('can manually update the cache after a mutation by passing update prop to the Mutation component', () => { + { + // $FlowExpectedError data may be undefined + data.updateHero; + if (data && data.updateHero) { + const hero = cache.readQuery({ + query: HERO_QUERY, + variables: { episoe: 'episode' }, + }); + cache.writeQuery({ + query: HERO_QUERY, + variables: { episode: 'episode' }, + data: { hero: data.updateHero }, + }); + } + }} + > + {updateHero => { + const onClick = () => { + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + }); + }; + return ; + }} + ; + }); + + it('can manually update the cache after a mutation using update on the mutation function', () => { + + {updateHero => { + const onClick = () => { + updateHero({ + variables: { input: { id: '1', name: 'hero1' } }, + update: (cache, { data }) => { + // $FlowExpectedError data may be undefined + data.updateHero; + + if (data && data.updateHero) { + const hero = cache.readQuery({ + query: HERO_QUERY, + variables: { episoe: 'episode' }, + }); + cache.writeQuery({ + query: HERO_QUERY, + variables: { episode: 'episode' }, + data: { hero: data.updateHero }, + }); + if (data.updateHero && data.updateHero.hero) { + cache.writeFragment({ + id: '1', + fragment: gql` + fragment myHero on Hero { + name + } + `, + data: { + name: data.updateHero.hero.name, + }, + }); + } + + // $FlowExpectedError readQuery requires query + cache.readQuery({ + variables: { episode: 'episode' }, + }); + // $FlowExpectedError writeQuery requires data + cache.writeQuery({ + query: HERO_QUERY, + variables: { episode: 'episode' }, + }); + // $FlowExpectedError writeFragment requires id + cache.writeFragment({ + fragment: gql` + fragment myHero on Hero { + name + } + `, + data: { + name: 'name', + }, + }); + // $FlowExpectedError cannot call unknownFunction on cache + cache.unknwonFunction(); + } + }, + }); + }; + return ; + }} + ; + }); + }); +}); + +describe('', () => { + it('works when passed client', () => { + // Should be an instance of ApolloClient + const client = {}; + +
+ ; + }); + + it('raises an error when not passed a client', () => { + // $FlowExpectedError ApolloPrivder requires client prop + +
+ ; + }); + + it('raises an error when not passed children', () => { + // Should be an instance of ApolloClient + const client = {}; + + // $FlowExpectedError ApolloPrivder requires client prop + ; + }); +}); + +describe('', () => { + it('passes ApolloClient to the consumer children', () => { + + {client => { + const onClick = () => { + client.resetStore(); + client.query({ query: HERO_QUERY }); + client.readQuery({ + query: HERO_QUERY, + variables: { episode: 'episode' }, + }); + // $FlowExpectedError doSomethingElse is not a method of ApolloClient + client.doSomethingElse(); + }; + return ; + }} + ; + }); +}); diff --git a/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-/react-hoc_v3.x.x.js b/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-v.200.x/react-hoc_v3.x.x.js similarity index 100% rename from definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-/react-hoc_v3.x.x.js rename to definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-v.200.x/react-hoc_v3.x.x.js diff --git a/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-/test_react-hoc_v3.x.x.js b/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-v.200.x/test_react-hoc_v3.x.x.js similarity index 100% rename from definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-/test_react-hoc_v3.x.x.js rename to definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.104.x-v.200.x/test_react-hoc_v3.x.x.js diff --git a/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.201.x-/react-hoc_v3.x.x.js b/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.201.x-/react-hoc_v3.x.x.js new file mode 100644 index 0000000000..a3eefa25dc --- /dev/null +++ b/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.201.x-/react-hoc_v3.x.x.js @@ -0,0 +1,935 @@ +declare module '@apollo/react-hoc' { + import type { ComponentType, Element, Node } from 'react'; + + declare type Dict = { [key: string]: any, ...}; + + + declare type MakeOptional = (V) => ?V; + declare type MakeDataOptional = $ObjMap | void; + /** + * Copied types from Apollo Client libdef + * Please update apollo-client libdef as well if updating these types + */ + declare class ObservableQuery extends Observable> { + options: WatchQueryOptions; + queryId: string; + variables: V; + isCurrentlyPolling: boolean; + shouldSubscribe: boolean; + isTornDown: boolean; + scheduler: QueryScheduler; + queryManager: QueryManager; + observers: Observer>[]; + subscriptionHandles: SubscriptionLINK[]; + lastResult: ApolloQueryResult; + lastError: ApolloError; + lastVariables: V; + + constructor(data: { + scheduler: QueryScheduler, + options: WatchQueryOptions, + shouldSubscribe?: boolean, + ... + }): this; + result(): Promise>; + currentResult(): ApolloCurrentResult; + getLastResult(): ApolloQueryResult; + getLastError(): ApolloError; + resetLastResults(): void; + refetch(variables?: V): Promise>; + fetchMore( + fetchMoreOptions: FetchMoreQueryOptions & FetchMoreOptions + ): Promise>; + subscribeToMore(options: SubscribeToMoreOptions): () => void; + setOptions( + opts: ModifiableWatchQueryOptions + ): Promise>; + setVariables( + variables: V, + tryFetch?: boolean, + fetchResults?: boolean + ): Promise>; + updateQuery( + mapFn: (previousQueryResult: any, options: UpdateQueryOptions) => mixed + ): void; + stopPolling(): void; + startPolling(pollInterval: number): void; + } + + declare class QueryManager { + scheduler: QueryScheduler; + link: ApolloLink; + mutationStore: MutationStore; + queryStore: QueryStore; + dataStore: DataStore; + + constructor({ + link: ApolloLink, + queryDeduplication?: boolean, + store: DataStore, + onBroadcast?: () => mixed, + ssrMode?: boolean, + ... + }): this; + + mutate(options: MutationOptions<>): Promise>; + fetchQuery( + queryId: string, + options: WatchQueryOptions, + fetchType?: FetchType, + fetchMoreForQueryId?: string + ): Promise>; + queryListenerForObserver( + queryId: string, + options: WatchQueryOptions, + observer: Observer> + ): QueryListener; + watchQuery( + options: WatchQueryOptions, + shouldSubscribe?: boolean + ): ObservableQuery; + query(options: WatchQueryOptions): Promise>; + generateQueryId(): string; + stopQueryInStore(queryId: string): void; + addQueryListener(queryId: string, listener: QueryListener): void; + updateQueryWatch( + queryId: string, + document: DocumentNode, + options: WatchQueryOptions + ): void; + addFetchQueryPromise( + requestId: number, + promise: Promise>, + resolve: (result: ApolloQueryResult) => void, + reject: (error: Error) => void + ): void; + removeFetchQueryPromise(requestId: number): void; + addObservableQuery( + queryId: string, + observableQuery: ObservableQuery + ): void; + removeObservableQuery(queryId: string): void; + clearStore(): Promise; + resetStore(): Promise[]>; + } + + declare class QueryStore { + getStore(): { [queryId: string]: QueryStoreValue, ... }; + get(queryId: string): QueryStoreValue; + initQuery(query: { + queryId: string, + document: DocumentNode, + storePreviousVariables: boolean, + variables: Dict, + isPoll: boolean, + isRefetch: boolean, + metadata: any, + fetchMoreForQueryId: string | void, + ... + }): void; + markQueryResult( + queryId: string, + result: ExecutionResult<>, + fetchMoreForQueryId: string | void + ): void; + markQueryError( + queryId: string, + error: Error, + fetchMoreForQueryId: string | void + ): void; + markQueryResultClient(queryId: string, complete: boolean): void; + stopQuery(queryId: string): void; + reset(observableQueryIds: string[]): void; + } + + declare class QueryScheduler { + inFlightQueries: { [queryId: string]: WatchQueryOptions, ... }; + registeredQueries: { [queryId: string]: WatchQueryOptions, ... }; + intervalQueries: { [interval: number]: string[], ... }; + queryManager: QueryManager; + constructor({ + queryManager: QueryManager, + ssrMode?: boolean, + ... + }): this; + checkInFlight(queryId: string): ?boolean; + fetchQuery( + queryId: string, + options: WatchQueryOptions, + fetchType: FetchType + ): Promise>; + startPollingQuery( + options: WatchQueryOptions, + queryId: string, + listener?: QueryListener + ): string; + stopPollingQuery(queryId: string): void; + fetchQueriesOnInterval(interval: number): void; + addQueryOnInterval( + queryId: string, + queryOptions: WatchQueryOptions + ): void; + registerPollingQuery( + queryOptions: WatchQueryOptions + ): ObservableQuery; + markMutationError(mutationId: string, error: Error): void; + reset(): void; + } + + declare class DataStore { + constructor(initialCache: ApolloCache): this; + getCache(): ApolloCache; + markQueryResult( + result: ExecutionResult<>, + document: DocumentNode, + variables: any, + fetchMoreForQueryId: string | void, + ignoreErrors?: boolean + ): void; + markSubscriptionResult( + result: ExecutionResult<>, + document: DocumentNode, + variables: any + ): void; + markMutationInit(mutation: { + mutationId: string, + document: DocumentNode, + variables: any, + updateQueries: { [queryId: string]: QueryWithUpdater, ... }, + update: ((proxy: DataProxy, mutationResult: Dict) => mixed) | void, + optimisticResponse: Dict, + ... + }): void; + markMutationResult(mutation: { + mutationId: string, + result: ExecutionResult<>, + document: DocumentNode, + variables: any, + updateQueries: { [queryId: string]: QueryWithUpdater, ... }, + update: ((proxy: DataProxy, mutationResult: Dict) => mixed) | void, + ... + }): void; + markMutationComplete({ + mutationId: string, + optimisticResponse?: any, + ... + }): void; + markUpdateQueryResult( + document: DocumentNode, + variables: any, + newResult: any + ): void; + reset(): Promise; + } + + declare type QueryWithUpdater = { + updater: MutationQueryReducer, + query: QueryStoreValue, + ... + }; + + declare interface MutationStoreValue { + mutationString: string; + variables: Dict; + loading: boolean; + error: Error | null; + } + + declare class MutationStore { + getStore(): { [mutationId: string]: MutationStoreValue, ... }; + get(mutationId: string): MutationStoreValue; + initMutation( + mutationId: string, + mutationString: string, + variables: Dict + ): void; + } + + declare interface FetchMoreOptions { + updateQuery: ( + previousQueryResult: TData, + options: { + fetchMoreResult?: TData, + variables: TVariables, + ... + } + ) => TData; + } + + declare interface UpdateQueryOptions { + variables?: Dict; + } + + declare type ApolloCurrentResult = { + data: T | { ... }, + errors?: Array, + loading: boolean, + networkStatus: NetworkStatus, + error?: ApolloError, + partial?: boolean, + ... + }; + + declare interface ModifiableWatchQueryOptions { + variables?: { [key: string]: any, ... }; + pollInterval?: number; + fetchPolicy?: FetchPolicy; + errorPolicy?: ErrorPolicy; + fetchResults?: boolean; + notifyOnNetworkStatusChange?: boolean; + } + + declare interface WatchQueryOptions + extends ModifiableWatchQueryOptions { + query: DocumentNode; + metadata?: any; + context?: any; + } + + declare type RefetchQueryDescription = $ReadOnlyArray< + string | PureQueryOptions + >; + + declare interface MutationBaseOptions { + updateQueries?: MutationQueryReducersMap; + optimisticResponse?: Dict; + refetchQueries?: + | ((result: ExecutionResult<>) => RefetchQueryDescription) + | RefetchQueryDescription; + update?: MutationUpdaterFn; + errorPolicy?: ErrorPolicy; + variables?: any; + } + + declare interface MutationOptions + extends MutationBaseOptions { + mutation: DocumentNode; + context?: any; + fetchPolicy?: FetchPolicy; + } + + declare interface SubscriptionOptions { + query: DocumentNode; + variables?: { [key: string]: any, ... }; + } + + declare type FetchPolicy = + | 'cache-first' + | 'cache-and-network' + | 'network-only' + | 'cache-only' + | 'no-cache' + | 'standby'; + + declare type ErrorPolicy = 'none' | 'ignore' | 'all'; + + declare interface FetchMoreQueryOptions { + variables: $Shape; + } + + declare type SubscribeToMoreOptions< + TData, + TSubscriptionData, + TSubscriptionVariables = void + > = { + document?: DocumentNode, + variables?: TSubscriptionVariables, + updateQuery?: ( + previousResult: TData, + result: { + subscriptionData: { data?: TSubscriptionData, ... }, + variables: TSubscriptionVariables, + ... + } + ) => TData, + onError?: (error: Error) => mixed, + ... + }; + + declare type MutationUpdaterFn = ( + proxy: DataProxy, + mutationResult: FetchResult + ) => mixed; + + declare type NetworkStatus = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; + + declare type QueryListener = ( + queryStoreValue: QueryStoreValue, + newData?: any + ) => mixed; + + declare type QueryStoreValue = { + document: DocumentNode, + variables: Dict, + previousVariables?: Dict, + networkStatus: NetworkStatus, + networkError: Error | null, + graphQLErrors: GraphQLError[], + metadata: any, + ... + }; + + declare type PureQueryOptions = { + query: DocumentNode, + variables?: { [key: string]: any, ... }, + ... + }; + + declare type ApolloQueryResult = { + data: T, + errors?: Array, + loading: boolean, + networkStatus: NetworkStatus, + stale: boolean, + ... + }; + + declare type FetchType = 1 | 2 | 3; + + declare type MutationQueryReducer = ( + previousResult: { [key: string]: any, ... }, + options: { + mutationResult: FetchResult, + queryName: string | void, + queryVariables: { [key: string]: any, ... }, + ... + } + ) => { [key: string]: any, ... }; + + declare type MutationQueryReducersMap< + T = { [key: string]: any, ... } + > = { [queryName: string]: MutationQueryReducer, ... }; + + declare class $ApolloError extends Error { + message: string; + graphQLErrors: Array; + networkError: Error | null; + extraInfo: any; + constructor(info: ErrorConstructor): this; + } + declare export type ApolloError = $ApolloError; + + declare interface ErrorConstructor { + graphQLErrors?: Array; + networkError?: Error | null; + errorMessage?: string; + extraInfo?: any; + } + + declare interface DefaultOptions { + +watchQuery?: ModifiableWatchQueryOptions; + +query?: ModifiableWatchQueryOptions; + +mutate?: MutationBaseOptions<>; + } + + declare type ApolloClientOptions = { + link: ApolloLink, + cache: ApolloCache, + ssrMode?: boolean, + ssrForceFetchDelay?: number, + connectToDevTools?: boolean, + queryDeduplication?: boolean, + defaultOptions?: DefaultOptions, + ... + }; + + declare class ApolloClient { + link: ApolloLink; + store: DataStore; + cache: ApolloCache; + queryManager: QueryManager; + disableNetworkFetches: boolean; + version: string; + queryDeduplication: boolean; + defaultOptions: DefaultOptions; + devToolsHookCb: any; + proxy: ApolloCache | void; + ssrMode: boolean; + resetStoreCallbacks: Array<() => Promise>; + + constructor(options: ApolloClientOptions): this; + watchQuery(options: WatchQueryOptions): ObservableQuery; + query(options: WatchQueryOptions): Promise>; + mutate(options: MutationOptions): Promise>; + subscribe(options: SubscriptionOptions): Observable; + readQuery(options: DataProxyReadQueryOptions): T | null; + readFragment(options: DataProxyReadFragmentOptions): T | null; + writeQuery(options: DataProxyWriteQueryOptions): void; + writeFragment(options: DataProxyWriteFragmentOptions): void; + writeData(options: DataProxyWriteDataOptions): void; + __actionHookForDevTools(cb: () => mixed): void; + __requestRaw(payload: GraphQLRequest): Observable>; + initQueryManager(): void; + clearStore(): Promise; + resetStore(): Promise> | null>; + onResetStore(cb: () => Promise): () => void; + reFetchObservableQueries( + includeStandby?: boolean + ): Promise[]> | Promise; + extract(optimistic?: boolean): TCacheShape; + restore(serializedState: TCacheShape): ApolloCache; + } + + /* apollo-link types */ + declare class ApolloLink { + constructor(request?: RequestHandler): this; + + static empty(): ApolloLink; + static from(links: Array): ApolloLink; + static split( + test: (op: Operation) => boolean, + left: ApolloLink | RequestHandler, + right: ApolloLink | RequestHandler + ): ApolloLink; + static execute( + link: ApolloLink, + operation: GraphQLRequest + ): Observable>; + + split( + test: (op: Operation) => boolean, + left: ApolloLink | RequestHandler, + right: ApolloLink | RequestHandler + ): ApolloLink; + + concat(next: ApolloLink | RequestHandler): ApolloLink; + + request( + operation: Operation, + forward?: NextLink + ): Observable> | null; + } + + declare interface GraphQLRequest { + query: DocumentNode; + variables?: { [key: string]: any, ... }; + operationName?: string; + context?: { [key: string]: any, ... }; + extensions?: { [key: string]: any, ... }; + } + + declare interface Operation { + query: DocumentNode; + variables: { [key: string]: any, ... }; + operationName: string; + extensions: { [key: string]: any, ... }; + setContext: (context: { [key: string]: any, ... }) => { + [key: string]: any, + ..., + }; + getContext: () => { [key: string]: any, ... }; + toKey: () => string; + } + + declare type FetchResult< + C = { [key: string]: any, ... }, + E = { [key: string]: any, ... } + > = ExecutionResult & { + extension?: E, + context?: C, + ... + }; + + declare type NextLink = (operation: Operation) => Observable>; + + declare type RequestHandler = ( + operation: Operation, + forward?: NextLink + ) => Observable> | null; + + declare class Observable { + subscribe( + observerOrNext: ((value: T) => mixed) | ZenObservableObserver, + error?: (error: any) => mixed, + complete?: () => mixed + ): ZenObservableSubscription; + + forEach(fn: (value: T) => mixed): Promise; + + map(fn: (value: T) => R): Observable; + + filter(fn: (value: T) => boolean): Observable; + + reduce( + fn: (previousValue: R | T, currentValue: T) => R | T, + initialValue?: R | T + ): Observable; + + flatMap(fn: (value: T) => ZenObservableObservableLike): Observable; + + from( + observable: Observable | ZenObservableObservableLike | Array + ): Observable; + + of(...args: Array): Observable; + } + + declare interface Observer { + start?: (subscription: SubscriptionLINK) => any; + next?: (value: T) => void; + error?: (errorValue: any) => void; + complete?: () => void; + } + + declare interface SubscriptionLINK { + closed: boolean; + unsubscribe(): void; + } + + declare interface ZenObservableSubscriptionObserver { + closed: boolean; + next(value: T): void; + error(errorValue: any): void; + complete(): void; + } + + declare interface ZenObservableSubscription { + closed: boolean; + unsubscribe(): void; + } + + declare interface ZenObservableObserver { + start?: (subscription: ZenObservableSubscription) => mixed; + next?: (value: T) => mixed; + error?: (errorValue: any) => mixed; + complete?: () => mixed; + } + + declare type ZenObservableSubscriber = ( + observer: ZenObservableSubscriptionObserver + ) => mixed | (() => mixed) | SubscriptionLINK; + + declare interface ZenObservableObservableLike { + subscribe?: ZenObservableSubscriber; + } + /* apollo-link types */ + + /* apollo-cache types */ + declare class ApolloCache { + read(query: CacheReadOptions): T | null; + write(write: CacheWriteOptions): void; + diff(query: CacheDiffOptions): CacheDiffResult; + watch(watch: CacheWatchOptions): () => void; + evict(query: CacheEvictOptions): CacheEvictionResult; + reset(): Promise; + + restore(serializedState: TSerialized): ApolloCache; + extract(optimistic?: boolean): TSerialized; + + removeOptimistic(id: string): void; + + performTransaction(transaction: Transaction): void; + recordOptimisticTransaction( + transaction: Transaction, + id: string + ): void; + + transformDocument(document: DocumentNode): DocumentNode; + transformForLink(document: DocumentNode): DocumentNode; + + readQuery( + options: DataProxyReadQueryOptions, + optimistic?: boolean + ): QueryType | null; + readFragment( + options: DataProxyReadFragmentOptions, + optimistic?: boolean + ): FragmentType | null; + writeQuery(options: CacheWriteQueryOptions): void; + writeFragment(options: CacheWriteFragmentOptions): void; + writeData(options: CacheWriteDataOptions): void; + } + + declare type Transaction = (c: ApolloCache) => mixed; + + declare type CacheWatchCallback = (newData: any) => mixed; + + declare interface CacheEvictionResult { + success: boolean; + } + + declare interface CacheReadOptions extends DataProxyReadQueryOptions { + rootId?: string; + previousResult?: any; + optimistic: boolean; + } + + declare interface CacheWriteOptions extends DataProxyReadQueryOptions { + dataId: string; + result: any; + } + + declare interface CacheDiffOptions extends CacheReadOptions { + returnPartialData?: boolean; + } + + declare interface CacheWatchOptions extends CacheReadOptions { + callback: CacheWatchCallback; + } + + declare interface CacheEvictOptions extends DataProxyReadQueryOptions { + rootId?: string; + } + + declare type CacheDiffResult = DataProxyDiffResult; + declare type CacheWriteQueryOptions = DataProxyWriteQueryOptions; + declare type CacheWriteFragmentOptions = DataProxyWriteFragmentOptions; + declare type CacheWriteDataOptions = DataProxyWriteDataOptions; + + declare interface DataProxyReadQueryOptions { + query: DocumentNode; + variables?: any; + } + + declare interface DataProxyReadFragmentOptions { + id: string; + fragment: DocumentNode; + fragmentName?: string; + variables?: any; + } + + declare interface DataProxyWriteQueryOptions { + data: any; + query: DocumentNode; + variables?: any; + } + + declare interface DataProxyWriteFragmentOptions { + data: any; + id: string; + fragment: DocumentNode; + fragmentName?: string; + variables?: any; + } + + declare interface DataProxyWriteDataOptions { + data: any; + id?: string; + } + + declare type DataProxyDiffResult = { + result?: T, + complete?: boolean, + ... + }; + + declare interface DataProxy { + readQuery( + options: DataProxyReadQueryOptions, + optimistic?: boolean + ): QueryType | null; + readFragment( + options: DataProxyReadFragmentOptions, + optimistic?: boolean + ): FragmentType | null; + writeQuery(options: DataProxyWriteQueryOptions): void; + writeFragment(options: DataProxyWriteFragmentOptions): void; + writeData(options: DataProxyWriteDataOptions): void; + } + /* End apollo-cache types */ + + /** End from Apollo Client */ + + /** + * Types From graphql + * graphql types are maintained in the graphql-js repo + */ + declare type DocumentNode = any; + declare type ExecutionResult = { + data?: T, + extensions?: { [string]: any, ... }, + errors?: any[], + ... + }; + declare type GraphQLError = any; + /** End From graphql */ + + declare export interface ApolloProviderProps { + client: any; // ApolloClient; + children: Node; + } + + declare export interface ApolloConsumerProps { + children: (client: ApolloClient) => Node; + } + + declare export class ApolloConsumer extends React$Component {} + + declare export class ApolloProvider extends React$Component< + ApolloProviderProps + > { + childContextTypes: { + client: ApolloClient, + operations: Map< + string, + { + query: DocumentNode, + variables: any, + ... + } + >, + ... + }; + + getChildContext(): { + client: ApolloClient, + operations: Map< + string, + { + query: DocumentNode, + variables: any, + ... + } + >, + ... + }; + } + + declare type MutationFunc = ( + opts: MutationOpts + ) => Promise>; + + declare export type GraphqlData = TResult & + GraphqlQueryControls & { + variables: TVariables, + refetch: (variables?: TVariables) => Promise>, + ... + }; + + declare export type ChildProps< + TOwnProps, + TResult, + TVariables: Dict = { ... } + > = { + data: GraphqlData, + mutate: MutationFunc, + ... + } & TOwnProps; + + declare type RefetchQueriesProviderFn = ( + ...args: any[] + ) => RefetchQueryDescription; + + declare type MutationOpts = {| + variables?: TVariables, + optimisticResponse?: Dict, + refetchQueries?: RefetchQueryDescription | RefetchQueriesProviderFn, + update?: MutationUpdaterFn, + errorPolicy?: ErrorPolicy, + |}; + + declare type QueryOpts = {| + ssr?: boolean, + variables?: TVariables, + fetchPolicy?: FetchPolicy, + pollInterval?: number, + skip?: boolean, + errorPolicy?: ErrorPolicy, + context?: { [key: string]: any, ... }, + |}; + + declare export interface GraphqlQueryControls< + TGraphQLVariables = OperationVariables + > { + error?: ApolloError | any; // Added optional `any` to satisfy Flow < 0.62 + networkStatus: NetworkStatus; + loading: boolean; + variables: TGraphQLVariables; + fetchMore: ( + fetchMoreOptions: FetchMoreQueryOptions & + FetchMoreOptions + ) => Promise>; + refetch: (variables?: TGraphQLVariables) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: ( + mapFn: (previousQueryResult: any, options: UpdateQueryOptions) => mixed + ) => void; + } + + declare interface OptionProps { + ownProps: TProps; + data?: GraphqlData; + mutate: MutationFunc; + } + + declare type OptionDescription = + | QueryOpts + | MutationOpts + | ((props: TProps) => QueryOpts | MutationOpts); + + declare interface OperationOption< + TResult: { ... }, + TProps: { ... }, + TChildProps: { ... }, + TVariables: { ... } + > { + +options?: OptionDescription; + props?: ( + props: OptionProps + ) => TChildProps | ChildProps; + +skip?: boolean | ((props: any) => boolean); + name?: string; + withRef?: boolean; + shouldResubscribe?: (props: TProps, nextProps: TProps) => boolean; + alias?: string; + } + + declare export interface OperationComponent< + TResult: Dict = { ... }, + TOwnProps: Dict = { ... }, + TVariables: Dict = { ... }, + TMergedProps: Dict = ChildProps + > { + (component: ComponentType): ComponentType; + } + + declare export function graphql( + document: DocumentNode, + operationOptions?: OperationOption + ): OperationComponent; + + declare type WithApolloOptions = { withRef?: boolean, ... }; + + declare export function withApollo( + component: ComponentType<{ client: ApolloClient, ... } & TProps>, + operationOptions?: WithApolloOptions + ): ComponentType; + + declare type SubscriptionResult< + TData, + TVariables = OperationVariables + > = { + loading: boolean, + data?: MakeDataOptional, + error?: ApolloError, + ... + }; + + declare type SubscriptionRenderPropFunction = ( + result: SubscriptionResult + ) => Node; + + declare type OnSubscriptionDataOptions = { + client: ApolloClient, + subscriptionData: SubscriptionResult, + ... + }; + + declare type SubscriptionProps = { + subscription: DocumentNode, + variables?: TVariables, + shouldResubscribe?: + | boolean + | (( + SubscriptionProps, + SubscriptionProps + ) => boolean), + onSubscriptionData?: (OnSubscriptionDataOptions) => any, + children?: SubscriptionRenderPropFunction, + ... + }; + + declare type OperationVariables = { [key: string]: any, ... }; +} diff --git a/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.201.x-/test_react-hoc_v3.x.x.js b/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.201.x-/test_react-hoc_v3.x.x.js new file mode 100644 index 0000000000..cb21dd51e3 --- /dev/null +++ b/definitions/npm/@apollo/react-hoc_v3.x.x/flow_v0.201.x-/test_react-hoc_v3.x.x.js @@ -0,0 +1,289 @@ +// @flow +import * as React from 'react'; +import { it, describe } from 'flow-typed-test'; +import { + ApolloProvider, + ApolloConsumer, + graphql, + withApollo, + type OperationComponent, + type GraphqlQueryControls, + type ChildProps, + type GraphqlData, +} from '@apollo/react-hoc'; + +const gql = (strings, ...args) => {}; // graphql-tag stub + +const query = gql` + { + foo + } +`; +const mutation = gql` + mutation { + foo + } +`; + +type Hero = { + name: string, + id: string, + appearsIn: string[], + friends: Hero[], + ... +}; + +type IQuery = { + foo: string, + bar: string, + ... +}; + +const withData: OperationComponent = graphql(query); + +it('works with functional component', () => { + const FunctionalWithData = withData(({ data }) => { + // $FlowExpectedError string type being treated as numerical + if (data.foo > 1) return ; + + return null; + }); +}); + +it('works with class component, this requires a stricter definition', () => { + type BasicComponentProps = ChildProps<{ ... }, IQuery>; + class BasicComponent extends React.Component { + render() { + const { foo, bar } = this.props.data; + + // $FlowExpectedError string type being treated as numerical + if (bar > 1) return null; + + // The below works as expected + return
{foo.length} string length
; + } + } + const BasicClassWithData = withData(BasicComponent); +}); + +it("works with class component with it's own variable", () => { + type CmplxOwnProps = { faz: string, ... }; + type CmplxComponentProps = { + data: GraphqlQueryControls<> & IQuery, + // The mutation is actually required or we get a error at the withData + mutate: any, + ... + } & CmplxOwnProps; + class CmplxComponent extends React.Component { + render() { + const { + data: { loading, error, bar, foo }, + faz, + } = this.props; + if (loading) return
Loading
; + if (error) return

ERROR

; + + // $FlowExpectedError string type being treated as numerical + if (bar > 1) return null; + + // The below works as expected + return ( +
+ {foo.length} string length compared to faz {faz.length} length +
+ ); + } + } + const withFancyData: OperationComponent = graphql( + query + ); + const CmplxWithData = withFancyData(CmplxComponent); +}); + +it("works with class component with it's own variable Props specified at the end", () => { + // Same as above but with the Props specified at the end + // since we don't rely on the ChildProps we don't need the mutate: any + type Cmplx2OwnProps = { faz: string, ... }; // We can have exact own props as we don't rely on the TMergedProps + type Cmplx2ComponentProps = { + data: IQuery & GraphqlQueryControls<>, + ... + } & Cmplx2OwnProps; + class Cmplx2Component extends React.Component { + render() { + const { + data: { loading, error, bar, foo }, + faz, + } = this.props; + if (loading) return
Loading
; + if (error) return

ERROR

; + + // $FlowExpectedError string type being treated as numerical + if (bar > 1) return null; + + // The below works as expected + return ( +
+ {foo.length} string length compared to faz {faz.length} length +
+ ); + } + } + const withFancyData2: OperationComponent< + IQuery, + Cmplx2OwnProps, + any, + Cmplx2ComponentProps + > = graphql(query); + const Cmplx2WithData = withFancyData2(Cmplx2Component); +}); + +const HERO_QUERY = gql` + query GetCharacter($episode: String!, $offset: Int) { + hero(episode: $episode, offset: $offset) { + name + id + friends { + name + id + appearsIn + } + } + } +`; + +const OTHER_QUERY = gql` + query GetOther($other: String!) { + other(other: $other) { + name + } + } +`; + +const HERO_MUTATION = gql` + mutation UpdateHero($input: HeroInput!) { + updateHero(input: $input) { + hero { + name + id + } + } + } +`; + +const HERO_SUBSCRIPTION = gql` + mutation onHeroUpdate($heroId: ID!) { + heroUpdated(heroId: $heroId) { + hero { + name + id + } + } + } +`; + +it('works with Variables specified', () => { + type Response = { hero: Hero, ... }; + + type InputProps = { episode: string, ... }; + + type Variables = { episode: string, ... }; + + type Props = GraphqlData & { someProp: string, ... }; + + const withCharacter: OperationComponent< + Response, + InputProps, + Variables, + Props + > = graphql(HERO_QUERY, { + options: ({ episode }) => { + // $FlowExpectedError [string] The operand of an arithmetic operation must be a number + episode * 10; + return { + // $FlowExpectedError [number] This type is incompatible with string + variables: { episode: 10 }, + }; + }, + props: ({ data, ownProps }) => ({ + ...data, + // $FlowExpectedError [string] This type cannot be compared to number + episode: ownProps.episode > 1, + // $FlowExpectedError property `isHero`. Property not found on object type + isHero: data && data.hero && data.hero.isHero, + // $FlowExpectedError Property `someProp`. This type is incompatible with string + someProp: 1, + }), + }); + + withCharacter(({ loading, error }) => { + if (loading) return
Loading
; + if (error) return

ERROR

; + return null; + }); + + class Character extends React.Component { + render() { + const { loading, hero, error } = this.props; + if (loading) return
Loading
; + if (error) return

ERROR

; + return null; // actual component with data; + } + } + const CharacterWithData = withCharacter(Character); +}); + +it('works with withApollo HOC', () => { + const Manual = withApollo(({ client }) => { + // XXX please don't ever actually do this + client.query({ query: HERO_QUERY }); + return null; + }); + + // withApollo passes `client` property so that it is no longer required + (Manual: React.ComponentType<{ ... }>); +}); + +describe('', () => { + it('works when passed client', () => { + // Should be an instance of ApolloClient + const client = {}; + +
+ ; + }); + + it('raises an error when not passed a client', () => { + // $FlowExpectedError ApolloPrivder requires client prop + +
+ ; + }); + + it('raises an error when not passed children', () => { + // Should be an instance of ApolloClient + const client = {}; + + // $FlowExpectedError ApolloPrivder requires client prop + ; + }); +}); + +describe('', () => { + it('passes ApolloClient to the consumer children', () => { + + {client => { + const onClick = () => { + client.resetStore(); + client.query({ query: HERO_QUERY }); + client.readQuery({ + query: HERO_QUERY, + variables: { episode: 'episode' }, + }); + // $FlowExpectedError doSomethingElse is not a method of ApolloClient + client.doSomethingElse(); + }; + return ; + }} + ; + }); +}); diff --git a/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-/test_tree-select_v1.x.x.js b/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-v.200.x/test_tree-select_v1.x.x.js similarity index 100% rename from definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-/test_tree-select_v1.x.x.js rename to definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-v.200.x/test_tree-select_v1.x.x.js diff --git a/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-/tree-select_v1.x.x.js b/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-v.200.x/tree-select_v1.x.x.js similarity index 100% rename from definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-/tree-select_v1.x.x.js rename to definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.104.x-v.200.x/tree-select_v1.x.x.js diff --git a/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.201.x-/test_tree-select_v1.x.x.js b/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.201.x-/test_tree-select_v1.x.x.js new file mode 100644 index 0000000000..2465abe6d5 --- /dev/null +++ b/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.201.x-/test_tree-select_v1.x.x.js @@ -0,0 +1,86 @@ +// @flow +import treeSelect from '@automattic/tree-select'; +import { describe, it } from 'flow-typed-test'; +type Universe = + | 'Alien' + | 'Battlestar Galactica' + | 'Firefly' + | 'Star Wars' + | 'Star Trek' + +type Ship = {| + name: string, + universe: Universe, +|} + +type State = {| + ships: Ship[], + selectedUniverses: Universe[], +|} + +type Sorting = (T, T) => -1 | 0 | 1; + +describe('#treeSelect', () => { + const shipsInUniverses = treeSelect( + (state: State) => [state.ships, state.selectedUniverses], + ([ships, universes], sortBy?: Sorting) => + ships + .filter(ship => universes.indexOf(ship.name) > -1) + .sort(sortBy) + ); + + it('infers correct arugment type', () => { + // $FlowExpectedError requires State as parameter + shipsInUniverses('hi'); + }); + + it('infers correct return type', () => { + const state = { + ships: [], + selectedUniverses: [], + }; + + // $FlowExpectedError returns Ship[] + const badResult: String[] = shipsInUniverses(state); + const result: Ship[] = shipsInUniverses(state); + }) + + it('infers correct additinonal arguments', () => { + // $FlowExpectedError invalid sorting input types + shipsInUniverses(state, (a: string, b: string) => -1); + + // $FlowExpectedError invalid return type in second fn argument + shipsInUniverses(state, (a: Ship, b: Ship) => 'a'); + + shipsInUniverses(state, (a, b) => { + // $FlowExpectedError a is a Ship has no speed prop + a.speed; + return 1; + }) + }) + + it('infers correct dependency argument types', () => { + const findShip: (Ship[], (Ship) => boolean) => ?Ship = (ships, search) => { + return ships.find(search); + } + const selector = treeSelect( + (state: State) => [ state.ships, 'a', 1, false ], + ([ships, str, num, bool]) => { + // $FlowExpectedError ships should be Ship[] + (ships: boolean); + // $FlowExpectedError bool is boolean + (bool: string); + // $FlowExpectedError str is string + (str: boolean); + // $FlowExpectedError num is number + (num: boolean); + return ships.find(() => true); + } + ); + // $FlowExpectedError should be ?Ship + const bad: ?string = selector({ships: [], selectedUniverses: []}); + const good: ?Ship = selector({ships: [], selectedUniverses: []}); + }) +}); + + diff --git a/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.201.x-/tree-select_v1.x.x.js b/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.201.x-/tree-select_v1.x.x.js new file mode 100644 index 0000000000..1b276d1626 --- /dev/null +++ b/definitions/npm/@automattic/tree-select_v1.x.x/flow_v0.201.x-/tree-select_v1.x.x.js @@ -0,0 +1,84 @@ +declare module '@automattic/tree-select' { + /** + * Generics + * + * S: State - the application state + * D: Dependents - the dependent values returned by the DependentsSelector + * R: Result of Computation + * O: Other parameters that the computation and resulting CachedSelector are provided + */ + + /** + * DependentsSelector is a function that accepts a State (S) object and + * returns an array of values to be used in the Computation as well + * as the values used by the caching/memoization layer. + */ + declare type DependentsSelector = (S, ...O) => D; + + /** + * Function that computes a value based on the dependent values provided + * by the DependentsSelector. It receives the values returned by + * DependentsSelector as its first argument, the rest of the arguments + * given to the computation are the same as the CachedSelector retured + * by treeSelect. + */ + declare type Computation = (D, ...O) => R; + + /** + * The cached selector is the returned function from treeSelect. It should + * have the same signatrue as Computation except it accepts the State as its + * first argument instead of the result of DependentsSelector. The rest of + * the other (O) arguments are the same provided to the Computation. + */ + declare type CachedSelector = (S, ...O) => R; + + /** + * Configuration options for treeSelect. Currently a single key + * of getCacheKey that allows the implementor to calculate the cache + * key for this use of treeSelect. + */ + declare type Options = { /** + * getCachKey is given the dependent arguments and expects a string to + * use to identify the memoized return value + */ + getCacheKey: (...O) => string, ... }; + + /** + * Accepts two functions: + * 1. (S) => D - Accepts state (S) and returns dependents (D) which is a list + * of values that 1) are used to memoize calling the Computation and 2) + * are provided as the first argument to the Computation + * 2. (D, ...O) => R - Accepts the dependents (D) which is the result of the + * DependentsSelector as well as any number of other (O) parameters. + * These same parameters will be used in the returned CachedSelector + * + * Returns function of type: + * + * (S, ...O) => R + * + * The Computation<> is only executed if the dependencies form the first function change + * otherwise the memoized results are returned. + * + * A function that can be used as a selector accepting application state (S) as its + * first argument. It is an identical function signature to the Computation + * except instead of accepting the state (S) and other (O) arguments it accepts the + * dependents (D) from DependentsSelector as its first argument and the other (O) + * as the rest. + * + * Example: + * + * const mySelector: (State, SecondArgType) => number = treeSelect( + * (state) => [state.firstDependency, state.secondDependecy], + * ([firstDepedency, secondDependency], secondArg) => { + * // Do my CPU intensive calculation + * return result; + * } + * ); + */ + declare export default function treeSelect, R, O: Array>( + DependentsSelector, + Computation, + Options | void + ): CachedSelector; +} + diff --git a/definitions/npm/@react-navigation/bottom-tabs_v5.x.x/flow_v0.104.x-/bottom-tabs_v5.x.x.js b/definitions/npm/@react-navigation/bottom-tabs_v5.x.x/flow_v0.104.x-v.200.x/bottom-tabs_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/bottom-tabs_v5.x.x/flow_v0.104.x-/bottom-tabs_v5.x.x.js rename to definitions/npm/@react-navigation/bottom-tabs_v5.x.x/flow_v0.104.x-v.200.x/bottom-tabs_v5.x.x.js diff --git a/definitions/npm/@react-navigation/bottom-tabs_v5.x.x/flow_v0.201.x-/bottom-tabs_v5.x.x.js b/definitions/npm/@react-navigation/bottom-tabs_v5.x.x/flow_v0.201.x-/bottom-tabs_v5.x.x.js new file mode 100644 index 0000000000..64eda742f6 --- /dev/null +++ b/definitions/npm/@react-navigation/bottom-tabs_v5.x.x/flow_v0.201.x-/bottom-tabs_v5.x.x.js @@ -0,0 +1,2100 @@ +declare module '@react-navigation/bottom-tabs' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + /** + * createBottomTabNavigator + */ + + declare export var createBottomTabNavigator: CreateNavigator< + TabNavigationState, + BottomTabOptions, + BottomTabNavigationEventMap, + ExtraBottomTabNavigatorProps, + >; + + /** + * BottomTabBar + */ + + declare export var BottomTabBar: React$ComponentType; + + /** + * BottomTabView + */ + + declare export type BottomTabViewProps = {| + ...BottomTabNavigationConfig, + ...BottomTabNavigationBuilderResult, + |}; + declare export var BottomTabView: React$ComponentType; + +} diff --git a/definitions/npm/@react-navigation/core_v5.x.x/flow_v0.104.x-/core_v5.x.x.js b/definitions/npm/@react-navigation/core_v5.x.x/flow_v0.104.x-v.200.x/core_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/core_v5.x.x/flow_v0.104.x-/core_v5.x.x.js rename to definitions/npm/@react-navigation/core_v5.x.x/flow_v0.104.x-v.200.x/core_v5.x.x.js diff --git a/definitions/npm/@react-navigation/core_v5.x.x/flow_v0.201.x-/core_v5.x.x.js b/definitions/npm/@react-navigation/core_v5.x.x/flow_v0.201.x-/core_v5.x.x.js new file mode 100644 index 0000000000..9ee38a7e1f --- /dev/null +++ b/definitions/npm/@react-navigation/core_v5.x.x/flow_v0.201.x-/core_v5.x.x.js @@ -0,0 +1,2159 @@ +declare module '@react-navigation/core' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + /** + * Actions and routers + */ + + declare export var CommonActions: CommonActionsType; + declare export var StackActions: StackActionsType; + declare export var TabActions: TabActionsType; + declare export var DrawerActions: DrawerActionsType; + + declare export var BaseRouter: RouterFactory< + NavigationState, + CommonAction, + DefaultRouterOptions, + >; + declare export var StackRouter: RouterFactory< + StackNavigationState, + StackAction, + StackRouterOptions, + >; + declare export var TabRouter: RouterFactory< + TabNavigationState, + TabAction, + TabRouterOptions, + >; + declare export var DrawerRouter: RouterFactory< + DrawerNavigationState, + DrawerAction, + DrawerRouterOptions, + >; + + /** + * Navigator utils + */ + + declare export var BaseNavigationContainer: React$AbstractComponent< + BaseNavigationContainerProps, + BaseNavigationContainerInterface, + >; + + declare export var createNavigatorFactory: CreateNavigatorFactory; + + declare export var useNavigationBuilder: UseNavigationBuilder; + + declare export var NavigationHelpersContext: React$Context< + ?NavigationHelpers, + >; + + /** + * Navigation prop / route accessors + */ + + declare export var NavigationContext: React$Context< + ?NavigationProp, + >; + declare export function useNavigation(): NavigationProp; + + declare export var NavigationRouteContext: React$Context>; + declare export function useRoute(): LeafRoute<>; + + declare export function useNavigationState( + selector: NavigationState => T, + ): T; + + /** + * Focus utils + */ + + declare export function useFocusEffect( + effect: () => ?(() => mixed), + ): void; + declare export function useIsFocused(): boolean; + + /** + * State utils + */ + + declare export var getStateFromPath: GetStateFromPath; + + declare export var getPathFromState: GetPathFromState; + + declare export function getActionFromState( + state: PossiblyStaleNavigationState, + ): ?NavigateAction; + + declare export var getFocusedRouteNameFromRoute: GetFocusedRouteNameFromRoute; + +} diff --git a/definitions/npm/@react-navigation/devtools_v5.x.x/flow_v0.104.x-/devtools_v5.x.x.js b/definitions/npm/@react-navigation/devtools_v5.x.x/flow_v0.104.x-v.200.x/devtools_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/devtools_v5.x.x/flow_v0.104.x-/devtools_v5.x.x.js rename to definitions/npm/@react-navigation/devtools_v5.x.x/flow_v0.104.x-v.200.x/devtools_v5.x.x.js diff --git a/definitions/npm/@react-navigation/devtools_v5.x.x/flow_v0.201.x-/devtools_v5.x.x.js b/definitions/npm/@react-navigation/devtools_v5.x.x/flow_v0.201.x-/devtools_v5.x.x.js new file mode 100644 index 0000000000..62bab03dde --- /dev/null +++ b/definitions/npm/@react-navigation/devtools_v5.x.x/flow_v0.201.x-/devtools_v5.x.x.js @@ -0,0 +1,2077 @@ +declare module '@react-navigation/devtools' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + declare export function useReduxDevToolsExtension( + container: { +current: ?React$ElementRef, ... }, + ): void; + +} diff --git a/definitions/npm/@react-navigation/drawer_v5.x.x/flow_v0.104.x-/drawer_v5.x.x.js b/definitions/npm/@react-navigation/drawer_v5.x.x/flow_v0.104.x-v.200.x/drawer_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/drawer_v5.x.x/flow_v0.104.x-/drawer_v5.x.x.js rename to definitions/npm/@react-navigation/drawer_v5.x.x/flow_v0.104.x-v.200.x/drawer_v5.x.x.js diff --git a/definitions/npm/@react-navigation/drawer_v5.x.x/flow_v0.201.x-/drawer_v5.x.x.js b/definitions/npm/@react-navigation/drawer_v5.x.x/flow_v0.201.x-/drawer_v5.x.x.js new file mode 100644 index 0000000000..94e3150878 --- /dev/null +++ b/definitions/npm/@react-navigation/drawer_v5.x.x/flow_v0.201.x-/drawer_v5.x.x.js @@ -0,0 +1,2159 @@ +declare module '@react-navigation/drawer' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + /** + * createDrawerNavigator + */ + + declare export var createDrawerNavigator: CreateNavigator< + DrawerNavigationState, + DrawerOptions, + DrawerNavigationEventMap, + ExtraDrawerNavigatorProps, + >; + + /** + * DrawerView + */ + + declare export type DrawerViewProps = {| + ...DrawerNavigationConfig, + ...DrawerNavigationBuilderResult, + |}; + declare export var DrawerView: React$ComponentType; + + /** + * DrawerItem + */ + + declare export type DrawerItemProps = {| + +label: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + +onPress: () => mixed, + +icon?: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + +to?: string, + +focused?: boolean, + +activeTintColor?: string, + +inactiveTintColor?: string, + +activeBackgroundColor?: string, + +inactiveBackgroundColor?: string, + +labelStyle?: TextStyleProp, + +style?: ViewStyleProp, + |}; + declare export var DrawerItem: React$ComponentType; + + /** + * DrawerItemList + */ + + declare export type DrawerItemListProps = {| + ...DrawerItemListBaseOptions, + ...DrawerNavigationBuilderResult, + |}; + declare export var DrawerItemList: React$ComponentType; + + /** + * DrawerContent + */ + + declare export var DrawerContent: React$ComponentType; + + /** + * DrawerContentScrollView + */ + + declare export var DrawerContentScrollView: React$ComponentType<{ + +children: React$Node, + ... + }>; + + /** + * DrawerGestureContext + */ + + declare type GestureHandlerRef = React$Ref< + React$ComponentType, + >; + declare export var DrawerGestureContext: React$Context; + + /** + * useIsDrawerOpen + */ + + declare export function useIsDrawerOpen(): boolean; + +} diff --git a/definitions/npm/@react-navigation/material-bottom-tabs_v5.x.x/flow_v0.104.x-/material-bottom-tabs_v5.x.x.js b/definitions/npm/@react-navigation/material-bottom-tabs_v5.x.x/flow_v0.104.x-v.200.x/material-bottom-tabs_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/material-bottom-tabs_v5.x.x/flow_v0.104.x-/material-bottom-tabs_v5.x.x.js rename to definitions/npm/@react-navigation/material-bottom-tabs_v5.x.x/flow_v0.104.x-v.200.x/material-bottom-tabs_v5.x.x.js diff --git a/definitions/npm/@react-navigation/material-bottom-tabs_v5.x.x/flow_v0.201.x-/material-bottom-tabs_v5.x.x.js b/definitions/npm/@react-navigation/material-bottom-tabs_v5.x.x/flow_v0.201.x-/material-bottom-tabs_v5.x.x.js new file mode 100644 index 0000000000..fd3f1f23c2 --- /dev/null +++ b/definitions/npm/@react-navigation/material-bottom-tabs_v5.x.x/flow_v0.201.x-/material-bottom-tabs_v5.x.x.js @@ -0,0 +1,2102 @@ +declare module '@react-navigation/material-bottom-tabs' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + /** + * createMaterialBottomTabNavigator + */ + + declare export var createMaterialBottomTabNavigator: CreateNavigator< + TabNavigationState, + MaterialBottomTabOptions, + MaterialBottomTabNavigationEventMap, + ExtraMaterialBottomTabNavigatorProps, + >; + + /** + * MaterialBottomTabView + */ + + declare export type MaterialBottomTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + declare export type MaterialBottomTabViewProps = {| + ...MaterialBottomTabNavigationConfig, + +state: TabNavigationState, + +navigation: MaterialBottomTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialBottomTabDescriptor |}, + |}; + declare export var MaterialBottomTabView: React$ComponentType< + MaterialBottomTabViewProps, + >; + +} diff --git a/definitions/npm/@react-navigation/material-top-tabs_v5.x.x/flow_v0.104.x-/material-top-tabs_v5.x.x.js b/definitions/npm/@react-navigation/material-top-tabs_v5.x.x/flow_v0.104.x-v.200.x/material-top-tabs_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/material-top-tabs_v5.x.x/flow_v0.104.x-/material-top-tabs_v5.x.x.js rename to definitions/npm/@react-navigation/material-top-tabs_v5.x.x/flow_v0.104.x-v.200.x/material-top-tabs_v5.x.x.js diff --git a/definitions/npm/@react-navigation/material-top-tabs_v5.x.x/flow_v0.201.x-/material-top-tabs_v5.x.x.js b/definitions/npm/@react-navigation/material-top-tabs_v5.x.x/flow_v0.201.x-/material-top-tabs_v5.x.x.js new file mode 100644 index 0000000000..699e08b213 --- /dev/null +++ b/definitions/npm/@react-navigation/material-top-tabs_v5.x.x/flow_v0.201.x-/material-top-tabs_v5.x.x.js @@ -0,0 +1,2104 @@ +declare module '@react-navigation/material-top-tabs' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + /** + * createMaterialTopTabNavigator + */ + + declare export var createMaterialTopTabNavigator: CreateNavigator< + TabNavigationState, + MaterialTopTabOptions, + MaterialTopTabNavigationEventMap, + ExtraMaterialTopTabNavigatorProps, + >; + + /** + * MaterialTopTabView + */ + + declare export type MaterialTopTabViewProps = {| + ...MaterialTopTabNavigationConfig, + ...MaterialTopTabNavigationBuilderResult, + |}; + declare export var MaterialTopTabView: React$ComponentType< + MaterialTopTabViewProps, + >; + + /** + * MaterialTopTabBar + */ + + declare export var MaterialTopTabBar: React$ComponentType< + MaterialTopTabBarProps, + >; + +} diff --git a/definitions/npm/@react-navigation/native_v5.x.x/flow_v0.104.x-/native_v5.x.x.js b/definitions/npm/@react-navigation/native_v5.x.x/flow_v0.104.x-v.200.x/native_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/native_v5.x.x/flow_v0.104.x-/native_v5.x.x.js rename to definitions/npm/@react-navigation/native_v5.x.x/flow_v0.104.x-v.200.x/native_v5.x.x.js diff --git a/definitions/npm/@react-navigation/native_v5.x.x/flow_v0.201.x-/native_v5.x.x.js b/definitions/npm/@react-navigation/native_v5.x.x/flow_v0.201.x-/native_v5.x.x.js new file mode 100644 index 0000000000..b8ba5b2f55 --- /dev/null +++ b/definitions/npm/@react-navigation/native_v5.x.x/flow_v0.201.x-/native_v5.x.x.js @@ -0,0 +1,2241 @@ +declare module '@react-navigation/native' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + /** + * Actions and routers + */ + + declare export var CommonActions: CommonActionsType; + declare export var StackActions: StackActionsType; + declare export var TabActions: TabActionsType; + declare export var DrawerActions: DrawerActionsType; + + declare export var BaseRouter: RouterFactory< + NavigationState, + CommonAction, + DefaultRouterOptions, + >; + declare export var StackRouter: RouterFactory< + StackNavigationState, + StackAction, + StackRouterOptions, + >; + declare export var TabRouter: RouterFactory< + TabNavigationState, + TabAction, + TabRouterOptions, + >; + declare export var DrawerRouter: RouterFactory< + DrawerNavigationState, + DrawerAction, + DrawerRouterOptions, + >; + + /** + * Navigator utils + */ + + declare export var BaseNavigationContainer: React$AbstractComponent< + BaseNavigationContainerProps, + BaseNavigationContainerInterface, + >; + + declare export var createNavigatorFactory: CreateNavigatorFactory; + + declare export var useNavigationBuilder: UseNavigationBuilder; + + declare export var NavigationHelpersContext: React$Context< + ?NavigationHelpers, + >; + + /** + * Navigation prop / route accessors + */ + + declare export var NavigationContext: React$Context< + ?NavigationProp, + >; + declare export function useNavigation(): NavigationProp; + + declare export var NavigationRouteContext: React$Context>; + declare export function useRoute(): LeafRoute<>; + + declare export function useNavigationState( + selector: NavigationState => T, + ): T; + + /** + * Focus utils + */ + + declare export function useFocusEffect( + effect: () => ?(() => mixed), + ): void; + declare export function useIsFocused(): boolean; + + /** + * State utils + */ + + declare export var getStateFromPath: GetStateFromPath; + + declare export var getPathFromState: GetPathFromState; + + declare export function getActionFromState( + state: PossiblyStaleNavigationState, + ): ?NavigateAction; + + declare export var getFocusedRouteNameFromRoute: GetFocusedRouteNameFromRoute; + + /** + * useScrollToTop + */ + + declare type ScrollToOptions = { y?: number, animated?: boolean, ... }; + declare type ScrollToOffsetOptions = { + offset: number, + animated?: boolean, + ... + }; + declare type ScrollableView = + | { scrollToTop(): void, ... } + | { scrollTo(options: ScrollToOptions): void, ... } + | { scrollToOffset(options: ScrollToOffsetOptions): void, ... } + | { scrollResponderScrollTo(options: ScrollToOptions): void, ... }; + declare type ScrollableWrapper = + | { getScrollResponder(): React$Node, ... } + | { getNode(): ScrollableView, ... } + | ScrollableView; + declare export function useScrollToTop( + ref: { +current: ?ScrollableWrapper, ... }, + ): void; + + /** + * Themes + */ + + declare export var DefaultTheme: Theme & { +dark: false, ... }; + declare export var DarkTheme: Theme & { +dark: true, ... }; + declare export function useTheme(): Theme; + declare export var ThemeProvider: React$ComponentType<{| + +value: Theme, + +children: React$Node, + |}>; + + /** + * Linking + */ + + declare export var Link: React$ComponentType<{ + +to: string, + +action?: GenericNavigationAction, + +target?: string, + +children: React$Node, + ... + }>; + + declare export function useLinking( + container: { +current: ?React$ElementRef, ... }, + options: LinkingOptions, + ): {| +getInitialState: () => Promise |}; + + declare export function useLinkTo(): (path: string) => void; + + declare export function useLinkProps(props: {| + +to: To, + +action?: GenericNavigationAction, + |}): {| + +href: To, + +accessibilityRole: 'link', + +onPress: (MouseEvent | PressEvent) => void, + |}; + + declare export function useLinkBuilder(): ( + name: string, + params?: ScreenParams, + ) => ?string; + + /** + * NavigationContainer + */ + + declare export var NavigationContainer: NavigationContainerType; + + /** + * useBackButton + */ + + declare export function useBackButton( + container: { +current: ?React$ElementRef, ... }, + ): void; + +} diff --git a/definitions/npm/@react-navigation/stack_v5.x.x/flow_v0.104.x-/stack_v5.x.x.js b/definitions/npm/@react-navigation/stack_v5.x.x/flow_v0.104.x-v.200.x/stack_v5.x.x.js similarity index 100% rename from definitions/npm/@react-navigation/stack_v5.x.x/flow_v0.104.x-/stack_v5.x.x.js rename to definitions/npm/@react-navigation/stack_v5.x.x/flow_v0.104.x-v.200.x/stack_v5.x.x.js diff --git a/definitions/npm/@react-navigation/stack_v5.x.x/flow_v0.201.x-/stack_v5.x.x.js b/definitions/npm/@react-navigation/stack_v5.x.x/flow_v0.201.x-/stack_v5.x.x.js new file mode 100644 index 0000000000..22d96b2d1d --- /dev/null +++ b/definitions/npm/@react-navigation/stack_v5.x.x/flow_v0.201.x-/stack_v5.x.x.js @@ -0,0 +1,2195 @@ +declare module '@react-navigation/stack' { + + //--------------------------------------------------------------------------- + // SECTION 1: IDENTICAL TYPE DEFINITIONS + // This section is identical across all React Navigation libdefs and contains + // shared definitions. We wish we could make it DRY and import from a shared + // definition, but that isn't yet possible. + //--------------------------------------------------------------------------- + + /** + * We start with some definitions that we have copy-pasted from React Native + * source files. + */ + + // This is a bastardization of the true StyleObj type located in + // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't + // import that here, and it's too lengthy (and consequently too brittle) to + // copy-paste here either. + declare type StyleObj = + | null + | void + | number + | false + | '' + | $ReadOnlyArray + | { [name: string]: any, ... }; + declare type ViewStyleProp = StyleObj; + declare type TextStyleProp = StyleObj; + declare type AnimatedViewStyleProp = StyleObj; + declare type AnimatedTextStyleProp = StyleObj; + + // Vaguely copied from + // react-native/Libraries/Animated/src/animations/Animation.js + declare type EndResult = { finished: boolean, ... }; + declare type EndCallback = (result: EndResult) => void; + declare interface Animation { + start( + fromValue: number, + onUpdate: (value: number) => void, + onEnd: ?EndCallback, + previousAnimation: ?Animation, + animatedValue: AnimatedValue, + ): void; + stop(): void; + } + declare type AnimationConfig = { + isInteraction?: boolean, + useNativeDriver: boolean, + onComplete?: ?EndCallback, + iterations?: number, + ... + }; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js + declare interface AnimatedTracking { + constructor( + value: AnimatedValue, + parent: any, + animationClass: any, + animationConfig: Object, + callback?: ?EndCallback, + ): void; + update(): void; + } + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedValue.js + declare type ValueListenerCallback = (state: { value: number, ... }) => void; + declare interface AnimatedValue { + constructor(value: number): void; + setValue(value: number): void; + setOffset(offset: number): void; + flattenOffset(): void; + extractOffset(): void; + addListener(callback: ValueListenerCallback): string; + removeListener(id: string): void; + removeAllListeners(): void; + stopAnimation(callback?: ?(value: number) => void): void; + resetAnimation(callback?: ?(value: number) => void): void; + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + animate(animation: Animation, callback: ?EndCallback): void; + stopTracking(): void; + track(tracking: AnimatedTracking): void; + } + + // Copied from + // react-native/Libraries/Animated/src/animations/TimingAnimation.js + declare type TimingAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + easing?: (value: number) => number, + duration?: number, + delay?: number, + ... + }; + + // Copied from + // react-native/Libraries/Animated/src/animations/SpringAnimation.js + declare type SpringAnimationConfigSingle = AnimationConfig & { + toValue: number | AnimatedValue, + overshootClamping?: boolean, + restDisplacementThreshold?: number, + restSpeedThreshold?: number, + velocity?: number, + bounciness?: number, + speed?: number, + tension?: number, + friction?: number, + stiffness?: number, + damping?: number, + mass?: number, + delay?: number, + ... + }; + + // Copied from react-native/Libraries/Types/CoreEventTypes.js + declare type SyntheticEvent = $ReadOnly<{| + bubbles: ?boolean, + cancelable: ?boolean, + currentTarget: number, + defaultPrevented: ?boolean, + dispatchConfig: $ReadOnly<{| + registrationName: string, + |}>, + eventPhase: ?number, + preventDefault: () => void, + isDefaultPrevented: () => boolean, + stopPropagation: () => void, + isPropagationStopped: () => boolean, + isTrusted: ?boolean, + nativeEvent: T, + persist: () => void, + target: ?number, + timeStamp: number, + type: ?string, + |}>; + declare type Layout = $ReadOnly<{| + x: number, + y: number, + width: number, + height: number, + |}>; + declare type LayoutEvent = SyntheticEvent< + $ReadOnly<{| + layout: Layout, + |}>, + >; + declare type BlurEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type FocusEvent = SyntheticEvent< + $ReadOnly<{| + target: number, + |}>, + >; + declare type ResponderSyntheticEvent = $ReadOnly<{| + ...SyntheticEvent, + touchHistory: $ReadOnly<{| + indexOfSingleActiveTouch: number, + mostRecentTimeStamp: number, + numberActiveTouches: number, + touchBank: $ReadOnlyArray< + $ReadOnly<{| + touchActive: boolean, + startPageX: number, + startPageY: number, + startTimeStamp: number, + currentPageX: number, + currentPageY: number, + currentTimeStamp: number, + previousPageX: number, + previousPageY: number, + previousTimeStamp: number, + |}>, + >, + |}>, + |}>; + declare type PressEvent = ResponderSyntheticEvent< + $ReadOnly<{| + changedTouches: $ReadOnlyArray<$PropertyType>, + force: number, + identifier: number, + locationX: number, + locationY: number, + pageX: number, + pageY: number, + target: ?number, + timestamp: number, + touches: $ReadOnlyArray<$PropertyType>, + |}>, + >; + + // Vaguely copied from + // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js + declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + declare type InterpolationConfigType = { + inputRange: Array, + outputRange: Array | Array, + easing?: (input: number) => number, + extrapolate?: ExtrapolateType, + extrapolateLeft?: ExtrapolateType, + extrapolateRight?: ExtrapolateType, + ... + }; + declare interface AnimatedInterpolation { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + // Copied from react-native/Libraries/Components/View/ViewAccessibility.js + declare type AccessibilityRole = + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar'; + declare type AccessibilityActionInfo = $ReadOnly<{ + name: string, + label?: string, + ... + }>; + declare type AccessibilityActionEvent = SyntheticEvent< + $ReadOnly<{actionName: string, ...}>, + >; + declare type AccessibilityState = { + disabled?: boolean, + selected?: boolean, + checked?: ?boolean | 'mixed', + busy?: boolean, + expanded?: boolean, + ... + }; + declare type AccessibilityValue = $ReadOnly<{| + min?: number, + max?: number, + now?: number, + text?: string, + |}>; + + // Copied from + // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js + declare type Stringish = string; + declare type EdgeInsetsProp = $ReadOnly>; + declare type TouchableWithoutFeedbackProps = $ReadOnly<{| + accessibilityActions?: ?$ReadOnlyArray, + accessibilityElementsHidden?: ?boolean, + accessibilityHint?: ?Stringish, + accessibilityIgnoresInvertColors?: ?boolean, + accessibilityLabel?: ?Stringish, + accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), + accessibilityRole?: ?AccessibilityRole, + accessibilityState?: ?AccessibilityState, + accessibilityValue?: ?AccessibilityValue, + accessibilityViewIsModal?: ?boolean, + accessible?: ?boolean, + children?: ?React$Node, + delayLongPress?: ?number, + delayPressIn?: ?number, + delayPressOut?: ?number, + disabled?: ?boolean, + focusable?: ?boolean, + hitSlop?: ?EdgeInsetsProp, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onBlur?: ?(event: BlurEvent) => mixed, + onFocus?: ?(event: FocusEvent) => mixed, + onLayout?: ?(event: LayoutEvent) => mixed, + onLongPress?: ?(event: PressEvent) => mixed, + onPress?: ?(event: PressEvent) => mixed, + onPressIn?: ?(event: PressEvent) => mixed, + onPressOut?: ?(event: PressEvent) => mixed, + pressRetentionOffset?: ?EdgeInsetsProp, + rejectResponderTermination?: ?boolean, + testID?: ?string, + touchSoundDisabled?: ?boolean, + |}>; + + // Copied from react-native/Libraries/Image/ImageSource.js + declare type ImageURISource = $ReadOnly<{ + uri?: ?string, + bundle?: ?string, + method?: ?string, + headers?: ?Object, + body?: ?string, + cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + width?: ?number, + height?: ?number, + scale?: ?number, + ... + }>; + + /** + * The following is copied from react-native-gesture-handler's libdef + */ + + declare type StateUndetermined = 0; + declare type StateFailed = 1; + declare type StateBegan = 2; + declare type StateCancelled = 3; + declare type StateActive = 4; + declare type StateEnd = 5; + + declare type GestureHandlerState = + | StateUndetermined + | StateFailed + | StateBegan + | StateCancelled + | StateActive + | StateEnd; + + declare type $SyntheticEvent = { + +nativeEvent: $ReadOnly<$Exact>, + ... + }; + + declare type $Event = $SyntheticEvent<{ + handlerTag: number, + numberOfPointers: number, + state: GestureHandlerState, + oldState: GestureHandlerState, + ...$Exact, + ... + }>; + + declare type $EventHandlers = {| + onGestureEvent?: ($Event) => mixed, + onHandlerStateChange?: ($Event) => mixed, + onBegan?: ($Event) => mixed, + onFailed?: ($Event) => mixed, + onCancelled?: ($Event) => mixed, + onActivated?: ($Event) => mixed, + onEnded?: ($Event) => mixed, + |}; + + declare type HitSlop = + | number + | {| + left?: number, + top?: number, + right?: number, + bottom?: number, + vertical?: number, + horizontal?: number, + width?: number, + height?: number, + |} + | {| + width: number, + left: number, + |} + | {| + width: number, + right: number, + |} + | {| + height: number, + top: number, + |} + | {| + height: number, + bottom: number, + |}; + + declare type $GestureHandlerProps< + AdditionalProps: {...}, + ExtraEventsProps: {...} + > = $ReadOnly<{| + ...$Exact, + ...$EventHandlers, + id?: string, + enabled?: boolean, + waitFor?: React$Ref | Array>, + simultaneousHandlers?: React$Ref | Array>, + shouldCancelWhenOutside?: boolean, + minPointers?: number, + hitSlop?: HitSlop, + children?: React$Node, + |}>; + + declare type PanGestureHandlerProps = $GestureHandlerProps< + { + activeOffsetY?: number | [number, number], + activeOffsetX?: number | [number, number], + failOffsetY?: number | [number, number], + failOffsetX?: number | [number, number], + minDist?: number, + minVelocity?: number, + minVelocityX?: number, + minVelocityY?: number, + minPointers?: number, + maxPointers?: number, + avgTouches?: boolean, + ... + }, + { + x: number, + y: number, + absoluteX: number, + absoluteY: number, + translationX: number, + translationY: number, + velocityX: number, + velocityY: number, + ... + } + >; + + /** + * MAGIC + */ + + declare type $If = $Call< + ((true, Then, Else) => Then) & ((false, Then, Else) => Else), + Test, + Then, + Else, + >; + declare type $IsA = $Call< + (Y => true) & (mixed => false), + X, + >; + declare type $IsUndefined = $IsA; + + declare type Partial = $ReadOnly<$Rest>; + + /** + * Actions, state, etc. + */ + + declare export type ScreenParams = { +[key: string]: mixed, ... }; + + declare export type BackAction = {| + +type: 'GO_BACK', + +source?: string, + +target?: string, + |}; + declare export type NavigateAction = {| + +type: 'NAVIGATE', + +payload: + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type ResetAction = {| + +type: 'RESET', + +payload: StaleNavigationState, + +source?: string, + +target?: string, + |}; + declare export type SetParamsAction = {| + +type: 'SET_PARAMS', + +payload: {| +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type CommonAction = + | BackAction + | NavigateAction + | ResetAction + | SetParamsAction; + + declare type NavigateActionCreator = {| + (routeName: string, params?: ScreenParams): NavigateAction, + ( + | {| +key: string, +params?: ScreenParams |} + | {| +name: string, +key?: string, +params?: ScreenParams |}, + ): NavigateAction, + |}; + declare export type CommonActionsType = {| + +navigate: NavigateActionCreator, + +goBack: () => BackAction, + +reset: (state: PossiblyStaleNavigationState) => ResetAction, + +setParams: (params: ScreenParams) => SetParamsAction, + |}; + + declare export type GenericNavigationAction = {| + +type: string, + +payload?: { +[key: string]: mixed, ... }, + +source?: string, + +target?: string, + |}; + + declare export type LeafRoute = {| + +key: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StateRoute = {| + ...LeafRoute, + +state: NavigationState | StaleNavigationState, + |}; + declare export type Route = + | LeafRoute + | StateRoute; + + declare export type NavigationState = {| + +key: string, + +index: number, + +routeNames: $ReadOnlyArray, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type: string, + +stale: false, + |}; + + declare export type StaleLeafRoute = {| + +key?: string, + +name: RouteName, + +params?: ScreenParams, + |}; + declare export type StaleStateRoute = {| + ...StaleLeafRoute, + +state: StaleNavigationState, + |}; + declare export type StaleRoute = + | StaleLeafRoute + | StaleStateRoute; + declare export type StaleNavigationState = {| + // It's possible to pass React Nav a StaleNavigationState with an undefined + // index, but React Nav will always return one with the index set. This is + // the same as for the type property below, but in the case of index we tend + // to rely on it being set more... + +index: number, + +history?: $ReadOnlyArray, + +routes: $ReadOnlyArray>, + +type?: string, + +stale?: true, + |}; + + declare export type PossiblyStaleNavigationState = + | NavigationState + | StaleNavigationState; + declare export type PossiblyStaleRoute = + | Route + | StaleRoute; + + /** + * Routers + */ + + declare type ActionCreators< + State: NavigationState, + Action: GenericNavigationAction, + > = { + +[key: string]: (...args: any) => (Action | State => Action), + ... + }; + + declare export type DefaultRouterOptions = { + +initialRouteName?: string, + ... + }; + + declare export type RouterFactory< + State: NavigationState, + Action: GenericNavigationAction, + RouterOptions: DefaultRouterOptions, + > = (options: RouterOptions) => Router; + + declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; + + declare export type RouterConfigOptions = {| + +routeNames: $ReadOnlyArray, + +routeParamList: ParamListBase, + |}; + + declare export type Router< + State: NavigationState, + Action: GenericNavigationAction, + > = {| + +type: $PropertyType, + +getInitialState: (options: RouterConfigOptions) => State, + +getRehydratedState: ( + partialState: PossiblyStaleNavigationState, + options: RouterConfigOptions, + ) => State, + +getStateForRouteNamesChange: ( + state: State, + options: RouterConfigOptions, + ) => State, + +getStateForRouteFocus: (state: State, key: string) => State, + +getStateForAction: ( + state: State, + action: Action, + options: RouterConfigOptions, + ) => ?PossiblyStaleNavigationState; + +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, + +actionCreators?: ActionCreators, + |}; + + /** + * Stack actions and router + */ + + declare export type StackNavigationState = {| + ...NavigationState, + +type: 'stack', + |}; + + declare export type ReplaceAction = {| + +type: 'REPLACE', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PushAction = {| + +type: 'PUSH', + +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type PopAction = {| + +type: 'POP', + +payload: {| +count: number |}, + +source?: string, + +target?: string, + |}; + declare export type PopToTopAction = {| + +type: 'POP_TO_TOP', + +source?: string, + +target?: string, + |}; + declare export type StackAction = + | CommonAction + | ReplaceAction + | PushAction + | PopAction + | PopToTopAction; + + declare export type StackActionsType = {| + +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, + +push: (routeName: string, params?: ScreenParams) => PushAction, + +pop: (count?: number) => PopAction, + +popToTop: () => PopToTopAction, + |}; + + declare export type StackRouterOptions = $Exact; + + /** + * Tab actions and router + */ + + declare export type TabNavigationState = {| + ...NavigationState, + +type: 'tab', + +history: $ReadOnlyArray<{| type: 'route', key: string |}>, + |}; + + declare export type JumpToAction = {| + +type: 'JUMP_TO', + +payload: {| +name: string, +params?: ScreenParams |}, + +source?: string, + +target?: string, + |}; + declare export type TabAction = + | CommonAction + | JumpToAction; + + declare export type TabActionsType = {| + +jumpTo: string => JumpToAction, + |}; + + declare export type TabRouterOptions = {| + ...$Exact, + +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', + |}; + + /** + * Drawer actions and router + */ + + declare type DrawerHistoryEntry = + | {| +type: 'route', +key: string |} + | {| +type: 'drawer' |}; + declare export type DrawerNavigationState = {| + ...NavigationState, + +type: 'drawer', + +history: $ReadOnlyArray, + |}; + + declare export type OpenDrawerAction = {| + +type: 'OPEN_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type CloseDrawerAction = {| + +type: 'CLOSE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type ToggleDrawerAction = {| + +type: 'TOGGLE_DRAWER', + +source?: string, + +target?: string, + |}; + declare export type DrawerAction = + | TabAction + | OpenDrawerAction + | CloseDrawerAction + | ToggleDrawerAction; + + declare export type DrawerActionsType = {| + ...TabActionsType, + +openDrawer: () => OpenDrawerAction, + +closeDrawer: () => CloseDrawerAction, + +toggleDrawer: () => ToggleDrawerAction, + |}; + + declare export type DrawerRouterOptions = {| + ...TabRouterOptions, + +openByDefault?: boolean, + |}; + + /** + * Events + */ + + declare export type EventMapBase = { + +[name: string]: {| + +data?: mixed, + +canPreventDefault?: boolean, + |}, + ... + }; + declare type EventPreventDefaultProperties = $If< + Test, + {| +defaultPrevented: boolean, +preventDefault: () => void |}, + {| |}, + >; + declare type EventDataProperties = $If< + $IsUndefined, + {| |}, + {| +data: Data |}, + >; + declare type EventArg< + EventName: string, + CanPreventDefault: ?boolean = false, + Data = void, + > = {| + ...EventPreventDefaultProperties, + ...EventDataProperties, + +type: EventName, + +target?: string, + |}; + declare type GlobalEventMap = {| + +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, + |}; + declare type EventMapCore = {| + ...GlobalEventMap, + +focus: {| +data: void, +canPreventDefault: false |}, + +blur: {| +data: void, +canPreventDefault: false |}, + +beforeRemove: {| + +data: {| +action: GenericNavigationAction |}, + +canPreventDefault: true, + |}, + |}; + declare type EventListenerCallback< + EventName: string, + State: PossiblyStaleNavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = (e: EventArg< + EventName, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'canPreventDefault', + >, + $PropertyType< + $ElementType< + {| ...EventMap, ...EventMapCore |}, + EventName, + >, + 'data', + >, + >) => mixed; + + /** + * Navigation prop + */ + + declare export type SimpleNavigate = + >( + routeName: DestinationRouteName, + params: $ElementType, + ) => void; + + declare export type Navigate = + & SimpleNavigate + & >( + route: + | {| + +key: string, + +params?: $ElementType, + |} + | {| + +name: DestinationRouteName, + +key?: string, + +params?: $ElementType, + |}, + ) => void; + + declare type NavigationHelpers< + ParamList: ParamListBase, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + EventMap: EventMapBase = EventMapCore, + > = { + +navigate: Navigate, + +dispatch: ( + action: + | GenericNavigationAction + | (State => GenericNavigationAction), + ) => void, + +reset: PossiblyStaleNavigationState => void, + +goBack: () => void, + +isFocused: () => boolean, + +canGoBack: () => boolean, + +dangerouslyGetParent: >() => ?Parent, + +dangerouslyGetState: () => NavigationState, + +addListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => () => void, + +removeListener: |}, + >>( + name: EventName, + callback: EventListenerCallback, + ) => void, + ... + }; + + declare export type NavigationProp< + ParamList: ParamListBase, + RouteName: $Keys = $Keys, + State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = { + ...$Exact>, + +setOptions: (options: Partial) => void, + +setParams: ( + params: $If< + $IsUndefined<$ElementType>, + empty, + Partial<$NonMaybeType<$ElementType>>, + >, + ) => void, + ... + }; + + /** + * CreateNavigator + */ + + declare export type RouteProp< + ParamList: ParamListBase, + RouteName: $Keys, + > = {| + ...LeafRoute, + +params: $ElementType, + |}; + + declare export type ScreenListeners< + State: NavigationState = NavigationState, + EventMap: EventMapBase = EventMapCore, + > = $ObjMapi< + {| [name: $Keys]: empty |}, + >(K, empty) => EventListenerCallback, + >; + + declare type BaseScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = {| + +name: RouteName, + +options?: + | ScreenOptions + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenOptions, + +listeners?: + | ScreenListeners + | ({| + route: RouteProp, + navigation: NavProp, + |}) => ScreenListeners, + +initialParams?: Partial<$ElementType>, + |}; + + declare export type ScreenProps< + ParamList: ParamListBase, + NavProp, + RouteName: $Keys = $Keys, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +component: React$ComponentType<{| + route: RouteProp, + navigation: NavProp, + |}>, + |} + | {| + ...BaseScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >, + +children: ({| + route: RouteProp, + navigation: NavProp, + |}) => React$Node, + |}; + + declare export type ScreenComponent< + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + State: NavigationState = NavigationState, + ScreenOptions: {...} = {...}, + EventMap: EventMapBase = EventMapCore, + > = < + RouteName: $Keys, + NavProp: NavigationProp< + GlobalParamList, + RouteName, + State, + ScreenOptions, + EventMap, + >, + >(props: ScreenProps< + ParamList, + NavProp, + RouteName, + State, + ScreenOptions, + EventMap, + >) => React$Node; + + declare type ScreenOptionsProp = {| + +screenOptions?: + | ScreenOptions + | ({| route: LeafRoute<>, navigation: NavProp |}) => ScreenOptions, + |}; + declare export type ExtraNavigatorPropsBase = { + ...$Exact, + +children?: React$Node, + ... + }; + declare export type NavigatorPropsBase = { + ...$Exact, + ...ScreenOptionsProp, + ... + }; + + declare export type CreateNavigator< + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + > = < + GlobalParamList: ParamListBase, + ParamList: ParamListBase, + NavProp: NavigationHelpers< + GlobalParamList, + State, + EventMap, + >, + >() => {| + +Screen: ScreenComponent< + GlobalParamList, + ParamList, + State, + ScreenOptions, + EventMap, + >, + +Navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + |}; + + declare export type CreateNavigatorFactory = < + State: NavigationState, + ScreenOptions: {...}, + EventMap: EventMapBase, + NavProp: NavigationHelpers< + ParamListBase, + State, + EventMap, + >, + ExtraNavigatorProps: ExtraNavigatorPropsBase, + >( + navigator: React$ComponentType<{| + ...$Exact, + ...ScreenOptionsProp, + |}>, + ) => CreateNavigator; + + /** + * useNavigationBuilder + */ + + declare export type Descriptor< + NavProp, + ScreenOptions: {...} = {...}, + > = {| + +render: () => React$Node, + +options: $ReadOnly, + +navigation: NavProp, + |}; + + declare export type UseNavigationBuilder = < + State: NavigationState, + Action: GenericNavigationAction, + ScreenOptions: {...}, + RouterOptions: DefaultRouterOptions, + NavProp, + >( + routerFactory: RouterFactory, + options: {| + ...$Exact, + ...ScreenOptionsProp, + +children?: React$Node, + |}, + ) => {| + +state: State, + +descriptors: {| +[key: string]: Descriptor |}, + +navigation: NavProp, + |}; + + /** + * EdgeInsets + */ + + declare type EdgeInsets = {| + +top: number, + +right: number, + +bottom: number, + +left: number, + |}; + + /** + * TransitionPreset + */ + + declare export type TransitionSpec = + | {| + animation: 'spring', + config: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |} + | {| + animation: 'timing', + config: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, ... }, + >, + |}; + + declare export type StackCardInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +index: number, + +closing: AnimatedInterpolation, + +swiping: AnimatedInterpolation, + +inverted: AnimatedInterpolation, + +layouts: {| + +screen: {| +width: number, +height: number |}, + |}, + +insets: EdgeInsets, + |}; + declare export type StackCardInterpolatedStyle = {| + containerStyle?: AnimatedViewStyleProp, + cardStyle?: AnimatedViewStyleProp, + overlayStyle?: AnimatedViewStyleProp, + shadowStyle?: AnimatedViewStyleProp, + |}; + declare export type StackCardStyleInterpolator = ( + props: StackCardInterpolationProps, + ) => StackCardInterpolatedStyle; + + declare export type StackHeaderInterpolationProps = {| + +current: {| + +progress: AnimatedInterpolation, + |}, + +next?: {| + +progress: AnimatedInterpolation, + |}, + +layouts: {| + +header: {| +width: number, +height: number |}, + +screen: {| +width: number, +height: number |}, + +title?: {| +width: number, +height: number |}, + +leftLabel?: {| +width: number, +height: number |}, + |}, + |}; + declare export type StackHeaderInterpolatedStyle = {| + leftLabelStyle?: AnimatedViewStyleProp, + leftButtonStyle?: AnimatedViewStyleProp, + rightButtonStyle?: AnimatedViewStyleProp, + titleStyle?: AnimatedViewStyleProp, + backgroundStyle?: AnimatedViewStyleProp, + |}; + declare export type StackHeaderStyleInterpolator = ( + props: StackHeaderInterpolationProps, + ) => StackHeaderInterpolatedStyle; + + declare type GestureDirection = + | 'horizontal' + | 'horizontal-inverted' + | 'vertical' + | 'vertical-inverted'; + + declare export type TransitionPreset = {| + +gestureDirection: GestureDirection, + +transitionSpec: {| + +open: TransitionSpec, + +close: TransitionSpec, + |}, + +cardStyleInterpolator: StackCardStyleInterpolator, + +headerStyleInterpolator: StackHeaderStyleInterpolator, + |}; + + /** + * Stack options + */ + + declare export type StackDescriptor = Descriptor< + StackNavigationProp<>, + StackOptions, + >; + + declare type Scene = {| + +route: T, + +descriptor: StackDescriptor, + +progress: {| + +current: AnimatedInterpolation, + +next?: AnimatedInterpolation, + +previous?: AnimatedInterpolation, + |}, + |}; + + declare export type StackHeaderProps = {| + +mode: 'float' | 'screen', + +layout: {| +width: number, +height: number |}, + +insets: EdgeInsets, + +scene: Scene>, + +previous?: Scene>, + +navigation: StackNavigationProp, + +styleInterpolator: StackHeaderStyleInterpolator, + |}; + + declare export type StackHeaderLeftButtonProps = Partial<{| + +onPress: (() => void), + +pressColorAndroid: string; + +backImage: (props: {| tintColor: string |}) => React$Node, + +tintColor: string, + +label: string, + +truncatedLabel: string, + +labelVisible: boolean, + +labelStyle: AnimatedTextStyleProp, + +allowFontScaling: boolean, + +onLabelLayout: LayoutEvent => void, + +screenLayout: {| +width: number, +height: number |}, + +titleLayout: {| +width: number, +height: number |}, + +canGoBack: boolean, + |}>; + + declare type StackHeaderTitleInputBase = { + +onLayout: LayoutEvent => void, + +children: string, + +allowFontScaling: ?boolean, + +tintColor: ?string, + +style: ?AnimatedTextStyleProp, + ... + }; + + declare export type StackHeaderTitleInputProps = + $Exact; + + declare export type StackOptions = Partial<{| + +title: string, + +header: StackHeaderProps => React$Node, + +headerShown: boolean, + +cardShadowEnabled: boolean, + +cardOverlayEnabled: boolean, + +cardOverlay: {| style: ViewStyleProp |} => React$Node, + +cardStyle: ViewStyleProp, + +animationEnabled: boolean, + +animationTypeForReplace: 'push' | 'pop', + +gestureEnabled: boolean, + +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, + +gestureVelocityImpact: number, + +safeAreaInsets: Partial, + // Transition + ...TransitionPreset, + // Header + +headerTitle: string | (StackHeaderTitleInputProps => React$Node), + +headerTitleAlign: 'left' | 'center', + +headerTitleStyle: AnimatedTextStyleProp, + +headerTitleContainerStyle: ViewStyleProp, + +headerTintColor: string, + +headerTitleAllowFontScaling: boolean, + +headerBackAllowFontScaling: boolean, + +headerBackTitle: string | null, + +headerBackTitleStyle: TextStyleProp, + +headerBackTitleVisible: boolean, + +headerTruncatedBackTitle: string, + +headerLeft: StackHeaderLeftButtonProps => React$Node, + +headerLeftContainerStyle: ViewStyleProp, + +headerRight: {| tintColor?: string |} => React$Node, + +headerRightContainerStyle: ViewStyleProp, + +headerBackImage: $PropertyType, + +headerPressColorAndroid: string, + +headerBackground: ({| style: ViewStyleProp |}) => React$Node, + +headerStyle: ViewStyleProp, + +headerTransparent: boolean, + +headerStatusBarHeight: number, + |}>; + + /** + * Stack navigation prop + */ + + declare export type StackNavigationEventMap = {| + ...EventMapCore, + +transitionStart: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +transitionEnd: {| + +data: {| +closing: boolean |}, + +canPreventDefault: false, + |}, + +gestureStart: {| +data: void, +canPreventDefault: false |}, + +gestureEnd: {| +data: void, +canPreventDefault: false |}, + +gestureCancel: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactStackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = { + ...$Exact>, + +replace: SimpleNavigate, + +push: SimpleNavigate, + +pop: (count?: number) => void, + +popToTop: () => void, + ... + }; + + declare export type StackNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = StackOptions, + EventMap: EventMapBase = StackNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous stack exports + */ + + declare type StackNavigationConfig = {| + +mode?: 'card' | 'modal', + +headerMode?: 'float' | 'screen' | 'none', + +keyboardHandlingEnabled?: boolean, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraStackNavigatorProps = {| + ...$Exact, + ...StackRouterOptions, + ...StackNavigationConfig, + |}; + + declare export type StackNavigatorProps< + NavProp: InexactStackNavigationProp<> = StackNavigationProp<>, + > = {| + ...ExtraStackNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Bottom tab options + */ + + declare export type BottomTabBarButtonProps = {| + ...$Diff< + TouchableWithoutFeedbackProps, + {| onPress?: ?(event: PressEvent) => mixed |}, + >, + +to?: string, + +children: React$Node, + +onPress?: (MouseEvent | PressEvent) => void, + |}; + + declare export type TabBarVisibilityAnimationConfig = + | {| + +animation: 'spring', + +config?: $Diff< + SpringAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |} + | {| + +animation: 'timing', + +config?: $Diff< + TimingAnimationConfigSingle, + { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, + >, + |}; + + declare export type BottomTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| focused: boolean, color: string |}) => React$Node, + +tabBarIcon: ({| + focused: boolean, + color: string, + size: number, + |}) => React$Node, + +tabBarBadge: number | string, + +tabBarBadgeStyle: TextStyleProp, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + +tabBarVisible: boolean, + +tabBarVisibilityAnimationConfig: Partial<{| + +show: TabBarVisibilityAnimationConfig, + +hide: TabBarVisibilityAnimationConfig, + |}>, + +tabBarButton: BottomTabBarButtonProps => React$Node, + +unmountOnBlur: boolean, + |}>; + + /** + * Bottom tab navigation prop + */ + + declare export type BottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + |}; + + declare type InexactTabNavigationProp< + ParamList: ParamListBase, + RouteName: $Keys, + Options: {...}, + EventMap: EventMapBase, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + ... + }; + + declare export type InexactBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type BottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = BottomTabOptions, + EventMap: EventMapBase = BottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous bottom tab exports + */ + + declare export type BottomTabDescriptor = Descriptor< + BottomTabNavigationProp<>, + BottomTabOptions, + >; + + declare export type BottomTabBarOptions = Partial<{| + +keyboardHidesTabBar: boolean, + +activeTintColor: string, + +inactiveTintColor: string, + +activeBackgroundColor: string, + +inactiveBackgroundColor: string, + +allowFontScaling: boolean, + +showLabel: boolean, + +showIcon: boolean, + +labelStyle: TextStyleProp, + +iconStyle: TextStyleProp, + +tabStyle: ViewStyleProp, + +labelPosition: 'beside-icon' | 'below-icon', + +adaptive: boolean, + +safeAreaInsets: Partial, + +style: ViewStyleProp, + |}>; + + declare type BottomTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: BottomTabNavigationProp<>, + +descriptors: {| +[key: string]: BottomTabDescriptor |}, + |}; + + declare export type BottomTabBarProps = {| + ...BottomTabBarOptions, + ...BottomTabNavigationBuilderResult, + |} + + declare type BottomTabNavigationConfig = {| + +lazy?: boolean, + +tabBar?: BottomTabBarProps => React$Node, + +tabBarOptions?: BottomTabBarOptions, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...BottomTabNavigationConfig, + |}; + + declare export type BottomTabNavigatorProps< + NavProp: InexactBottomTabNavigationProp<> = BottomTabNavigationProp<>, + > = {| + ...ExtraBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material bottom tab options + */ + + declare export type MaterialBottomTabOptions = Partial<{| + +title: string, + +tabBarColor: string, + +tabBarLabel: string, + +tabBarIcon: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarBadge: boolean | number | string, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material bottom tab navigation prop + */ + + declare export type MaterialBottomTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + |}; + + declare export type InexactMaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialBottomTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialBottomTabOptions, + EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material bottom tab exports + */ + + declare export type PaperFont = {| + +fontFamily: string, + +fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + |}; + + declare export type PaperFonts = {| + +regular: PaperFont, + +medium: PaperFont, + +light: PaperFont, + +thin: PaperFont, + |}; + + declare export type PaperTheme = {| + +dark: boolean, + +mode?: 'adaptive' | 'exact', + +roundness: number, + +colors: {| + +primary: string, + +background: string, + +surface: string, + +accent: string, + +error: string, + +text: string, + +onSurface: string, + +onBackground: string, + +disabled: string, + +placeholder: string, + +backdrop: string, + +notification: string, + |}, + +fonts: PaperFonts, + +animation: {| + +scale: number, + |}, + |}; + + declare export type PaperRoute = {| + +key: string, + +title?: string, + +icon?: any, + +badge?: string | number | boolean, + +color?: string, + +accessibilityLabel?: string, + +testID?: string, + |}; + + declare export type PaperTouchableProps = {| + ...TouchableWithoutFeedbackProps, + +key: string, + +route: PaperRoute, + +children: React$Node, + +borderless?: boolean, + +centered?: boolean, + +rippleColor?: string, + |}; + + declare export type MaterialBottomTabNavigationConfig = {| + +shifting?: boolean, + +labeled?: boolean, + +renderTouchable?: PaperTouchableProps => React$Node, + +activeColor?: string, + +inactiveColor?: string, + +sceneAnimationEnabled?: boolean, + +keyboardHidesNavigationBar?: boolean, + +barStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +theme?: PaperTheme, + |}; + + declare export type ExtraMaterialBottomTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialBottomTabNavigationConfig, + |}; + + declare export type MaterialBottomTabNavigatorProps< + NavProp: InexactMaterialBottomTabNavigationProp<> = + MaterialBottomTabNavigationProp<>, + > = {| + ...ExtraMaterialBottomTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Material top tab options + */ + + declare export type MaterialTopTabOptions = Partial<{| + +title: string, + +tabBarLabel: + | string + | ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, + +tabBarAccessibilityLabel: string, + +tabBarTestID: string, + |}>; + + /** + * Material top tab navigation prop + */ + + declare export type MaterialTopTabNavigationEventMap = {| + ...EventMapCore, + +tabPress: {| +data: void, +canPreventDefault: true |}, + +tabLongPress: {| +data: void, +canPreventDefault: false |}, + +swipeStart: {| +data: void, +canPreventDefault: false |}, + +swipeEnd: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactMaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = InexactTabNavigationProp< + ParamList, + RouteName, + Options, + EventMap, + >; + + declare export type MaterialTopTabNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = MaterialTopTabOptions, + EventMap: EventMapBase = MaterialTopTabNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous material top tab exports + */ + + declare type MaterialTopTabPagerCommonProps = {| + +keyboardDismissMode: 'none' | 'on-drag' | 'auto', + +swipeEnabled: boolean, + +swipeVelocityImpact?: number, + +springVelocityScale?: number, + +springConfig: Partial<{| + +damping: number, + +mass: number, + +stiffness: number, + +restSpeedThreshold: number, + +restDisplacementThreshold: number, + |}>, + +timingConfig: Partial<{| + +duration: number, + |}>, + |}; + + declare export type MaterialTopTabPagerProps = {| + ...MaterialTopTabPagerCommonProps, + +onSwipeStart?: () => void, + +onSwipeEnd?: () => void, + +onIndexChange: (index: number) => void, + +navigationState: TabNavigationState, + +layout: {| +width: number, +height: number |}, + +removeClippedSubviews: boolean, + +children: ({| + +addListener: (type: 'enter', listener: number => void) => void, + +removeListener: (type: 'enter', listener: number => void) => void, + +position: any, // Reanimated.Node + +render: React$Node => React$Node, + +jumpTo: string => void, + |}) => React$Node, + +gestureHandlerProps: PanGestureHandlerProps, + |}; + + declare export type MaterialTopTabBarIndicatorProps = {| + +navigationState: TabNavigationState, + +width: string, + +style?: ViewStyleProp, + +getTabWidth: number => number, + |}; + + declare export type MaterialTopTabBarOptions = Partial<{| + +scrollEnabled: boolean, + +bounces: boolean, + +pressColor: string, + +pressOpacity: number, + +getAccessible: ({| +route: Route<> |}) => boolean, + +renderBadge: ({| +route: Route<> |}) => React$Node, + +renderIndicator: MaterialTopTabBarIndicatorProps => React$Node, + +tabStyle: ViewStyleProp, + +indicatorStyle: ViewStyleProp, + +indicatorContainerStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + +activeTintColor: string, + +inactiveTintColor: string, + +iconStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + +showLabel: boolean, + +showIcon: boolean, + +allowFontScaling: boolean, + |}>; + + declare export type MaterialTopTabDescriptor = Descriptor< + MaterialBottomTabNavigationProp<>, + MaterialBottomTabOptions, + >; + + declare type MaterialTopTabNavigationBuilderResult = {| + +state: TabNavigationState, + +navigation: MaterialTopTabNavigationProp<>, + +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, + |}; + + declare export type MaterialTopTabBarProps = {| + ...MaterialTopTabBarOptions, + ...MaterialTopTabNavigationBuilderResult, + +layout: {| +width: number, +height: number |}, + +position: any, // Reanimated.Node + +jumpTo: string => void, + |}; + + declare export type MaterialTopTabNavigationConfig = {| + ...Partial, + +position?: any, // Reanimated.Value + +tabBarPosition?: 'top' | 'bottom', + +initialLayout?: Partial<{| +width: number, +height: number |}>, + +lazy?: boolean, + +lazyPreloadDistance?: number, + +removeClippedSubviews?: boolean, + +sceneContainerStyle?: ViewStyleProp, + +style?: ViewStyleProp, + +gestureHandlerProps?: PanGestureHandlerProps, + +pager?: MaterialTopTabPagerProps => React$Node, + +lazyPlaceholder?: ({| +route: Route<> |}) => React$Node, + +tabBar?: MaterialTopTabBarProps => React$Node, + +tabBarOptions?: MaterialTopTabBarOptions, + |}; + + declare export type ExtraMaterialTopTabNavigatorProps = {| + ...$Exact, + ...TabRouterOptions, + ...MaterialTopTabNavigationConfig, + |}; + + declare export type MaterialTopTabNavigatorProps< + NavProp: InexactMaterialTopTabNavigationProp<> = + MaterialTopTabNavigationProp<>, + > = {| + ...ExtraMaterialTopTabNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * Drawer options + */ + + declare export type DrawerOptions = Partial<{| + title: string, + drawerLabel: + | string + | ({| +color: string, +focused: boolean |}) => React$Node, + drawerIcon: ({| + +color: string, + +size: number, + +focused: boolean, + |}) => React$Node, + gestureEnabled: boolean, + swipeEnabled: boolean, + unmountOnBlur: boolean, + |}>; + + /** + * Drawer navigation prop + */ + + declare export type DrawerNavigationEventMap = {| + ...EventMapCore, + +drawerOpen: {| +data: void, +canPreventDefault: false |}, + +drawerClose: {| +data: void, +canPreventDefault: false |}, + |}; + + declare export type InexactDrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = { + ...$Exact>, + +jumpTo: SimpleNavigate, + +openDrawer: () => void, + +closeDrawer: () => void, + +toggleDrawer: () => void, + ... + }; + + declare export type DrawerNavigationProp< + ParamList: ParamListBase = ParamListBase, + RouteName: $Keys = $Keys, + Options: {...} = DrawerOptions, + EventMap: EventMapBase = DrawerNavigationEventMap, + > = $Exact>; + + /** + * Miscellaneous drawer exports + */ + + declare export type DrawerDescriptor = Descriptor< + DrawerNavigationProp<>, + DrawerOptions, + >; + + declare export type DrawerItemListBaseOptions = Partial<{| + +activeTintColor: string, + +activeBackgroundColor: string, + +inactiveTintColor: string, + +inactiveBackgroundColor: string, + +itemStyle: ViewStyleProp, + +labelStyle: TextStyleProp, + |}>; + + declare export type DrawerContentOptions = Partial<{| + ...DrawerItemListBaseOptions, + +contentContainerStyle: ViewStyleProp, + +style: ViewStyleProp, + |}>; + + declare type DrawerNavigationBuilderResult = {| + +state: DrawerNavigationState, + +navigation: DrawerNavigationProp<>, + +descriptors: {| +[key: string]: DrawerDescriptor |}, + |}; + + declare export type DrawerContentProps = {| + ...DrawerContentOptions, + ...DrawerNavigationBuilderResult, + +progress: any, // Reanimated.Node + |}; + + declare export type DrawerNavigationConfig = {| + +drawerPosition?: 'left' | 'right', + +drawerType?: 'front' | 'back' | 'slide' | 'permanent', + +edgeWidth?: number, + +hideStatusBar?: boolean, + +keyboardDismissMode?: 'on-drag' | 'none', + +minSwipeDistance?: number, + +overlayColor?: string, + +statusBarAnimation?: 'slide' | 'none' | 'fade', + +gestureHandlerProps?: PanGestureHandlerProps, + +lazy?: boolean, + +drawerContent?: DrawerContentProps => React$Node, + +drawerContentOptions?: DrawerContentOptions, + +sceneContainerStyle?: ViewStyleProp, + +drawerStyle?: ViewStyleProp, + +detachInactiveScreens?: boolean, + |}; + + declare export type ExtraDrawerNavigatorProps = {| + ...$Exact, + ...DrawerRouterOptions, + ...DrawerNavigationConfig, + |}; + + declare export type DrawerNavigatorProps< + NavProp: InexactDrawerNavigationProp<> = DrawerNavigationProp<>, + > = {| + ...ExtraDrawerNavigatorProps, + ...ScreenOptionsProp, + |}; + + /** + * BaseNavigationContainer + */ + + declare export type BaseNavigationContainerProps = {| + +children: React$Node, + +initialState?: PossiblyStaleNavigationState, + +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, + +independent?: boolean, + |}; + + declare export type ContainerEventMap = {| + ...GlobalEventMap, + +options: {| + +data: {| +options: { +[key: string]: mixed, ... } |}, + +canPreventDefault: false, + |}, + +__unsafe_action__: {| + +data: {| + +action: GenericNavigationAction, + +noop: boolean, + |}, + +canPreventDefault: false, + |}, + |}; + + declare export type BaseNavigationContainerInterface = {| + ...$Exact>, + +setParams: (params: ScreenParams) => void, + +resetRoot: (state?: ?PossiblyStaleNavigationState) => void, + +getRootState: () => PossiblyStaleNavigationState, + |}; + + /** + * State utils + */ + + declare export type GetStateFromPath = ( + path: string, + options?: LinkingConfig, + ) => PossiblyStaleNavigationState; + + declare export type GetPathFromState = ( + state?: ?PossiblyStaleNavigationState, + options?: LinkingConfig, + ) => string; + + declare export type GetFocusedRouteNameFromRoute = + PossiblyStaleRoute => ?string; + + /** + * Linking + */ + + declare export type ScreenLinkingConfig = {| + +path?: string, + +exact?: boolean, + +parse?: {| +[param: string]: string => mixed |}, + +stringify?: {| +[param: string]: mixed => string |}, + +screens?: ScreenLinkingConfigMap, + +initialRouteName?: string, + |}; + + declare export type ScreenLinkingConfigMap = {| + +[routeName: string]: string | ScreenLinkingConfig, + |}; + + declare export type LinkingConfig = {| + +initialRouteName?: string, + +screens: ScreenLinkingConfigMap, + |}; + + declare export type LinkingOptions = {| + +enabled?: boolean, + +prefixes: $ReadOnlyArray, + +config?: LinkingConfig, + +getStateFromPath?: GetStateFromPath, + +getPathFromState?: GetPathFromState, + |}; + + /** + * NavigationContainer + */ + + declare export type Theme = {| + +dark: boolean, + +colors: {| + +primary: string, + +background: string, + +card: string, + +text: string, + +border: string, + |}, + |}; + + declare export type NavigationContainerType = React$AbstractComponent< + {| + ...BaseNavigationContainerProps, + +theme?: Theme, + +linking?: LinkingOptions, + +fallback?: React$Node, + +onReady?: () => mixed, + |}, + BaseNavigationContainerInterface, + >; + + //--------------------------------------------------------------------------- + // SECTION 2: EXPORTED MODULE + // This section defines the module exports and contains exported types that + // are not present in any other React Navigation libdef. + //--------------------------------------------------------------------------- + + /** + * StackView + */ + + declare export var StackView: React$ComponentType<{| + ...StackNavigationConfig, + +state: StackNavigationState, + +navigation: StackNavigationProp<>, + +descriptors: {| +[key: string]: StackDescriptor |}, + |}>; + + /** + * createStackNavigator + */ + + declare export var createStackNavigator: CreateNavigator< + StackNavigationState, + StackOptions, + StackNavigationEventMap, + ExtraStackNavigatorProps, + >; + + /** + * Header components + */ + + declare export var Header: React$ComponentType; + + declare export type StackHeaderTitleProps = Partial; + declare export var HeaderTitle: React$ComponentType; + + declare export type HeaderBackButtonProps = Partial<{| + ...StackHeaderLeftButtonProps, + +disabled: boolean, + +accessibilityLabel: string, + |}>; + declare export var HeaderBackButton: React$ComponentType< + HeaderBackButtonProps, + >; + + declare export type HeaderBackgroundProps = Partial<{ + +children: React$Node, + +style: AnimatedViewStyleProp, + ... + }>; + declare export var HeaderBackground: React$ComponentType< + HeaderBackgroundProps, + >; + + /** + * Style/animation options + */ + + declare export var CardStyleInterpolators: {| + +forHorizontalIOS: StackCardStyleInterpolator, + +forVerticalIOS: StackCardStyleInterpolator, + +forModalPresentationIOS: StackCardStyleInterpolator, + +forFadeFromBottomAndroid: StackCardStyleInterpolator, + +forRevealFromBottomAndroid: StackCardStyleInterpolator, + +forScaleFromCenterAndroid: StackCardStyleInterpolator, + +forNoAnimation: StackCardStyleInterpolator, + |}; + declare export var HeaderStyleInterpolators: {| + +forUIKit: StackHeaderStyleInterpolator, + +forFade: StackHeaderStyleInterpolator, + +forSlideLeft: StackHeaderStyleInterpolator, + +forSlideRight: StackHeaderStyleInterpolator, + +forSlideUp: StackHeaderStyleInterpolator, + +forNoAnimation: StackHeaderStyleInterpolator, + |}; + declare export var TransitionSpecs: {| + +TransitionIOSSpec: TransitionSpec, + +FadeInFromBottomAndroidSpec: TransitionSpec, + +FadeOutToBottomAndroidSpec: TransitionSpec, + +RevealFromBottomAndroidSpec: TransitionSpec, + +ScaleFromCenterAndroidSpec: TransitionSpec, + |}; + declare export var TransitionPresets: {| + +SlideFromRightIOS: TransitionPreset, + +ModalSlideFromBottomIOS: TransitionPreset, + +ModalPresentationIOS: TransitionPreset, + +FadeFromBottomAndroid: TransitionPreset, + +RevealFromBottomAndroid: TransitionPreset, + +ScaleFromCenterAndroid: TransitionPreset, + +DefaultTransition: TransitionPreset, + +ModalTransition: TransitionPreset, + |}; + + /** + * Image assets + */ + + declare export var Assets: $ReadOnlyArray; + + /** + * CardAnimation accessors + */ + + declare export var CardAnimationContext: React$Context< + ?StackCardInterpolationProps, + >; + declare export function useCardAnimation(): StackCardInterpolationProps + + /** + * HeaderHeight accessors + */ + + declare export var HeaderHeightContext: React$Context; + declare export function useHeaderHeight(): number; + + /** + * GestureHandler accessors + */ + + declare type GestureHandlerRef = React$Ref< + React$ComponentType, + >; + declare export var GestureHandlerRefContext: React$Context< + ?GestureHandlerRef, + >; + declare export function useGestureHandlerRef(): GestureHandlerRef; + +} diff --git a/definitions/npm/@storybook/addon-a11y_v3.x.x/flow_v0.104.x-/addon-a11y_v3.x.x.js b/definitions/npm/@storybook/addon-a11y_v3.x.x/flow_v0.104.x-v.200.x/addon-a11y_v3.x.x.js similarity index 100% rename from definitions/npm/@storybook/addon-a11y_v3.x.x/flow_v0.104.x-/addon-a11y_v3.x.x.js rename to definitions/npm/@storybook/addon-a11y_v3.x.x/flow_v0.104.x-v.200.x/addon-a11y_v3.x.x.js diff --git a/definitions/npm/@storybook/addon-a11y_v3.x.x/flow_v0.201.x-/addon-a11y_v3.x.x.js b/definitions/npm/@storybook/addon-a11y_v3.x.x/flow_v0.201.x-/addon-a11y_v3.x.x.js new file mode 100644 index 0000000000..32e97b3e7a --- /dev/null +++ b/definitions/npm/@storybook/addon-a11y_v3.x.x/flow_v0.201.x-/addon-a11y_v3.x.x.js @@ -0,0 +1,54 @@ +declare module '@storybook/addon-a11y' { + declare type Context = { + kind: string, + story: string, + ... + }; + declare type Renderable = React$Element; + declare type RenderFunction = () => Renderable | Array; + + declare type StoryDecorator = ( + story: RenderFunction, + context: Context + ) => Renderable | null; + + declare type AxeCheck = { + id: string, + evaluate: (options: mixed) => void, + after?: () => void, + options?: mixed, + enabled?: boolean, + ... + }; + + declare type AxeOptions = { + branding?: { + brand?: string, + application?: string, + ... + }, + reporter?: 'v1' | 'v2', + checks?: Array, + rules?: Array<{ + id: string, + selector?: string, + excludeHidden?: boolean, + enabled?: boolean, + pageLevel?: boolean, + any?: Array, + all?: Array, + none?: Array, + tags?: Array, + matches?: string, + ... + }>, + disableOtherRules?: boolean, + ... + }; + + declare module.exports: { + checkA11y: StoryDecorator, + configureA11y: (options?: AxeOptions) => void, + ... + }; +} diff --git a/definitions/npm/@storybook/addon-knobs_v3.x.x/flow_v0.104.x-/addon-knobs_v3.x.x.js b/definitions/npm/@storybook/addon-knobs_v3.x.x/flow_v0.104.x-v.200.x/addon-knobs_v3.x.x.js similarity index 100% rename from definitions/npm/@storybook/addon-knobs_v3.x.x/flow_v0.104.x-/addon-knobs_v3.x.x.js rename to definitions/npm/@storybook/addon-knobs_v3.x.x/flow_v0.104.x-v.200.x/addon-knobs_v3.x.x.js diff --git a/definitions/npm/@storybook/addon-knobs_v3.x.x/flow_v0.201.x-/addon-knobs_v3.x.x.js b/definitions/npm/@storybook/addon-knobs_v3.x.x/flow_v0.201.x-/addon-knobs_v3.x.x.js new file mode 100644 index 0000000000..11f73ed4a5 --- /dev/null +++ b/definitions/npm/@storybook/addon-knobs_v3.x.x/flow_v0.201.x-/addon-knobs_v3.x.x.js @@ -0,0 +1,31 @@ +declare module "@storybook/addon-knobs/react" { + declare type Context = { + kind: string, + story: string, + ... + }; + declare type Renderable = React$Element; + declare type RenderFunction = () => Renderable | Array; + declare type GroupId = string; + + declare function array(string, (Array | { [string]: T, ... }), ?string, ?GroupId): Array; + declare function boolean(string, boolean, ?GroupId): boolean; + declare function button(string, ((?{...}) => void), ?GroupId): void; + declare function color(string, string, ?GroupId): string; + declare function date(string, Date, ?GroupId): number; + declare function number(string, number, ?{ + range?: boolean, + min?: number, + max?: number, + step?: number, + ... + }, ?GroupId): number; + declare function object(string, any, ?GroupId): any; + declare function select(string, Array | { [T]: string, ... }, T, ?GroupId): T; + declare function selectV2(string, Array | { [string]: T, ... }, T, ?GroupId): T; + declare function text(string, string, ?GroupId): string; + declare function withKnobs( + story: RenderFunction, + context: Context + ): Renderable | null; +} diff --git a/definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-/react_v10.x.x.js b/definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-v.200.x/react_v10.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-/react_v10.x.x.js rename to definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-v.200.x/react_v10.x.x.js diff --git a/definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-/test_react_v10.x.x.js b/definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-v.200.x/test_react_v10.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-/test_react_v10.x.x.js rename to definitions/npm/@testing-library/react_v10.x.x/flow_v0.104.x-v.200.x/test_react_v10.x.x.js diff --git a/definitions/npm/@testing-library/react_v10.x.x/flow_v0.201.x-/react_v10.x.x.js b/definitions/npm/@testing-library/react_v10.x.x/flow_v0.201.x-/react_v10.x.x.js new file mode 100644 index 0000000000..7afc86f728 --- /dev/null +++ b/definitions/npm/@testing-library/react_v10.x.x/flow_v0.201.x-/react_v10.x.x.js @@ -0,0 +1,448 @@ +declare module '@testing-library/react' { + // This type comes from react-dom_v17.x.x.js + declare interface ReactDOMTestUtilsThenable { + then(resolve: () => mixed, reject?: () => mixed): mixed; + } + + // This type comes from react-dom_v17.x.x.js + declare type ReactDOMTestUtilsAct = ( + callback: () => void | ReactDOMTestUtilsThenable + ) => ReactDOMTestUtilsThenable; + + declare type WaitForElementOptions = {| + container?: HTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + |}; + + declare type TextMatch = + | string + | RegExp + | ((content: string, element: HTMLElement) => boolean); + + declare type TextMatchOptions = { + exact?: boolean, + trim?: boolean, + collapseWhitespace?: boolean, + normalizer?: (text: string) => string, + ... + }; + + declare type SelectorMatchOptions = { + selector?: string, + ... + } & TextMatchOptions; + + declare type QueryByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement; + + declare type AllByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => Array; + + declare type FindAllByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions, + waitForElementOptions?: WaitForElementOptions + ) => Promise; + + declare type GetByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => HTMLElement; + + declare type FindByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions, + waitForElementOptions?: WaitForElementOptions + ) => Promise; + + declare type QueryByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => ?HTMLElement; + + declare type AllByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => Array; + + declare type FindAllByText = ( + text: TextMatch, + options?: SelectorMatchOptions, + waitForElementOptions?: WaitForElementOptions + ) => Promise; + + declare type GetByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => HTMLElement; + + declare type FindByText = ( + text: TextMatch, + options?: SelectorMatchOptions, + waitForElementOptions?: WaitForElementOptions + ) => Promise; + + declare type ByRoleOptions = { + /** + * If true includes elements in the query set that are usually excluded from + * the accessibility tree. `role="none"` or `role="presentation"` are included + * in either case. + * @default false + */ + hidden?: boolean, + /** + * Includes every role used in the `role` attribute + * For example *ByRole('progressbar', {queryFallbacks: true})` will find
`. + */ + queryFallbacks?: boolean, + /** + * Only considers elements with the specified accessible name. + */ + name?: + | string + | RegExp + | ((accessibleName: string, element: Element) => boolean), + ... + } & TextMatchOptions; + + declare type AllByRole = ( + role: TextMatch, + options?: ByRoleOptions + ) => HTMLElement[]; + + declare type GetByRole = ( + role: TextMatch, + options?: ByRoleOptions + ) => HTMLElement; + + declare type QueryByRole = ( + role: TextMatch, + options?: ByRoleOptions + ) => HTMLElement | null; + + declare type FindByRole = ( + role: TextMatch, + options?: ByRoleOptions, + waitForElementOptions?: WaitForElementOptions + ) => Promise; + + declare type FindAllByRole = ( + role: any, + options?: ByRoleOptions, + waitForElementOptions?: WaitForElementOptions + ) => Promise; + + declare type GetsAndQueries = {| + getByLabelText: GetByText, + getAllByLabelText: AllByText, + queryByLabelText: QueryByText, + queryAllByLabelText: AllByText, + findByLabelText: FindByText, + findAllByLabelText: FindAllByText, + + getByPlaceholderText: GetByBoundAttribute, + getAllByPlaceholderText: AllByBoundAttribute, + queryByPlaceholderText: QueryByBoundAttribute, + queryAllByPlaceholderText: AllByBoundAttribute, + findByPlaceholderText: FindByBoundAttribute, + findAllByPlaceholderText: FindAllByBoundAttribute, + + getByText: GetByText, + getAllByText: AllByText, + queryByText: QueryByText, + queryAllByText: AllByText, + findByText: FindByText, + findAllByText: FindAllByText, + + getByAltText: GetByBoundAttribute, + getAllByAltText: AllByBoundAttribute, + queryByAltText: QueryByBoundAttribute, + queryAllByAltText: AllByBoundAttribute, + findByAltText: FindByBoundAttribute, + findAllByAltText: FindAllByBoundAttribute, + + getByTitle: GetByBoundAttribute, + getAllByTitle: AllByBoundAttribute, + queryByTitle: QueryByBoundAttribute, + queryAllByTitle: AllByBoundAttribute, + findByTitle: FindByBoundAttribute, + findAllByTitle: FindAllByBoundAttribute, + + getByDisplayValue: GetByBoundAttribute, + getAllByDisplayValue: AllByBoundAttribute, + queryByDisplayValue: QueryByBoundAttribute, + queryAllByDisplayValue: AllByBoundAttribute, + findByDisplayValue: FindByBoundAttribute, + findAllByDisplayValue: FindAllByBoundAttribute, + + getByRole: GetByRole, + getAllByRole: AllByRole, + queryByRole: QueryByRole, + queryAllByRole: AllByRole, + findByRole: FindByRole, + findAllByRole: FindAllByRole, + + getByTestId: GetByBoundAttribute, + getAllByTestId: AllByBoundAttribute, + queryByTestId: QueryByBoundAttribute, + queryAllByTestId: AllByBoundAttribute, + findByTestId: FindByBoundAttribute, + findAllByTestId: FindAllByBoundAttribute, + |}; + + declare type FireEvent = ( + element: HTMLElement, + eventProperties?: TInit + ) => boolean; + + declare type Screen = { + ...Queries, + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number + ) => void, + ... + }; + + declare type RenderResult = { + ...Queries, + container: HTMLElement, + unmount: () => boolean, + baseElement: HTMLElement, + asFragment: () => DocumentFragment, + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number + ) => void, + rerender: (ui: React$Element) => void, + ... + }; + + declare export type RenderOptionsWithoutCustomQueries = {| + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export type RenderOptionsWithCustomQueries< + CustomQueries: { ... } + > = {| + queries: CustomQueries, + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export function render( + ui: React$Element, + options?: RenderOptionsWithoutCustomQueries + ): RenderResult<>; + declare export function render< + CustomQueries: { [string]: (...args: Array) => any, ... } + >( + ui: React$Element, + options: RenderOptionsWithCustomQueries + ): RenderResult; + + declare export var act: ReactDOMTestUtilsAct; + declare export function cleanup(): Promise; + + declare export function waitFor( + callback: () => T, + options?: {| + container?: HTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + declare export function waitForElementToBeRemoved( + callback: (() => T) | T, + options?: {| + container?: HTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + /* Deprecated */ + declare export function wait( + callback?: () => void, + options?: { + timeout?: number, + interval?: number, + ... + } + ): Promise; + + /* Deprecated */ + declare export function waitForDomChange(options?: { + container?: HTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + }): Promise; + + /* Deprecated */ + declare export function waitForElement( + callback?: () => T, + options?: { + container?: HTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + } + ): Promise; + + declare export function within( + element: HTMLElement, + queriesToBind?: GetsAndQueries | Array + ): GetsAndQueries; + + declare export var fireEvent: {| + (element: HTMLElement, event: Event): void, + + copy: FireEvent, + cut: FireEvent, + paste: FireEvent, + compositionEnd: FireEvent, + compositionStart: FireEvent, + compositionUpdate: FireEvent, + keyDown: FireEvent, + keyPress: FireEvent, + keyUp: FireEvent, + focus: FireEvent, + blur: FireEvent, + change: FireEvent, + input: FireEvent, + invalid: FireEvent, + submit: FireEvent, + click: FireEvent, + contextMenu: FireEvent, + dblClick: FireEvent, + doubleClick: FireEvent, + drag: FireEvent, + dragEnd: FireEvent, + dragEnter: FireEvent, + dragExit: FireEvent, + dragLeave: FireEvent, + dragOver: FireEvent, + dragStart: FireEvent, + drop: FireEvent, + mouseDown: FireEvent, + mouseEnter: FireEvent, + mouseLeave: FireEvent, + mouseMove: FireEvent, + mouseOut: FireEvent, + mouseOver: FireEvent, + mouseUp: FireEvent, + select: FireEvent, + touchCancel: FireEvent, + touchEnd: FireEvent, + touchMove: FireEvent, + touchStart: FireEvent, + scroll: FireEvent, + wheel: FireEvent, + abort: FireEvent, + canPlay: FireEvent, + canPlayThrough: FireEvent, + durationChange: FireEvent, + emptied: FireEvent, + encrypted: FireEvent, + ended: FireEvent, + loadedData: FireEvent, + loadedMetadata: FireEvent, + loadStart: FireEvent, + pause: FireEvent, + play: FireEvent, + playing: FireEvent, + progress: FireEvent, + rateChange: FireEvent, + seeked: FireEvent, + seeking: FireEvent, + stalled: FireEvent, + suspend: FireEvent, + timeUpdate: FireEvent, + volumeChange: FireEvent, + waiting: FireEvent, + load: FireEvent, + error: FireEvent, + animationStart: FireEvent, + animationEnd: FireEvent, + animationIteration: FireEvent, + transitionEnd: FireEvent, + |}; + // dom-testing-library re-declares + declare export function queryByTestId( + container: HTMLElement, + id: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByTestId( + container: HTMLElement, + id: TextMatch, + options?: TextMatchOptions + ): HTMLElement; + declare export function getAllByTestId( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): Array; + declare export function queryByText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByText( + container: HTMLElement, + text: TextMatch, + options?: { selector?: string, ... } & TextMatchOptions + ): HTMLElement; + declare export function queryByPlaceholderText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByPlaceholderText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): HTMLElement; + declare export function queryByLabelText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByLabelText( + container: HTMLElement, + text: TextMatch, + options?: { selector?: string, ... } & TextMatchOptions + ): HTMLElement; + declare export function queryByAltText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByAltText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): HTMLElement; + declare export function getNodeText(node: HTMLElement): string; + declare export var screen: Screen<>; +} diff --git a/definitions/npm/@testing-library/react_v10.x.x/flow_v0.201.x-/test_react_v10.x.x.js b/definitions/npm/@testing-library/react_v10.x.x/flow_v0.201.x-/test_react_v10.x.x.js new file mode 100644 index 0000000000..1cb2c721e7 --- /dev/null +++ b/definitions/npm/@testing-library/react_v10.x.x/flow_v0.201.x-/test_react_v10.x.x.js @@ -0,0 +1,1319 @@ +// @flow + +import React from 'react'; +import { + act, + render, + fireEvent, + cleanup, + waitFor, + waitForDomChange, + waitForElement, + waitForElementToBeRemoved, + within, + screen, + getNodeText, + getAllByTestId, +} from '@testing-library/react'; +import { describe, it } from 'flow-typed-test'; + +describe('act', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + act(1); + // $FlowExpectedError[extra-arg] + act(() => {}, 1); + // $FlowExpectedError[incompatible-call] + act(() => 1); + }); + + it('should pass on correct inputs', () => { + act(() => {}); + act(() => Promise.resolve()); + act(() => ({ + then: resolve => {}, + })); + }); + + it('should fail on incorrect usage of result', () => { + // $FlowExpectedError[incompatible-type] + act(() => {}) + 1; + // $FlowExpectedError[prop-missing] + act(() => {}).doesNotExist(); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(1); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(() => {}, 1); + }); + + it('should pass on correct usage of result', () => { + act(() => {}).then(() => {}); + act(() => {}).then(() => {}, () => {}); + }); +}); + +describe('waitFor', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitFor(1); + // $FlowExpectedError[incompatible-call] + waitFor(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitFor(() => {}); + waitFor(() => {}, { timeout: 1 }); + }); +}); + +describe('waitForDomChange', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForDomChange(1); + // $FlowExpectedError[incompatible-call] + waitForDomChange('1'); + }); + + it('should pass on correct inputs', () => { + waitForDomChange({ container: document.createElement('div') }); + waitForDomChange({ timeout: 1 }); + }); +}); + +describe('waitForElement', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElement(1); + // $FlowExpectedError[incompatible-call] + waitForElement(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitForElement(() => document.createElement('div')); + waitForElement(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async n => { + const usernameElement = await waitForElement(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('waitForElementToBeRemoved', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElementToBeRemoved(() => {}, 1); + }); + + it('should pass on correct inputs (callback)', () => { + waitForElementToBeRemoved(() => document.createElement('div')); + waitForElementToBeRemoved(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should pass on correct inputs (node)', () => { + waitForElementToBeRemoved(document.createElement('div')); + waitForElementToBeRemoved(document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async n => { + const usernameElement = await waitForElementToBeRemoved(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('render', () => { + class Component extends React.Component<{ ... }> {} + const { + container, + unmount, + baseElement, + asFragment, + debug, + rerender, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('unmount should has 0 arguments', () => { + unmount(); + // $FlowExpectedError[extra-arg] + unmount(1); + }); + + it('container should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = container; + const b: HTMLElement = container; + }); + + it('baseElement should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = baseElement; + const b: HTMLElement = baseElement; + }); + + it('asFragment should return a document fragment', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = asFragment(); + const b: DocumentFragment = asFragment(); + }); + + it('debug maybe has 1 argument an html element', () => { + // $FlowExpectedError[incompatible-call] + debug(1); + debug(container); + }); + + it('rerender should has 1 argument an react element', () => { + // $FlowExpectedError[incompatible-call] + rerender(); + rerender(); + }); + + it('getByAltText should return HTML element', () => { + const a: HTMLElement = getByAltText('1'); + }); + + it('getAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByAltText('1'); + const b: Array = getAllByAltText('2'); + }); + + it('queryByAltText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByAltText('1'); + const b: ?HTMLElement = queryByAltText('2'); + }); + + it('queryAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByAltText('1'); + const b: Array = queryAllByAltText('2'); + }); + + it('findByAltText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByAltText('1'); + const b: Promise = findByAltText('1'); + }); + + it('findAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByAltText('1'); + const b: Promise> = findAllByAltText('2'); + }); + + it('getByDisplayValue should return HTML element', () => { + const a: HTMLElement = getByDisplayValue('1'); + }); + + it('getAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByDisplayValue('1'); + const b: Array = getAllByDisplayValue('2'); + }); + + it('queryByDisplayValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByDisplayValue('1'); + const b: ?HTMLElement = queryByDisplayValue('2'); + }); + + it('queryAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByDisplayValue('1'); + const b: Array = queryAllByDisplayValue('2'); + }); + + it('findByDisplayValue should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByDisplayValue('1'); + const b: Promise = findByDisplayValue('1'); + }); + + it('findAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByDisplayValue('1'); + const b: Promise> = findAllByDisplayValue('2'); + }); + + it('getByLabelText should return HTML element', () => { + const a: HTMLElement = getByLabelText('1'); + }); + + it('getAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByLabelText('1'); + const b: Array = getAllByLabelText('2'); + }); + + it('queryByLabelText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByLabelText('1'); + const b: ?HTMLElement = queryByLabelText('2'); + }); + + it('queryAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByLabelText('1'); + const b: Array = queryAllByLabelText('2'); + }); + + it('findByLabelText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByLabelText('1'); + const b: Promise = findByLabelText('1'); + }); + + it('findAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByLabelText('1'); + const b: Promise> = findAllByLabelText('2'); + }); + + it('getByPlaceholderText should return HTML element', () => { + const a: HTMLElement = getByPlaceholderText('1'); + }); + + it('getAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByPlaceholderText('1'); + const b: Array = getAllByPlaceholderText('2'); + }); + + it('queryByPlaceholderText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByPlaceholderText('1'); + const b: ?HTMLElement = queryByPlaceholderText('2'); + }); + + it('queryAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByPlaceholderText('1'); + const b: Array = queryAllByPlaceholderText('2'); + }); + + it('findByPlaceholderText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByPlaceholderText('1'); + const b: Promise = findByPlaceholderText('1'); + }); + + it('findAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByPlaceholderText('1'); + const b: Promise> = findAllByPlaceholderText('2'); + }); + + it('getByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: string = getByRole('1'); + const b: HTMLElement = getByRole('1'); + }); + + it('getAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByRole('1'); + const b: Array = getAllByRole('2'); + }); + + it('queryByRole should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByRole('1'); + const b: ?HTMLElement = queryByRole('2'); + }); + + it('queryAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByRole('1'); + const b: Array = queryAllByRole('2'); + }); + + it('findByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByRole('1'); + const b: Promise = findByRole('1'); + }); + + it('findAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByRole('1'); + const b: Promise> = findAllByRole('2'); + }); + + it('getByTestId should return HTML element', () => { + const a: HTMLElement = getByTestId('1'); + }); + + it('getAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByTestId('1'); + const b: Array = getAllByTestId('2'); + }); + + it('queryByTestId should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByTestId('1'); + const b: ?HTMLElement = queryByTestId('2'); + }); + + it('queryAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByTestId('1'); + const b: Array = queryAllByTestId('2'); + }); + + it('findByTestId should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByTestId('1'); + const b: Promise = findByTestId('1'); + }); + + it('findAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findAllByTestId('1'); + const b: Promise> = findAllByTestId('2'); + }); + + it('getByText should return HTML element', () => { + const a: HTMLElement = getByText('1'); + }); + + it('getAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByText('1'); + const b: Array = getAllByText('2'); + }); + + it('queryByText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByText('1'); + const b: ?HTMLElement = queryByText('2'); + }); + + it('queryAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByText('1'); + const b: Array = queryAllByText('2'); + }); + + it('findByText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByText('1'); + const b: Promise = findByText('1'); + }); + + it('findAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByText('1'); + const b: Promise> = findAllByText('2'); + }); + + it('getByTitle should return HTML element', () => { + const a: HTMLElement = getByTitle('1'); + }); + + it('getAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByTitle('1'); + const b: Array = getAllByTitle('2'); + }); + + it('queryByTitle should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByTitle('1'); + const b: ?HTMLElement = queryByTitle('2'); + }); + + it('queryAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByTitle('1'); + const b: Array = queryAllByTitle('2'); + }); + + it('findByTitle should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findByTitle('1'); + const b: Promise = findByTitle('1'); + }); + + it('findAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = findAllByTitle('1'); + const b: Promise> = findAllByTitle('2'); + }); +}); + +describe('cleanup', () => { + it('should be a function w/o arguments', () => { + cleanup(); + // $FlowExpectedError[extra-arg] + cleanup(1); + }); +}); + +describe('within', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should has html element as argument', () => { + // $FlowExpectedError[incompatible-call] + within(); + within(container); + }); + + it('should have getByAltText', () => { + within(container).getByAltText('1'); + }); + + it('should have getAllByAltText', () => { + within(container).getAllByAltText('1'); + }); + + it('should have queryByAltText', () => { + within(container).queryByAltText('1'); + }); + + it('should have queryAllByAltText', () => { + within(container).queryAllByAltText('1'); + }); + + it('should have findByAltText', async () => { + await within(container).findByAltText('1'); + }); + + it('should have findAllByAltText', async () => { + await within(container).findAllByAltText('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); + + it('should have getByLabelText', () => { + within(container).getByLabelText('1'); + }); + + it('should have getAllByLabelText', () => { + within(container).getAllByLabelText('1'); + }); + + it('should have queryByLabelText', () => { + within(container).queryByLabelText('1'); + }); + + it('should have queryAllByLabelText', () => { + within(container).queryAllByLabelText('1'); + }); + + it('should have findByLabelText', async () => { + await within(container).findByLabelText('1'); + }); + + it('should have findAllByLabelText', async () => { + await within(container).findAllByLabelText('1'); + }); + + it('should have getByPlaceholderText', () => { + within(container).getByPlaceholderText('1'); + }); + + it('should have getAllByPlaceholderText', () => { + within(container).getAllByPlaceholderText('1'); + }); + + it('should have queryByPlaceholderText', () => { + within(container).queryByPlaceholderText('1'); + }); + + it('should have queryAllByPlaceholderText', () => { + within(container).queryAllByPlaceholderText('1'); + }); + + it('should have findByPlaceholderText', async () => { + await within(container).findByPlaceholderText('1'); + }); + + it('should have findAllByPlaceholderText', async () => { + await within(container).findAllByPlaceholderText('1'); + }); + + it('should have getByRole', () => { + within(container).getByRole('1'); + }); + + it('should have getAllByRole', () => { + within(container).getAllByRole('1'); + }); + + it('should have queryByRole', () => { + within(container).queryByRole('1'); + }); + + it('should have queryAllByRole', () => { + within(container).queryAllByRole('1'); + }); + + it('should have findByRole', async () => { + await within(container).findByRole('1'); + }); + + it('should have findAllByRole', async () => { + await within(container).findAllByRole('1'); + }); + + it('should have getByTestId', () => { + within(container).getByTestId('1'); + }); + + it('should have getAllByTestId', () => { + within(container).getAllByTestId('1'); + }); + + it('should have queryByTestId', () => { + within(container).queryByTestId('1'); + }); + + it('should have queryAllByTestId', () => { + within(container).queryAllByTestId('1'); + }); + + it('should have findByTestId', async () => { + await within(container).findByTestId('1'); + }); + + it('should have findAllByTestId', async () => { + await within(container).findAllByTestId('1'); + }); + + it('should have getByText', () => { + within(container).getByText('1'); + }); + + it('should have getAllByText', () => { + within(container).getAllByText('1'); + }); + + it('should have queryByText', () => { + within(container).queryByText('1'); + }); + + it('should have queryAllByText', () => { + within(container).queryAllByText('1'); + }); + + it('should have findByText', async () => { + await within(container).findByText('1'); + }); + + it('should have findAllByText', async () => { + await within(container).findAllByText('1'); + }); + + it('should have getByTitle', () => { + within(container).getByTitle('1'); + }); + + it('should have getAllByTitle', () => { + within(container).getAllByTitle('1'); + }); + + it('should have queryByTitle', () => { + within(container).queryByTitle('1'); + }); + + it('should have queryAllByTitle', () => { + within(container).queryAllByTitle('1'); + }); + + it('should have findByTitle', async () => { + await within(container).findByTitle('1'); + }); + + it('should have findAllByTitle', async () => { + await within(container).findAllByTitle('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); +}); + +describe('screen', () => { + it('should have all the queries available', () => { + // $FlowExpectedError[prop-missing] + const { notAQuery } = screen; + const { + debug, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = screen; + }); +}); + +describe('fireEvent', () => { + const htmlEl = document.createElement('div'); + + it('should be callable', () => { + fireEvent( + htmlEl, + new MouseEvent('click', { + bubbles: true, + cancelable: true, + }) + ); + }); + + it('should throw on invalid arguments', () => { + // $FlowExpectedError[incompatible-call] + fireEvent(1); + // $FlowExpectedError[incompatible-call] + fireEvent(htmlEl, 1); + }); + + it('should expose fire event helpers', () => { + fireEvent.copy(htmlEl); + fireEvent.cut(htmlEl); + fireEvent.paste(htmlEl); + fireEvent.compositionEnd(htmlEl); + fireEvent.compositionStart(htmlEl); + fireEvent.compositionUpdate(htmlEl); + fireEvent.keyDown(htmlEl); + fireEvent.keyPress(htmlEl); + fireEvent.keyUp(htmlEl); + fireEvent.focus(htmlEl); + fireEvent.blur(htmlEl); + fireEvent.change(htmlEl); + fireEvent.input(htmlEl); + fireEvent.invalid(htmlEl); + fireEvent.submit(htmlEl); + fireEvent.click(htmlEl); + fireEvent.contextMenu(htmlEl); + fireEvent.dblClick(htmlEl); + fireEvent.doubleClick(htmlEl); + fireEvent.drag(htmlEl); + fireEvent.dragEnd(htmlEl); + fireEvent.dragEnter(htmlEl); + fireEvent.dragExit(htmlEl); + fireEvent.dragLeave(htmlEl); + fireEvent.dragOver(htmlEl); + fireEvent.dragStart(htmlEl); + fireEvent.drop(htmlEl); + fireEvent.mouseDown(htmlEl); + fireEvent.mouseEnter(htmlEl); + fireEvent.mouseLeave(htmlEl); + fireEvent.mouseMove(htmlEl); + fireEvent.mouseOut(htmlEl); + fireEvent.mouseOver(htmlEl); + fireEvent.mouseUp(htmlEl); + fireEvent.select(htmlEl); + fireEvent.touchCancel(htmlEl); + fireEvent.touchEnd(htmlEl); + fireEvent.touchMove(htmlEl); + fireEvent.touchStart(htmlEl); + fireEvent.scroll(htmlEl); + fireEvent.wheel(htmlEl); + fireEvent.abort(htmlEl); + fireEvent.canPlay(htmlEl); + fireEvent.canPlayThrough(htmlEl); + fireEvent.durationChange(htmlEl); + fireEvent.emptied(htmlEl); + fireEvent.encrypted(htmlEl); + fireEvent.ended(htmlEl); + fireEvent.loadedData(htmlEl); + fireEvent.loadedMetadata(htmlEl); + fireEvent.loadStart(htmlEl); + fireEvent.pause(htmlEl); + fireEvent.play(htmlEl); + fireEvent.playing(htmlEl); + fireEvent.progress(htmlEl); + fireEvent.rateChange(htmlEl); + fireEvent.seeked(htmlEl); + fireEvent.seeking(htmlEl); + fireEvent.stalled(htmlEl); + fireEvent.suspend(htmlEl); + fireEvent.timeUpdate(htmlEl); + fireEvent.volumeChange(htmlEl); + fireEvent.waiting(htmlEl); + fireEvent.load(htmlEl); + fireEvent.error(htmlEl); + fireEvent.animationStart(htmlEl); + fireEvent.animationEnd(htmlEl); + fireEvent.animationIteration(htmlEl); + fireEvent.transitionEnd(htmlEl); + }); +}); + +describe('getNodeText', () => { + class Component extends React.Component<{ ... }> {}; + const { container } = render(); + + it('should return string', () => { + const a: string = getNodeText(container); + }); +}); + +describe('getAllByTestId', () => { + class Component extends React.Component<{ ... }> {}; + const { container } = render(); + + it('should return array of html elements', () => { + const a: Array = getAllByTestId(container, 'test'); + }); + + it('optionally takes options', () => { + getAllByTestId(container, 'test', { ...null }); + }); +}); + +describe('text matching API', () => { + class Component extends React.Component<{ ... }> {} + const { + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('getByAltText should accept text match arguments', () => { + getByAltText('1'); + getByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByAltText(/1/); + getByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByAltText((content: string, element) => true); + getByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByAltText should accept text match arguments', () => { + const result: Array = getAllByAltText('1'); + }); + + it('queryByAltText should accept text match arguments', () => { + queryByAltText('1'); + queryByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText(/1/); + queryByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText((content: string, element) => true); + queryByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByAltText should accept text match arguments', () => { + const result: Array = queryAllByAltText('1'); + }); + + it('getByDisplayValue should accept text match arguments', () => { + getByDisplayValue('1'); + getByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue(/1/); + getByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue((content: string, element) => true); + getByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByDisplayValue should accept text match arguments', () => { + const result: Array = getAllByDisplayValue('1'); + }); + + it('queryByDisplayValue should accept text match arguments', () => { + queryByDisplayValue('1'); + queryByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue(/1/); + queryByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue((content: string, element) => true); + queryByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByDisplayValue should accept text match arguments', () => { + const result: Array = queryAllByDisplayValue('1'); + }); + + it('getByLabelText should accept text match arguments', () => { + getByLabelText('1'); + getByLabelText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText(/1/); + getByLabelText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText((content: string, element) => true); + getByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByLabelText should accept text match arguments', () => { + const result: Array = getAllByLabelText('1'); + }); + + it('queryByLabelText should accept text match arguments', () => { + queryByLabelText('1'); + queryByLabelText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByLabelText(/1/); + queryByLabelText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + queryByLabelText((content: string, element) => true); + queryByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByLabelText should accept text match arguments', () => { + const result: Array = queryAllByLabelText('1'); + }); + + it('getByPlaceholderText should accept text match arguments', () => { + getByPlaceholderText('1'); + getByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText(/1/); + getByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText((content: string, element) => true); + getByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByPlaceholderText should accept text match arguments', () => { + const result: Array = getAllByPlaceholderText('1'); + }); + + it('queryByPlaceholderText should accept text match arguments', () => { + queryByPlaceholderText('1'); + queryByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText(/1/); + queryByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText((content: string, element) => true); + queryByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByPlaceholderText should accept text match arguments', () => { + const result: Array = queryAllByPlaceholderText('1'); + }); + + it('getByRole should accept text match arguments', () => { + getByRole('1'); + getByRole('1', { trim: true, collapseWhitespace: true, exact: true }); + getByRole(/1/); + getByRole(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByRole((content: string, element) => true); + getByRole((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByRole should accept text match arguments', () => { + const result: Array = getAllByRole('1'); + }); + + it('queryByRole should accept text match arguments', () => { + queryByRole('1'); + queryByRole('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByRole(/1/); + queryByRole(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByRole((content: string, element) => true); + queryByRole((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByRole should accept text match arguments', () => { + const result: Array = queryAllByRole('1'); + }); + + it('getByTestId should accept text match arguments', () => { + getByTestId('1'); + getByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTestId(/1/); + getByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTestId((content: string, element) => true); + getByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTestId should accept text match arguments', () => { + const result: Array = getAllByTestId('1'); + }); + + it('queryByTestId should accept text match arguments', () => { + queryByTestId('1'); + queryByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId(/1/); + queryByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId((content: string, element) => true); + queryByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTestId should accept text match arguments', () => { + const result: Array = queryAllByTestId('1'); + }); + + it('getByText should accept text match arguments', () => { + getByText('1'); + getByText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByText(/1/); + getByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByText((content: string, element) => true); + getByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByText should accept text match arguments', () => { + const result: Array = getAllByText('1'); + }); + + it('queryByText should accept text match arguments', () => { + queryByText('1'); + queryByText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByText(/1/); + queryByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByText((content: string, element) => true); + queryByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByText should accept text match arguments', () => { + const result: Array = queryAllByText('1'); + }); + + it('getByTitle should accept text match arguments', () => { + getByTitle('1'); + getByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTitle(/1/); + getByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTitle((content: string, element) => true); + getByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTitle should accept text match arguments', () => { + const result: Array = getAllByTitle('1'); + }); + + it('queryByTitle should accept text match arguments', () => { + queryByTitle('1'); + queryByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle(/1/); + queryByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle((content: string, element) => true); + queryByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTitle should accept text match arguments', () => { + const result: Array = queryAllByTitle('1'); + }); +}); + +describe('render() parameters', () => { + class Component extends React.Component<{ ... }> {} + + it('allows supplying parameters to render()', () => { + class CustomWrapper extends React.Component<{ ... }> {} + const element = document.createElement('div'); + render(, { + baseElement: element, + container: element, + hydrate: true, + wrapper: CustomWrapper, + }); + }); + + it('allows overriding render() with custom queries', () => { + type CustomReturnType = 123456; + declare var customValue: CustomReturnType; + const customQueries = { + getByOverride: (param1: string) => customValue, + }; + const result = render<{| + getByOverride: (string) => CustomReturnType, + |}>(, { queries: customQueries }); + const a: CustomReturnType = result.getByOverride('something'); + // $FlowExpectedError[incompatible-call] bad type for getByOverride parameter + result.getByOverride(1234); + // $FlowExpectedError[incompatible-call] missing getByOverride parameter + result.getByOverride(); + // $FlowExpectedError[prop-missing] default queries are not available when using custom queries + result.getByTestId('indifferent'); + }); +}); diff --git a/definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-/react_v11.x.x.js b/definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-v.200.x/react_v11.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-/react_v11.x.x.js rename to definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-v.200.x/react_v11.x.x.js diff --git a/definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-/test_react_v11.x.x.js b/definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-v.200.x/test_react_v11.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-/test_react_v11.x.x.js rename to definitions/npm/@testing-library/react_v11.x.x/flow_v0.104.x-v.200.x/test_react_v11.x.x.js diff --git a/definitions/npm/@testing-library/react_v11.x.x/flow_v0.201.x-/react_v11.x.x.js b/definitions/npm/@testing-library/react_v11.x.x/flow_v0.201.x-/react_v11.x.x.js new file mode 100644 index 0000000000..49fec27ec7 --- /dev/null +++ b/definitions/npm/@testing-library/react_v11.x.x/flow_v0.201.x-/react_v11.x.x.js @@ -0,0 +1,681 @@ +/** + * A local copy from: + * https://github.com/A11yance/aria-query/blob/2e6a3011a0d8987655f3a14853934fe3df38a8d8/flow/aria.js + */ + declare module '@@aria-query' { + declare export type ARIAAbstractRole = + | 'command' + | 'composite' + | 'input' + | 'landmark' + | 'range' + | 'roletype' + | 'section' + | 'sectionhead' + | 'select' + | 'structure' + | 'widget' + | 'window'; + + declare export type ARIAWidgetRole = + | 'button' + | 'checkbox' + | 'gridcell' + | 'link' + | 'menuitem' + | 'menuitemcheckbox' + | 'menuitemradio' + | 'option' + | 'progressbar' + | 'radio' + | 'scrollbar' + | 'searchbox' + | 'slider' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tabpanel' + | 'textbox' + | 'treeitem'; + + declare export type ARIACompositeWidgetRole = + | 'combobox' + | 'grid' + | 'listbox' + | 'menu' + | 'menubar' + | 'radiogroup' + | 'tablist' + | 'tree' + | 'treegrid'; + + declare export type ARIADocumentStructureRole = + | 'application' + | 'article' + | 'blockquote' + | 'caption' + | 'cell' + | 'columnheader' + | 'definition' + | 'deletion' + | 'directory' + | 'document' + | 'emphasis' + | 'feed' + | 'figure' + | 'generic' + | 'group' + | 'heading' + | 'img' + | 'insertion' + | 'list' + | 'listitem' + | 'math' + | 'meter' + | 'none' + | 'note' + | 'paragraph' + | 'presentation' + | 'row' + | 'rowgroup' + | 'rowheader' + | 'separator' + | 'strong' + | 'subscript' + | 'superscript' + | 'table' + | 'term' + | 'time' + | 'toolbar' + | 'tooltip'; + + declare export type ARIALandmarkRole = + | 'banner' + | 'complementary' + | 'contentinfo' + | 'form' + | 'main' + | 'navigation' + | 'region' + | 'search'; + + declare export type ARIALiveRegionRole = + | 'alert' + | 'log' + | 'marquee' + | 'status' + | 'timer'; + + declare export type ARIAWindowRole = 'alertdialog' | 'dialog'; + + declare export type ARIAUncategorizedRole = 'code'; + + declare export type ARIADPubRole = + | 'doc-abstract' + | 'doc-acknowledgments' + | 'doc-afterword' + | 'doc-appendix' + | 'doc-backlink' + | 'doc-biblioentry' + | 'doc-bibliography' + | 'doc-biblioref' + | 'doc-chapter' + | 'doc-colophon' + | 'doc-conclusion' + | 'doc-cover' + | 'doc-credit' + | 'doc-credits' + | 'doc-dedication' + | 'doc-endnote' + | 'doc-endnotes' + | 'doc-epigraph' + | 'doc-epilogue' + | 'doc-errata' + | 'doc-example' + | 'doc-footnote' + | 'doc-foreword' + | 'doc-glossary' + | 'doc-glossref' + | 'doc-index' + | 'doc-introduction' + | 'doc-noteref' + | 'doc-notice' + | 'doc-pagebreak' + | 'doc-pagelist' + | 'doc-part' + | 'doc-preface' + | 'doc-prologue' + | 'doc-pullquote' + | 'doc-qna' + | 'doc-subtitle' + | 'doc-tip' + | 'doc-toc'; + + declare export type ARIARole = + | ARIAWidgetRole + | ARIACompositeWidgetRole + | ARIADocumentStructureRole + | ARIALandmarkRole + | ARIALiveRegionRole + | ARIAWindowRole + | ARIAUncategorizedRole; +} + +declare module '@testing-library/react' { + import type { ARIARole } from '@@aria-query'; + + // This type comes from react-dom_v17.x.x.js + declare interface ReactDOMTestUtilsThenable { + then(resolve: () => mixed, reject?: () => mixed): mixed; + } + + // This type comes from react-dom_v17.x.x.js + declare type ReactDOMTestUtilsAct = ( + callback: () => void | ReactDOMTestUtilsThenable + ) => ReactDOMTestUtilsThenable; + + declare type WaitForOptions = {| + container?: HTMLElement, + timeout?: number, + interval?: number, + onTimeout?: (error: Error) => Error, + mutationObserverOptions?: MutationObserverInit, + |}; + + declare type MatcherFunction = ( + content: string, + element: ?Element + ) => boolean; + + declare type Matcher = MatcherFunction | RegExp | string | number; + + declare type ByRoleMatcher = ARIARole | MatcherFunction; + + declare type NormalizerFn = (text: string) => string; + + declare type MatcherOptions = {| + exact?: boolean, + /** Use normalizer with getDefaultNormalizer instead */ + trim?: boolean, + /** Use normalizer with getDefaultNormalizer instead */ + collapseWhitespace?: boolean, + normalizer?: NormalizerFn, + /** suppress suggestions for a specific query */ + suggest?: boolean, + |}; + + declare type ByRoleOptions = {| + ...MatcherOptions, + /** + * If true includes elements in the query set that are usually excluded from + * the accessibility tree. `role="none"` or `role="presentation"` are included + * in either case. + */ + hidden?: boolean, + /** + * If true only includes elements in the query set that are marked as + * selected in the accessibility tree, i.e., `aria-selected="true"` + */ + selected?: boolean, + /** + * If true only includes elements in the query set that are marked as + * checked in the accessibility tree, i.e., `aria-checked="true"` + */ + checked?: boolean, + /** + * If true only includes elements in the query set that are marked as + * pressed in the accessibility tree, i.e., `aria-pressed="true"` + */ + pressed?: boolean, + /** + * If true only includes elements in the query set that are marked as + * expanded in the accessibility tree, i.e., `aria-expanded="true"` + */ + expanded?: boolean, + /** + * Includes elements with the `"heading"` role matching the indicated level, + * either by the semantic HTML heading elements `

-

` or matching + * the `aria-level` attribute. + */ + level?: number, + /** + * Includes every role used in the `role` attribute + * For example *ByRole('progressbar', {queryFallbacks: true})` will find
`. + */ + queryFallbacks?: boolean, + /** + * Only considers elements with the specified accessible name. + */ + name?: + | string + | RegExp + | ((accessibleName: string, element: Element) => boolean), + |}; + + declare type SelectorMatcherOptions = {| + ...MatcherOptions, + selector?: string, + |}; + + // These two types must be updated kept in sync + declare export type UnionHTMLElement = + | HTMLElement + | HTMLInputElement + | HTMLAnchorElement + | HTMLButtonElement + | HTMLSelectElement; + + declare export type IntersectionHTMLElement = + & HTMLElement + & HTMLInputElement + & HTMLAnchorElement + & HTMLButtonElement + & HTMLSelectElement; + // End mixed html types + + declare type QueryByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => ?IntersectionHTMLElement; + + declare type AllByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => Array; + + declare type FindAllByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => IntersectionHTMLElement; + + declare type FindByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type QueryByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => ?IntersectionHTMLElement; + + declare type AllByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => Array; + + declare type FindAllByText = ( + text: Matcher, + options?: SelectorMatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => IntersectionHTMLElement; + + declare type FindByText = ( + text: Matcher, + options?: SelectorMatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type AllByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement[]; + + declare type GetByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement; + + declare type QueryByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement | null; + + declare type FindByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type FindAllByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetsAndQueries = {| + getByLabelText: GetByText, + getAllByLabelText: AllByText, + queryByLabelText: QueryByText, + queryAllByLabelText: AllByText, + findByLabelText: FindByText, + findAllByLabelText: FindAllByText, + + getByPlaceholderText: GetByBoundAttribute, + getAllByPlaceholderText: AllByBoundAttribute, + queryByPlaceholderText: QueryByBoundAttribute, + queryAllByPlaceholderText: AllByBoundAttribute, + findByPlaceholderText: FindByBoundAttribute, + findAllByPlaceholderText: FindAllByBoundAttribute, + + getByText: GetByText, + getAllByText: AllByText, + queryByText: QueryByText, + queryAllByText: AllByText, + findByText: FindByText, + findAllByText: FindAllByText, + + getByAltText: GetByBoundAttribute, + getAllByAltText: AllByBoundAttribute, + queryByAltText: QueryByBoundAttribute, + queryAllByAltText: AllByBoundAttribute, + findByAltText: FindByBoundAttribute, + findAllByAltText: FindAllByBoundAttribute, + + getByTitle: GetByBoundAttribute, + getAllByTitle: AllByBoundAttribute, + queryByTitle: QueryByBoundAttribute, + queryAllByTitle: AllByBoundAttribute, + findByTitle: FindByBoundAttribute, + findAllByTitle: FindAllByBoundAttribute, + + getByDisplayValue: GetByBoundAttribute, + getAllByDisplayValue: AllByBoundAttribute, + queryByDisplayValue: QueryByBoundAttribute, + queryAllByDisplayValue: AllByBoundAttribute, + findByDisplayValue: FindByBoundAttribute, + findAllByDisplayValue: FindAllByBoundAttribute, + + getByRole: GetByRole, + getAllByRole: AllByRole, + queryByRole: QueryByRole, + queryAllByRole: AllByRole, + findByRole: FindByRole, + findAllByRole: FindAllByRole, + + getByTestId: GetByBoundAttribute, + getAllByTestId: AllByBoundAttribute, + queryByTestId: QueryByBoundAttribute, + queryAllByTestId: AllByBoundAttribute, + findByTestId: FindByBoundAttribute, + findAllByTestId: FindAllByBoundAttribute, + |}; + + declare type FireEvent = ( + element: UnionHTMLElement, + eventProperties?: TInit + ) => boolean; + + declare type Screen = { + ...Queries, + /** + * Convenience function for `pretty-dom` which also allows an array + * of elements + */ + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number, + options?: { ... } // @TODO pretty format OptionsReceived + ) => void, + /** + * Convenience function for `Testing Playground` which logs URL that + * can be opened in a browser + */ + logTestingPlaygroundURL: (element?: Element | Document) => void, + ... + }; + + declare type RenderResult = { + ...Queries, + container: HTMLElement, + unmount: () => boolean, + baseElement: HTMLElement, + asFragment: () => DocumentFragment, + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number + ) => void, + rerender: (ui: React$Element) => void, + ... + }; + + declare export type RenderOptionsWithoutCustomQueries = {| + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export type RenderOptionsWithCustomQueries< + CustomQueries: { ... } + > = {| + queries: CustomQueries, + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export function render( + ui: React$Element, + options?: RenderOptionsWithoutCustomQueries + ): RenderResult<>; + declare export function render< + CustomQueries: { [string]: (...args: Array) => any, ... } + >( + ui: React$Element, + options: RenderOptionsWithCustomQueries + ): RenderResult; + + declare export var act: ReactDOMTestUtilsAct; + declare export function cleanup(): void; + + declare export function waitFor( + callback: () => T | Promise, + options?: {| + container?: UnionHTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + declare export function waitForElementToBeRemoved( + callback: (() => T) | T, + options?: {| + container?: UnionHTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + /** + * @deprecated `wait` has been deprecated and replaced by `waitFor` instead. + * In most cases you should be able to find/replace `wait` with `waitFor`. + * Learn more: https://testing-library.com/docs/dom-testing-library/api-async#waitfor. + */ + declare export function wait( + callback?: () => void, + options?: { + timeout?: number, + interval?: number, + ... + } + ): Promise; + + /** + * @deprecated `waitForDomChange` has been deprecated. + * Use `waitFor` instead: https://testing-library.com/docs/dom-testing-library/api-async#waitfor. + */ + declare export function waitForDomChange(options?: { + container?: UnionHTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + }): Promise; + + /** + * @deprecated `waitForElement` has been deprecated. + * Use a `find*` query (preferred: https://testing-library.com/docs/dom-testing-library/api-queries#findby) + * or use `waitFor` instead: https://testing-library.com/docs/dom-testing-library/api-async#waitfor + */ + declare export function waitForElement( + callback?: () => T, + options?: { + container?: UnionHTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + } + ): Promise; + + declare export function within( + element: UnionHTMLElement, + queriesToBind?: GetsAndQueries | Array + ): GetsAndQueries; + + declare export var fireEvent: {| + (element: UnionHTMLElement, event: Event): void, + + copy: FireEvent, + cut: FireEvent, + paste: FireEvent, + compositionEnd: FireEvent, + compositionStart: FireEvent, + compositionUpdate: FireEvent, + keyDown: FireEvent, + keyPress: FireEvent, + keyUp: FireEvent, + focus: FireEvent, + blur: FireEvent, + change: FireEvent, + input: FireEvent, + invalid: FireEvent, + submit: FireEvent, + click: FireEvent, + contextMenu: FireEvent, + dblClick: FireEvent, + doubleClick: FireEvent, + drag: FireEvent, + dragEnd: FireEvent, + dragEnter: FireEvent, + dragExit: FireEvent, + dragLeave: FireEvent, + dragOver: FireEvent, + dragStart: FireEvent, + drop: FireEvent, + mouseDown: FireEvent, + mouseEnter: FireEvent, + mouseLeave: FireEvent, + mouseMove: FireEvent, + mouseOut: FireEvent, + mouseOver: FireEvent, + mouseUp: FireEvent, + select: FireEvent, + touchCancel: FireEvent, + touchEnd: FireEvent, + touchMove: FireEvent, + touchStart: FireEvent, + scroll: FireEvent, + wheel: FireEvent, + abort: FireEvent, + canPlay: FireEvent, + canPlayThrough: FireEvent, + durationChange: FireEvent, + emptied: FireEvent, + encrypted: FireEvent, + ended: FireEvent, + loadedData: FireEvent, + loadedMetadata: FireEvent, + loadStart: FireEvent, + pause: FireEvent, + play: FireEvent, + playing: FireEvent, + progress: FireEvent, + rateChange: FireEvent, + seeked: FireEvent, + seeking: FireEvent, + stalled: FireEvent, + suspend: FireEvent, + timeUpdate: FireEvent, + volumeChange: FireEvent, + waiting: FireEvent, + load: FireEvent, + error: FireEvent, + animationStart: FireEvent, + animationEnd: FireEvent, + animationIteration: FireEvent, + transitionEnd: FireEvent, + |}; + // dom-testing-library re-declares + declare export function queryByTestId( + container: UnionHTMLElement, + id: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByTestId( + container: UnionHTMLElement, + id: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByText( + container: UnionHTMLElement, + text: Matcher, + options?: { selector?: string, ... } & MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByPlaceholderText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByPlaceholderText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByLabelText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByLabelText( + container: UnionHTMLElement, + text: Matcher, + options?: { selector?: string, ... } & MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByAltText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByAltText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function getNodeText(node: UnionHTMLElement): string; + declare export var screen: Screen<>; +} diff --git a/definitions/npm/@testing-library/react_v11.x.x/flow_v0.201.x-/test_react_v11.x.x.js b/definitions/npm/@testing-library/react_v11.x.x/flow_v0.201.x-/test_react_v11.x.x.js new file mode 100644 index 0000000000..d785817fbd --- /dev/null +++ b/definitions/npm/@testing-library/react_v11.x.x/flow_v0.201.x-/test_react_v11.x.x.js @@ -0,0 +1,1308 @@ +// @flow + +import * as React from 'react'; +import { + act, + render, + fireEvent, + cleanup, + waitFor, + waitForDomChange, + waitForElement, + waitForElementToBeRemoved, + within, + screen, + getNodeText, + type IntersectionHTMLElement, +} from '@testing-library/react'; +import { describe, it } from 'flow-typed-test'; + +describe('act', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + act(1); + // $FlowExpectedError[extra-arg] + act(() => {}, 1); + // $FlowExpectedError[incompatible-call] + act(() => 1); + }); + + it('should pass on correct inputs', () => { + act(() => {}); + act(() => Promise.resolve()); + act(() => ({ + then: (resolve) => {}, + })); + }); + + it('should fail on incorrect usage of result', () => { + // $FlowExpectedError[incompatible-type] + act(() => {}) + 1; + // $FlowExpectedError[prop-missing] + act(() => {}).doesNotExist(); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(1); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(() => {}, 1); + }); + + it('should pass on correct usage of result', () => { + act(() => {}).then(() => {}); + act(() => {}).then( + () => {}, + () => {} + ); + }); +}); + +describe('waitFor', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitFor(1); + // $FlowExpectedError[incompatible-call] + waitFor(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitFor(() => {}); + waitFor(() => {}, { timeout: 1 }); + }); +}); + +describe('waitForDomChange', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForDomChange(1); + // $FlowExpectedError[incompatible-call] + waitForDomChange('1'); + }); + + it('should pass on correct inputs', () => { + waitForDomChange({ container: document.createElement('div') }); + waitForDomChange({ timeout: 1 }); + }); +}); + +describe('waitForElement', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElement(1); + // $FlowExpectedError[incompatible-call] + waitForElement(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitForElement(() => document.createElement('div')); + waitForElement(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async (n) => { + const usernameElement = await waitForElement(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('waitForElementToBeRemoved', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElementToBeRemoved(() => {}, 1); + }); + + it('should pass on correct inputs (callback)', () => { + waitForElementToBeRemoved(() => document.createElement('div')); + waitForElementToBeRemoved(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should pass on correct inputs (node)', () => { + waitForElementToBeRemoved(document.createElement('div')); + waitForElementToBeRemoved(document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async (n) => { + const usernameElement = await waitForElementToBeRemoved(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('render', () => { + class Component extends React.Component<{ ... }> {} + const { + container, + unmount, + baseElement, + asFragment, + debug, + rerender, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('unmount should has 0 arguments', () => { + unmount(); + // $FlowExpectedError[extra-arg] + unmount(1); + }); + + it('container should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = container; + const b: HTMLElement = container; + }); + + it('baseElement should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = baseElement; + const b: HTMLElement = baseElement; + }); + + it('asFragment should return a document fragment', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = asFragment(); + const b: DocumentFragment = asFragment(); + }); + + it('debug maybe has 1 argument an html element', () => { + // $FlowExpectedError[incompatible-call] + debug(1); + debug(container); + }); + + it('rerender should has 1 argument an react element', () => { + // $FlowExpectedError[incompatible-call] + rerender(); + rerender(); + }); + + it('getByAltText should return HTML element', () => { + const a: IntersectionHTMLElement = getByAltText('1'); + }); + + it('getAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByAltText('1'); + const b: Array = getAllByAltText('2'); + }); + + it('queryByAltText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByAltText('1'); + const b: ?IntersectionHTMLElement = queryByAltText('2'); + }); + + it('queryAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByAltText('1'); + const b: Array = queryAllByAltText('2'); + }); + + it('findByAltText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByAltText('1'); + const b: Promise = findByAltText('1'); + }); + + it('findAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByAltText('1'); + const b: Promise> = findAllByAltText('2'); + }); + + it('getByDisplayValue should return HTML element', () => { + const a: IntersectionHTMLElement = getByDisplayValue('1'); + }); + + it('getAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByDisplayValue('1'); + const b: Array = getAllByDisplayValue('2'); + }); + + it('queryByDisplayValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByDisplayValue('1'); + const b: ?IntersectionHTMLElement = queryByDisplayValue('2'); + }); + + it('queryAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByDisplayValue('1'); + const b: Array = queryAllByDisplayValue('2'); + }); + + it('findByDisplayValue should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByDisplayValue('1'); + const b: Promise = findByDisplayValue('1'); + }); + + it('findAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByDisplayValue('1'); + const b: Promise> = findAllByDisplayValue('2'); + }); + + it('getByLabelText should return HTML element', () => { + const a: IntersectionHTMLElement = getByLabelText('1'); + }); + + it('getAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByLabelText('1'); + const b: Array = getAllByLabelText('2'); + }); + + it('queryByLabelText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByLabelText('1'); + const b: ?IntersectionHTMLElement = queryByLabelText('2'); + }); + + it('queryAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByLabelText('1'); + const b: Array = queryAllByLabelText('2'); + }); + + it('findByLabelText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByLabelText('1'); + const b: Promise = findByLabelText('1'); + }); + + it('findAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByLabelText('1'); + const b: Promise> = findAllByLabelText('2'); + }); + + it('getByPlaceholderText should return HTML element', () => { + const a: IntersectionHTMLElement = getByPlaceholderText('1'); + }); + + it('getAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByPlaceholderText('1'); + const b: Array = getAllByPlaceholderText('2'); + }); + + it('queryByPlaceholderText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByPlaceholderText('1'); + const b: ?IntersectionHTMLElement = queryByPlaceholderText('2'); + }); + + it('queryAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByPlaceholderText('1'); + const b: Array = queryAllByPlaceholderText('2'); + }); + + it('findByPlaceholderText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByPlaceholderText('1'); + const b: Promise = findByPlaceholderText('1'); + }); + + it('findAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByPlaceholderText('1'); + const b: Promise> = findAllByPlaceholderText('2'); + }); + + it('getByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: string = getByRole('button'); + const b: IntersectionHTMLElement = getByRole('button'); + }); + + it('getAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByRole('button'); + const b: Array = getAllByRole('button'); + }); + + it('queryByRole should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByRole('button'); + const b: ?IntersectionHTMLElement = queryByRole('button'); + }); + + it('queryAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByRole('button'); + const b: Array = queryAllByRole('button'); + }); + + it('findByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByRole('button'); + const b: Promise = findByRole('button'); + }); + + it('findAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByRole('button'); + const b: Promise> = findAllByRole('button'); + }); + + it('getByTestId should return HTML element', () => { + const a: IntersectionHTMLElement = getByTestId('1'); + }); + + it('getByTestId returns a mixed HTML type', () => { + const a = getByTestId('1'); + a.value; + a.disabled; + a.href; + }); + + it('getAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByTestId('1'); + const b: Array = getAllByTestId('2'); + }); + + it('queryByTestId should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByTestId('1'); + const b: ?IntersectionHTMLElement = queryByTestId('2'); + }); + + it('queryAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByTestId('1'); + const b: Array = queryAllByTestId('2'); + }); + + it('findByTestId should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByTestId('1'); + const b: Promise = findByTestId('1'); + }); + + it('findAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findAllByTestId('1'); + const b: Promise> = findAllByTestId('2'); + }); + + it('getByText should return HTML element', () => { + const a: IntersectionHTMLElement = getByText('1'); + }); + + it('getAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByText('1'); + const b: Array = getAllByText('2'); + }); + + it('queryByText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByText('1'); + const b: ?IntersectionHTMLElement = queryByText('2'); + }); + + it('queryAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByText('1'); + const b: Array = queryAllByText('2'); + }); + + it('findByText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByText('1'); + const b: Promise = findByText('1'); + }); + + it('findAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByText('1'); + const b: Promise> = findAllByText('2'); + }); + + it('getByTitle should return HTML element', () => { + const a: IntersectionHTMLElement = getByTitle('1'); + }); + + it('getAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByTitle('1'); + const b: Array = getAllByTitle('2'); + }); + + it('queryByTitle should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByTitle('1'); + const b: ?IntersectionHTMLElement = queryByTitle('2'); + }); + + it('queryAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByTitle('1'); + const b: Array = queryAllByTitle('2'); + }); + + it('findByTitle should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByTitle('1'); + const b: Promise = findByTitle('1'); + }); + + it('findAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findAllByTitle('1'); + const b: Promise> = findAllByTitle('2'); + }); +}); + +describe('cleanup', () => { + it('should be a function w/o arguments', () => { + cleanup(); + // $FlowExpectedError[extra-arg] + cleanup(1); + }); +}); + +describe('within', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should has html element as argument', () => { + // $FlowExpectedError[incompatible-call] + within(); + within(container); + }); + + it('should have getByAltText', () => { + within(container).getByAltText('1'); + }); + + it('should have getAllByAltText', () => { + within(container).getAllByAltText('1'); + }); + + it('should have queryByAltText', () => { + within(container).queryByAltText('1'); + }); + + it('should have queryAllByAltText', () => { + within(container).queryAllByAltText('1'); + }); + + it('should have findByAltText', async () => { + await within(container).findByAltText('1'); + }); + + it('should have findAllByAltText', async () => { + await within(container).findAllByAltText('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); + + it('should have getByLabelText', () => { + within(container).getByLabelText('1'); + }); + + it('should have getAllByLabelText', () => { + within(container).getAllByLabelText('1'); + }); + + it('should have queryByLabelText', () => { + within(container).queryByLabelText('1'); + }); + + it('should have queryAllByLabelText', () => { + within(container).queryAllByLabelText('1'); + }); + + it('should have findByLabelText', async () => { + await within(container).findByLabelText('1'); + }); + + it('should have findAllByLabelText', async () => { + await within(container).findAllByLabelText('1'); + }); + + it('should have getByPlaceholderText', () => { + within(container).getByPlaceholderText('1'); + }); + + it('should have getAllByPlaceholderText', () => { + within(container).getAllByPlaceholderText('1'); + }); + + it('should have queryByPlaceholderText', () => { + within(container).queryByPlaceholderText('1'); + }); + + it('should have queryAllByPlaceholderText', () => { + within(container).queryAllByPlaceholderText('1'); + }); + + it('should have findByPlaceholderText', async () => { + await within(container).findByPlaceholderText('1'); + }); + + it('should have findAllByPlaceholderText', async () => { + await within(container).findAllByPlaceholderText('1'); + }); + + it('should have getByRole', () => { + within(container).getByRole('button'); + }); + + it('should have getAllByRole', () => { + within(container).getAllByRole('button'); + }); + + it('should have queryByRole', () => { + within(container).queryByRole('button'); + }); + + it('should have queryAllByRole', () => { + within(container).queryAllByRole('button'); + }); + + it('should have findByRole', async () => { + await within(container).findByRole('button'); + }); + + it('should have findAllByRole', async () => { + await within(container).findAllByRole('button'); + }); + + it('should have getByTestId', () => { + within(container).getByTestId('1'); + }); + + it('should have getAllByTestId', () => { + within(container).getAllByTestId('1'); + }); + + it('should have queryByTestId', () => { + within(container).queryByTestId('1'); + }); + + it('should have queryAllByTestId', () => { + within(container).queryAllByTestId('1'); + }); + + it('should have findByTestId', async () => { + await within(container).findByTestId('1'); + }); + + it('should have findAllByTestId', async () => { + await within(container).findAllByTestId('1'); + }); + + it('should have getByText', () => { + within(container).getByText('1'); + }); + + it('should have getAllByText', () => { + within(container).getAllByText('1'); + }); + + it('should have queryByText', () => { + within(container).queryByText('1'); + }); + + it('should have queryAllByText', () => { + within(container).queryAllByText('1'); + }); + + it('should have findByText', async () => { + await within(container).findByText('1'); + }); + + it('should have findAllByText', async () => { + await within(container).findAllByText('1'); + }); + + it('should have getByTitle', () => { + within(container).getByTitle('1'); + }); + + it('should have getAllByTitle', () => { + within(container).getAllByTitle('1'); + }); + + it('should have queryByTitle', () => { + within(container).queryByTitle('1'); + }); + + it('should have queryAllByTitle', () => { + within(container).queryAllByTitle('1'); + }); + + it('should have findByTitle', async () => { + await within(container).findByTitle('1'); + }); + + it('should have findAllByTitle', async () => { + await within(container).findAllByTitle('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); +}); + +describe('screen', () => { + it('should have all the queries available', () => { + // $FlowExpectedError[prop-missing] + const { notAQuery } = screen; + const { + debug, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = screen; + }); +}); + +describe('fireEvent', () => { + const htmlEl = document.createElement('div'); + + it('should be callable', () => { + fireEvent( + htmlEl, + new MouseEvent('click', { + bubbles: true, + cancelable: true, + }) + ); + }); + + it('should throw on invalid arguments', () => { + // $FlowExpectedError[incompatible-call] + fireEvent(1); + // $FlowExpectedError[incompatible-call] + fireEvent(htmlEl, 1); + }); + + it('should expose fire event helpers', () => { + fireEvent.copy(htmlEl); + fireEvent.cut(htmlEl); + fireEvent.paste(htmlEl); + fireEvent.compositionEnd(htmlEl); + fireEvent.compositionStart(htmlEl); + fireEvent.compositionUpdate(htmlEl); + fireEvent.keyDown(htmlEl); + fireEvent.keyPress(htmlEl); + fireEvent.keyUp(htmlEl); + fireEvent.focus(htmlEl); + fireEvent.blur(htmlEl); + fireEvent.change(htmlEl); + fireEvent.input(htmlEl); + fireEvent.invalid(htmlEl); + fireEvent.submit(htmlEl); + fireEvent.click(htmlEl); + fireEvent.contextMenu(htmlEl); + fireEvent.dblClick(htmlEl); + fireEvent.doubleClick(htmlEl); + fireEvent.drag(htmlEl); + fireEvent.dragEnd(htmlEl); + fireEvent.dragEnter(htmlEl); + fireEvent.dragExit(htmlEl); + fireEvent.dragLeave(htmlEl); + fireEvent.dragOver(htmlEl); + fireEvent.dragStart(htmlEl); + fireEvent.drop(htmlEl); + fireEvent.mouseDown(htmlEl); + fireEvent.mouseEnter(htmlEl); + fireEvent.mouseLeave(htmlEl); + fireEvent.mouseMove(htmlEl); + fireEvent.mouseOut(htmlEl); + fireEvent.mouseOver(htmlEl); + fireEvent.mouseUp(htmlEl); + fireEvent.select(htmlEl); + fireEvent.touchCancel(htmlEl); + fireEvent.touchEnd(htmlEl); + fireEvent.touchMove(htmlEl); + fireEvent.touchStart(htmlEl); + fireEvent.scroll(htmlEl); + fireEvent.wheel(htmlEl); + fireEvent.abort(htmlEl); + fireEvent.canPlay(htmlEl); + fireEvent.canPlayThrough(htmlEl); + fireEvent.durationChange(htmlEl); + fireEvent.emptied(htmlEl); + fireEvent.encrypted(htmlEl); + fireEvent.ended(htmlEl); + fireEvent.loadedData(htmlEl); + fireEvent.loadedMetadata(htmlEl); + fireEvent.loadStart(htmlEl); + fireEvent.pause(htmlEl); + fireEvent.play(htmlEl); + fireEvent.playing(htmlEl); + fireEvent.progress(htmlEl); + fireEvent.rateChange(htmlEl); + fireEvent.seeked(htmlEl); + fireEvent.seeking(htmlEl); + fireEvent.stalled(htmlEl); + fireEvent.suspend(htmlEl); + fireEvent.timeUpdate(htmlEl); + fireEvent.volumeChange(htmlEl); + fireEvent.waiting(htmlEl); + fireEvent.load(htmlEl); + fireEvent.error(htmlEl); + fireEvent.animationStart(htmlEl); + fireEvent.animationEnd(htmlEl); + fireEvent.animationIteration(htmlEl); + fireEvent.transitionEnd(htmlEl); + }); +}); + +describe('getNodeText', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should return string', () => { + const a: string = getNodeText(container); + }); +}); + +describe('text matching API', () => { + class Component extends React.Component<{ ... }> {} + const { + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('getByAltText should accept text match arguments', () => { + getByAltText('1'); + getByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByAltText(/1/); + getByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByAltText((content: string, element) => true); + getByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByAltText should accept text match arguments', () => { + const result: Array = getAllByAltText('1'); + }); + + it('queryByAltText should accept text match arguments', () => { + queryByAltText('1'); + queryByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText(/1/); + queryByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText((content: string, element) => true); + queryByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByAltText should accept text match arguments', () => { + const result: Array = queryAllByAltText('1'); + }); + + it('getByDisplayValue should accept text match arguments', () => { + getByDisplayValue('1'); + getByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue(/1/); + getByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue((content: string, element) => true); + getByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByDisplayValue should accept text match arguments', () => { + const result: Array = getAllByDisplayValue('1'); + }); + + it('queryByDisplayValue should accept text match arguments', () => { + queryByDisplayValue('1'); + queryByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue(/1/); + queryByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue((content: string, element) => true); + queryByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByDisplayValue should accept text match arguments', () => { + const result: Array = queryAllByDisplayValue('1'); + }); + + it('getByLabelText should accept text match arguments', () => { + getByLabelText('1'); + getByLabelText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText(/1/); + getByLabelText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText((content: string, element) => true); + getByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByLabelText should accept text match arguments', () => { + const result: Array = getAllByLabelText('1'); + }); + + it('queryByLabelText should accept text match arguments', () => { + queryByLabelText('1'); + queryByLabelText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByLabelText(/1/); + queryByLabelText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + queryByLabelText((content: string, element) => true); + queryByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByLabelText should accept text match arguments', () => { + const result: Array = queryAllByLabelText('1'); + }); + + it('getByPlaceholderText should accept text match arguments', () => { + getByPlaceholderText('1'); + getByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText(/1/); + getByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText((content: string, element) => true); + getByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByPlaceholderText should accept text match arguments', () => { + const result: Array = getAllByPlaceholderText('1'); + }); + + it('queryByPlaceholderText should accept text match arguments', () => { + queryByPlaceholderText('1'); + queryByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText(/1/); + queryByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText((content: string, element) => true); + queryByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByPlaceholderText should accept text match arguments', () => { + const result: Array = queryAllByPlaceholderText('1'); + }); + + it('getByRole should accept by role arguments', () => { + getByRole('button'); + getByRole('button', { hidden: true }); + getByRole((content: string, element) => true); + getByRole((content: string, element) => true, { + hidden: true, + }); + }); + + it('getAllByRole should accept by role arguments', () => { + const result: Array = getAllByRole('button'); + }); + + it('queryByRole should accept by role arguments', () => { + queryByRole('button'); + queryByRole('button', { hidden: true }); + queryByRole((content: string, element) => true); + queryByRole((content: string, element) => true, { + hidden: true, + }); + }); + + it('queryAllByRole should accept by role arguments', () => { + const result: Array = queryAllByRole('button'); + }); + + it('getByTestId should accept text match arguments', () => { + getByTestId('1'); + getByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTestId(/1/); + getByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTestId((content: string, element) => true); + getByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTestId should accept text match arguments', () => { + const result: Array = getAllByTestId('1'); + }); + + it('queryByTestId should accept text match arguments', () => { + queryByTestId('1'); + queryByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId(/1/); + queryByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId((content: string, element) => true); + queryByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTestId should accept text match arguments', () => { + const result: Array = queryAllByTestId('1'); + }); + + it('getByText should accept text match arguments', () => { + getByText('1'); + getByText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByText(/1/); + getByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByText((content: string, element) => true); + getByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByText should accept text match arguments', () => { + const result: Array = getAllByText('1'); + }); + + it('queryByText should accept text match arguments', () => { + queryByText('1'); + queryByText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByText(/1/); + queryByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByText((content: string, element) => true); + queryByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByText should accept text match arguments', () => { + const result: Array = queryAllByText('1'); + }); + + it('getByTitle should accept text match arguments', () => { + getByTitle('1'); + getByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTitle(/1/); + getByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTitle((content: string, element) => true); + getByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTitle should accept text match arguments', () => { + const result: Array = getAllByTitle('1'); + }); + + it('queryByTitle should accept text match arguments', () => { + queryByTitle('1'); + queryByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle(/1/); + queryByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle((content: string, element) => true); + queryByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTitle should accept text match arguments', () => { + const result: Array = queryAllByTitle('1'); + }); +}); + +describe('render() parameters', () => { + class Component extends React.Component<{ ... }> {} + + it('allows supplying parameters to render()', () => { + class CustomWrapper extends React.Component<{ ... }> {} + const element = document.createElement('div'); + render(, { + baseElement: element, + container: element, + hydrate: true, + wrapper: CustomWrapper, + }); + }); + + it('allows overriding render() with custom queries', () => { + type CustomReturnType = 123456; + declare var customValue: CustomReturnType; + const customQueries = { + getByOverride: (param1: string) => customValue, + }; + const result = render<{| + getByOverride: (string) => CustomReturnType, + |}>(, { queries: customQueries }); + const a: CustomReturnType = result.getByOverride('something'); + // $FlowExpectedError[incompatible-call] bad type for getByOverride parameter + result.getByOverride(1234); + // $FlowExpectedError[incompatible-call] missing getByOverride parameter + result.getByOverride(); + // $FlowExpectedError[prop-missing] default queries are not available when using custom queries + result.getByTestId('indifferent'); + }); +}); diff --git a/definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-/react_v12.x.x.js b/definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-v.200.x/react_v12.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-/react_v12.x.x.js rename to definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-v.200.x/react_v12.x.x.js diff --git a/definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-/test_react_v12.x.x.js b/definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-v.200.x/test_react_v12.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-/test_react_v12.x.x.js rename to definitions/npm/@testing-library/react_v12.x.x/flow_v0.104.x-v.200.x/test_react_v12.x.x.js diff --git a/definitions/npm/@testing-library/react_v12.x.x/flow_v0.201.x-/react_v12.x.x.js b/definitions/npm/@testing-library/react_v12.x.x/flow_v0.201.x-/react_v12.x.x.js new file mode 100644 index 0000000000..8529594869 --- /dev/null +++ b/definitions/npm/@testing-library/react_v12.x.x/flow_v0.201.x-/react_v12.x.x.js @@ -0,0 +1,646 @@ +/** + * A local copy from: + * https://github.com/A11yance/aria-query/blob/2e6a3011a0d8987655f3a14853934fe3df38a8d8/flow/aria.js + */ + declare module '@@aria-query' { + declare export type ARIAAbstractRole = + | 'command' + | 'composite' + | 'input' + | 'landmark' + | 'range' + | 'roletype' + | 'section' + | 'sectionhead' + | 'select' + | 'structure' + | 'widget' + | 'window'; + + declare export type ARIAWidgetRole = + | 'button' + | 'checkbox' + | 'gridcell' + | 'link' + | 'menuitem' + | 'menuitemcheckbox' + | 'menuitemradio' + | 'option' + | 'progressbar' + | 'radio' + | 'scrollbar' + | 'searchbox' + | 'slider' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tabpanel' + | 'textbox' + | 'treeitem'; + + declare export type ARIACompositeWidgetRole = + | 'combobox' + | 'grid' + | 'listbox' + | 'menu' + | 'menubar' + | 'radiogroup' + | 'tablist' + | 'tree' + | 'treegrid'; + + declare export type ARIADocumentStructureRole = + | 'application' + | 'article' + | 'blockquote' + | 'caption' + | 'cell' + | 'columnheader' + | 'definition' + | 'deletion' + | 'directory' + | 'document' + | 'emphasis' + | 'feed' + | 'figure' + | 'generic' + | 'group' + | 'heading' + | 'img' + | 'insertion' + | 'list' + | 'listitem' + | 'math' + | 'meter' + | 'none' + | 'note' + | 'paragraph' + | 'presentation' + | 'row' + | 'rowgroup' + | 'rowheader' + | 'separator' + | 'strong' + | 'subscript' + | 'superscript' + | 'table' + | 'term' + | 'time' + | 'toolbar' + | 'tooltip'; + + declare export type ARIALandmarkRole = + | 'banner' + | 'complementary' + | 'contentinfo' + | 'form' + | 'main' + | 'navigation' + | 'region' + | 'search'; + + declare export type ARIALiveRegionRole = + | 'alert' + | 'log' + | 'marquee' + | 'status' + | 'timer'; + + declare export type ARIAWindowRole = 'alertdialog' | 'dialog'; + + declare export type ARIAUncategorizedRole = 'code'; + + declare export type ARIADPubRole = + | 'doc-abstract' + | 'doc-acknowledgments' + | 'doc-afterword' + | 'doc-appendix' + | 'doc-backlink' + | 'doc-biblioentry' + | 'doc-bibliography' + | 'doc-biblioref' + | 'doc-chapter' + | 'doc-colophon' + | 'doc-conclusion' + | 'doc-cover' + | 'doc-credit' + | 'doc-credits' + | 'doc-dedication' + | 'doc-endnote' + | 'doc-endnotes' + | 'doc-epigraph' + | 'doc-epilogue' + | 'doc-errata' + | 'doc-example' + | 'doc-footnote' + | 'doc-foreword' + | 'doc-glossary' + | 'doc-glossref' + | 'doc-index' + | 'doc-introduction' + | 'doc-noteref' + | 'doc-notice' + | 'doc-pagebreak' + | 'doc-pagelist' + | 'doc-part' + | 'doc-preface' + | 'doc-prologue' + | 'doc-pullquote' + | 'doc-qna' + | 'doc-subtitle' + | 'doc-tip' + | 'doc-toc'; + + declare export type ARIARole = + | ARIAWidgetRole + | ARIACompositeWidgetRole + | ARIADocumentStructureRole + | ARIALandmarkRole + | ARIALiveRegionRole + | ARIAWindowRole + | ARIAUncategorizedRole; +} + +declare module '@testing-library/react' { + import type { ARIARole } from '@@aria-query'; + + // This type comes from react-dom_v17.x.x.js + declare interface ReactDOMTestUtilsThenable { + then(resolve: () => mixed, reject?: () => mixed): mixed; + } + + // This type comes from react-dom_v17.x.x.js + declare type ReactDOMTestUtilsAct = ( + callback: () => void | ReactDOMTestUtilsThenable + ) => ReactDOMTestUtilsThenable; + + declare type WaitForOptions = {| + container?: HTMLElement, + timeout?: number, + interval?: number, + onTimeout?: (error: Error) => Error, + mutationObserverOptions?: MutationObserverInit, + |}; + + declare type MatcherFunction = ( + content: string, + element: HTMLElement + ) => boolean; + + declare type Matcher = MatcherFunction | RegExp | string | number; + + declare type ByRoleMatcher = ARIARole | MatcherFunction; + + declare type NormalizerFn = (text: string) => string; + + declare type MatcherOptions = {| + exact?: boolean, + /** Use normalizer with getDefaultNormalizer instead */ + trim?: boolean, + /** Use normalizer with getDefaultNormalizer instead */ + collapseWhitespace?: boolean, + normalizer?: NormalizerFn, + /** suppress suggestions for a specific query */ + suggest?: boolean, + |}; + + declare type ByRoleOptions = {| + ...MatcherOptions, + /** + * If true includes elements in the query set that are usually excluded from + * the accessibility tree. `role="none"` or `role="presentation"` are included + * in either case. + */ + hidden?: boolean, + /** + * If true only includes elements in the query set that are marked as + * selected in the accessibility tree, i.e., `aria-selected="true"` + */ + selected?: boolean, + /** + * If true only includes elements in the query set that are marked as + * checked in the accessibility tree, i.e., `aria-checked="true"` + */ + checked?: boolean, + /** + * If true only includes elements in the query set that are marked as + * pressed in the accessibility tree, i.e., `aria-pressed="true"` + */ + pressed?: boolean, + /** + * If true only includes elements in the query set that are marked as + * expanded in the accessibility tree, i.e., `aria-expanded="true"` + */ + expanded?: boolean, + /** + * Includes elements with the `"heading"` role matching the indicated level, + * either by the semantic HTML heading elements `

-

` or matching + * the `aria-level` attribute. + */ + level?: number, + /** + * Includes every role used in the `role` attribute + * For example *ByRole('progressbar', {queryFallbacks: true})` will find
`. + */ + queryFallbacks?: boolean, + /** + * Only considers elements with the specified accessible name. + */ + name?: + | string + | RegExp + | ((accessibleName: string, element: Element) => boolean), + |}; + + declare type SelectorMatcherOptions = {| + ...MatcherOptions, + selector?: string, + ignore?: string | boolean + |}; + + // These two types must be updated kept in sync + declare export type UnionHTMLElement = + | HTMLElement + | HTMLInputElement + | HTMLAnchorElement + | HTMLButtonElement + | HTMLLabelElement + | HTMLSelectElement; + + declare export type IntersectionHTMLElement = + & HTMLElement + & HTMLInputElement + & HTMLAnchorElement + & HTMLButtonElement + & HTMLLabelElement + & HTMLSelectElement; + // End mixed html types + + declare type MaybeIntersectionHTMLElement = null | IntersectionHTMLElement; + + declare type QueryByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => MaybeIntersectionHTMLElement; + + declare type AllByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => Array; + + declare type FindAllByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => IntersectionHTMLElement; + + declare type FindByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type QueryByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => MaybeIntersectionHTMLElement; + + declare type AllByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => Array; + + declare type FindAllByText = ( + text: Matcher, + options?: SelectorMatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => IntersectionHTMLElement; + + declare type FindByText = ( + text: Matcher, + options?: SelectorMatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type AllByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement[]; + + declare type GetByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement; + + declare type QueryByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement | null; + + declare type FindByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type FindAllByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetsAndQueries = {| + getByLabelText: GetByText, + getAllByLabelText: AllByText, + queryByLabelText: QueryByText, + queryAllByLabelText: AllByText, + findByLabelText: FindByText, + findAllByLabelText: FindAllByText, + + getByPlaceholderText: GetByBoundAttribute, + getAllByPlaceholderText: AllByBoundAttribute, + queryByPlaceholderText: QueryByBoundAttribute, + queryAllByPlaceholderText: AllByBoundAttribute, + findByPlaceholderText: FindByBoundAttribute, + findAllByPlaceholderText: FindAllByBoundAttribute, + + getByText: GetByText, + getAllByText: AllByText, + queryByText: QueryByText, + queryAllByText: AllByText, + findByText: FindByText, + findAllByText: FindAllByText, + + getByAltText: GetByBoundAttribute, + getAllByAltText: AllByBoundAttribute, + queryByAltText: QueryByBoundAttribute, + queryAllByAltText: AllByBoundAttribute, + findByAltText: FindByBoundAttribute, + findAllByAltText: FindAllByBoundAttribute, + + getByTitle: GetByBoundAttribute, + getAllByTitle: AllByBoundAttribute, + queryByTitle: QueryByBoundAttribute, + queryAllByTitle: AllByBoundAttribute, + findByTitle: FindByBoundAttribute, + findAllByTitle: FindAllByBoundAttribute, + + getByDisplayValue: GetByBoundAttribute, + getAllByDisplayValue: AllByBoundAttribute, + queryByDisplayValue: QueryByBoundAttribute, + queryAllByDisplayValue: AllByBoundAttribute, + findByDisplayValue: FindByBoundAttribute, + findAllByDisplayValue: FindAllByBoundAttribute, + + getByRole: GetByRole, + getAllByRole: AllByRole, + queryByRole: QueryByRole, + queryAllByRole: AllByRole, + findByRole: FindByRole, + findAllByRole: FindAllByRole, + + getByTestId: GetByBoundAttribute, + getAllByTestId: AllByBoundAttribute, + queryByTestId: QueryByBoundAttribute, + queryAllByTestId: AllByBoundAttribute, + findByTestId: FindByBoundAttribute, + findAllByTestId: FindAllByBoundAttribute, + |}; + + declare type FireEvent = ( + element: UnionHTMLElement, + eventProperties?: TInit + ) => boolean; + + declare type Screen = { + ...Queries, + /** + * Convenience function for `pretty-dom` which also allows an array + * of elements + */ + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number, + options?: { ... } // @TODO pretty format OptionsReceived + ) => void, + /** + * Convenience function for `Testing Playground` which logs URL that + * can be opened in a browser + */ + logTestingPlaygroundURL: (element?: Element | Document) => void, + ... + }; + + declare type RenderResult = { + ...Queries, + container: HTMLElement, + unmount: () => boolean, + baseElement: HTMLElement, + asFragment: () => DocumentFragment, + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number + ) => void, + rerender: (ui: React$Element) => void, + ... + }; + + declare export type RenderOptionsWithoutCustomQueries = {| + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export type RenderOptionsWithCustomQueries< + CustomQueries: { ... } + > = {| + queries: CustomQueries, + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export function render( + ui: React$Element, + options?: RenderOptionsWithoutCustomQueries + ): RenderResult<>; + declare export function render< + CustomQueries: { [string]: (...args: Array) => any, ... } + >( + ui: React$Element, + options: RenderOptionsWithCustomQueries + ): RenderResult; + + declare export var act: ReactDOMTestUtilsAct; + declare export function cleanup(): void; + + declare export function waitFor( + callback: () => T | Promise, + options?: {| + container?: UnionHTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + declare export function waitForElementToBeRemoved( + callback: (() => T) | T, + options?: {| + container?: UnionHTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + declare export function within( + element: UnionHTMLElement, + queriesToBind?: GetsAndQueries | Array + ): GetsAndQueries; + + declare export var fireEvent: {| + (element: UnionHTMLElement, event: Event): void, + + copy: FireEvent, + cut: FireEvent, + paste: FireEvent, + compositionEnd: FireEvent, + compositionStart: FireEvent, + compositionUpdate: FireEvent, + keyDown: FireEvent, + keyPress: FireEvent, + keyUp: FireEvent, + focus: FireEvent, + blur: FireEvent, + change: FireEvent, + input: FireEvent, + invalid: FireEvent, + submit: FireEvent, + click: FireEvent, + contextMenu: FireEvent, + dblClick: FireEvent, + doubleClick: FireEvent, + drag: FireEvent, + dragEnd: FireEvent, + dragEnter: FireEvent, + dragExit: FireEvent, + dragLeave: FireEvent, + dragOver: FireEvent, + dragStart: FireEvent, + drop: FireEvent, + mouseDown: FireEvent, + mouseEnter: FireEvent, + mouseLeave: FireEvent, + mouseMove: FireEvent, + mouseOut: FireEvent, + mouseOver: FireEvent, + mouseUp: FireEvent, + select: FireEvent, + touchCancel: FireEvent, + touchEnd: FireEvent, + touchMove: FireEvent, + touchStart: FireEvent, + scroll: FireEvent, + wheel: FireEvent, + abort: FireEvent, + canPlay: FireEvent, + canPlayThrough: FireEvent, + durationChange: FireEvent, + emptied: FireEvent, + encrypted: FireEvent, + ended: FireEvent, + loadedData: FireEvent, + loadedMetadata: FireEvent, + loadStart: FireEvent, + pause: FireEvent, + play: FireEvent, + playing: FireEvent, + progress: FireEvent, + rateChange: FireEvent, + seeked: FireEvent, + seeking: FireEvent, + stalled: FireEvent, + suspend: FireEvent, + timeUpdate: FireEvent, + volumeChange: FireEvent, + waiting: FireEvent, + load: FireEvent, + error: FireEvent, + animationStart: FireEvent, + animationEnd: FireEvent, + animationIteration: FireEvent, + transitionEnd: FireEvent, + |}; + // dom-testing-library re-declares + declare export function queryByTestId( + container: UnionHTMLElement, + id: Matcher, + options?: MatcherOptions + ): MaybeIntersectionHTMLElement; + declare export function getByTestId( + container: UnionHTMLElement, + id: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): MaybeIntersectionHTMLElement; + declare export function getByText( + container: UnionHTMLElement, + text: Matcher, + options?: { selector?: string, ... } & MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByPlaceholderText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): MaybeIntersectionHTMLElement; + declare export function getByPlaceholderText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByLabelText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): MaybeIntersectionHTMLElement; + declare export function getByLabelText( + container: UnionHTMLElement, + text: Matcher, + options?: { selector?: string, ... } & MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByAltText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): MaybeIntersectionHTMLElement; + declare export function getByAltText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function getNodeText(node: UnionHTMLElement): string; + declare export var screen: Screen<>; +} diff --git a/definitions/npm/@testing-library/react_v12.x.x/flow_v0.201.x-/test_react_v12.x.x.js b/definitions/npm/@testing-library/react_v12.x.x/flow_v0.201.x-/test_react_v12.x.x.js new file mode 100644 index 0000000000..92c07e522e --- /dev/null +++ b/definitions/npm/@testing-library/react_v12.x.x/flow_v0.201.x-/test_react_v12.x.x.js @@ -0,0 +1,1275 @@ +// @flow + +import * as React from 'react'; +import { + act, + render, + fireEvent, + cleanup, + waitFor, + waitForElementToBeRemoved, + within, + screen, + getNodeText, + type IntersectionHTMLElement, +} from '@testing-library/react'; +import { describe, it } from 'flow-typed-test'; + +declare type MaybeIntersectionHTMLElement = null | IntersectionHTMLElement; + +describe('act', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + act(1); + // $FlowExpectedError[extra-arg] + act(() => {}, 1); + // $FlowExpectedError[incompatible-call] + act(() => 1); + }); + + it('should pass on correct inputs', () => { + act(() => {}); + act(() => Promise.resolve()); + act(() => ({ + then: (resolve) => {}, + })); + }); + + it('should fail on incorrect usage of result', () => { + // $FlowExpectedError[incompatible-type] + act(() => {}) + 1; + // $FlowExpectedError[prop-missing] + act(() => {}).doesNotExist(); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(1); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(() => {}, 1); + }); + + it('should pass on correct usage of result', () => { + act(() => {}).then(() => {}); + act(() => {}).then( + () => {}, + () => {} + ); + }); +}); + +describe('waitFor', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitFor(1); + // $FlowExpectedError[incompatible-call] + waitFor(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitFor(() => {}); + waitFor(() => {}, { timeout: 1 }); + }); +}); + +describe('waitForElementToBeRemoved', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElementToBeRemoved(() => {}, 1); + }); + + it('should pass on correct inputs (callback)', () => { + waitForElementToBeRemoved(() => document.createElement('div')); + waitForElementToBeRemoved(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should pass on correct inputs (node)', () => { + waitForElementToBeRemoved(document.createElement('div')); + waitForElementToBeRemoved(document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async (n) => { + const usernameElement = await waitForElementToBeRemoved(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('render', () => { + class Component extends React.Component<{ ... }> {} + const { + container, + unmount, + baseElement, + asFragment, + debug, + rerender, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('unmount should has 0 arguments', () => { + unmount(); + // $FlowExpectedError[extra-arg] + unmount(1); + }); + + it('container should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = container; + const b: HTMLElement = container; + }); + + it('baseElement should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = baseElement; + const b: HTMLElement = baseElement; + }); + + it('asFragment should return a document fragment', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = asFragment(); + const b: DocumentFragment = asFragment(); + }); + + it('debug maybe has 1 argument an html element', () => { + // $FlowExpectedError[incompatible-call] + debug(1); + debug(container); + }); + + it('rerender should has 1 argument an react element', () => { + // $FlowExpectedError[incompatible-call] + rerender(); + rerender(); + }); + + it('matcher function should receive HTMLElement type elements', () => { + const a: IntersectionHTMLElement = getByText( + (_, node) => node.style.height === '100px' + ); + }); + + it('getByAltText should return HTML element', () => { + const a: IntersectionHTMLElement = getByAltText('1'); + }); + + it('getAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByAltText('1'); + const b: Array = getAllByAltText('2'); + }); + + it('queryByAltText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByAltText('1'); + const b: MaybeIntersectionHTMLElement = queryByAltText('2'); + }); + + it('queryAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByAltText('1'); + const b: Array = queryAllByAltText('2'); + }); + + it('findByAltText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByAltText('1'); + const b: Promise = findByAltText('1'); + }); + + it('findAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByAltText('1'); + const b: Promise> = findAllByAltText('2'); + }); + + it('getByDisplayValue should return HTML element', () => { + const a: IntersectionHTMLElement = getByDisplayValue('1'); + }); + + it('getAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByDisplayValue('1'); + const b: Array = getAllByDisplayValue('2'); + }); + + it('queryByDisplayValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByDisplayValue('1'); + const b: MaybeIntersectionHTMLElement = queryByDisplayValue('2'); + }); + + it('queryAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByDisplayValue('1'); + const b: Array = queryAllByDisplayValue('2'); + }); + + it('findByDisplayValue should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByDisplayValue('1'); + const b: Promise = findByDisplayValue('1'); + }); + + it('findAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByDisplayValue('1'); + const b: Promise> = findAllByDisplayValue('2'); + }); + + it('getByLabelText should return HTML element', () => { + const a: IntersectionHTMLElement = getByLabelText('1'); + }); + + it('getAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByLabelText('1'); + const b: Array = getAllByLabelText('2'); + }); + + it('queryByLabelText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByLabelText('1'); + const b: MaybeIntersectionHTMLElement = queryByLabelText('2'); + }); + + it('queryAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByLabelText('1'); + const b: Array = queryAllByLabelText('2'); + }); + + it('findByLabelText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByLabelText('1'); + const b: Promise = findByLabelText('1'); + }); + + it('findAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByLabelText('1'); + const b: Promise> = findAllByLabelText('2'); + }); + + it('getByPlaceholderText should return HTML element', () => { + const a: IntersectionHTMLElement = getByPlaceholderText('1'); + }); + + it('getAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByPlaceholderText('1'); + const b: Array = getAllByPlaceholderText('2'); + }); + + it('queryByPlaceholderText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByPlaceholderText('1'); + const b: MaybeIntersectionHTMLElement = queryByPlaceholderText('2'); + }); + + it('queryAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByPlaceholderText('1'); + const b: Array = queryAllByPlaceholderText('2'); + }); + + it('findByPlaceholderText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByPlaceholderText('1'); + const b: Promise = findByPlaceholderText('1'); + }); + + it('findAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByPlaceholderText('1'); + const b: Promise> = findAllByPlaceholderText('2'); + }); + + it('getByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: string = getByRole('button'); + const b: IntersectionHTMLElement = getByRole('button'); + }); + + it('getAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByRole('button'); + const b: Array = getAllByRole('button'); + }); + + it('queryByRole should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByRole('button'); + const b: MaybeIntersectionHTMLElement = queryByRole('button'); + }); + + it('queryAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByRole('button'); + const b: Array = queryAllByRole('button'); + }); + + it('findByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByRole('button'); + const b: Promise = findByRole('button'); + }); + + it('findAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByRole('button'); + const b: Promise> = findAllByRole('button'); + }); + + it('getByTestId should return HTML element', () => { + const a: IntersectionHTMLElement = getByTestId('1'); + }); + + it('getByTestId returns a mixed HTML type', () => { + const a = getByTestId('1'); + a.value; + a.disabled; + a.href; + }); + + it('getAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByTestId('1'); + const b: Array = getAllByTestId('2'); + }); + + it('queryByTestId should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByTestId('1'); + const b: MaybeIntersectionHTMLElement = queryByTestId('2'); + }); + + it('queryAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByTestId('1'); + const b: Array = queryAllByTestId('2'); + }); + + it('findByTestId should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByTestId('1'); + const b: Promise = findByTestId('1'); + }); + + it('findAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findAllByTestId('1'); + const b: Promise> = findAllByTestId('2'); + }); + + it('getByText should return HTML element', () => { + const a: IntersectionHTMLElement = getByText('1'); + }); + + it('getAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByText('1'); + const b: Array = getAllByText('2'); + }); + + it('queryByText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByText('1'); + const b: MaybeIntersectionHTMLElement = queryByText('2'); + }); + + it('queryAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByText('1'); + const b: Array = queryAllByText('2'); + }); + + it('findByText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByText('1'); + const b: Promise = findByText('1'); + }); + + it('findAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByText('1'); + const b: Promise> = findAllByText('2'); + }); + + it('getByTitle should return HTML element', () => { + const a: IntersectionHTMLElement = getByTitle('1'); + }); + + it('getAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByTitle('1'); + const b: Array = getAllByTitle('2'); + }); + + it('queryByTitle should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByTitle('1'); + const b: MaybeIntersectionHTMLElement = queryByTitle('2'); + }); + + it('queryAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByTitle('1'); + const b: Array = queryAllByTitle('2'); + }); + + it('findByTitle should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByTitle('1'); + const b: Promise = findByTitle('1'); + }); + + it('findAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findAllByTitle('1'); + const b: Promise> = findAllByTitle('2'); + }); +}); + +describe('cleanup', () => { + it('should be a function w/o arguments', () => { + cleanup(); + // $FlowExpectedError[extra-arg] + cleanup(1); + }); +}); + +describe('within', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should has html element as argument', () => { + // $FlowExpectedError[incompatible-call] + within(); + within(container); + }); + + it('should have getByAltText', () => { + within(container).getByAltText('1'); + }); + + it('should have getAllByAltText', () => { + within(container).getAllByAltText('1'); + }); + + it('should have queryByAltText', () => { + within(container).queryByAltText('1'); + }); + + it('should have queryAllByAltText', () => { + within(container).queryAllByAltText('1'); + }); + + it('should have findByAltText', async () => { + await within(container).findByAltText('1'); + }); + + it('should have findAllByAltText', async () => { + await within(container).findAllByAltText('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); + + it('should have getByLabelText', () => { + within(container).getByLabelText('1'); + }); + + it('should have getAllByLabelText', () => { + within(container).getAllByLabelText('1'); + }); + + it('should have queryByLabelText', () => { + within(container).queryByLabelText('1'); + }); + + it('should have queryAllByLabelText', () => { + within(container).queryAllByLabelText('1'); + }); + + it('should have findByLabelText', async () => { + await within(container).findByLabelText('1'); + }); + + it('should have findAllByLabelText', async () => { + await within(container).findAllByLabelText('1'); + }); + + it('should have getByPlaceholderText', () => { + within(container).getByPlaceholderText('1'); + }); + + it('should have getAllByPlaceholderText', () => { + within(container).getAllByPlaceholderText('1'); + }); + + it('should have queryByPlaceholderText', () => { + within(container).queryByPlaceholderText('1'); + }); + + it('should have queryAllByPlaceholderText', () => { + within(container).queryAllByPlaceholderText('1'); + }); + + it('should have findByPlaceholderText', async () => { + await within(container).findByPlaceholderText('1'); + }); + + it('should have findAllByPlaceholderText', async () => { + await within(container).findAllByPlaceholderText('1'); + }); + + it('should have getByRole', () => { + within(container).getByRole('button'); + }); + + it('should have getAllByRole', () => { + within(container).getAllByRole('button'); + }); + + it('should have queryByRole', () => { + within(container).queryByRole('button'); + }); + + it('should have queryAllByRole', () => { + within(container).queryAllByRole('button'); + }); + + it('should have findByRole', async () => { + await within(container).findByRole('button'); + }); + + it('should have findAllByRole', async () => { + await within(container).findAllByRole('button'); + }); + + it('should have getByTestId', () => { + within(container).getByTestId('1'); + }); + + it('should have getAllByTestId', () => { + within(container).getAllByTestId('1'); + }); + + it('should have queryByTestId', () => { + within(container).queryByTestId('1'); + }); + + it('should have queryAllByTestId', () => { + within(container).queryAllByTestId('1'); + }); + + it('should have findByTestId', async () => { + await within(container).findByTestId('1'); + }); + + it('should have findAllByTestId', async () => { + await within(container).findAllByTestId('1'); + }); + + it('should have getByText', () => { + within(container).getByText('1'); + }); + + it('should have getAllByText', () => { + within(container).getAllByText('1'); + }); + + it('should have queryByText', () => { + within(container).queryByText('1'); + }); + + it('should have queryAllByText', () => { + within(container).queryAllByText('1'); + }); + + it('should have findByText', async () => { + await within(container).findByText('1'); + }); + + it('should have findAllByText', async () => { + await within(container).findAllByText('1'); + }); + + it('should have getByTitle', () => { + within(container).getByTitle('1'); + }); + + it('should have getAllByTitle', () => { + within(container).getAllByTitle('1'); + }); + + it('should have queryByTitle', () => { + within(container).queryByTitle('1'); + }); + + it('should have queryAllByTitle', () => { + within(container).queryAllByTitle('1'); + }); + + it('should have findByTitle', async () => { + await within(container).findByTitle('1'); + }); + + it('should have findAllByTitle', async () => { + await within(container).findAllByTitle('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); +}); + +describe('screen', () => { + it('should have all the queries available', () => { + // $FlowExpectedError[prop-missing] + const { notAQuery } = screen; + const { + debug, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = screen; + }); +}); + +describe('fireEvent', () => { + const htmlEl = document.createElement('div'); + + it('should be callable', () => { + fireEvent( + htmlEl, + new MouseEvent('click', { + bubbles: true, + cancelable: true, + }) + ); + }); + + it('should throw on invalid arguments', () => { + // $FlowExpectedError[incompatible-call] + fireEvent(1); + // $FlowExpectedError[incompatible-call] + fireEvent(htmlEl, 1); + }); + + it('should expose fire event helpers', () => { + fireEvent.copy(htmlEl); + fireEvent.cut(htmlEl); + fireEvent.paste(htmlEl); + fireEvent.compositionEnd(htmlEl); + fireEvent.compositionStart(htmlEl); + fireEvent.compositionUpdate(htmlEl); + fireEvent.keyDown(htmlEl); + fireEvent.keyPress(htmlEl); + fireEvent.keyUp(htmlEl); + fireEvent.focus(htmlEl); + fireEvent.blur(htmlEl); + fireEvent.change(htmlEl); + fireEvent.input(htmlEl); + fireEvent.invalid(htmlEl); + fireEvent.submit(htmlEl); + fireEvent.click(htmlEl); + fireEvent.contextMenu(htmlEl); + fireEvent.dblClick(htmlEl); + fireEvent.doubleClick(htmlEl); + fireEvent.drag(htmlEl); + fireEvent.dragEnd(htmlEl); + fireEvent.dragEnter(htmlEl); + fireEvent.dragExit(htmlEl); + fireEvent.dragLeave(htmlEl); + fireEvent.dragOver(htmlEl); + fireEvent.dragStart(htmlEl); + fireEvent.drop(htmlEl); + fireEvent.mouseDown(htmlEl); + fireEvent.mouseEnter(htmlEl); + fireEvent.mouseLeave(htmlEl); + fireEvent.mouseMove(htmlEl); + fireEvent.mouseOut(htmlEl); + fireEvent.mouseOver(htmlEl); + fireEvent.mouseUp(htmlEl); + fireEvent.select(htmlEl); + fireEvent.touchCancel(htmlEl); + fireEvent.touchEnd(htmlEl); + fireEvent.touchMove(htmlEl); + fireEvent.touchStart(htmlEl); + fireEvent.scroll(htmlEl); + fireEvent.wheel(htmlEl); + fireEvent.abort(htmlEl); + fireEvent.canPlay(htmlEl); + fireEvent.canPlayThrough(htmlEl); + fireEvent.durationChange(htmlEl); + fireEvent.emptied(htmlEl); + fireEvent.encrypted(htmlEl); + fireEvent.ended(htmlEl); + fireEvent.loadedData(htmlEl); + fireEvent.loadedMetadata(htmlEl); + fireEvent.loadStart(htmlEl); + fireEvent.pause(htmlEl); + fireEvent.play(htmlEl); + fireEvent.playing(htmlEl); + fireEvent.progress(htmlEl); + fireEvent.rateChange(htmlEl); + fireEvent.seeked(htmlEl); + fireEvent.seeking(htmlEl); + fireEvent.stalled(htmlEl); + fireEvent.suspend(htmlEl); + fireEvent.timeUpdate(htmlEl); + fireEvent.volumeChange(htmlEl); + fireEvent.waiting(htmlEl); + fireEvent.load(htmlEl); + fireEvent.error(htmlEl); + fireEvent.animationStart(htmlEl); + fireEvent.animationEnd(htmlEl); + fireEvent.animationIteration(htmlEl); + fireEvent.transitionEnd(htmlEl); + }); +}); + +describe('getNodeText', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should return string', () => { + const a: string = getNodeText(container); + }); +}); + +describe('text matching API', () => { + class Component extends React.Component<{ ... }> {} + const { + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('getByAltText should accept text match arguments', () => { + getByAltText('1'); + getByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByAltText(/1/); + getByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByAltText((content: string, element) => true); + getByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByAltText should accept text match arguments', () => { + const result: Array = getAllByAltText('1'); + }); + + it('queryByAltText should accept text match arguments', () => { + queryByAltText('1'); + queryByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText(/1/); + queryByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText((content: string, element) => true); + queryByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByAltText should accept text match arguments', () => { + const result: Array = queryAllByAltText('1'); + }); + + it('getByDisplayValue should accept text match arguments', () => { + getByDisplayValue('1'); + getByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue(/1/); + getByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue((content: string, element) => true); + getByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByDisplayValue should accept text match arguments', () => { + const result: Array = getAllByDisplayValue('1'); + }); + + it('queryByDisplayValue should accept text match arguments', () => { + queryByDisplayValue('1'); + queryByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue(/1/); + queryByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue((content: string, element) => true); + queryByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByDisplayValue should accept text match arguments', () => { + const result: Array = queryAllByDisplayValue('1'); + }); + + it('getByLabelText should accept text match arguments', () => { + getByLabelText('1'); + getByLabelText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText(/1/); + getByLabelText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText((content: string, element) => true); + getByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByLabelText should accept text match arguments', () => { + const result: Array = getAllByLabelText('1'); + }); + + it('queryByLabelText should accept text match arguments', () => { + queryByLabelText('1'); + queryByLabelText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByLabelText(/1/); + queryByLabelText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + queryByLabelText((content: string, element) => true); + queryByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByLabelText should accept text match arguments', () => { + const result: Array = queryAllByLabelText('1'); + }); + + it('getByPlaceholderText should accept text match arguments', () => { + getByPlaceholderText('1'); + getByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText(/1/); + getByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText((content: string, element) => true); + getByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByPlaceholderText should accept text match arguments', () => { + const result: Array = getAllByPlaceholderText('1'); + }); + + it('queryByPlaceholderText should accept text match arguments', () => { + queryByPlaceholderText('1'); + queryByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText(/1/); + queryByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText((content: string, element) => true); + queryByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByPlaceholderText should accept text match arguments', () => { + const result: Array = queryAllByPlaceholderText('1'); + }); + + it('getByRole should accept by role arguments', () => { + getByRole('button'); + getByRole('button', { hidden: true }); + getByRole((content: string, element) => true); + getByRole((content: string, element) => true, { + hidden: true, + }); + }); + + it('getAllByRole should accept by role arguments', () => { + const result: Array = getAllByRole('button'); + }); + + it('queryByRole should accept by role arguments', () => { + queryByRole('button'); + queryByRole('button', { hidden: true }); + queryByRole((content: string, element) => true); + queryByRole((content: string, element) => true, { + hidden: true, + }); + }); + + it('queryAllByRole should accept by role arguments', () => { + const result: Array = queryAllByRole('button'); + }); + + it('getByTestId should accept text match arguments', () => { + getByTestId('1'); + getByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTestId(/1/); + getByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTestId((content: string, element) => true); + getByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTestId should accept text match arguments', () => { + const result: Array = getAllByTestId('1'); + }); + + it('queryByTestId should accept text match arguments', () => { + queryByTestId('1'); + queryByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId(/1/); + queryByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId((content: string, element) => true); + queryByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTestId should accept text match arguments', () => { + const result: Array = queryAllByTestId('1'); + }); + + it('getByText should accept text match arguments', () => { + getByText('1'); + getByText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByText(/1/); + getByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByText((content: string, element) => true); + getByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByText should accept text match arguments', () => { + const result: Array = getAllByText('1'); + }); + + it('queryByText should accept text match arguments', () => { + queryByText('1'); + queryByText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByText(/1/); + queryByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByText((content: string, element) => true); + queryByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByText should accept text match arguments', () => { + const result: Array = queryAllByText('1'); + }); + + it('getByTitle should accept text match arguments', () => { + getByTitle('1'); + getByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTitle(/1/); + getByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTitle((content: string, element) => true); + getByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTitle should accept text match arguments', () => { + const result: Array = getAllByTitle('1'); + }); + + it('queryByTitle should accept text match arguments', () => { + queryByTitle('1'); + queryByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle(/1/); + queryByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle((content: string, element) => true); + queryByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTitle should accept text match arguments', () => { + const result: Array = queryAllByTitle('1'); + }); +}); + +describe('render() parameters', () => { + class Component extends React.Component<{ ... }> {} + + it('allows supplying parameters to render()', () => { + class CustomWrapper extends React.Component<{ ... }> {} + const element = document.createElement('div'); + render(, { + baseElement: element, + container: element, + hydrate: true, + wrapper: CustomWrapper, + }); + }); + + it('allows overriding render() with custom queries', () => { + type CustomReturnType = 123456; + declare var customValue: CustomReturnType; + const customQueries = { + getByOverride: (param1: string) => customValue, + }; + const result = render<{| + getByOverride: (string) => CustomReturnType, + |}>(, { queries: customQueries }); + const a: CustomReturnType = result.getByOverride('something'); + // $FlowExpectedError[incompatible-call] bad type for getByOverride parameter + result.getByOverride(1234); + // $FlowExpectedError[incompatible-call] missing getByOverride parameter + result.getByOverride(); + // $FlowExpectedError[prop-missing] default queries are not available when using custom queries + result.getByTestId('indifferent'); + }); +}); diff --git a/definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-/react_v13.x.x.js b/definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-v.200.x/react_v13.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-/react_v13.x.x.js rename to definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-v.200.x/react_v13.x.x.js diff --git a/definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-/test_react_v13.x.x.js b/definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-v.200.x/test_react_v13.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-/test_react_v13.x.x.js rename to definitions/npm/@testing-library/react_v13.x.x/flow_v0.104.x-v.200.x/test_react_v13.x.x.js diff --git a/definitions/npm/@testing-library/react_v13.x.x/flow_v0.201.x-/react_v13.x.x.js b/definitions/npm/@testing-library/react_v13.x.x/flow_v0.201.x-/react_v13.x.x.js new file mode 100644 index 0000000000..c7c1ec8f25 --- /dev/null +++ b/definitions/npm/@testing-library/react_v13.x.x/flow_v0.201.x-/react_v13.x.x.js @@ -0,0 +1,644 @@ +/** + * A local copy from: + * https://github.com/A11yance/aria-query/blob/2e6a3011a0d8987655f3a14853934fe3df38a8d8/flow/aria.js + */ + declare module '@@aria-query' { + declare export type ARIAAbstractRole = + | 'command' + | 'composite' + | 'input' + | 'landmark' + | 'range' + | 'roletype' + | 'section' + | 'sectionhead' + | 'select' + | 'structure' + | 'widget' + | 'window'; + + declare export type ARIAWidgetRole = + | 'button' + | 'checkbox' + | 'gridcell' + | 'link' + | 'menuitem' + | 'menuitemcheckbox' + | 'menuitemradio' + | 'option' + | 'progressbar' + | 'radio' + | 'scrollbar' + | 'searchbox' + | 'slider' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tabpanel' + | 'textbox' + | 'treeitem'; + + declare export type ARIACompositeWidgetRole = + | 'combobox' + | 'grid' + | 'listbox' + | 'menu' + | 'menubar' + | 'radiogroup' + | 'tablist' + | 'tree' + | 'treegrid'; + + declare export type ARIADocumentStructureRole = + | 'application' + | 'article' + | 'blockquote' + | 'caption' + | 'cell' + | 'columnheader' + | 'definition' + | 'deletion' + | 'directory' + | 'document' + | 'emphasis' + | 'feed' + | 'figure' + | 'generic' + | 'group' + | 'heading' + | 'img' + | 'insertion' + | 'list' + | 'listitem' + | 'math' + | 'meter' + | 'none' + | 'note' + | 'paragraph' + | 'presentation' + | 'row' + | 'rowgroup' + | 'rowheader' + | 'separator' + | 'strong' + | 'subscript' + | 'superscript' + | 'table' + | 'term' + | 'time' + | 'toolbar' + | 'tooltip'; + + declare export type ARIALandmarkRole = + | 'banner' + | 'complementary' + | 'contentinfo' + | 'form' + | 'main' + | 'navigation' + | 'region' + | 'search'; + + declare export type ARIALiveRegionRole = + | 'alert' + | 'log' + | 'marquee' + | 'status' + | 'timer'; + + declare export type ARIAWindowRole = 'alertdialog' | 'dialog'; + + declare export type ARIAUncategorizedRole = 'code'; + + declare export type ARIADPubRole = + | 'doc-abstract' + | 'doc-acknowledgments' + | 'doc-afterword' + | 'doc-appendix' + | 'doc-backlink' + | 'doc-biblioentry' + | 'doc-bibliography' + | 'doc-biblioref' + | 'doc-chapter' + | 'doc-colophon' + | 'doc-conclusion' + | 'doc-cover' + | 'doc-credit' + | 'doc-credits' + | 'doc-dedication' + | 'doc-endnote' + | 'doc-endnotes' + | 'doc-epigraph' + | 'doc-epilogue' + | 'doc-errata' + | 'doc-example' + | 'doc-footnote' + | 'doc-foreword' + | 'doc-glossary' + | 'doc-glossref' + | 'doc-index' + | 'doc-introduction' + | 'doc-noteref' + | 'doc-notice' + | 'doc-pagebreak' + | 'doc-pagelist' + | 'doc-part' + | 'doc-preface' + | 'doc-prologue' + | 'doc-pullquote' + | 'doc-qna' + | 'doc-subtitle' + | 'doc-tip' + | 'doc-toc'; + + declare export type ARIARole = + | ARIAWidgetRole + | ARIACompositeWidgetRole + | ARIADocumentStructureRole + | ARIALandmarkRole + | ARIALiveRegionRole + | ARIAWindowRole + | ARIAUncategorizedRole; +} + +declare module '@testing-library/react' { + import type { ARIARole } from '@@aria-query'; + + // This type comes from react-dom_v17.x.x.js + declare interface ReactDOMTestUtilsThenable { + then(resolve: () => mixed, reject?: () => mixed): mixed; + } + + // This type comes from react-dom_v17.x.x.js + declare type ReactDOMTestUtilsAct = ( + callback: () => void | ReactDOMTestUtilsThenable + ) => ReactDOMTestUtilsThenable; + + declare type WaitForOptions = {| + container?: HTMLElement, + timeout?: number, + interval?: number, + onTimeout?: (error: Error) => Error, + mutationObserverOptions?: MutationObserverInit, + |}; + + declare type MatcherFunction = ( + content: string, + element: ?Element + ) => boolean; + + declare type Matcher = MatcherFunction | RegExp | string | number; + + declare type ByRoleMatcher = ARIARole | MatcherFunction; + + declare type NormalizerFn = (text: string) => string; + + declare type MatcherOptions = {| + exact?: boolean, + /** Use normalizer with getDefaultNormalizer instead */ + trim?: boolean, + /** Use normalizer with getDefaultNormalizer instead */ + collapseWhitespace?: boolean, + normalizer?: NormalizerFn, + /** suppress suggestions for a specific query */ + suggest?: boolean, + |}; + + declare type ByRoleOptions = {| + ...MatcherOptions, + /** + * If true includes elements in the query set that are usually excluded from + * the accessibility tree. `role="none"` or `role="presentation"` are included + * in either case. + */ + hidden?: boolean, + /** + * If true only includes elements in the query set that are marked as + * selected in the accessibility tree, i.e., `aria-selected="true"` + */ + selected?: boolean, + /** + * If true only includes elements in the query set that are marked as + * checked in the accessibility tree, i.e., `aria-checked="true"` + */ + checked?: boolean, + /** + * If true only includes elements in the query set that are marked as + * pressed in the accessibility tree, i.e., `aria-pressed="true"` + */ + pressed?: boolean, + /** + * If true only includes elements in the query set that are marked as + * expanded in the accessibility tree, i.e., `aria-expanded="true"` + */ + expanded?: boolean, + /** + * Includes elements with the `"heading"` role matching the indicated level, + * either by the semantic HTML heading elements `

-

` or matching + * the `aria-level` attribute. + */ + level?: number, + /** + * Includes every role used in the `role` attribute + * For example *ByRole('progressbar', {queryFallbacks: true})` will find
`. + */ + queryFallbacks?: boolean, + /** + * Only considers elements with the specified accessible name. + */ + name?: + | string + | RegExp + | ((accessibleName: string, element: Element) => boolean), + |}; + + declare type SelectorMatcherOptions = {| + ...MatcherOptions, + selector?: string, + ignore?: string | boolean + |}; + + // These two types must be updated kept in sync + declare export type UnionHTMLElement = + | HTMLElement + | HTMLInputElement + | HTMLAnchorElement + | HTMLButtonElement + | HTMLLabelElement + | HTMLSelectElement; + + declare export type IntersectionHTMLElement = + & HTMLElement + & HTMLInputElement + & HTMLAnchorElement + & HTMLButtonElement + & HTMLLabelElement + & HTMLSelectElement; + // End mixed html types + + declare type QueryByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => ?IntersectionHTMLElement; + + declare type AllByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => Array; + + declare type FindAllByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions + ) => IntersectionHTMLElement; + + declare type FindByBoundAttribute = ( + text: Matcher, + options?: MatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type QueryByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => ?IntersectionHTMLElement; + + declare type AllByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => Array; + + declare type FindAllByText = ( + text: Matcher, + options?: SelectorMatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetByText = ( + text: Matcher, + options?: SelectorMatcherOptions + ) => IntersectionHTMLElement; + + declare type FindByText = ( + text: Matcher, + options?: SelectorMatcherOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type AllByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement[]; + + declare type GetByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement; + + declare type QueryByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions + ) => IntersectionHTMLElement | null; + + declare type FindByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type FindAllByRole = ( + role: ByRoleMatcher, + options?: ByRoleOptions, + waitForElementOptions?: WaitForOptions + ) => Promise; + + declare type GetsAndQueries = {| + getByLabelText: GetByText, + getAllByLabelText: AllByText, + queryByLabelText: QueryByText, + queryAllByLabelText: AllByText, + findByLabelText: FindByText, + findAllByLabelText: FindAllByText, + + getByPlaceholderText: GetByBoundAttribute, + getAllByPlaceholderText: AllByBoundAttribute, + queryByPlaceholderText: QueryByBoundAttribute, + queryAllByPlaceholderText: AllByBoundAttribute, + findByPlaceholderText: FindByBoundAttribute, + findAllByPlaceholderText: FindAllByBoundAttribute, + + getByText: GetByText, + getAllByText: AllByText, + queryByText: QueryByText, + queryAllByText: AllByText, + findByText: FindByText, + findAllByText: FindAllByText, + + getByAltText: GetByBoundAttribute, + getAllByAltText: AllByBoundAttribute, + queryByAltText: QueryByBoundAttribute, + queryAllByAltText: AllByBoundAttribute, + findByAltText: FindByBoundAttribute, + findAllByAltText: FindAllByBoundAttribute, + + getByTitle: GetByBoundAttribute, + getAllByTitle: AllByBoundAttribute, + queryByTitle: QueryByBoundAttribute, + queryAllByTitle: AllByBoundAttribute, + findByTitle: FindByBoundAttribute, + findAllByTitle: FindAllByBoundAttribute, + + getByDisplayValue: GetByBoundAttribute, + getAllByDisplayValue: AllByBoundAttribute, + queryByDisplayValue: QueryByBoundAttribute, + queryAllByDisplayValue: AllByBoundAttribute, + findByDisplayValue: FindByBoundAttribute, + findAllByDisplayValue: FindAllByBoundAttribute, + + getByRole: GetByRole, + getAllByRole: AllByRole, + queryByRole: QueryByRole, + queryAllByRole: AllByRole, + findByRole: FindByRole, + findAllByRole: FindAllByRole, + + getByTestId: GetByBoundAttribute, + getAllByTestId: AllByBoundAttribute, + queryByTestId: QueryByBoundAttribute, + queryAllByTestId: AllByBoundAttribute, + findByTestId: FindByBoundAttribute, + findAllByTestId: FindAllByBoundAttribute, + |}; + + declare type FireEvent = ( + element: UnionHTMLElement, + eventProperties?: TInit + ) => boolean; + + declare type Screen = { + ...Queries, + /** + * Convenience function for `pretty-dom` which also allows an array + * of elements + */ + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number, + options?: { ... } // @TODO pretty format OptionsReceived + ) => void, + /** + * Convenience function for `Testing Playground` which logs URL that + * can be opened in a browser + */ + logTestingPlaygroundURL: (element?: Element | Document) => void, + ... + }; + + declare type RenderResult = { + ...Queries, + container: HTMLElement, + unmount: () => boolean, + baseElement: HTMLElement, + asFragment: () => DocumentFragment, + debug: ( + baseElement?: + | HTMLElement + | DocumentFragment + | Array, + maxLength?: number + ) => void, + rerender: (ui: React$Element) => void, + ... + }; + + declare export type RenderOptionsWithoutCustomQueries = {| + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export type RenderOptionsWithCustomQueries< + CustomQueries: { ... } + > = {| + queries: CustomQueries, + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export function render( + ui: React$Element, + options?: RenderOptionsWithoutCustomQueries + ): RenderResult<>; + declare export function render< + CustomQueries: { [string]: (...args: Array) => any, ... } + >( + ui: React$Element, + options: RenderOptionsWithCustomQueries + ): RenderResult; + + declare export var act: ReactDOMTestUtilsAct; + declare export function cleanup(): void; + + declare export function waitFor( + callback: () => T | Promise, + options?: {| + container?: UnionHTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + declare export function waitForElementToBeRemoved( + callback: (() => T) | T, + options?: {| + container?: UnionHTMLElement, + timeout?: number, + interval?: number, + mutationObserverOptions?: MutationObserverInit, + |} + ): Promise; + + declare export function within( + element: UnionHTMLElement, + queriesToBind?: GetsAndQueries | Array + ): GetsAndQueries; + + declare export var fireEvent: {| + (element: UnionHTMLElement, event: Event): void, + + copy: FireEvent, + cut: FireEvent, + paste: FireEvent, + compositionEnd: FireEvent, + compositionStart: FireEvent, + compositionUpdate: FireEvent, + keyDown: FireEvent, + keyPress: FireEvent, + keyUp: FireEvent, + focus: FireEvent, + blur: FireEvent, + change: FireEvent, + input: FireEvent, + invalid: FireEvent, + submit: FireEvent, + click: FireEvent, + contextMenu: FireEvent, + dblClick: FireEvent, + doubleClick: FireEvent, + drag: FireEvent, + dragEnd: FireEvent, + dragEnter: FireEvent, + dragExit: FireEvent, + dragLeave: FireEvent, + dragOver: FireEvent, + dragStart: FireEvent, + drop: FireEvent, + mouseDown: FireEvent, + mouseEnter: FireEvent, + mouseLeave: FireEvent, + mouseMove: FireEvent, + mouseOut: FireEvent, + mouseOver: FireEvent, + mouseUp: FireEvent, + select: FireEvent, + touchCancel: FireEvent, + touchEnd: FireEvent, + touchMove: FireEvent, + touchStart: FireEvent, + scroll: FireEvent, + wheel: FireEvent, + abort: FireEvent, + canPlay: FireEvent, + canPlayThrough: FireEvent, + durationChange: FireEvent, + emptied: FireEvent, + encrypted: FireEvent, + ended: FireEvent, + loadedData: FireEvent, + loadedMetadata: FireEvent, + loadStart: FireEvent, + pause: FireEvent, + play: FireEvent, + playing: FireEvent, + progress: FireEvent, + rateChange: FireEvent, + seeked: FireEvent, + seeking: FireEvent, + stalled: FireEvent, + suspend: FireEvent, + timeUpdate: FireEvent, + volumeChange: FireEvent, + waiting: FireEvent, + load: FireEvent, + error: FireEvent, + animationStart: FireEvent, + animationEnd: FireEvent, + animationIteration: FireEvent, + transitionEnd: FireEvent, + |}; + // dom-testing-library re-declares + declare export function queryByTestId( + container: UnionHTMLElement, + id: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByTestId( + container: UnionHTMLElement, + id: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByText( + container: UnionHTMLElement, + text: Matcher, + options?: { selector?: string, ... } & MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByPlaceholderText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByPlaceholderText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByLabelText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByLabelText( + container: UnionHTMLElement, + text: Matcher, + options?: { selector?: string, ... } & MatcherOptions + ): IntersectionHTMLElement; + declare export function queryByAltText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): ?IntersectionHTMLElement; + declare export function getByAltText( + container: UnionHTMLElement, + text: Matcher, + options?: MatcherOptions + ): IntersectionHTMLElement; + declare export function getNodeText(node: UnionHTMLElement): string; + declare export var screen: Screen<>; +} diff --git a/definitions/npm/@testing-library/react_v13.x.x/flow_v0.201.x-/test_react_v13.x.x.js b/definitions/npm/@testing-library/react_v13.x.x/flow_v0.201.x-/test_react_v13.x.x.js new file mode 100644 index 0000000000..b55501628c --- /dev/null +++ b/definitions/npm/@testing-library/react_v13.x.x/flow_v0.201.x-/test_react_v13.x.x.js @@ -0,0 +1,1267 @@ +// @flow + +import * as React from 'react'; +import { + act, + render, + fireEvent, + cleanup, + waitFor, + waitForElementToBeRemoved, + within, + screen, + getNodeText, + type IntersectionHTMLElement, +} from '@testing-library/react'; +import { describe, it } from 'flow-typed-test'; + +describe('act', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + act(1); + // $FlowExpectedError[extra-arg] + act(() => {}, 1); + // $FlowExpectedError[incompatible-call] + act(() => 1); + }); + + it('should pass on correct inputs', () => { + act(() => {}); + act(() => Promise.resolve()); + act(() => ({ + then: (resolve) => {}, + })); + }); + + it('should fail on incorrect usage of result', () => { + // $FlowExpectedError[incompatible-type] + act(() => {}) + 1; + // $FlowExpectedError[prop-missing] + act(() => {}).doesNotExist(); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(1); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(() => {}, 1); + }); + + it('should pass on correct usage of result', () => { + act(() => {}).then(() => {}); + act(() => {}).then( + () => {}, + () => {} + ); + }); +}); + +describe('waitFor', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitFor(1); + // $FlowExpectedError[incompatible-call] + waitFor(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitFor(() => {}); + waitFor(() => {}, { timeout: 1 }); + }); +}); + +describe('waitForElementToBeRemoved', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElementToBeRemoved(() => {}, 1); + }); + + it('should pass on correct inputs (callback)', () => { + waitForElementToBeRemoved(() => document.createElement('div')); + waitForElementToBeRemoved(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should pass on correct inputs (node)', () => { + waitForElementToBeRemoved(document.createElement('div')); + waitForElementToBeRemoved(document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async (n) => { + const usernameElement = await waitForElementToBeRemoved(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('render', () => { + class Component extends React.Component<{ ... }> {} + const { + container, + unmount, + baseElement, + asFragment, + debug, + rerender, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('unmount should has 0 arguments', () => { + unmount(); + // $FlowExpectedError[extra-arg] + unmount(1); + }); + + it('container should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = container; + const b: HTMLElement = container; + }); + + it('baseElement should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = baseElement; + const b: HTMLElement = baseElement; + }); + + it('asFragment should return a document fragment', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = asFragment(); + const b: DocumentFragment = asFragment(); + }); + + it('debug maybe has 1 argument an html element', () => { + // $FlowExpectedError[incompatible-call] + debug(1); + debug(container); + }); + + it('rerender should has 1 argument an react element', () => { + // $FlowExpectedError[incompatible-call] + rerender(); + rerender(); + }); + + it('getByAltText should return HTML element', () => { + const a: IntersectionHTMLElement = getByAltText('1'); + }); + + it('getAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByAltText('1'); + const b: Array = getAllByAltText('2'); + }); + + it('queryByAltText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByAltText('1'); + const b: ?IntersectionHTMLElement = queryByAltText('2'); + }); + + it('queryAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByAltText('1'); + const b: Array = queryAllByAltText('2'); + }); + + it('findByAltText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByAltText('1'); + const b: Promise = findByAltText('1'); + }); + + it('findAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByAltText('1'); + const b: Promise> = findAllByAltText('2'); + }); + + it('getByDisplayValue should return HTML element', () => { + const a: IntersectionHTMLElement = getByDisplayValue('1'); + }); + + it('getAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByDisplayValue('1'); + const b: Array = getAllByDisplayValue('2'); + }); + + it('queryByDisplayValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByDisplayValue('1'); + const b: ?IntersectionHTMLElement = queryByDisplayValue('2'); + }); + + it('queryAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByDisplayValue('1'); + const b: Array = queryAllByDisplayValue('2'); + }); + + it('findByDisplayValue should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByDisplayValue('1'); + const b: Promise = findByDisplayValue('1'); + }); + + it('findAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByDisplayValue('1'); + const b: Promise> = findAllByDisplayValue('2'); + }); + + it('getByLabelText should return HTML element', () => { + const a: IntersectionHTMLElement = getByLabelText('1'); + }); + + it('getAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByLabelText('1'); + const b: Array = getAllByLabelText('2'); + }); + + it('queryByLabelText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByLabelText('1'); + const b: ?IntersectionHTMLElement = queryByLabelText('2'); + }); + + it('queryAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByLabelText('1'); + const b: Array = queryAllByLabelText('2'); + }); + + it('findByLabelText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByLabelText('1'); + const b: Promise = findByLabelText('1'); + }); + + it('findAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByLabelText('1'); + const b: Promise> = findAllByLabelText('2'); + }); + + it('getByPlaceholderText should return HTML element', () => { + const a: IntersectionHTMLElement = getByPlaceholderText('1'); + }); + + it('getAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByPlaceholderText('1'); + const b: Array = getAllByPlaceholderText('2'); + }); + + it('queryByPlaceholderText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByPlaceholderText('1'); + const b: ?IntersectionHTMLElement = queryByPlaceholderText('2'); + }); + + it('queryAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByPlaceholderText('1'); + const b: Array = queryAllByPlaceholderText('2'); + }); + + it('findByPlaceholderText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByPlaceholderText('1'); + const b: Promise = findByPlaceholderText('1'); + }); + + it('findAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByPlaceholderText('1'); + const b: Promise> = findAllByPlaceholderText('2'); + }); + + it('getByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: string = getByRole('button'); + const b: IntersectionHTMLElement = getByRole('button'); + }); + + it('getAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByRole('button'); + const b: Array = getAllByRole('button'); + }); + + it('queryByRole should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByRole('button'); + const b: ?IntersectionHTMLElement = queryByRole('button'); + }); + + it('queryAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByRole('button'); + const b: Array = queryAllByRole('button'); + }); + + it('findByRole should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByRole('button'); + const b: Promise = findByRole('button'); + }); + + it('findAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByRole('button'); + const b: Promise> = findAllByRole('button'); + }); + + it('getByTestId should return HTML element', () => { + const a: IntersectionHTMLElement = getByTestId('1'); + }); + + it('getByTestId returns a mixed HTML type', () => { + const a = getByTestId('1'); + a.value; + a.disabled; + a.href; + }); + + it('getAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByTestId('1'); + const b: Array = getAllByTestId('2'); + }); + + it('queryByTestId should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByTestId('1'); + const b: ?IntersectionHTMLElement = queryByTestId('2'); + }); + + it('queryAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByTestId('1'); + const b: Array = queryAllByTestId('2'); + }); + + it('findByTestId should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByTestId('1'); + const b: Promise = findByTestId('1'); + }); + + it('findAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findAllByTestId('1'); + const b: Promise> = findAllByTestId('2'); + }); + + it('getByText should return HTML element', () => { + const a: IntersectionHTMLElement = getByText('1'); + }); + + it('getAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByText('1'); + const b: Array = getAllByText('2'); + }); + + it('queryByText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByText('1'); + const b: ?IntersectionHTMLElement = queryByText('2'); + }); + + it('queryAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByText('1'); + const b: Array = queryAllByText('2'); + }); + + it('findByText should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByText('1'); + const b: Promise = findByText('1'); + }); + + it('findAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type-arg] + const a: Promise = findAllByText('1'); + const b: Promise> = findAllByText('2'); + }); + + it('getByTitle should return HTML element', () => { + const a: IntersectionHTMLElement = getByTitle('1'); + }); + + it('getAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = getAllByTitle('1'); + const b: Array = getAllByTitle('2'); + }); + + it('queryByTitle should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryByTitle('1'); + const b: ?IntersectionHTMLElement = queryByTitle('2'); + }); + + it('queryAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = queryAllByTitle('1'); + const b: Array = queryAllByTitle('2'); + }); + + it('findByTitle should return HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findByTitle('1'); + const b: Promise = findByTitle('1'); + }); + + it('findAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: IntersectionHTMLElement = findAllByTitle('1'); + const b: Promise> = findAllByTitle('2'); + }); +}); + +describe('cleanup', () => { + it('should be a function w/o arguments', () => { + cleanup(); + // $FlowExpectedError[extra-arg] + cleanup(1); + }); +}); + +describe('within', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should has html element as argument', () => { + // $FlowExpectedError[incompatible-call] + within(); + within(container); + }); + + it('should have getByAltText', () => { + within(container).getByAltText('1'); + }); + + it('should have getAllByAltText', () => { + within(container).getAllByAltText('1'); + }); + + it('should have queryByAltText', () => { + within(container).queryByAltText('1'); + }); + + it('should have queryAllByAltText', () => { + within(container).queryAllByAltText('1'); + }); + + it('should have findByAltText', async () => { + await within(container).findByAltText('1'); + }); + + it('should have findAllByAltText', async () => { + await within(container).findAllByAltText('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); + + it('should have getByLabelText', () => { + within(container).getByLabelText('1'); + }); + + it('should have getAllByLabelText', () => { + within(container).getAllByLabelText('1'); + }); + + it('should have queryByLabelText', () => { + within(container).queryByLabelText('1'); + }); + + it('should have queryAllByLabelText', () => { + within(container).queryAllByLabelText('1'); + }); + + it('should have findByLabelText', async () => { + await within(container).findByLabelText('1'); + }); + + it('should have findAllByLabelText', async () => { + await within(container).findAllByLabelText('1'); + }); + + it('should have getByPlaceholderText', () => { + within(container).getByPlaceholderText('1'); + }); + + it('should have getAllByPlaceholderText', () => { + within(container).getAllByPlaceholderText('1'); + }); + + it('should have queryByPlaceholderText', () => { + within(container).queryByPlaceholderText('1'); + }); + + it('should have queryAllByPlaceholderText', () => { + within(container).queryAllByPlaceholderText('1'); + }); + + it('should have findByPlaceholderText', async () => { + await within(container).findByPlaceholderText('1'); + }); + + it('should have findAllByPlaceholderText', async () => { + await within(container).findAllByPlaceholderText('1'); + }); + + it('should have getByRole', () => { + within(container).getByRole('button'); + }); + + it('should have getAllByRole', () => { + within(container).getAllByRole('button'); + }); + + it('should have queryByRole', () => { + within(container).queryByRole('button'); + }); + + it('should have queryAllByRole', () => { + within(container).queryAllByRole('button'); + }); + + it('should have findByRole', async () => { + await within(container).findByRole('button'); + }); + + it('should have findAllByRole', async () => { + await within(container).findAllByRole('button'); + }); + + it('should have getByTestId', () => { + within(container).getByTestId('1'); + }); + + it('should have getAllByTestId', () => { + within(container).getAllByTestId('1'); + }); + + it('should have queryByTestId', () => { + within(container).queryByTestId('1'); + }); + + it('should have queryAllByTestId', () => { + within(container).queryAllByTestId('1'); + }); + + it('should have findByTestId', async () => { + await within(container).findByTestId('1'); + }); + + it('should have findAllByTestId', async () => { + await within(container).findAllByTestId('1'); + }); + + it('should have getByText', () => { + within(container).getByText('1'); + }); + + it('should have getAllByText', () => { + within(container).getAllByText('1'); + }); + + it('should have queryByText', () => { + within(container).queryByText('1'); + }); + + it('should have queryAllByText', () => { + within(container).queryAllByText('1'); + }); + + it('should have findByText', async () => { + await within(container).findByText('1'); + }); + + it('should have findAllByText', async () => { + await within(container).findAllByText('1'); + }); + + it('should have getByTitle', () => { + within(container).getByTitle('1'); + }); + + it('should have getAllByTitle', () => { + within(container).getAllByTitle('1'); + }); + + it('should have queryByTitle', () => { + within(container).queryByTitle('1'); + }); + + it('should have queryAllByTitle', () => { + within(container).queryAllByTitle('1'); + }); + + it('should have findByTitle', async () => { + await within(container).findByTitle('1'); + }); + + it('should have findAllByTitle', async () => { + await within(container).findAllByTitle('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have findByDisplayValue', async () => { + await within(container).findByDisplayValue('1'); + }); + + it('should have findAllByDisplayValue', async () => { + await within(container).findAllByDisplayValue('1'); + }); +}); + +describe('screen', () => { + it('should have all the queries available', () => { + // $FlowExpectedError[prop-missing] + const { notAQuery } = screen; + const { + debug, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = screen; + }); +}); + +describe('fireEvent', () => { + const htmlEl = document.createElement('div'); + + it('should be callable', () => { + fireEvent( + htmlEl, + new MouseEvent('click', { + bubbles: true, + cancelable: true, + }) + ); + }); + + it('should throw on invalid arguments', () => { + // $FlowExpectedError[incompatible-call] + fireEvent(1); + // $FlowExpectedError[incompatible-call] + fireEvent(htmlEl, 1); + }); + + it('should expose fire event helpers', () => { + fireEvent.copy(htmlEl); + fireEvent.cut(htmlEl); + fireEvent.paste(htmlEl); + fireEvent.compositionEnd(htmlEl); + fireEvent.compositionStart(htmlEl); + fireEvent.compositionUpdate(htmlEl); + fireEvent.keyDown(htmlEl); + fireEvent.keyPress(htmlEl); + fireEvent.keyUp(htmlEl); + fireEvent.focus(htmlEl); + fireEvent.blur(htmlEl); + fireEvent.change(htmlEl); + fireEvent.input(htmlEl); + fireEvent.invalid(htmlEl); + fireEvent.submit(htmlEl); + fireEvent.click(htmlEl); + fireEvent.contextMenu(htmlEl); + fireEvent.dblClick(htmlEl); + fireEvent.doubleClick(htmlEl); + fireEvent.drag(htmlEl); + fireEvent.dragEnd(htmlEl); + fireEvent.dragEnter(htmlEl); + fireEvent.dragExit(htmlEl); + fireEvent.dragLeave(htmlEl); + fireEvent.dragOver(htmlEl); + fireEvent.dragStart(htmlEl); + fireEvent.drop(htmlEl); + fireEvent.mouseDown(htmlEl); + fireEvent.mouseEnter(htmlEl); + fireEvent.mouseLeave(htmlEl); + fireEvent.mouseMove(htmlEl); + fireEvent.mouseOut(htmlEl); + fireEvent.mouseOver(htmlEl); + fireEvent.mouseUp(htmlEl); + fireEvent.select(htmlEl); + fireEvent.touchCancel(htmlEl); + fireEvent.touchEnd(htmlEl); + fireEvent.touchMove(htmlEl); + fireEvent.touchStart(htmlEl); + fireEvent.scroll(htmlEl); + fireEvent.wheel(htmlEl); + fireEvent.abort(htmlEl); + fireEvent.canPlay(htmlEl); + fireEvent.canPlayThrough(htmlEl); + fireEvent.durationChange(htmlEl); + fireEvent.emptied(htmlEl); + fireEvent.encrypted(htmlEl); + fireEvent.ended(htmlEl); + fireEvent.loadedData(htmlEl); + fireEvent.loadedMetadata(htmlEl); + fireEvent.loadStart(htmlEl); + fireEvent.pause(htmlEl); + fireEvent.play(htmlEl); + fireEvent.playing(htmlEl); + fireEvent.progress(htmlEl); + fireEvent.rateChange(htmlEl); + fireEvent.seeked(htmlEl); + fireEvent.seeking(htmlEl); + fireEvent.stalled(htmlEl); + fireEvent.suspend(htmlEl); + fireEvent.timeUpdate(htmlEl); + fireEvent.volumeChange(htmlEl); + fireEvent.waiting(htmlEl); + fireEvent.load(htmlEl); + fireEvent.error(htmlEl); + fireEvent.animationStart(htmlEl); + fireEvent.animationEnd(htmlEl); + fireEvent.animationIteration(htmlEl); + fireEvent.transitionEnd(htmlEl); + }); +}); + +describe('getNodeText', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should return string', () => { + const a: string = getNodeText(container); + }); +}); + +describe('text matching API', () => { + class Component extends React.Component<{ ... }> {} + const { + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + findByAltText, + findAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + findByDisplayValue, + findAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + findByLabelText, + findAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + findByPlaceholderText, + findAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + findByRole, + findAllByRole, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + findByTestId, + findAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + findByText, + findAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + findByTitle, + findAllByTitle, + } = render(); + + it('getByAltText should accept text match arguments', () => { + getByAltText('1'); + getByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByAltText(/1/); + getByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByAltText((content: string, element) => true); + getByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByAltText should accept text match arguments', () => { + const result: Array = getAllByAltText('1'); + }); + + it('queryByAltText should accept text match arguments', () => { + queryByAltText('1'); + queryByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText(/1/); + queryByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText((content: string, element) => true); + queryByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByAltText should accept text match arguments', () => { + const result: Array = queryAllByAltText('1'); + }); + + it('getByDisplayValue should accept text match arguments', () => { + getByDisplayValue('1'); + getByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue(/1/); + getByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue((content: string, element) => true); + getByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByDisplayValue should accept text match arguments', () => { + const result: Array = getAllByDisplayValue('1'); + }); + + it('queryByDisplayValue should accept text match arguments', () => { + queryByDisplayValue('1'); + queryByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue(/1/); + queryByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue((content: string, element) => true); + queryByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByDisplayValue should accept text match arguments', () => { + const result: Array = queryAllByDisplayValue('1'); + }); + + it('getByLabelText should accept text match arguments', () => { + getByLabelText('1'); + getByLabelText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText(/1/); + getByLabelText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText((content: string, element) => true); + getByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByLabelText should accept text match arguments', () => { + const result: Array = getAllByLabelText('1'); + }); + + it('queryByLabelText should accept text match arguments', () => { + queryByLabelText('1'); + queryByLabelText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByLabelText(/1/); + queryByLabelText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + queryByLabelText((content: string, element) => true); + queryByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByLabelText should accept text match arguments', () => { + const result: Array = queryAllByLabelText('1'); + }); + + it('getByPlaceholderText should accept text match arguments', () => { + getByPlaceholderText('1'); + getByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText(/1/); + getByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText((content: string, element) => true); + getByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByPlaceholderText should accept text match arguments', () => { + const result: Array = getAllByPlaceholderText('1'); + }); + + it('queryByPlaceholderText should accept text match arguments', () => { + queryByPlaceholderText('1'); + queryByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText(/1/); + queryByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText((content: string, element) => true); + queryByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByPlaceholderText should accept text match arguments', () => { + const result: Array = queryAllByPlaceholderText('1'); + }); + + it('getByRole should accept by role arguments', () => { + getByRole('button'); + getByRole('button', { hidden: true }); + getByRole((content: string, element) => true); + getByRole((content: string, element) => true, { + hidden: true, + }); + }); + + it('getAllByRole should accept by role arguments', () => { + const result: Array = getAllByRole('button'); + }); + + it('queryByRole should accept by role arguments', () => { + queryByRole('button'); + queryByRole('button', { hidden: true }); + queryByRole((content: string, element) => true); + queryByRole((content: string, element) => true, { + hidden: true, + }); + }); + + it('queryAllByRole should accept by role arguments', () => { + const result: Array = queryAllByRole('button'); + }); + + it('getByTestId should accept text match arguments', () => { + getByTestId('1'); + getByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTestId(/1/); + getByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTestId((content: string, element) => true); + getByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTestId should accept text match arguments', () => { + const result: Array = getAllByTestId('1'); + }); + + it('queryByTestId should accept text match arguments', () => { + queryByTestId('1'); + queryByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId(/1/); + queryByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId((content: string, element) => true); + queryByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTestId should accept text match arguments', () => { + const result: Array = queryAllByTestId('1'); + }); + + it('getByText should accept text match arguments', () => { + getByText('1'); + getByText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByText(/1/); + getByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByText((content: string, element) => true); + getByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByText should accept text match arguments', () => { + const result: Array = getAllByText('1'); + }); + + it('queryByText should accept text match arguments', () => { + queryByText('1'); + queryByText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByText(/1/); + queryByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByText((content: string, element) => true); + queryByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByText should accept text match arguments', () => { + const result: Array = queryAllByText('1'); + }); + + it('getByTitle should accept text match arguments', () => { + getByTitle('1'); + getByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTitle(/1/); + getByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTitle((content: string, element) => true); + getByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTitle should accept text match arguments', () => { + const result: Array = getAllByTitle('1'); + }); + + it('queryByTitle should accept text match arguments', () => { + queryByTitle('1'); + queryByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle(/1/); + queryByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle((content: string, element) => true); + queryByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTitle should accept text match arguments', () => { + const result: Array = queryAllByTitle('1'); + }); +}); + +describe('render() parameters', () => { + class Component extends React.Component<{ ... }> {} + + it('allows supplying parameters to render()', () => { + class CustomWrapper extends React.Component<{ ... }> {} + const element = document.createElement('div'); + render(, { + baseElement: element, + container: element, + hydrate: true, + wrapper: CustomWrapper, + }); + }); + + it('allows overriding render() with custom queries', () => { + type CustomReturnType = 123456; + declare var customValue: CustomReturnType; + const customQueries = { + getByOverride: (param1: string) => customValue, + }; + const result = render<{| + getByOverride: (string) => CustomReturnType, + |}>(, { queries: customQueries }); + const a: CustomReturnType = result.getByOverride('something'); + // $FlowExpectedError[incompatible-call] bad type for getByOverride parameter + result.getByOverride(1234); + // $FlowExpectedError[incompatible-call] missing getByOverride parameter + result.getByOverride(); + // $FlowExpectedError[prop-missing] default queries are not available when using custom queries + result.getByTestId('indifferent'); + }); +}); diff --git a/definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-/react_v8.x.x.js b/definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-v.200.x/react_v8.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-/react_v8.x.x.js rename to definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-v.200.x/react_v8.x.x.js diff --git a/definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-/test_react_v8.x.x.js b/definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-v.200.x/test_react_v8.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-/test_react_v8.x.x.js rename to definitions/npm/@testing-library/react_v8.x.x/flow_v0.104.x-v.200.x/test_react_v8.x.x.js diff --git a/definitions/npm/@testing-library/react_v8.x.x/flow_v0.201.x-/react_v8.x.x.js b/definitions/npm/@testing-library/react_v8.x.x/flow_v0.201.x-/react_v8.x.x.js new file mode 100644 index 0000000000..a25080063e --- /dev/null +++ b/definitions/npm/@testing-library/react_v8.x.x/flow_v0.201.x-/react_v8.x.x.js @@ -0,0 +1,293 @@ +declare module '@testing-library/react' { + // This type comes from react-dom_v17.x.x.js + declare interface ReactDOMTestUtilsThenable { + then(resolve: () => mixed, reject?: () => mixed): mixed; + } + + // This type comes from react-dom_v17.x.x.js + declare type ReactDOMTestUtilsAct = ( + callback: () => void | ReactDOMTestUtilsThenable + ) => ReactDOMTestUtilsThenable; + + declare type TextMatch = + | string + | RegExp + | ((content: string, element: HTMLElement) => boolean); + + declare type TextMatchOptions = { + exact?: boolean, + trim?: boolean, + collapseWhitespace?: boolean, + ... + }; + + declare type SelectorMatchOptions = { + selector?: string, + ... + } & TextMatchOptions; + + declare type GetByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => HTMLElement; + + declare type QueryByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => ?HTMLElement; + + declare type AllByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => Array; + + declare type GetByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => HTMLElement; + + declare type QueryByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement; + + declare type AllByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => Array; + + declare type GetsAndQueries = {| + getByAltText: GetByBoundAttribute, + getAllByAltText: AllByBoundAttribute, + queryByAltText: QueryByBoundAttribute, + queryAllByAltText: AllByBoundAttribute, + + getByDisplayValue: GetByBoundAttribute, + getAllByDisplayValue: AllByBoundAttribute, + queryByDisplayValue: QueryByBoundAttribute, + queryAllByDisplayValue: AllByBoundAttribute, + + getByLabelText: GetByText, + getAllByLabelText: AllByText, + queryByLabelText: QueryByText, + queryAllByLabelText: AllByText, + + getByPlaceholderText: GetByBoundAttribute, + getAllByPlaceholderText: AllByBoundAttribute, + queryByPlaceholderText: QueryByBoundAttribute, + queryAllByPlaceholderText: AllByBoundAttribute, + + getByRole: GetByBoundAttribute, + getAllByRole: AllByBoundAttribute, + queryByRole: QueryByBoundAttribute, + queryAllByRole: AllByBoundAttribute, + + getBySelectText: GetByBoundAttribute, + getAllBySelectText: AllByBoundAttribute, + queryBySelectText: QueryByBoundAttribute, + queryAllBySelectText: AllByBoundAttribute, + + getByTestId: GetByBoundAttribute, + getAllByTestId: AllByBoundAttribute, + queryByTestId: QueryByBoundAttribute, + queryAllByTestId: AllByBoundAttribute, + + getByText: GetByText, + getAllByText: AllByText, + queryByText: QueryByText, + queryAllByText: AllByText, + + getByTitle: GetByBoundAttribute, + getAllByTitle: AllByBoundAttribute, + queryByTitle: QueryByBoundAttribute, + queryAllByTitle: AllByBoundAttribute, + + getByValue: GetByBoundAttribute, + getAllByValue: AllByBoundAttribute, + queryByValue: QueryByBoundAttribute, + queryAllByValue: AllByBoundAttribute, + |}; + + declare type FireEvent = ( + element: HTMLElement, + eventProperties?: TInit + ) => boolean; + + declare type RenderResult = { + ...Queries, + container: HTMLDivElement, + unmount: () => void, + baseElement: HTMLElement, + asFragment: () => DocumentFragment, + debug: (baseElement?: HTMLElement) => void, + rerender: (ui: React$Element) => void, + ... + }; + + declare export type RenderOptions = {| + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + queries?: any, + wrapper?: React$ComponentType, + |}; + + declare module.exports: { + render(ui: React$Element, options?: RenderOptions): RenderResult<>, + + act: ReactDOMTestUtilsAct, + cleanup: () => void, + wait: ( + callback?: () => void, + options?: { + timeout?: number, + interval?: number, + ... + } + ) => Promise, + waitForDomChange: (options?: { + container?: HTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + }) => Promise, + waitForElement: ( + callback?: () => T, + options?: { + container?: HTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + } + ) => Promise, + within: ( + element: HTMLElement, + queriesToBind?: GetsAndQueries | Array + ) => GetsAndQueries, + fireEvent: {| + (element: HTMLElement, event: Event): void, + + copy: FireEvent, + cut: FireEvent, + paste: FireEvent, + compositionEnd: FireEvent, + compositionStart: FireEvent, + compositionUpdate: FireEvent, + keyDown: FireEvent, + keyPress: FireEvent, + keyUp: FireEvent, + focus: FireEvent, + blur: FireEvent, + change: FireEvent, + input: FireEvent, + invalid: FireEvent, + submit: FireEvent, + click: FireEvent, + contextMenu: FireEvent, + dblClick: FireEvent, + doubleClick: FireEvent, + drag: FireEvent, + dragEnd: FireEvent, + dragEnter: FireEvent, + dragExit: FireEvent, + dragLeave: FireEvent, + dragOver: FireEvent, + dragStart: FireEvent, + drop: FireEvent, + mouseDown: FireEvent, + mouseEnter: FireEvent, + mouseLeave: FireEvent, + mouseMove: FireEvent, + mouseOut: FireEvent, + mouseOver: FireEvent, + mouseUp: FireEvent, + select: FireEvent, + touchCancel: FireEvent, + touchEnd: FireEvent, + touchMove: FireEvent, + touchStart: FireEvent, + scroll: FireEvent, + wheel: FireEvent, + abort: FireEvent, + canPlay: FireEvent, + canPlayThrough: FireEvent, + durationChange: FireEvent, + emptied: FireEvent, + encrypted: FireEvent, + ended: FireEvent, + loadedData: FireEvent, + loadedMetadata: FireEvent, + loadStart: FireEvent, + pause: FireEvent, + play: FireEvent, + playing: FireEvent, + progress: FireEvent, + rateChange: FireEvent, + seeked: FireEvent, + seeking: FireEvent, + stalled: FireEvent, + suspend: FireEvent, + timeUpdate: FireEvent, + volumeChange: FireEvent, + waiting: FireEvent, + load: FireEvent, + error: FireEvent, + animationStart: FireEvent, + animationEnd: FireEvent, + animationIteration: FireEvent, + transitionEnd: FireEvent, + |}, + // dom-testing-library re-exports + queryByTestId: ( + container: HTMLElement, + id: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement, + getByTestId: ( + container: HTMLElement, + id: TextMatch, + options?: TextMatchOptions + ) => HTMLElement, + queryByText: ( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement, + getByText: ( + container: HTMLElement, + text: TextMatch, + options?: { selector?: string, ... } & TextMatchOptions + ) => HTMLElement, + queryByPlaceholderText: ( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement, + getByPlaceholderText: ( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ) => HTMLElement, + queryByLabelText: ( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement, + getByLabelText: ( + container: HTMLElement, + text: TextMatch, + options?: { selector?: string, ... } & TextMatchOptions + ) => HTMLElement, + queryByAltText: ( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement, + getByAltText: ( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ) => HTMLElement, + ... + }; +} diff --git a/definitions/npm/@testing-library/react_v8.x.x/flow_v0.201.x-/test_react_v8.x.x.js b/definitions/npm/@testing-library/react_v8.x.x/flow_v0.201.x-/test_react_v8.x.x.js new file mode 100644 index 0000000000..b2d8845e35 --- /dev/null +++ b/definitions/npm/@testing-library/react_v8.x.x/flow_v0.201.x-/test_react_v8.x.x.js @@ -0,0 +1,1121 @@ +// @flow + +import React from 'react'; +import { + act, + render, + wait, + fireEvent, + cleanup, + waitForDomChange, + waitForElement, + within, +} from '@testing-library/react'; +import { describe, it } from 'flow-typed-test'; + +describe('act', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + act(1); + // $FlowExpectedError[extra-arg] + act(() => {}, 1); + // $FlowExpectedError[incompatible-call] + act(() => 1); + }); + + it('should pass on correct inputs', () => { + act(() => {}); + act(() => Promise.resolve()); + act(() => ({ + then: resolve => {}, + })); + }); + + it('should fail on incorrect usage of result', () => { + // $FlowExpectedError[incompatible-type] + act(() => {}) + 1; + // $FlowExpectedError[prop-missing] + act(() => {}).doesNotExist(); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(1); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(() => {}, 1); + }); + + it('should pass on correct usage of result', () => { + act(() => {}).then(() => {}); + act(() => {}).then(() => {}, () => {}); + }); +}); + +describe('wait', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + wait(1); + // $FlowExpectedError[incompatible-call] + wait(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + wait(() => {}); + wait(() => {}, { timeout: 1 }); + }); +}); + +describe('waitForDomChange', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForDomChange(1); + // $FlowExpectedError[incompatible-call] + waitForDomChange('1'); + }); + + it('should pass on correct inputs', () => { + waitForDomChange({ container: document.createElement('div') }); + waitForDomChange({ timeout: 1 }); + }); +}); + +describe('waitForElement', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElement(1); + // $FlowExpectedError[incompatible-call] + waitForElement(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitForElement(() => document.createElement('div')); + waitForElement(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async n => { + const usernameElement = await waitForElement(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('render', () => { + class Component extends React.Component<{ ... }> {} + const { + container, + unmount, + baseElement, + asFragment, + debug, + rerender, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + getBySelectText, + getAllBySelectText, + queryBySelectText, + queryAllBySelectText, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + getByValue, + getAllByValue, + queryByValue, + queryAllByValue, + } = render(); + + it('unmount should has 0 arguments', () => { + unmount(); + // $FlowExpectedError[extra-arg] + unmount(1); + }); + + it('container should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = container; + const b: HTMLElement = container; + }); + + it('baseElement should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = baseElement; + const b: HTMLElement = baseElement; + }); + + it('asFragment should return a document fragment', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = asFragment(); + const b: DocumentFragment = asFragment(); + }); + + it('debug maybe has 1 argument an html element', () => { + // $FlowExpectedError[incompatible-call] + debug(1); + debug(container); + }); + + it('rerender should has 1 argument an react element', () => { + // $FlowExpectedError[incompatible-call] + rerender(); + rerender(); + }); + + it('getByAltText should return HTML element', () => { + const a: HTMLElement = getByAltText('1'); + }); + + it('getAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByAltText('1'); + const b: Array = getAllByAltText('2'); + }); + + it('queryByAltText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByAltText('1'); + const b: ?HTMLElement = queryByAltText('2'); + }); + + it('queryAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByAltText('1'); + const b: Array = queryAllByAltText('2'); + }); + + it('getByDisplayValue should return HTML element', () => { + const a: HTMLElement = getByDisplayValue('1'); + }); + + it('getAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByDisplayValue('1'); + const b: Array = getAllByDisplayValue('2'); + }); + + it('queryByDisplayValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByDisplayValue('1'); + const b: ?HTMLElement = queryByDisplayValue('2'); + }); + + it('queryAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByDisplayValue('1'); + const b: Array = queryAllByDisplayValue('2'); + }); + + it('getByLabelText should return HTML element', () => { + const a: HTMLElement = getByLabelText('1'); + }); + + it('getAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByLabelText('1'); + const b: Array = getAllByLabelText('2'); + }); + + it('queryByLabelText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByLabelText('1'); + const b: ?HTMLElement = queryByLabelText('2'); + }); + + it('queryAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByLabelText('1'); + const b: Array = queryAllByLabelText('2'); + }); + + it('getByPlaceholderText should return HTML element', () => { + const a: HTMLElement = getByPlaceholderText('1'); + }); + + it('getAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByPlaceholderText('1'); + const b: Array = getAllByPlaceholderText('2'); + }); + + it('queryByPlaceholderText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByPlaceholderText('1'); + const b: ?HTMLElement = queryByPlaceholderText('2'); + }); + + it('queryAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByPlaceholderText('1'); + const b: Array = queryAllByPlaceholderText('2'); + }); + + it('getByRole should return HTML element', () => { + const a: HTMLElement = getByRole('1'); + }); + + it('getAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByRole('1'); + const b: Array = getAllByRole('2'); + }); + + it('queryByRole should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByRole('1'); + const b: ?HTMLElement = queryByRole('2'); + }); + + it('queryAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByRole('1'); + const b: Array = queryAllByRole('2'); + }); + + it('getBySelectText should return HTML element', () => { + const a: HTMLElement = getBySelectText('1'); + }); + + it('getAllBySelectText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllBySelectText('1'); + const b: Array = getAllBySelectText('2'); + }); + + it('queryBySelectText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryBySelectText('1'); + const b: ?HTMLElement = queryBySelectText('2'); + }); + + it('queryAllBySelectText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllBySelectText('1'); + const b: Array = queryAllBySelectText('2'); + }); + + it('getByTestId should return HTML element', () => { + const a: HTMLElement = getByTestId('1'); + }); + + it('getAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByTestId('1'); + const b: Array = getAllByTestId('2'); + }); + + it('queryByTestId should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByTestId('1'); + const b: ?HTMLElement = queryByTestId('2'); + }); + + it('queryAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByTestId('1'); + const b: Array = queryAllByTestId('2'); + }); + + it('getByText should return HTML element', () => { + const a: HTMLElement = getByText('1'); + }); + + it('getAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByText('1'); + const b: Array = getAllByText('2'); + }); + + it('queryByText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByText('1'); + const b: ?HTMLElement = queryByText('2'); + }); + + it('queryAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByText('1'); + const b: Array = queryAllByText('2'); + }); + + it('getByTitle should return HTML element', () => { + const a: HTMLElement = getByTitle('1'); + }); + + it('getAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByTitle('1'); + const b: Array = getAllByTitle('2'); + }); + + it('queryByTitle should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByTitle('1'); + const b: ?HTMLElement = queryByTitle('2'); + }); + + it('queryAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByTitle('1'); + const b: Array = queryAllByTitle('2'); + }); + + it('getByValue should return HTML element', () => { + const a: HTMLElement = getByValue('1'); + }); + + it('getAllByValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByValue('1'); + const b: Array = getAllByValue('2'); + }); + + it('queryByValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByValue('1'); + const b: ?HTMLElement = queryByValue('2'); + }); + + it('queryAllByValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByValue('1'); + const b: Array = queryAllByValue('2'); + }); +}); + +describe('cleanup', () => { + it('should be a function w/o arguments', () => { + cleanup(); + // $FlowExpectedError[extra-arg] + cleanup(1); + }); +}); + +describe('within', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should has html element as argument', () => { + // $FlowExpectedError[incompatible-call] + within(); + within(container); + }); + + it('should have getByAltText', () => { + within(container).getByAltText('1'); + }); + + it('should have getAllByAltText', () => { + within(container).getAllByAltText('1'); + }); + + it('should have queryByAltText', () => { + within(container).queryByAltText('1'); + }); + + it('should have queryAllByAltText', () => { + within(container).queryAllByAltText('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have getByLabelText', () => { + within(container).getByLabelText('1'); + }); + + it('should have getAllByLabelText', () => { + within(container).getAllByLabelText('1'); + }); + + it('should have queryByLabelText', () => { + within(container).queryByLabelText('1'); + }); + + it('should have queryAllByLabelText', () => { + within(container).queryAllByLabelText('1'); + }); + + it('should have getByPlaceholderText', () => { + within(container).getByPlaceholderText('1'); + }); + + it('should have getAllByPlaceholderText', () => { + within(container).getAllByPlaceholderText('1'); + }); + + it('should have queryByPlaceholderText', () => { + within(container).queryByPlaceholderText('1'); + }); + + it('should have queryAllByPlaceholderText', () => { + within(container).queryAllByPlaceholderText('1'); + }); + + it('should have getByRole', () => { + within(container).getByRole('1'); + }); + + it('should have getAllByRole', () => { + within(container).getAllByRole('1'); + }); + + it('should have queryByRole', () => { + within(container).queryByRole('1'); + }); + + it('should have queryAllByRole', () => { + within(container).queryAllByRole('1'); + }); + + it('should have getBySelectText', () => { + within(container).getBySelectText('1'); + }); + + it('should have getAllBySelectText', () => { + within(container).getAllBySelectText('1'); + }); + + it('should have queryBySelectText', () => { + within(container).queryBySelectText('1'); + }); + + it('should have queryAllBySelectText', () => { + within(container).queryAllBySelectText('1'); + }); + + it('should have getByTestId', () => { + within(container).getByTestId('1'); + }); + + it('should have getAllByTestId', () => { + within(container).getAllByTestId('1'); + }); + + it('should have queryByTestId', () => { + within(container).queryByTestId('1'); + }); + + it('should have queryAllByTestId', () => { + within(container).queryAllByTestId('1'); + }); + + it('should have getByText', () => { + within(container).getByText('1'); + }); + + it('should have getAllByText', () => { + within(container).getAllByText('1'); + }); + + it('should have queryByText', () => { + within(container).queryByText('1'); + }); + + it('should have queryAllByText', () => { + within(container).queryAllByText('1'); + }); + + it('should have getByTitle', () => { + within(container).getByTitle('1'); + }); + + it('should have getAllByTitle', () => { + within(container).getAllByTitle('1'); + }); + + it('should have queryByTitle', () => { + within(container).queryByTitle('1'); + }); + + it('should have queryAllByTitle', () => { + within(container).queryAllByTitle('1'); + }); + + it('should have getByValue', () => { + within(container).getByValue('1'); + }); + + it('should have getAllByValue', () => { + within(container).getAllByValue('1'); + }); + + it('should have queryByValue', () => { + within(container).queryByValue('1'); + }); + + it('should have queryAllByValue', () => { + within(container).queryAllByValue('1'); + }); +}); + +describe('fireEvent', () => { + const htmlEl = document.createElement('div'); + + it('should be callable', () => { + fireEvent( + htmlEl, + new MouseEvent('click', { + bubbles: true, + cancelable: true, + }) + ); + }); + + it('should throw on invalid arguments', () => { + // $FlowExpectedError[incompatible-call] + fireEvent(1); + // $FlowExpectedError[incompatible-call] + fireEvent(htmlEl, 1); + }); + + it('should expose fire event helpers', () => { + fireEvent.copy(htmlEl); + fireEvent.cut(htmlEl); + fireEvent.paste(htmlEl); + fireEvent.compositionEnd(htmlEl); + fireEvent.compositionStart(htmlEl); + fireEvent.compositionUpdate(htmlEl); + fireEvent.keyDown(htmlEl); + fireEvent.keyPress(htmlEl); + fireEvent.keyUp(htmlEl); + fireEvent.focus(htmlEl); + fireEvent.blur(htmlEl); + fireEvent.change(htmlEl); + fireEvent.input(htmlEl); + fireEvent.invalid(htmlEl); + fireEvent.submit(htmlEl); + fireEvent.click(htmlEl); + fireEvent.contextMenu(htmlEl); + fireEvent.dblClick(htmlEl); + fireEvent.doubleClick(htmlEl); + fireEvent.drag(htmlEl); + fireEvent.dragEnd(htmlEl); + fireEvent.dragEnter(htmlEl); + fireEvent.dragExit(htmlEl); + fireEvent.dragLeave(htmlEl); + fireEvent.dragOver(htmlEl); + fireEvent.dragStart(htmlEl); + fireEvent.drop(htmlEl); + fireEvent.mouseDown(htmlEl); + fireEvent.mouseEnter(htmlEl); + fireEvent.mouseLeave(htmlEl); + fireEvent.mouseMove(htmlEl); + fireEvent.mouseOut(htmlEl); + fireEvent.mouseOver(htmlEl); + fireEvent.mouseUp(htmlEl); + fireEvent.select(htmlEl); + fireEvent.touchCancel(htmlEl); + fireEvent.touchEnd(htmlEl); + fireEvent.touchMove(htmlEl); + fireEvent.touchStart(htmlEl); + fireEvent.scroll(htmlEl); + fireEvent.wheel(htmlEl); + fireEvent.abort(htmlEl); + fireEvent.canPlay(htmlEl); + fireEvent.canPlayThrough(htmlEl); + fireEvent.durationChange(htmlEl); + fireEvent.emptied(htmlEl); + fireEvent.encrypted(htmlEl); + fireEvent.ended(htmlEl); + fireEvent.loadedData(htmlEl); + fireEvent.loadedMetadata(htmlEl); + fireEvent.loadStart(htmlEl); + fireEvent.pause(htmlEl); + fireEvent.play(htmlEl); + fireEvent.playing(htmlEl); + fireEvent.progress(htmlEl); + fireEvent.rateChange(htmlEl); + fireEvent.seeked(htmlEl); + fireEvent.seeking(htmlEl); + fireEvent.stalled(htmlEl); + fireEvent.suspend(htmlEl); + fireEvent.timeUpdate(htmlEl); + fireEvent.volumeChange(htmlEl); + fireEvent.waiting(htmlEl); + fireEvent.load(htmlEl); + fireEvent.error(htmlEl); + fireEvent.animationStart(htmlEl); + fireEvent.animationEnd(htmlEl); + fireEvent.animationIteration(htmlEl); + fireEvent.transitionEnd(htmlEl); + }); +}); + +describe('text matching API', () => { + class Component extends React.Component<{ ... }> {} + const { + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + getBySelectText, + getAllBySelectText, + queryBySelectText, + queryAllBySelectText, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + getByValue, + getAllByValue, + queryByValue, + queryAllByValue, + } = render(); + + it('getByAltText should accept text match arguments', () => { + getByAltText('1'); + getByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByAltText(/1/); + getByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByAltText((content: string, element) => true); + getByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByAltText should accept text match arguments', () => { + const result: Array = getAllByAltText('1'); + }); + + it('queryByAltText should accept text match arguments', () => { + queryByAltText('1'); + queryByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText(/1/); + queryByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText((content: string, element) => true); + queryByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByAltText should accept text match arguments', () => { + const result: Array = queryAllByAltText('1'); + }); + + it('getByDisplayValue should accept text match arguments', () => { + getByDisplayValue('1'); + getByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue(/1/); + getByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue((content: string, element) => true); + getByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByDisplayValue should accept text match arguments', () => { + const result: Array = getAllByDisplayValue('1'); + }); + + it('queryByDisplayValue should accept text match arguments', () => { + queryByDisplayValue('1'); + queryByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue(/1/); + queryByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue((content: string, element) => true); + queryByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByDisplayValue should accept text match arguments', () => { + const result: Array = queryAllByDisplayValue('1'); + }); + + it('getByLabelText should accept text match arguments', () => { + getByLabelText('1'); + getByLabelText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText(/1/); + getByLabelText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText((content: string, element) => true); + getByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByLabelText should accept text match arguments', () => { + const result: Array = getAllByLabelText('1'); + }); + + it('queryByLabelText should accept text match arguments', () => { + queryByLabelText('1'); + queryByLabelText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByLabelText(/1/); + queryByLabelText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + queryByLabelText((content: string, element) => true); + queryByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByLabelText should accept text match arguments', () => { + const result: Array = queryAllByLabelText('1'); + }); + + it('getByPlaceholderText should accept text match arguments', () => { + getByPlaceholderText('1'); + getByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText(/1/); + getByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText((content: string, element) => true); + getByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByPlaceholderText should accept text match arguments', () => { + const result: Array = getAllByPlaceholderText('1'); + }); + + it('queryByPlaceholderText should accept text match arguments', () => { + queryByPlaceholderText('1'); + queryByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText(/1/); + queryByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText((content: string, element) => true); + queryByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByPlaceholderText should accept text match arguments', () => { + const result: Array = queryAllByPlaceholderText('1'); + }); + + it('getByRole should accept text match arguments', () => { + getByRole('1'); + getByRole('1', { trim: true, collapseWhitespace: true, exact: true }); + getByRole(/1/); + getByRole(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByRole((content: string, element) => true); + getByRole((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByRole should accept text match arguments', () => { + const result: Array = getAllByRole('1'); + }); + + it('queryByRole should accept text match arguments', () => { + queryByRole('1'); + queryByRole('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByRole(/1/); + queryByRole(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByRole((content: string, element) => true); + queryByRole((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByRole should accept text match arguments', () => { + const result: Array = queryAllByRole('1'); + }); + + it('getBySelectText should accept text match arguments', () => { + getBySelectText('1'); + getBySelectText('1', { trim: true, collapseWhitespace: true, exact: true }); + getBySelectText(/1/); + getBySelectText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getBySelectText((content: string, element) => true); + getBySelectText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllBySelectText should accept text match arguments', () => { + const result: Array = getAllBySelectText('1'); + }); + + it('queryBySelectText should accept text match arguments', () => { + queryBySelectText('1'); + queryBySelectText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryBySelectText(/1/); + queryBySelectText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryBySelectText((content: string, element) => true); + queryBySelectText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllBySelectText should accept text match arguments', () => { + const result: Array = queryAllBySelectText('1'); + }); + + it('getByTestId should accept text match arguments', () => { + getByTestId('1'); + getByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTestId(/1/); + getByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTestId((content: string, element) => true); + getByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTestId should accept text match arguments', () => { + const result: Array = getAllByTestId('1'); + }); + + it('queryByTestId should accept text match arguments', () => { + queryByTestId('1'); + queryByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId(/1/); + queryByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId((content: string, element) => true); + queryByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTestId should accept text match arguments', () => { + const result: Array = queryAllByTestId('1'); + }); + + it('getByText should accept text match arguments', () => { + getByText('1'); + getByText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByText(/1/); + getByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByText((content: string, element) => true); + getByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByText should accept text match arguments', () => { + const result: Array = getAllByText('1'); + }); + + it('queryByText should accept text match arguments', () => { + queryByText('1'); + queryByText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByText(/1/); + queryByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByText((content: string, element) => true); + queryByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByText should accept text match arguments', () => { + const result: Array = queryAllByText('1'); + }); + + it('getByTitle should accept text match arguments', () => { + getByTitle('1'); + getByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTitle(/1/); + getByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTitle((content: string, element) => true); + getByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTitle should accept text match arguments', () => { + const result: Array = getAllByTitle('1'); + }); + + it('queryByTitle should accept text match arguments', () => { + queryByTitle('1'); + queryByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle(/1/); + queryByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle((content: string, element) => true); + queryByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTitle should accept text match arguments', () => { + const result: Array = queryAllByTitle('1'); + }); + + it('getByValue should accept text match arguments', () => { + getByValue('1'); + getByValue('1', { trim: true, collapseWhitespace: true, exact: true }); + getByValue(/1/); + getByValue(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByValue((content: string, element) => true); + getByValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByValue should accept text match arguments', () => { + const result: Array = getAllByValue('1'); + }); + + it('queryByValue should accept text match arguments', () => { + queryByValue('1'); + queryByValue('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByValue(/1/); + queryByValue(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByValue((content: string, element) => true); + queryByValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByValue should accept text match arguments', () => { + const result: Array = queryAllByValue('1'); + }); +}); diff --git a/definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-/react_v9.x.x.js b/definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-v.200.x/react_v9.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-/react_v9.x.x.js rename to definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-v.200.x/react_v9.x.x.js diff --git a/definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-/test_react_v9.x.x.js b/definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-v.200.x/test_react_v9.x.x.js similarity index 100% rename from definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-/test_react_v9.x.x.js rename to definitions/npm/@testing-library/react_v9.x.x/flow_v0.104.x-v.200.x/test_react_v9.x.x.js diff --git a/definitions/npm/@testing-library/react_v9.x.x/flow_v0.201.x-/react_v9.x.x.js b/definitions/npm/@testing-library/react_v9.x.x/flow_v0.201.x-/react_v9.x.x.js new file mode 100644 index 0000000000..249f0398f2 --- /dev/null +++ b/definitions/npm/@testing-library/react_v9.x.x/flow_v0.201.x-/react_v9.x.x.js @@ -0,0 +1,308 @@ +declare module '@testing-library/react' { + // This type comes from react-dom_v17.x.x.js + declare interface ReactDOMTestUtilsThenable { + then(resolve: () => mixed, reject?: () => mixed): mixed; + } + + // This type comes from react-dom_v17.x.x.js + declare type ReactDOMTestUtilsAct = ( + callback: () => void | ReactDOMTestUtilsThenable + ) => ReactDOMTestUtilsThenable; + + declare type TextMatch = + | string + | RegExp + | ((content: string, element: HTMLElement) => boolean); + + declare type TextMatchOptions = { + exact?: boolean, + trim?: boolean, + collapseWhitespace?: boolean, + ... + }; + + declare type SelectorMatchOptions = { + selector?: string, + ... + } & TextMatchOptions; + + declare type GetByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => HTMLElement; + + declare type QueryByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => ?HTMLElement; + + declare type AllByText = ( + text: TextMatch, + options?: SelectorMatchOptions + ) => Array; + + declare type GetByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => HTMLElement; + + declare type QueryByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => ?HTMLElement; + + declare type AllByBoundAttribute = ( + text: TextMatch, + options?: TextMatchOptions + ) => Array; + + declare type GetsAndQueries = {| + getByAltText: GetByBoundAttribute, + getAllByAltText: AllByBoundAttribute, + queryByAltText: QueryByBoundAttribute, + queryAllByAltText: AllByBoundAttribute, + + getByDisplayValue: GetByBoundAttribute, + getAllByDisplayValue: AllByBoundAttribute, + queryByDisplayValue: QueryByBoundAttribute, + queryAllByDisplayValue: AllByBoundAttribute, + + getByLabelText: GetByText, + getAllByLabelText: AllByText, + queryByLabelText: QueryByText, + queryAllByLabelText: AllByText, + + getByPlaceholderText: GetByBoundAttribute, + getAllByPlaceholderText: AllByBoundAttribute, + queryByPlaceholderText: QueryByBoundAttribute, + queryAllByPlaceholderText: AllByBoundAttribute, + + getByRole: GetByBoundAttribute, + getAllByRole: AllByBoundAttribute, + queryByRole: QueryByBoundAttribute, + queryAllByRole: AllByBoundAttribute, + + getBySelectText: GetByBoundAttribute, + getAllBySelectText: AllByBoundAttribute, + queryBySelectText: QueryByBoundAttribute, + queryAllBySelectText: AllByBoundAttribute, + + getByTestId: GetByBoundAttribute, + getAllByTestId: AllByBoundAttribute, + queryByTestId: QueryByBoundAttribute, + queryAllByTestId: AllByBoundAttribute, + + getByText: GetByText, + getAllByText: AllByText, + queryByText: QueryByText, + queryAllByText: AllByText, + + getByTitle: GetByBoundAttribute, + getAllByTitle: AllByBoundAttribute, + queryByTitle: QueryByBoundAttribute, + queryAllByTitle: AllByBoundAttribute, + + getByValue: GetByBoundAttribute, + getAllByValue: AllByBoundAttribute, + queryByValue: QueryByBoundAttribute, + queryAllByValue: AllByBoundAttribute, + |}; + + declare type FireEvent = ( + element: HTMLElement, + eventProperties?: TInit + ) => boolean; + + declare type RenderResult = { + ...Queries, + container: HTMLDivElement, + unmount: () => void, + baseElement: HTMLElement, + asFragment: () => DocumentFragment, + debug: (baseElement?: HTMLElement) => void, + rerender: (ui: React$Element) => void, + ... + }; + + declare export type RenderOptionsWithoutCustomQueries = {| + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export type RenderOptionsWithCustomQueries< + CustomQueries: { ... } + > = {| + queries: CustomQueries, + container?: HTMLElement, + baseElement?: HTMLElement, + hydrate?: boolean, + wrapper?: React$ComponentType, + |}; + + declare export function render( + ui: React$Element, + options?: RenderOptionsWithoutCustomQueries + ): RenderResult<>; + declare export function render< + CustomQueries: { [string]: (...args: Array) => any, ... } + >( + ui: React$Element, + options: RenderOptionsWithCustomQueries + ): RenderResult; + + declare export var act: ReactDOMTestUtilsAct; + declare export function cleanup(): void; + declare export function wait( + callback?: () => void, + options?: { + timeout?: number, + interval?: number, + ... + } + ): Promise; + declare export function waitForDomChange(options?: { + container?: HTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + }): Promise; + declare export function waitForElement( + callback?: () => T, + options?: { + container?: HTMLElement, + timeout?: number, + mutationObserverOptions?: MutationObserverInit, + ... + } + ): Promise; + declare export function within( + element: HTMLElement, + queriesToBind?: GetsAndQueries | Array + ): GetsAndQueries; + declare export var fireEvent: {| + (element: HTMLElement, event: Event): void, + + copy: FireEvent, + cut: FireEvent, + paste: FireEvent, + compositionEnd: FireEvent, + compositionStart: FireEvent, + compositionUpdate: FireEvent, + keyDown: FireEvent, + keyPress: FireEvent, + keyUp: FireEvent, + focus: FireEvent, + blur: FireEvent, + change: FireEvent, + input: FireEvent, + invalid: FireEvent, + submit: FireEvent, + click: FireEvent, + contextMenu: FireEvent, + dblClick: FireEvent, + doubleClick: FireEvent, + drag: FireEvent, + dragEnd: FireEvent, + dragEnter: FireEvent, + dragExit: FireEvent, + dragLeave: FireEvent, + dragOver: FireEvent, + dragStart: FireEvent, + drop: FireEvent, + mouseDown: FireEvent, + mouseEnter: FireEvent, + mouseLeave: FireEvent, + mouseMove: FireEvent, + mouseOut: FireEvent, + mouseOver: FireEvent, + mouseUp: FireEvent, + select: FireEvent, + touchCancel: FireEvent, + touchEnd: FireEvent, + touchMove: FireEvent, + touchStart: FireEvent, + scroll: FireEvent, + wheel: FireEvent, + abort: FireEvent, + canPlay: FireEvent, + canPlayThrough: FireEvent, + durationChange: FireEvent, + emptied: FireEvent, + encrypted: FireEvent, + ended: FireEvent, + loadedData: FireEvent, + loadedMetadata: FireEvent, + loadStart: FireEvent, + pause: FireEvent, + play: FireEvent, + playing: FireEvent, + progress: FireEvent, + rateChange: FireEvent, + seeked: FireEvent, + seeking: FireEvent, + stalled: FireEvent, + suspend: FireEvent, + timeUpdate: FireEvent, + volumeChange: FireEvent, + waiting: FireEvent, + load: FireEvent, + error: FireEvent, + animationStart: FireEvent, + animationEnd: FireEvent, + animationIteration: FireEvent, + transitionEnd: FireEvent, + |}; + // dom-testing-library re-exports + declare export function queryByTestId( + container: HTMLElement, + id: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByTestId( + container: HTMLElement, + id: TextMatch, + options?: TextMatchOptions + ): HTMLElement; + declare export function queryByText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByText( + container: HTMLElement, + text: TextMatch, + options?: { selector?: string, ... } & TextMatchOptions + ): HTMLElement; + declare export function queryByPlaceholderText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByPlaceholderText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): HTMLElement; + declare export function queryByLabelText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByLabelText( + container: HTMLElement, + text: TextMatch, + options?: { selector?: string, ... } & TextMatchOptions + ): HTMLElement; + declare export function queryByAltText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): ?HTMLElement; + declare export function getByAltText( + container: HTMLElement, + text: TextMatch, + options?: TextMatchOptions + ): HTMLElement; +} diff --git a/definitions/npm/@testing-library/react_v9.x.x/flow_v0.201.x-/test_react_v9.x.x.js b/definitions/npm/@testing-library/react_v9.x.x/flow_v0.201.x-/test_react_v9.x.x.js new file mode 100644 index 0000000000..a5c48a5d7f --- /dev/null +++ b/definitions/npm/@testing-library/react_v9.x.x/flow_v0.201.x-/test_react_v9.x.x.js @@ -0,0 +1,1154 @@ +// @flow + +import React from 'react'; +import { + act, + render, + wait, + fireEvent, + cleanup, + waitForDomChange, + waitForElement, + within, +} from '@testing-library/react'; +import { describe, it } from 'flow-typed-test'; + +describe('act', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + act(1); + // $FlowExpectedError[extra-arg] + act(() => {}, 1); + // $FlowExpectedError[incompatible-call] + act(() => 1); + }); + + it('should pass on correct inputs', () => { + act(() => {}); + act(() => Promise.resolve()); + act(() => ({ + then: resolve => {}, + })); + }); + + it('should fail on incorrect usage of result', () => { + // $FlowExpectedError[incompatible-type] + act(() => {}) + 1; + // $FlowExpectedError[prop-missing] + act(() => {}).doesNotExist(); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(1); + // $FlowExpectedError[incompatible-call] + act(() => {}).then(() => {}, 1); + }); + + it('should pass on correct usage of result', () => { + act(() => {}).then(() => {}); + act(() => {}).then(() => {}, () => {}); + }); +}); + +describe('wait', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + wait(1); + // $FlowExpectedError[incompatible-call] + wait(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + wait(() => {}); + wait(() => {}, { timeout: 1 }); + }); +}); + +describe('waitForDomChange', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForDomChange(1); + // $FlowExpectedError[incompatible-call] + waitForDomChange('1'); + }); + + it('should pass on correct inputs', () => { + waitForDomChange({ container: document.createElement('div') }); + waitForDomChange({ timeout: 1 }); + }); +}); + +describe('waitForElement', () => { + it('should fail on invalid inputs', () => { + // $FlowExpectedError[incompatible-call] + waitForElement(1); + // $FlowExpectedError[incompatible-call] + waitForElement(() => {}, 1); + }); + + it('should pass on correct inputs', () => { + waitForElement(() => document.createElement('div')); + waitForElement(() => document.createElement('div'), { + container: document.createElement('div'), + timeout: 100, + }); + }); + + it('should return a usable value.', async n => { + const usernameElement = await waitForElement(() => + document.createElement('input') + ); + + usernameElement.value = 'chucknorris'; + }); +}); + +describe('render', () => { + class Component extends React.Component<{ ... }> {} + const { + container, + unmount, + baseElement, + asFragment, + debug, + rerender, + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + getBySelectText, + getAllBySelectText, + queryBySelectText, + queryAllBySelectText, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + getByValue, + getAllByValue, + queryByValue, + queryAllByValue, + } = render(); + + it('unmount should has 0 arguments', () => { + unmount(); + // $FlowExpectedError[extra-arg] + unmount(1); + }); + + it('container should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = container; + const b: HTMLElement = container; + }); + + it('baseElement should be an html element', () => { + // $FlowExpectedError[incompatible-type] + const a: number = baseElement; + const b: HTMLElement = baseElement; + }); + + it('asFragment should return a document fragment', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = asFragment(); + const b: DocumentFragment = asFragment(); + }); + + it('debug maybe has 1 argument an html element', () => { + // $FlowExpectedError[incompatible-call] + debug(1); + debug(container); + }); + + it('rerender should has 1 argument an react element', () => { + // $FlowExpectedError[incompatible-call] + rerender(); + rerender(); + }); + + it('getByAltText should return HTML element', () => { + const a: HTMLElement = getByAltText('1'); + }); + + it('getAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByAltText('1'); + const b: Array = getAllByAltText('2'); + }); + + it('queryByAltText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByAltText('1'); + const b: ?HTMLElement = queryByAltText('2'); + }); + + it('queryAllByAltText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByAltText('1'); + const b: Array = queryAllByAltText('2'); + }); + + it('getByDisplayValue should return HTML element', () => { + const a: HTMLElement = getByDisplayValue('1'); + }); + + it('getAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByDisplayValue('1'); + const b: Array = getAllByDisplayValue('2'); + }); + + it('queryByDisplayValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByDisplayValue('1'); + const b: ?HTMLElement = queryByDisplayValue('2'); + }); + + it('queryAllByDisplayValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByDisplayValue('1'); + const b: Array = queryAllByDisplayValue('2'); + }); + + it('getByLabelText should return HTML element', () => { + const a: HTMLElement = getByLabelText('1'); + }); + + it('getAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByLabelText('1'); + const b: Array = getAllByLabelText('2'); + }); + + it('queryByLabelText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByLabelText('1'); + const b: ?HTMLElement = queryByLabelText('2'); + }); + + it('queryAllByLabelText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByLabelText('1'); + const b: Array = queryAllByLabelText('2'); + }); + + it('getByPlaceholderText should return HTML element', () => { + const a: HTMLElement = getByPlaceholderText('1'); + }); + + it('getAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByPlaceholderText('1'); + const b: Array = getAllByPlaceholderText('2'); + }); + + it('queryByPlaceholderText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByPlaceholderText('1'); + const b: ?HTMLElement = queryByPlaceholderText('2'); + }); + + it('queryAllByPlaceholderText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByPlaceholderText('1'); + const b: Array = queryAllByPlaceholderText('2'); + }); + + it('getByRole should return HTML element', () => { + const a: HTMLElement = getByRole('1'); + }); + + it('getAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByRole('1'); + const b: Array = getAllByRole('2'); + }); + + it('queryByRole should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByRole('1'); + const b: ?HTMLElement = queryByRole('2'); + }); + + it('queryAllByRole should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByRole('1'); + const b: Array = queryAllByRole('2'); + }); + + it('getBySelectText should return HTML element', () => { + const a: HTMLElement = getBySelectText('1'); + }); + + it('getAllBySelectText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllBySelectText('1'); + const b: Array = getAllBySelectText('2'); + }); + + it('queryBySelectText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryBySelectText('1'); + const b: ?HTMLElement = queryBySelectText('2'); + }); + + it('queryAllBySelectText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllBySelectText('1'); + const b: Array = queryAllBySelectText('2'); + }); + + it('getByTestId should return HTML element', () => { + const a: HTMLElement = getByTestId('1'); + }); + + it('getAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByTestId('1'); + const b: Array = getAllByTestId('2'); + }); + + it('queryByTestId should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByTestId('1'); + const b: ?HTMLElement = queryByTestId('2'); + }); + + it('queryAllByTestId should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByTestId('1'); + const b: Array = queryAllByTestId('2'); + }); + + it('getByText should return HTML element', () => { + const a: HTMLElement = getByText('1'); + }); + + it('getAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByText('1'); + const b: Array = getAllByText('2'); + }); + + it('queryByText should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByText('1'); + const b: ?HTMLElement = queryByText('2'); + }); + + it('queryAllByText should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByText('1'); + const b: Array = queryAllByText('2'); + }); + + it('getByTitle should return HTML element', () => { + const a: HTMLElement = getByTitle('1'); + }); + + it('getAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByTitle('1'); + const b: Array = getAllByTitle('2'); + }); + + it('queryByTitle should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByTitle('1'); + const b: ?HTMLElement = queryByTitle('2'); + }); + + it('queryAllByTitle should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByTitle('1'); + const b: Array = queryAllByTitle('2'); + }); + + it('getByValue should return HTML element', () => { + const a: HTMLElement = getByValue('1'); + }); + + it('getAllByValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = getAllByValue('1'); + const b: Array = getAllByValue('2'); + }); + + it('queryByValue should return maybe HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryByValue('1'); + const b: ?HTMLElement = queryByValue('2'); + }); + + it('queryAllByValue should return array of HTML element', () => { + // $FlowExpectedError[incompatible-type] + const a: HTMLElement = queryAllByValue('1'); + const b: Array = queryAllByValue('2'); + }); +}); + +describe('cleanup', () => { + it('should be a function w/o arguments', () => { + cleanup(); + // $FlowExpectedError[extra-arg] + cleanup(1); + }); +}); + +describe('within', () => { + class Component extends React.Component<{ ... }> {} + const { container } = render(); + + it('should has html element as argument', () => { + // $FlowExpectedError[incompatible-call] + within(); + within(container); + }); + + it('should have getByAltText', () => { + within(container).getByAltText('1'); + }); + + it('should have getAllByAltText', () => { + within(container).getAllByAltText('1'); + }); + + it('should have queryByAltText', () => { + within(container).queryByAltText('1'); + }); + + it('should have queryAllByAltText', () => { + within(container).queryAllByAltText('1'); + }); + + it('should have getByDisplayValue', () => { + within(container).getByDisplayValue('1'); + }); + + it('should have getAllByDisplayValue', () => { + within(container).getAllByDisplayValue('1'); + }); + + it('should have queryByDisplayValue', () => { + within(container).queryByDisplayValue('1'); + }); + + it('should have queryAllByDisplayValue', () => { + within(container).queryAllByDisplayValue('1'); + }); + + it('should have getByLabelText', () => { + within(container).getByLabelText('1'); + }); + + it('should have getAllByLabelText', () => { + within(container).getAllByLabelText('1'); + }); + + it('should have queryByLabelText', () => { + within(container).queryByLabelText('1'); + }); + + it('should have queryAllByLabelText', () => { + within(container).queryAllByLabelText('1'); + }); + + it('should have getByPlaceholderText', () => { + within(container).getByPlaceholderText('1'); + }); + + it('should have getAllByPlaceholderText', () => { + within(container).getAllByPlaceholderText('1'); + }); + + it('should have queryByPlaceholderText', () => { + within(container).queryByPlaceholderText('1'); + }); + + it('should have queryAllByPlaceholderText', () => { + within(container).queryAllByPlaceholderText('1'); + }); + + it('should have getByRole', () => { + within(container).getByRole('1'); + }); + + it('should have getAllByRole', () => { + within(container).getAllByRole('1'); + }); + + it('should have queryByRole', () => { + within(container).queryByRole('1'); + }); + + it('should have queryAllByRole', () => { + within(container).queryAllByRole('1'); + }); + + it('should have getBySelectText', () => { + within(container).getBySelectText('1'); + }); + + it('should have getAllBySelectText', () => { + within(container).getAllBySelectText('1'); + }); + + it('should have queryBySelectText', () => { + within(container).queryBySelectText('1'); + }); + + it('should have queryAllBySelectText', () => { + within(container).queryAllBySelectText('1'); + }); + + it('should have getByTestId', () => { + within(container).getByTestId('1'); + }); + + it('should have getAllByTestId', () => { + within(container).getAllByTestId('1'); + }); + + it('should have queryByTestId', () => { + within(container).queryByTestId('1'); + }); + + it('should have queryAllByTestId', () => { + within(container).queryAllByTestId('1'); + }); + + it('should have getByText', () => { + within(container).getByText('1'); + }); + + it('should have getAllByText', () => { + within(container).getAllByText('1'); + }); + + it('should have queryByText', () => { + within(container).queryByText('1'); + }); + + it('should have queryAllByText', () => { + within(container).queryAllByText('1'); + }); + + it('should have getByTitle', () => { + within(container).getByTitle('1'); + }); + + it('should have getAllByTitle', () => { + within(container).getAllByTitle('1'); + }); + + it('should have queryByTitle', () => { + within(container).queryByTitle('1'); + }); + + it('should have queryAllByTitle', () => { + within(container).queryAllByTitle('1'); + }); + + it('should have getByValue', () => { + within(container).getByValue('1'); + }); + + it('should have getAllByValue', () => { + within(container).getAllByValue('1'); + }); + + it('should have queryByValue', () => { + within(container).queryByValue('1'); + }); + + it('should have queryAllByValue', () => { + within(container).queryAllByValue('1'); + }); +}); + +describe('fireEvent', () => { + const htmlEl = document.createElement('div'); + + it('should be callable', () => { + fireEvent( + htmlEl, + new MouseEvent('click', { + bubbles: true, + cancelable: true, + }) + ); + }); + + it('should throw on invalid arguments', () => { + // $FlowExpectedError[incompatible-call] + fireEvent(1); + // $FlowExpectedError[incompatible-call] + fireEvent(htmlEl, 1); + }); + + it('should expose fire event helpers', () => { + fireEvent.copy(htmlEl); + fireEvent.cut(htmlEl); + fireEvent.paste(htmlEl); + fireEvent.compositionEnd(htmlEl); + fireEvent.compositionStart(htmlEl); + fireEvent.compositionUpdate(htmlEl); + fireEvent.keyDown(htmlEl); + fireEvent.keyPress(htmlEl); + fireEvent.keyUp(htmlEl); + fireEvent.focus(htmlEl); + fireEvent.blur(htmlEl); + fireEvent.change(htmlEl); + fireEvent.input(htmlEl); + fireEvent.invalid(htmlEl); + fireEvent.submit(htmlEl); + fireEvent.click(htmlEl); + fireEvent.contextMenu(htmlEl); + fireEvent.dblClick(htmlEl); + fireEvent.doubleClick(htmlEl); + fireEvent.drag(htmlEl); + fireEvent.dragEnd(htmlEl); + fireEvent.dragEnter(htmlEl); + fireEvent.dragExit(htmlEl); + fireEvent.dragLeave(htmlEl); + fireEvent.dragOver(htmlEl); + fireEvent.dragStart(htmlEl); + fireEvent.drop(htmlEl); + fireEvent.mouseDown(htmlEl); + fireEvent.mouseEnter(htmlEl); + fireEvent.mouseLeave(htmlEl); + fireEvent.mouseMove(htmlEl); + fireEvent.mouseOut(htmlEl); + fireEvent.mouseOver(htmlEl); + fireEvent.mouseUp(htmlEl); + fireEvent.select(htmlEl); + fireEvent.touchCancel(htmlEl); + fireEvent.touchEnd(htmlEl); + fireEvent.touchMove(htmlEl); + fireEvent.touchStart(htmlEl); + fireEvent.scroll(htmlEl); + fireEvent.wheel(htmlEl); + fireEvent.abort(htmlEl); + fireEvent.canPlay(htmlEl); + fireEvent.canPlayThrough(htmlEl); + fireEvent.durationChange(htmlEl); + fireEvent.emptied(htmlEl); + fireEvent.encrypted(htmlEl); + fireEvent.ended(htmlEl); + fireEvent.loadedData(htmlEl); + fireEvent.loadedMetadata(htmlEl); + fireEvent.loadStart(htmlEl); + fireEvent.pause(htmlEl); + fireEvent.play(htmlEl); + fireEvent.playing(htmlEl); + fireEvent.progress(htmlEl); + fireEvent.rateChange(htmlEl); + fireEvent.seeked(htmlEl); + fireEvent.seeking(htmlEl); + fireEvent.stalled(htmlEl); + fireEvent.suspend(htmlEl); + fireEvent.timeUpdate(htmlEl); + fireEvent.volumeChange(htmlEl); + fireEvent.waiting(htmlEl); + fireEvent.load(htmlEl); + fireEvent.error(htmlEl); + fireEvent.animationStart(htmlEl); + fireEvent.animationEnd(htmlEl); + fireEvent.animationIteration(htmlEl); + fireEvent.transitionEnd(htmlEl); + }); +}); + +describe('text matching API', () => { + class Component extends React.Component<{ ... }> {} + const { + getByAltText, + getAllByAltText, + queryByAltText, + queryAllByAltText, + getByDisplayValue, + getAllByDisplayValue, + queryByDisplayValue, + queryAllByDisplayValue, + getByLabelText, + getAllByLabelText, + queryByLabelText, + queryAllByLabelText, + getByPlaceholderText, + getAllByPlaceholderText, + queryByPlaceholderText, + queryAllByPlaceholderText, + getByRole, + getAllByRole, + queryByRole, + queryAllByRole, + getBySelectText, + getAllBySelectText, + queryBySelectText, + queryAllBySelectText, + getByTestId, + getAllByTestId, + queryByTestId, + queryAllByTestId, + getByText, + getAllByText, + queryByText, + queryAllByText, + getByTitle, + getAllByTitle, + queryByTitle, + queryAllByTitle, + getByValue, + getAllByValue, + queryByValue, + queryAllByValue, + } = render(); + + it('getByAltText should accept text match arguments', () => { + getByAltText('1'); + getByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByAltText(/1/); + getByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByAltText((content: string, element) => true); + getByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByAltText should accept text match arguments', () => { + const result: Array = getAllByAltText('1'); + }); + + it('queryByAltText should accept text match arguments', () => { + queryByAltText('1'); + queryByAltText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText(/1/); + queryByAltText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByAltText((content: string, element) => true); + queryByAltText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByAltText should accept text match arguments', () => { + const result: Array = queryAllByAltText('1'); + }); + + it('getByDisplayValue should accept text match arguments', () => { + getByDisplayValue('1'); + getByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue(/1/); + getByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByDisplayValue((content: string, element) => true); + getByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByDisplayValue should accept text match arguments', () => { + const result: Array = getAllByDisplayValue('1'); + }); + + it('queryByDisplayValue should accept text match arguments', () => { + queryByDisplayValue('1'); + queryByDisplayValue('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue(/1/); + queryByDisplayValue(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByDisplayValue((content: string, element) => true); + queryByDisplayValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByDisplayValue should accept text match arguments', () => { + const result: Array = queryAllByDisplayValue('1'); + }); + + it('getByLabelText should accept text match arguments', () => { + getByLabelText('1'); + getByLabelText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText(/1/); + getByLabelText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByLabelText((content: string, element) => true); + getByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByLabelText should accept text match arguments', () => { + const result: Array = getAllByLabelText('1'); + }); + + it('queryByLabelText should accept text match arguments', () => { + queryByLabelText('1'); + queryByLabelText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByLabelText(/1/); + queryByLabelText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + queryByLabelText((content: string, element) => true); + queryByLabelText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByLabelText should accept text match arguments', () => { + const result: Array = queryAllByLabelText('1'); + }); + + it('getByPlaceholderText should accept text match arguments', () => { + getByPlaceholderText('1'); + getByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText(/1/); + getByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + getByPlaceholderText((content: string, element) => true); + getByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByPlaceholderText should accept text match arguments', () => { + const result: Array = getAllByPlaceholderText('1'); + }); + + it('queryByPlaceholderText should accept text match arguments', () => { + queryByPlaceholderText('1'); + queryByPlaceholderText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText(/1/); + queryByPlaceholderText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryByPlaceholderText((content: string, element) => true); + queryByPlaceholderText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByPlaceholderText should accept text match arguments', () => { + const result: Array = queryAllByPlaceholderText('1'); + }); + + it('getByRole should accept text match arguments', () => { + getByRole('1'); + getByRole('1', { trim: true, collapseWhitespace: true, exact: true }); + getByRole(/1/); + getByRole(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByRole((content: string, element) => true); + getByRole((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByRole should accept text match arguments', () => { + const result: Array = getAllByRole('1'); + }); + + it('queryByRole should accept text match arguments', () => { + queryByRole('1'); + queryByRole('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByRole(/1/); + queryByRole(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByRole((content: string, element) => true); + queryByRole((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByRole should accept text match arguments', () => { + const result: Array = queryAllByRole('1'); + }); + + it('getBySelectText should accept text match arguments', () => { + getBySelectText('1'); + getBySelectText('1', { trim: true, collapseWhitespace: true, exact: true }); + getBySelectText(/1/); + getBySelectText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getBySelectText((content: string, element) => true); + getBySelectText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllBySelectText should accept text match arguments', () => { + const result: Array = getAllBySelectText('1'); + }); + + it('queryBySelectText should accept text match arguments', () => { + queryBySelectText('1'); + queryBySelectText('1', { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryBySelectText(/1/); + queryBySelectText(/1/, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + queryBySelectText((content: string, element) => true); + queryBySelectText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllBySelectText should accept text match arguments', () => { + const result: Array = queryAllBySelectText('1'); + }); + + it('getByTestId should accept text match arguments', () => { + getByTestId('1'); + getByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTestId(/1/); + getByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTestId((content: string, element) => true); + getByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTestId should accept text match arguments', () => { + const result: Array = getAllByTestId('1'); + }); + + it('queryByTestId should accept text match arguments', () => { + queryByTestId('1'); + queryByTestId('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId(/1/); + queryByTestId(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTestId((content: string, element) => true); + queryByTestId((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTestId should accept text match arguments', () => { + const result: Array = queryAllByTestId('1'); + }); + + it('getByText should accept text match arguments', () => { + getByText('1'); + getByText('1', { trim: true, collapseWhitespace: true, exact: true }); + getByText(/1/); + getByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByText((content: string, element) => true); + getByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('getAllByText should accept text match arguments', () => { + const result: Array = getAllByText('1'); + }); + + it('queryByText should accept text match arguments', () => { + queryByText('1'); + queryByText('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByText(/1/); + queryByText(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByText((content: string, element) => true); + queryByText((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + selector: 'A', + }); + }); + + it('queryAllByText should accept text match arguments', () => { + const result: Array = queryAllByText('1'); + }); + + it('getByTitle should accept text match arguments', () => { + getByTitle('1'); + getByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + getByTitle(/1/); + getByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByTitle((content: string, element) => true); + getByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByTitle should accept text match arguments', () => { + const result: Array = getAllByTitle('1'); + }); + + it('queryByTitle should accept text match arguments', () => { + queryByTitle('1'); + queryByTitle('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle(/1/); + queryByTitle(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByTitle((content: string, element) => true); + queryByTitle((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByTitle should accept text match arguments', () => { + const result: Array = queryAllByTitle('1'); + }); + + it('getByValue should accept text match arguments', () => { + getByValue('1'); + getByValue('1', { trim: true, collapseWhitespace: true, exact: true }); + getByValue(/1/); + getByValue(/1/, { trim: true, collapseWhitespace: true, exact: true }); + getByValue((content: string, element) => true); + getByValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('getAllByValue should accept text match arguments', () => { + const result: Array = getAllByValue('1'); + }); + + it('queryByValue should accept text match arguments', () => { + queryByValue('1'); + queryByValue('1', { trim: true, collapseWhitespace: true, exact: true }); + queryByValue(/1/); + queryByValue(/1/, { trim: true, collapseWhitespace: true, exact: true }); + queryByValue((content: string, element) => true); + queryByValue((content: string, element) => true, { + trim: true, + collapseWhitespace: true, + exact: true, + }); + }); + + it('queryAllByValue should accept text match arguments', () => { + const result: Array = queryAllByValue('1'); + }); +}); + +describe('render() parameters', () => { + class Component extends React.Component<{ ... }> {} + + it('allows supplying parameters to render()', () => { + class CustomWrapper extends React.Component<{ ... }> {} + const element = document.createElement('div'); + render(, { + baseElement: element, + container: element, + hydrate: true, + wrapper: CustomWrapper, + }); + }); + + it('allows overriding render() with custom queries', () => { + type CustomReturnType = 123456; + declare var customValue: CustomReturnType; + const customQueries = { + getByOverride: (param1: string) => customValue, + }; + const result = render<{| + getByOverride: (string) => CustomReturnType, + |}>(, { queries: customQueries }); + const a: CustomReturnType = result.getByOverride('something'); + // $FlowExpectedError[incompatible-call] bad type for getByOverride parameter + result.getByOverride(1234); + // $FlowExpectedError[incompatible-call] missing getByOverride parameter + result.getByOverride(); + // $FlowExpectedError[prop-missing] default queries are not available when using custom queries + result.getByTestId('indifferent'); + }); +}); diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/angular_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/angular_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/angular_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/angular_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_component_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_component_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_component_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_component_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_interval_log_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_interval_log_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_interval_log_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_interval_log_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_scope_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_scope_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_scope_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_scope_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_stateProvider_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_stateProvider_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_stateProvider_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_stateProvider_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_timeout_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_timeout_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_timeout_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_timeout_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_angular_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_angular_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_utility_functions_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_utility_functions_v1.5.x.js similarity index 100% rename from definitions/npm/angular_v1.5.x/flow_v0.104.x-/test_utility_functions_v1.5.x.js rename to definitions/npm/angular_v1.5.x/flow_v0.104.x-v.200.x/test_utility_functions_v1.5.x.js diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/angular_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/angular_v1.5.x.js new file mode 100644 index 0000000000..7ee701b2cf --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/angular_v1.5.x.js @@ -0,0 +1,302 @@ +/** + * Credit to @faceleg for some of the typedefs seen here: + * https://github.com/solnet-aquarium/flow-interfaces-angular/blob/master/interfaces/angular.js + */ + +declare module angular { + // NOTE: if you don't use named scope bindings, remove string type in the end + // for stricter types + declare type ScopeBindings = "<" | "=" | "&" | ") => void; + + // I'm not sure how represent this properly: Angular DI declarations are a + // list of strings with a single function at the end. The function can vary, + // so it is a type param. + // + // NOTE: if you use compile step to mangle array, replace below with + // declare type $npm$angular$DependencyInjection = T + declare type $npm$angular$DependencyInjection = Array; + + // Extending Array allows us to do the `jq[0]` expression and friends + // to get the actual underlying Element. + // TODO: This is supposed to be interchangeable with JQuery. Can we possibly + // check to see if JQuery's types are already defined? + declare interface JqliteElement extends Array { + remove: () => JqliteElement; + contents: () => JqliteElement; + injector: Function; + } + + declare type AngularLinkFunction = ( + scope: $Scope, + element: JqliteElement, + attrs: mixed, + controller: mixed + ) => void; + + declare type AngularCompileLink = { + post?: AngularLinkFunction, + pre?: AngularLinkFunction, + ... + }; + + // TODO: Attrs and controller should be properly typed. + declare function CompileFunction( + element: JqliteElement, + attrs: mixed, + controller: ControllerFunction + ): AngularLinkFunction; + + // TODO: Expand to cover the whole matrix of AECM, in any order. Probably + // should write something to handle it. + declare type DirectiveRestrict = "A" | "E" | "AE" | "EA"; + declare type Directive = {| + restrict?: DirectiveRestrict, + template?: string, + templateUrl?: string, + scope?: Scope, + controller?: ControllerFunction, + link?: AngularLinkFunction, + controllerAs?: string, + bindToController?: boolean, + // TODO: flesh out this definition + compile?: (...a: any) => AngularCompileLink + |}; + + declare type DirectiveDeclaration = ( + name: string, + di: $npm$angular$DependencyInjection<(...a: Array) => Directive> + ) => AngularModule; + + declare type Component = {| + bindings?: Scope, + template?: string, + templateUrl?: string, + controllerAs?: string, + controller?: $npm$angular$DependencyInjection< + Class | ControllerFunction + >, + transclude?: boolean + |}; + + declare type ComponentDeclaration = ( + name: string, + component: Component + ) => AngularModule; + + declare type ControllerDeclaration = ( + name: string, + di: $npm$angular$DependencyInjection + ) => AngularModule; + + declare type ConfigDeclaration = ( + di: $npm$angular$DependencyInjection<(...a: Array) => void> + ) => AngularModule; + + declare type FactoryDeclaration = ( + name: string, + di: $npm$angular$DependencyInjection<(...a: Array) => {...}> + ) => AngularModule; + + declare type FilterDeclaration = ( + name: string, + di: $npm$angular$DependencyInjection<(...a: Array) => (: any => any)> + ) => AngularModule; + + declare type ServiceDeclaration = ( + name: string, + di: $npm$angular$DependencyInjection<(...a: Array) => (: any => any) | {...}> + ) => AngularModule; + + declare type RunDeclaration = ( + fn: $npm$angular$DependencyInjection<(...a: Array) => void> + ) => AngularModule; + + declare type ValueDeclaration = (name: string, value: mixed) => AngularModule; + + declare type ConstantDeclaration = ( + name: string, + value: mixed + ) => AngularModule; + + declare type AngularModule = {| + controller: ControllerDeclaration, + component: ComponentDeclaration, + directive: DirectiveDeclaration, + run: RunDeclaration, + config: ConfigDeclaration, + factory: FactoryDeclaration, + filter: FilterDeclaration, + service: ServiceDeclaration, + value: ValueDeclaration, + constant: ConstantDeclaration, + name: string + |}; + + declare type Dependency = AngularModule | string; + + declare function module( + name: string, + deps?: ?Array + ): AngularModule; + + declare function element(html: string | Element | Document): JqliteElement; + declare function copy(object: T): T; + declare function extend(a: A, b: B): A & B; + declare function extend(a: A, b: B, c: C): A & B & C; + declare function extend(a: A, b: B, c: C, d: D): A & B & C & D; + declare function extend( + a: A, + b: B, + c: C, + d: D, + e: E + ): A & B & C & D & E; + + declare function forEach( + obj: {...}, + iterator: (value: T, key: string) => void + ): void; + declare function forEach( + obj: Array, + iterator: (value: T, key: number) => void + ): void; + declare function fromJson(json: string): {...} | Array | string | number; + declare function toJson( + obj: {...} | Array | string | Date | number | boolean, + pretty?: boolean | number + ): string; + declare function isDefined(val: any): boolean; + declare function isArray(value: Array): true; + declare function isArray(value: any): false; + declare function noop(): void; + declare type AngularQ = { when: (value: T) => AngularPromise, ... }; + + declare type AngularPromise = { + then: (a: (resolve: U) => T) => AngularPromise, + catch: (a: (e: Error) => U) => AngularPromise, + finally: (a: (result: U | typeof Error) => T) => AngularPromise, + ... + }; + + //**************************************************************************** + // Angular testing tools + //**************************************************************************** + + declare type AngularMock = { + inject: (...a: Array) => (: any => any), + module: (...a: Array) => any) | {...}>) => () => void, + ... + }; + declare var mock: AngularMock; + + declare type StateProviderParams = { + url?: string, + abstract?: boolean, + params?: {...}, + views?: {...}, + data?: {...}, + templateUrl?: string, + template?: string, + controller?: string | ControllerFunction, + resolve?: {...}, + ... + }; + + declare type $StateProvider = { state: (name: string, conf: StateProviderParams) => $StateProvider, ... }; + + //---------------------------------------------------------------------------- + // Service specific stuff + //---------------------------------------------------------------------------- + + declare type AngularHttpService = { post: AngularHttpPost, ... }; + + declare type AngularHttpPost = ( + url: string, + data: mixed + ) => AngularPromise; + + declare type AngularResourceResult = { $promise: AngularPromise, ... }; + + declare type AngularResource = { get: (options?: {...}, callback?: Function) => AngularResourceResult, ... }; + + declare function AngularResourceFactory( + url: string, + defaultParams?: {...}, + actions?: {...}, + options?: {...} + ): AngularResource; + + declare function AngularCompileService(a: JqliteElement): JqliteElement; + + declare type WatchExpression = string | ((scope: $Scope) => any); + declare type EvalExpression = string | (() => void); + declare type ApplyExpression = string | (() => void); + declare type Listener = ( + newValue: any, + oldValue: any, + $scope: $Scope + ) => any; + + declare type _Watch1 = ( + expression: WatchExpression, + listener: Listener, + objectEquality?: boolean + ) => () => void; + declare type _Watch2 = ( + listener: Listener, + objectEquality?: boolean + ) => () => void; + + declare type $Scope = {| + $new(isolate: boolean, parent: $Scope): $Scope, + $watch: _Watch1 & _Watch2, + $watchGroup( + expressions: Array>, + listener: Listener + ): () => void, + $watchCollection( + expression: WatchExpression, + listener: Listener + ): () => void, + $digest(): void, + $destroy(): void, + $eval(expression: EvalExpression, locals?: {...}): void, + $evalAsync(expression: EvalExpression, locals?: {...}): void, + $apply(expression?: ApplyExpression): void, + $applyAsync(expression?: ApplyExpression): void, + $on(name: string, listener: (event: any, ...Array) => void): () => void, + $emit(name: string, ...Array): void, + $broadcast(name: string, ...Array): void, + + $$postDigest(cb: () => void): void, + + $id: string, + $parent: $Scope, + $root: $Scope + |} & T; + + declare type $Timeout = ( + fn?: any => any, + delay?: number, + invokeApply?: boolean, + additionalParams?: any + ) => AngularPromise; + + declare type $Log = {| + log(a: any): void, + info(a: any): void, + warn(a: any): void, + error(a: any): void, + debug(a: any): void, + |}; + + declare type $Interval = ( + fn: any => any, + delay: number, + count?: number, + invokeApply?: boolean, + ...pass: any + ) => AngularPromise; +} diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_component_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_component_v1.5.x.js new file mode 100644 index 0000000000..bca576a86f --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_component_v1.5.x.js @@ -0,0 +1,87 @@ +// @flow +import angular from "angular"; + +//all bells and whistles +angular.module("foo", []).component("foo", { + bindings: { + prop: "<" + }, + template: "
", + controllerAs: "ctrl", + controller: ["foo", "bar", () => {}], + transclude: false +}); + +//bindings can have strings +angular.module("foo", []).component("foo", { + bindings: { + prop: "<" + } +}); + +//$FlowExpectedError bindings cant have any other types +angular.module("foo", []).component("foo", { + bindings: { + prop: 123 + } +}); + +// template is string +angular.module("foo", []).component("foo", { + template: "
" +}); + +//$FlowExpectedError template does snot accept other types +angular.module("foo", []).component("foo", { + template: 123 +}); + +//controllerAs is string +angular.module("foo", []).component("foo", { + controllerAs: "ctrl" +}); + +//$FlowExpectedError controllerAs does snot accept other types +angular.module("foo", []).component("foo", { + controllerAs: 123 +}); + +// transclude is boolean +angular.module("foo", []).component("foo", { + transclude: true +}); + +//$FlowExpectedError transclude does snot accept other types +angular.module("foo", []).component("foo", { + transclude: 123 +}); + +// templateUrl is string +angular.module("foo", []).component("foo", { + templateUrl: "path/to/template.html" +}); + +//$FlowExpectedError template doe snot accept other types +angular.module("foo", []).component("foo", { + templateUrl: 123 +}); + +//controller accpets class +angular.module("foo", []).component("foo", { + controller: ["foo", "bar", class Ctrl {}] +}); + +//controller accpets controller function +angular.module("foo", []).component("foo", { + controller: ["foo", "bar", () => {}] +}); + +//$FlowExpectedError does not accept object as controller +angular.module("foo", []).component("foo", { + controller: ["foo", "bar", {}] +}); + +//$FlowExpectedError does not accept arbitrary properties +angular.module("foo", []).component("foo", { + random: "prop" +}); diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_interval_log_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_interval_log_v1.5.x.js new file mode 100644 index 0000000000..8c518e6ef7 --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_interval_log_v1.5.x.js @@ -0,0 +1,215 @@ +// @flow +import type { $Interval, $Log, AngularPromise } from 'angular'; +import { describe, it } from 'flow-typed-test'; + +describe('angular $Interval', () => { + it('can be called', () => { + it('with two args: fn, delay', () => { + function testInterval($interval: $Interval) { + $interval(() => {}, 0); + } + }); + + it('with third argument as number', () => { + function testInterval($interval: $Interval) { + $interval(() => {}, 0, 1); + } + }); + + it('with fourth argument as boolean', () => { + function testInterval($interval: $Interval) { + $interval(() => {}, 0, 1, true); + } + }); + + it('with additional arguments to be passed to the function', () => { + function testInterval($interval: $Interval) { + $interval((a, b, c) => {}, 0, 1, false, 'a', 'b', 'c'); + } + }); + }); + + it('cannot be called', () => { + it('with something other than a number in the third argument', () => { + function testInterval($interval: $Interval) { + //$FlowExpectedError + $interval(() => {}, 0, true); + } + }); + + it('with something other than a boolean in the fourth argument', () => { + function testInterval($interval: $Interval) { + //$FlowExpectedError + $interval(() => {}, 0, 1, 2); + } + }); + + it('with less than two arguments', () => { + function testInterval($interval: $Interval) { + //$FlowExpectedError + $interval(() => {}); + //$FlowExpectedError + $interval(); + } + }); + + it('with something other than [function, number] in first two arguments', () => { + function testInterval($interval: $Interval) { + //$FlowExpectedError + $interval(123, 1); + //$FlowExpectedError + $interval(123, () => {}); + //$FlowExpectedError + $interval(() => {}, 'string'); + } + }); + }); + + it('returns back the angular promise', () => { + function testInterval($interval: $Interval) { + ($interval(() => {}, 0): AngularPromise); + } + }); +}); + +describe('angular $Log', () => { + describe('log', () => { + it('can be passed an argument of any type or none at all', () => { + function testLog($log: $Log) { + $log.log('anything'); + $log.log(1); + $log.log(() => {}); + $log.log(null); + $log.log({ a: 1 }); + $log.log(['a', 1, 3, { a: 10 }]); + $log.log(Symbol('test')); + $log.log(); + } + }); + + it('cannot pass more than one argument', () => { + function testLog($log: $Log) { + //$FlowExpectedError + $log.log(1, 'x'); + } + }); + + it('returns back nothing', () => { + function testLog($log: $Log) { + ($log.log(1): void); + } + }); + }); + + describe('info', () => { + it('can be passed an argument of any type or none at all', () => { + function testLog($log: $Log) { + $log.info('anything'); + $log.info(1); + $log.info(() => {}); + $log.info(null); + $log.info({ a: 1 }); + $log.info(['a', 1, 3, { a: 10 }]); + $log.info(Symbol('test')); + $log.info(); + } + }); + + it('cannot pass more than one argument', () => { + function testLog($log: $Log) { + //$FlowExpectedError + $log.info(1, 'x'); + } + }); + + it('returns back nothing', () => { + function testLog($log: $Log) { + ($log.info(1): void); + } + }); + }); + + describe('warn', () => { + it('can be passed an argument of any type or none at all', () => { + function testLog($log: $Log) { + $log.warn('anything'); + $log.warn(1); + $log.warn(() => {}); + $log.warn(null); + $log.warn({ a: 1 }); + $log.warn(['a', 1, 3, { a: 10 }]); + $log.warn(Symbol('test')); + $log.warn(); + } + }); + + it('cannot pass more than one argument', () => { + function testLog($log: $Log) { + //$FlowExpectedError + $log.warn(1, 'x'); + } + }); + + it('returns back nothing', () => { + function testLog($log: $Log) { + ($log.warn(1): void); + } + }); + }); + + describe('error', () => { + it('can be passed an argument of any type or none at all', () => { + function testLog($log: $Log) { + $log.error('anything'); + $log.error(1); + $log.error(() => {}); + $log.error(null); + $log.error({ a: 1 }); + $log.error(['a', 1, 3, { a: 10 }]); + $log.error(Symbol('test')); + $log.error(); + } + }); + + it('cannot pass more than one argument', () => { + function testLog($log: $Log) { + //$FlowExpectedError + $log.error(1, 'x'); + } + }); + + it('returns back nothing', () => { + function testLog($log: $Log) { + ($log.error(1): void); + } + }); + }); + + describe('debug', () => { + it('can be passed an argument of any type or none at all', () => { + function testLog($log: $Log) { + $log.debug('anything'); + $log.debug(1); + $log.debug(() => {}); + $log.debug(null); + $log.debug({ a: 1 }); + $log.debug(['a', 1, 3, { a: 10 }]); + $log.debug(Symbol('test')); + $log.debug(); + } + }); + + it('cannot pass more than one argument', () => { + function testLog($log: $Log) { + //$FlowExpectedError + $log.debug(1, 'x'); + } + }); + + it('returns back nothing', () => { + function testLog($log: $Log) { + ($log.debug(1): void); + } + }); + }); +}); diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_scope_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_scope_v1.5.x.js new file mode 100644 index 0000000000..9676dd40f0 --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_scope_v1.5.x.js @@ -0,0 +1,237 @@ +// @flow +import type { $Scope } from "angular"; + +function testScope$new($scope: $Scope<{ myVar: boolean, ... }>) { + //$FlowExpectedError first argument needs to be boolean + $scope.$new(123, $scope); + //$FlowExpectedError second argument needs to be scope + $scope.$new(true, {}); + + const newScope = $scope.$new(true, $scope); + (newScope.myVar: boolean); +} + +function testScope$watch($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$watch("my.prop", () => {}); + //$FlowExpectedError does not accept other than watch funcion or string as first argument + $scope.$watch(123, () => {}); + // is ok with callback as first argument + $scope.$watch(() => {}, () => {}); + // watcher function gets current scope + $scope.$watch( + scope => { + (scope.myVar: boolean); + }, + () => {} + ); + // watch callback gets current scope as third param + $scope.$watch("prop", (var1, var2, scope) => { + (scope.myVar: boolean); + }); + + // watch accepts object equality boolean as last param + $scope.$watch("prop", () => {}, true); + + //$FlowExpectedError watch does not accept other types as third param + $scope.$watch("prop", () => {}, ""); + + //watch accepts listener callback also as first argument + $scope.$watch((var1, var2, scope) => { + (scope.myVar: boolean); + }); + + // takes object equality as second argument + $scope.$watch(() => {}, true); + //$FlowExpectedError watch does not accept other types as second param + $scope.$watch(() => {}, ""); +} + +function testScope$watchGroup($scope: $Scope<{ myVar: boolean, ... }>) { + // takes array strings as first argument + $scope.$watchGroup(["first", "second"], () => {}); + // takes array of watch functions as first argument + $scope.$watchGroup( + [ + scope => { + (scope.myVar: boolean); + } + ], + () => {} + ); + //$FlowExpectedError does not take anything else as array arguments + $scope.$watchGroup([123], () => {}); + + //listener gets current scope + $scope.$watchGroup(["prop"], (var1, var2, scope) => { + (scope.myVar: boolean); + }); + //$FlowExpectedError listener fails when trying to access scope as wrong type + $scope.$watchGroup(["prop"], (var1, var2, scope: boolean) => scope); + + //returns function + const ret = $scope.$watchGroup(["first"], () => {}); + ret(); + + //$FlowExpectedError returned function does not take arguments + const ret2 = $scope.$watchGroup(["first"], () => {}); + ret2(123); +} + +function testScope$watchCollection($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$watchCollection("prop", () => {}); + // takes watch function as first argument + $scope.$watchCollection( + scope => { + (scope.myVar: boolean); + }, + () => {} + ); + //$FlowExpectedError does not take any other type + $scope.$watchCollection(123, () => {}); + + //listener gets current scope + $scope.$watchCollection("prop", (var1, var2, scope) => { + (scope.myVar: boolean); + }); + //$FlowExpectedError listener fails when trying to access scope as wrong type + $scope.$watchCollection("prop", (var1, var2, scope: boolean) => scope); + + //returns function + const ret = $scope.$watchCollection("first", () => {}); + ret(); + + //$FlowExpectedError returned function does not take arguments + const ret2 = $scope.$watchCollection("first", () => {}); + ret2(123); +} + +function testScope$Digest($scope: $Scope<{ myVar: boolean, ... }>) { + // is callable + $scope.$digest(); + //$FlowExpectedError does not take arguments + $scope.$digest(123); +} + +function testScope$Destroy($scope: $Scope<{ myVar: boolean, ... }>) { + // is callable + $scope.$digest(); + //$FlowExpectedError does not take arguments + $scope.$digest(123); +} + +function testScope$Eval($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$eval("str"); + // takes function as first argument + $scope.$eval(() => {}); + //$FlowExpectedError function does not get arguments + $scope.$eval((arg: number) => {}); + // takes optional object as second argument + $scope.$eval(() => {}, {}); + //$FlowExpectedError does not take other types as second argument + $scope.$eval(() => {}, 123); +} + +function testScope$EvalAsync($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$evalAsync("str"); + // takes function as first argument + $scope.$evalAsync(() => {}); + //$FlowExpectedError function does not get arguments + $scope.$evalAsync((arg: number) => {}); + // takes optional object as second argument + $scope.$eval(() => {}, {}); + //$FlowExpectedError does not take other types as second argument + $scope.$evalAsync(() => {}, 123); +} + +function testScope$apply($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$apply("str"); + // takes function as first argument + $scope.$apply(() => {}); + //$FlowExpectedError function does not get arguments + $scope.$apply((arg: number) => {}); +} + +function testScope$applyAsync($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$applyAsync("str"); + // takes function as first argument + $scope.$applyAsync(() => {}); + //$FlowExpectedError function does not get arguments + $scope.$applyAsync((arg: number) => {}); +} + +function testScope$on($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$on("str", () => {}); + //$FlowExpectedError does not take other types as first argument + $scope.$on(123, () => {}); + // callback takes arbitrary amount of args + $scope.$on("str", (a, b, c, d, e) => {}); + //$FlowExpectedError does not take other types as second argument + $scope.$on("str", "str"); + //returns deregistration callback + const cb = $scope.$on("str", () => {}); + cb(); + //$FlowExpectedError callback deos not take arguments + const cb2 = $scope.$on("str", () => {}); + cb2(123); +} + +function testScope$emit($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$emit("str", () => {}); + //$FlowExpectedError does not take other types as first argument + $scope.$emit(123, () => {}); + // takes arbitrary second argument + $scope.$emit("str", 123); + $scope.$emit("str", "abc"); + // takes arbitrary amount of arguments + $scope.$emit("str", 123, 321, 123); + $scope.$emit("str", "abc", "abc", "abc", "abc"); +} + +function testScope$broadcast($scope: $Scope<{ myVar: boolean, ... }>) { + // takes string as first argument + $scope.$broadcast("str", () => {}); + //$FlowExpectedError does not take other types as first argument + $scope.$broadcast(123, () => {}); + // takes arbitrary second argument + $scope.$broadcast("str", 123); + $scope.$broadcast("str", "abc"); + // takes arbitrary amount of arguments + $scope.$broadcast("str", 123, 321, 123); + $scope.$broadcast("str", "abc", "abc", "abc", "abc"); +} + +function testScope$$postDigest($scope: $Scope<{ myVar: boolean, ... }>) { + // takes callback + $scope.$$postDigest(() => {}); + //$FlowExpectedError does not take other types + $scope.$$postDigest(123); + //$FlowExpectedError does not take more arguments + $scope.$$postDigest(() => {}, 123); +} + +function testScope$id($scope: $Scope<{ myVar: boolean, ... }>) { + // is string + ($scope.$id: string); +} + +function testScope$parent($scope: $Scope<{ myVar: boolean, ... }>) { + // is scope + ($scope.$parent: $Scope); +} + +function testScope$root($scope: $Scope<{ myVar: boolean, ... }>) { + // is scope + ($scope.$root: $Scope); +} + +function testScopeExtraProps($scope: $Scope<{ myVar: boolean, ... }>) { + $scope.myVar; +} diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_stateProvider_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_stateProvider_v1.5.x.js new file mode 100644 index 0000000000..a066257064 --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_stateProvider_v1.5.x.js @@ -0,0 +1,8 @@ +// @flow +import type { $StateProvider, AngularPromise } from "angular"; + +function testStateProvider($stateProvider: $StateProvider) { + ($stateProvider.state("name", { + url: "http://www.example.com" + }): $StateProvider); +} diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_timeout_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_timeout_v1.5.x.js new file mode 100644 index 0000000000..7474846835 --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_timeout_v1.5.x.js @@ -0,0 +1,68 @@ +// @flow +import type { $Timeout, AngularPromise } from 'angular'; +import { describe, it } from 'flow-typed-test'; + +describe('angular $Timeout', () => { + it('can be called', () => { + it('without arguments', () => { + function testTimeout($timeout: $Timeout) { + $timeout(); + } + }); + + it('with first argument as a function', () => { + function testTimeout($timeout: $Timeout) { + $timeout(() => {}); + } + }); + + it('with second argument as number', () => { + function testTimeout($timeout: $Timeout) { + $timeout(() => {}, 123); + } + }); + + it('with third argument as boolean', () => { + function testTimeout($timeout: $Timeout) { + $timeout(() => {}, 123, true); + } + }); + + it('with fourth argument as anything', () => { + function testTimeout($timeout: $Timeout) { + $timeout(() => {}, 123, true, 123); + $timeout(() => {}, 123, true, 'text'); + $timeout(() => {}, 123, true, {}); + } + }); + }); + + it('cannot be called', () => { + it('with something other than function as first argument', () => { + function testTimeout($timeout: $Timeout) { + //$FlowExpectedError + $timeout(123); + } + }); + + it('with something other than a number in the second argument', () => { + function testTimeout($timeout: $Timeout) { + //$FlowExpectedError + $timeout(() => {}, '123'); + } + }); + + it('with something other than a boolean in the third argument', () => { + function testTimeout($timeout: $Timeout) { + //$FlowExpectedError + $timeout(() => {}, 123, 'text'); + } + }); + }); + + it('returns back the angular promise', () => { + function testTimeout($timeout: $Timeout) { + ($timeout(): AngularPromise); + } + }); +}); diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_v1.5.x.js new file mode 100644 index 0000000000..a4a37be9a4 --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_angular_v1.5.x.js @@ -0,0 +1,368 @@ +// @flow +import { describe, it } from "flow-typed-test"; +import { + type AngularPromise, + type AngularQ, + type JqliteElement, + type AngularHttpService, + typeof AngularResourceFactory, + type AngularResourceResult, + type AngularResource, + typeof AngularCompileService +} from "angular"; + +("use strict"); +const angular = require("angular"); + +describe("Angular modules", () => { + it("can be declared", () => { + const module1 = angular.module("foo", []); + const module2 = angular.module("foo", ["bazz", "qux"]); + }); + + it("can be retrieved after being declared", () => { + const module1 = angular.module("foo"); + }); + + it("requires a name", () => { + // $FlowExpectedError undefined. This type is incompatible with string + const module1 = angular.module(); + }); +}); + +describe("directives", () => { + it("can be declared", () => { + angular.module("foo", []).directive("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return { + restrict: "E", + templateUrl: "foo.html" + }; + } + ]); + }); + + it("requires a directive to be returned", () => { + angular.module("foo", []).directive("foo", [ + "bar", + "bazz", + (bar, bazz) => { + // $FlowExpectedError string. This type is incompatible with Directive + return "this is clearly not a directive"; + } + ]); + }); + + it("requires proper restrict when defined", () => { + // $FlowExpectedError + angular.module("foo", []).directive("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return { + restrict: "fails to this", + templateUrl: "foo.html" + }; + } + ]); + }); + + it("does not accept random properties", () => { + angular.module("foo", []).directive("foo", [ + "bar", + "bazz", + (bar, bazz) => { + // $FlowExpectedError + return { + random: "prop which is not allowed", + templateUrl: "foo.html" + }; + } + ]); + }); + + it("all bells and whistles for directive", () => { + angular.module("foo", []).directive("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return { + bindToController: true, + controllerAs: "ctrl", + templateUrl: "foo.html", + scope: { + prop: "<" + }, + controller: () => {} + }; + } + ]); + }); +}); + +describe("service", () => { + it("can be declared", () => { + angular.module("foo", []).service("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return { foo: "bar" }; + } + ]); + }); + + it("can return object", () => { + angular.module("foo", []).service("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return { foo: "bar" }; + } + ]); + }); + + it("can return function", () => { + angular.module("foo", []).service("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return () => {}; + } + ]); + }); + + it("cant return other types", () => { + angular.module("foo", []).service("foo", [ + "bar", + "bazz", + (bar, bazz) => { + //$FlowExpectedError + return 123; + } + ]); + }); +}); + +describe("factory", () => { + it("can be declared", () => { + angular.module("foo", []).factory("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return { a: bar, b: bazz }; + } + ]); + }); + + it("requires a return value of some kind", () => { + angular + .module("foo", []) + // $FlowExpectedError undefined. This type is incompatible with + .factory("foo", ["bar", "bazz", (bar, bazz) => undefined]); + }); +}); + +describe("controller", () => { + it("can be declared", () => { + angular + .module("foo", []) + .controller("foo", ["bar", "bazz", (bar, bazz) => {}]); + }); +}); + +describe("config", () => { + it("can be declared", () => { + angular.module("foo", []).config(["bar", "bazz", (bar, bazz) => {}]); + }); +}); + +describe("filter", () => { + it("can be declared", () => { + angular.module("foo", []).filter("foo", [ + "bar", + "bazz", + (bar, bazz) => { + return () => {}; + } + ]); + }); + + it("requires a return value of some kind", () => { + // $FlowExpectedError cant return object + angular.module("foo", []).filter("foo", ["bar", "bazz", () => ({})]); + }); +}); + +describe("filter", () => { + it("can be declared", () => { + angular.module("foo", []).run(["bar", "bazz", (bar, bazz) => {}]); + }); +}); + +describe("value", () => { + it("can be declared to any value", () => { + angular.module("foo", []).value("foo", 123); + angular.module("foo", []).value("foo", "str"); + angular.module("foo", []).value("foo", {}); + }); +}); + +describe("constant", () => { + it("can be declared to any value", () => { + angular.module("foo", []).constant("foo", 123); + angular.module("foo", []).constant("foo", "str"); + angular.module("foo", []).constant("foo", {}); + }); +}); + +describe("element", () => { + it("creates a jqlite element from a string", () => { + const element: JqliteElement = angular.element("foo"); + }); + + it("creates a jqlite element from an element", () => { + const element: JqliteElement = angular.element(window.document.body); + }); + + it("does not accept other types as a parameter", () => { + // $FlowExpectedError number. This type is incompatible with string + angular.element(5); + }); +}); + +describe("copy", () => { + it("copies preserving the type", () => { + const foo: number = angular.copy(5); + }); + + it("does not change the type", () => { + // $FlowExpectedError string. This type is incompatible with number + const foo: number = angular.copy("5"); + }); +}); + +describe("jqlite", () => { + it("can remove itself", () => { + angular.element("foo").remove(); + }); + + it("yields nothing on removal", () => { + // $FlowExpectedError string. This type is incompatible with void + const removal: string = angular.element("foo").remove(); + }); + + it("can retrieve contents as a JqliteElement", () => { + const contents: JqliteElement = angular.element("foo").contents(); + }); + + it("does not yield a string", () => { + // $FlowExpectedError string. This type is incompatible with JqliteElement + const contents: string = angular.element("foo").contents("bar"); + }); +}); + +describe("$compile", () => { + it("is a function that uses a jqlite element", () => { + angular.mock.inject(($compile: AngularCompileService) => { + $compile(angular.element("foo")); + }); + }); + + it("returns a compiled jqlite element", () => { + angular.mock.inject(($compile: AngularCompileService) => { + const element: JqliteElement = $compile(angular.element("foo")); + }); + }); +}); + +describe("$resource", () => { + it("returns a $resource instance when invoked", () => { + angular.mock.inject(($resource: AngularResourceFactory) => { + const resource: AngularResource = $resource("/foo"); + }); + }); + + describe("instance", () => { + it("has a get function that returns a special $resource result", () => { + angular.mock.inject(($resource: AngularResourceFactory) => { + const resource: AngularResource = $resource("/foo"); + const promise: AngularPromise = resource.get().$promise; + }); + }); + }); +}); + +describe("$q", () => { + it("can create a promise that resolves a pre-defined value", () => { + angular.mock.inject(($q: AngularQ) => { + const promise: AngularPromise = $q.when("foo"); + }); + }); + + it("creates a promise with the type provided the value resolved", () => { + angular.mock.inject(($q: AngularQ) => { + // $FlowExpectedError number. This type is incompatible with string + const promise: AngularPromise = $q.when("foo"); + }); + }); + + it("can chain promises between mapped types", () => { + angular.mock.inject(($q: AngularQ) => { + const finalPromise: AngularPromise = $q + .when("foo") + .then(s => parseInt(s)) + .then(n => n.toString()); + }); + }); + + it("catches with errors", () => { + angular.mock.inject(($q: AngularQ) => { + $q.when("foo").catch(e => console.log(e.message)); + }); + }); + + it("chains rejected promises into resolved promises", () => { + angular.mock.inject(($q: AngularQ) => { + const promise: AngularPromise = $q.when("foo").catch(e => "bar"); + }); + }); + + it("has both an error and a resolved value potential in finally", () => { + angular.mock.inject(($q: AngularQ) => { + $q.when("foo").finally(v => { + if (typeof v == "string") { + const s: string = v; + } else if (v instanceof Error) { + const e: Error = v; + } + }); + }); + }); +}); + +describe("mock", () => { + describe("module", () => { + it("takes strings, functions and objects", () => { + angular.mock.module("string", () => {}, {}); + }); + + it("does not accept numbers", () => { + //$FlowExpectedError + angular.mock.module(123); + }); + + it("returns a function", () => { + angular.mock.module("string", {})(); + }); + }); +}); + +describe("$http", () => { + it("can POST", () => { + angular.mock.inject(($http: AngularHttpService) => { + const promise: AngularPromise = $http.post("/foo", { bar: "bazz" }); + }); + }); +}); diff --git a/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_utility_functions_v1.5.x.js b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_utility_functions_v1.5.x.js new file mode 100644 index 0000000000..0374d809f6 --- /dev/null +++ b/definitions/npm/angular_v1.5.x/flow_v0.201.x-/test_utility_functions_v1.5.x.js @@ -0,0 +1,79 @@ +// @flow + +import angular, { type JqliteElement } from "angular"; + +function testElement() { + //accepts string + angular.element("str"); + // accepts document + angular.element(document); + // returns JqLite object + (angular.element(document): JqliteElement); +} + +function testCopy() { + //returns given type + (angular.copy("str"): string); + (angular.copy(123): number); + (angular.copy({ a: 123 }).a: number); +} + +function testExtend() { + // extends object type + (angular.extend({ a: 1 }, { b: 2 }): { + a: number, + b: number, + ... + }); + (angular.extend({ a: 1 }, { b: 2 }, { c: "str", d: 123 }): { + a: number, + b: number, + c: string, + d: number, + ... + }); +} + +function testForEach() { + //accepts object + angular.forEach({}, () => {}); + // accepts array + angular.forEach([], (val: mixed, key: number) => {}); + //$FlowExpectedError does not accept anything else + angular.forEach(123, () => {}); + + // callback gets array stuff in + angular.forEach([1, 2, 3], val => { + (val: number); + }); + + // key is number if array + angular.forEach([1, 2, 3], (val: number, key: number) => { + (key: number); + }); + + // key is string if object + angular.forEach({ a: 123 }, (val, key) => { + (key: string); + }); +} + +function testFromJson() { + // accepts string + angular.fromJson(""); + //$FlowExpectedError does not take in other types + angular.fromJson(123); +} + +function testToJson() { + // returns string + (angular.toJson({}): string); + // takes boolean as second argument + angular.toJson({}, true); + // takes number as second argument + angular.toJson({}, 123); + //$FlowExpectedError does not take anything else as second argument + angular.toJson({}, ""); + //$FlowExpectedError cannot be called without parameters + angular.toJson(); +} diff --git a/definitions/npm/antd_v3.x.x/flow_v0.104.x-/antd_v3.x.x.js b/definitions/npm/antd_v3.x.x/flow_v0.104.x-v.200.x/antd_v3.x.x.js similarity index 100% rename from definitions/npm/antd_v3.x.x/flow_v0.104.x-/antd_v3.x.x.js rename to definitions/npm/antd_v3.x.x/flow_v0.104.x-v.200.x/antd_v3.x.x.js diff --git a/definitions/npm/antd_v3.x.x/flow_v0.104.x-/test_antd_v3.x.x.js b/definitions/npm/antd_v3.x.x/flow_v0.104.x-v.200.x/test_antd_v3.x.x.js similarity index 100% rename from definitions/npm/antd_v3.x.x/flow_v0.104.x-/test_antd_v3.x.x.js rename to definitions/npm/antd_v3.x.x/flow_v0.104.x-v.200.x/test_antd_v3.x.x.js diff --git a/definitions/npm/antd_v3.x.x/flow_v0.201.x-/antd_v3.x.x.js b/definitions/npm/antd_v3.x.x/flow_v0.201.x-/antd_v3.x.x.js new file mode 100644 index 0000000000..a4c0aa73fe --- /dev/null +++ b/definitions/npm/antd_v3.x.x/flow_v0.201.x-/antd_v3.x.x.js @@ -0,0 +1,686 @@ +declare module "antd" { + import type { Node, Component } from "react"; + + declare type ModalReference = { destroy: () => void, ... }; + + declare type messageFn = ( + content: React$Node, + duration?: number, + onClose?: () => mixed + ) => TReturn; + + declare type modalFnArguments = { + title?: string, + content?: React$Node, + onOk?: () => mixed, + ... + }; + + declare function modalFn(args: modalFnArguments): ModalReference; + + declare export class Alert extends React$Component<{...}> {} + + declare export class Avatar extends React$Component<{...}> {} + + declare export type AutoCompleteDataItem = + | string + | { + value: string, + text: string, + ... + } + | React$Element + | React$Element; + + declare export type AutoCompleteProps = { + allowClear?: boolean, + autoFocus?: boolean, + backfill?: boolean, + dataSource?: AutoCompleteDataItem[], + defaultActiveFirstOption?: boolean, + defaultValue?: T, + disabled?: boolean, + filterOption?: boolean | (input: string, option: React$Node) => boolean, + open?: boolean, + optionLabelProp?: string, + placeholder?: string, + value?: T, + onBlur?: () => void, + onChange?: (value: T) => void, + onDropdownVisibleChange?: (open: boolean) => void, + onFocus?: () => void, + onSearch?: (value: string) => void, + onSelect?: (value: T, option: React$Node) => void, + ... + } + + declare export class AutoComplete extends React$Component> { + static Option: typeof SelectOption; + static OptGroup: typeof SelectOptGroup; + } + + declare export class Badge extends React$Component<{...}> {} + + declare export type ButtonProps = { + disabled?: boolean, + ghost?: boolean, + href?: string, + htmlType?: string, + icon?: string, + loading?: boolean | { delay: number, ... }, + shape?: 'circle' | 'round', + size?: 'small' | 'large', + target?: string, + type?: 'primary' | 'ghost' | 'dashed' | 'danger' | 'link' | 'default', + onClick?: (event: SyntheticEvent) => void, + block?: boolean, + ... + } + + declare export class Button extends React$Component { + static Group: typeof ButtonGroup + } + + declare class ButtonGroup extends React$Component<{...}> {} + + declare export class Card extends React$Component<{...}> {} + + declare export class Checkbox extends React$Component<{...}> { + static Group: typeof CheckboxGroup; + } + + declare class CheckboxGroup extends React$Component<{...}> {} + + declare export class Divider extends React$Component<{...}> {} + + declare export class Col extends React$Component<{...}> {} + + declare export type DatePickerProps = {...}; + + declare export class DatePicker extends React$Component { + static RangePicker: typeof DatePicker$RangePicker; + } + + declare export class Dropdown extends React$Component<{...}> {} + + declare export class Grid extends React$Component<{ + className?: string, + style?: $Shape, + ... + }> {} + + declare export class Meta extends React$Component<{ + avatar?: React$Node, + className?: string, + description?: React$Node, + style?: $Shape, + title?: React$Node, + ... + }> {} + + declare export class Card extends React$Component<{ + actions?: Array, + activeTabKey?: string, + headStyle?: $Shape, + bodyStyle?: $Shape, + bordered?: boolean, + cover?: React$Node, + defaultActiveTabKey?: string, + extra?: React$Node, + hoverable?: boolean, + loading?: boolean, + tabList?: Array<{ + key: string, + tab: React$Node, + ... + }>, + title?: React$Node, + type?: "inner", + onTabChange?: (key: string) => void, + ... + }> { + static Grid: typeof Grid; + static Meta: typeof Meta; + } + + declare type CascaderOption = { + value: string, + label: string, + children?: CascaderOption[], + ... + }; + + declare export type CascaderProps = { + allowClear?: boolean, + autoFocus?: boolean, + changeOnSelect?: boolean, + className?: string, + disabled?: boolean, + expandTrigger?: "click" | "hover", + notFoundContent?: string, + onChange?: (values: string[]) => mixed, + options: CascaderOption[], + placeholder?: string, + popupClassName?: string, + popupPlacement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight", + popupVisible?: boolean, + showSearch?: boolean, + size?: "large" | "default" | "small", + value?: string[], + ... + }; + + declare export class Cascader extends React$Component {} + + declare export class Col extends React$Component<{...}> {} + + declare export type CollapsePanelProps = {...}; + + declare class CollapsePanel extends React$Component {} + + declare export type CollapseProps = {...}; + + declare export class Collapse extends React$Component { + static Panel: typeof CollapsePanel; + } + + declare export class Dropdown extends React$Component<{...}> {} + + declare export class Drawer extends React$Component<{...}> {} + + declare type ValidationRule = { + enum?: string | string[], + len?: number, + max?: number, + message?: string, + min?: number, + pattern?: RegExp, + required?: boolean, + transform?: (value: mixed) => mixed, + type?: string, + validator?: ( + rule: mixed, + value: mixed, + callback: mixed, + source?: mixed, + options?: mixed + ) => mixed, + whitespace?: boolean, + ... + }; + declare type ValidateCallback = (erros: mixed, values: mixed) => void; + declare type GetFieldDecoratorOptions = { + exclusive?: boolean, + getValueFromEvent?: (...args: mixed[]) => mixed, + initialValue?: mixed, + normalize?: (value: mixed, prevValue: mixed, allValues: mixed) => mixed, + rules?: ValidationRule[], + trigger?: string, + validateFirst?: boolean, + validateTrigger?: string | string[], + valuePropName?: string, + ... + }; + + declare export type WrappedFormUtils = { + getFieldDecorator( + id: string, + options?: GetFieldDecoratorOptions + ): (node: React$Node) => React$Node, + getFieldError(name: string): mixed[], + getFieldsError(names?: Array): mixed, + getFieldsValue(fieldNames?: Array): mixed, + getFieldValue(fieldName: string): mixed, + isFieldsTouched(names?: Array): boolean, + isFieldTouched(name: string): boolean, + isFieldValidating(name: string): boolean, + resetFields(names?: Array): void, + setFields(obj: Object): void, + setFieldsValue(obj: Object): void, + validateFields(callback: ValidateCallback): mixed, + validateFields( + fieldNames: Array, + callback: ValidateCallback + ): mixed, + validateFields( + fieldNames: Array, + options: Object, + callback: ValidateCallback + ): mixed, + validateFields(options: Object, callback: ValidateCallback): mixed, + validateFieldsAndScroll( + fieldNames?: Array, + options?: Object, + callback?: ValidateCallback + ): void, + validateFieldsAndScroll(callback?: ValidateCallback): void, + validateFieldsAndScroll( + fieldNames?: Array, + callback?: ValidateCallback + ): void, + validateFieldsAndScroll(options?: Object, callback?: ValidateCallback): void, + ... + }; + + declare interface RcBaseFormProps { + wrappedComponentRef?: any; + } + + declare interface FormComponentProps extends RcBaseFormProps { + form: WrappedFormUtils; + } + + declare type FormWrappedProps = > + (component: C) => React$ComponentType<$Diff>; + + declare export type FormProps = { + className?: string, + form?: WrappedFormUtils, + hideRequiredMark?: boolean, + horizontal?: boolean, + inline?: boolean, + layout?: "horizontal" | "inline" | "vertical", + onSubmit?: (e: SyntheticEvent) => void, + prefixCls?: string, + style?: $Shape, + vertical?: boolean, + ... + }; + + declare export type FormCreateOption = { + onFieldsChange?: (props: T, fields: Array) => void, + onValuesChange?: (props: T, values: mixed) => void, + mapPropsToFields?: (props: T) => void, + withRef?: boolean, + ... + }; + + declare export class Form extends React$Component { + static Item: typeof FormItem; + static create: ( + options?: FormCreateOption + ) => FormWrappedProps; + } + + declare export type FormItemProps = { + help?: React$Node, + extra?: React$Node, + validateStatus?: "success" | "warning" | "error" | "validating" | "", + ... + }; + + declare class FormItem extends React$Component {} + + declare export type RangePickerProps = {...}; + + declare export class DatePicker$RangePicker extends React$Component< + RangePickerProps + > {} + + declare export class Icon extends React$Component<{...}> {} + + declare export class InputNumber extends React$Component<{...}> {} + + declare type InputProps = { + onBlur?: (event: SyntheticFocusEvent) => mixed, + onChange?: (event: SyntheticKeyboardEvent) => mixed, + ... + }; + + declare export class Input extends React$Component { + static Search: typeof InputSearch; + static TextArea: typeof InputTextArea; + static Password: typeof InputPassword; + } + + declare class InputSearch extends React$Component<{...}> { + input: { input: HTMLInputElement, ... }; + } + + declare class InputTextArea extends React$Component<{...}> {} + + declare type InputPasswordProps = { visibilityToggle?: boolean, ... }; + + // Added in 3.12.0 + declare class InputPassword extends React$Component {} + + declare export class Layout extends React$Component<{...}> { + static Content: typeof LayoutContent; + static Footer: typeof LayoutFooter; + static Header: typeof LayoutHeader; + static Sider: typeof LayoutSider; + } + + declare class LayoutContent extends React$Component<{...}> {} + + declare class LayoutFooter extends React$Component<{...}> {} + + declare class LayoutHeader extends React$Component<{...}> {} + + declare class LayoutSider extends React$Component<{...}> {} + + declare export type ListItemProps = {...}; + + declare export class ListItem extends React$Component { + static Meta: typeof Meta; + } + + declare export class List extends React$Component<{...}> { + static Item: typeof ListItem; + } + + declare export class LocaleProvider extends React$Component<{...}> {} + + declare export type MenuProps = { onClick?: ({ + domEvent: SyntheticMouseEvent, + item: React$Component, + key: string, + keyPath: string[], + ... + }) => mixed, ... }; + + declare export class Menu extends React$Component { + static Item: typeof MenuItem; + static SubMenu: typeof MenuSubMenu; + } + + declare class MenuItem extends React$Component<{...}> {} + + declare class MenuSubMenu extends React$Component<{...}> {} + + declare export class message { + static config({ + duration?: number, + getContainer?: () => HTMLElement, + top?: number, + ... + }): void; + static destroy: () => void; + static success: messageFn; + static error: messageFn; + static info: messageFn; + static warning: messageFn; + static warn: messageFn; + static loading: messageFn<() => void>; + } + + declare export class Modal extends React$Component<{...}> { + static info: typeof modalFn; + static success: typeof modalFn; + static error: typeof modalFn; + static warning: typeof modalFn; + static confirm: typeof modalFn; + } + + declare export type PaginationProps = { + current?: number, + defaultCurrent?: number, + defaultPageSize?: number, + hideOnSinglePage?: boolean, + itemRender?: ( + page: number, + type: "page" | "prev" | "next", + originalElement: React$Node + ) => React$Node, + pageSize?: number, + pageSizeOptions?: string[], + showQuickJumper?: boolean, + showSizeChanger?: boolean, + showTotal?: (total: number, range: number[]) => React$Node, + simple?: boolean, + size?: string, + total?: number, + onChange?: (page: number, pageSize: number) => void, + onShowSizeChange?: (current: number, size: number) => void, + ... + }; + + declare export class Pagination extends React$Component {} + + // These props are shared by Tooltip, Popconfirm, and Poopover + declare type TooltipSharedProps = { + arrowPointAtCenter?: boolean, + autoAdjustOverflow?: boolean, + defaultVisible?: boolean, + getPopupContainer?: (element?: HTMLElement) => HTMLElement, + mouseEnterDelay?: number, + mouseLeaveDelay?: number, + overlayClassName?: string, + overlayStyle?: $Shape, + placement?: 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom', + trigger?: 'hover' | 'focus' | 'click' | 'contextMenu', + visible?: boolean, + onVisibleChange?: (visible: boolean) => void, + align?: AlignConfig, + ... + } + + // for alignConfig value, antd documentation points to rc-tooltip docs, + // which poits to https://github.com/yiminghe/dom-align + declare type AlignConfig = {| + points?: string, + offset?: number | string, + targetOffset?: number | string, + overflow?: {| adjustX?: boolean, adjustY?: boolean |}, + useCssRight?: boolean, + useCssBottom?: boolean, + useCssTransform:? boolean + |} + + declare export type PopconfirmProps = { + cancelText?: string, + okText?: string, + okType?: 'primary' | 'dashed' | 'ghost' | 'danger' | 'default', + title?: 'string' | React$Node, + onCancel?: (event: SyntheticEvent<>) => void, + onConfirm?: (event: SyntheticEvent<>) => void, + icon?: React$Node, + ... + } & TooltipSharedProps + + declare export class Popconfirm extends React$Component {} + + declare export type PopoverProps = { + content?: 'string' | React$Node, + title?: 'string' | React$Node, + ... + } & TooltipSharedProps + + declare export class Popover extends React$Component {} + + declare export class Progress extends React$Component<{...}> {} + + declare export class Radio extends React$Component<{...}> { + static Group: typeof RadioGroup; + static Button: typeof RadioButton; + } + + declare class RadioGroup extends React$Component<{...}> {} + + declare class RadioButton extends React$Component<{...}> {} + + declare export class Row extends React$Component<{...}> {} + + declare export type SelectValue = string | string[] | number | number[]; + + declare export type SelectProps = { + allowClear?: boolean, + autoClearSearchValue?: boolean, + autoFocus?: boolean, + defaultActiveFirstOption?: boolean, + defaultOpen?: boolean, + defaultValue?: T, + disabled?: boolean, + dropdownClassName?: string, + dropdownMatchSelectWidth?: boolean, + filterOption?: boolean | (input: string, option: React$Node) => boolean, + firstActiveValue?: string | string[], + labelInValue?: boolean, + loading?: boolean, + maxTagCount?: number, + mode?: 'default' | 'multiple' | 'tags', + notFoundContent?: string, + open?: boolean, + optionFilterProp?: string, + optionLabelProp?: string, + placeholder?: string | React$Node, + showArrow?: boolean, + showSearch?: boolean, + size?: 'default' | 'small' | 'large' | string, + suffixIcon?: React$Node, + removeIcon?: React$Node, + clearIcon?: React$Node, + menuItemSelectedIcon?: React$Node, + tokenSeparators?: string[], + value?: T, + onBlur?: () => void, + onChange?: (value: T, option: React$Node) => void, + onDeselect?: (value: T, option: React$Node) => void, + onDropdownVisibleChange?: (open: boolean) => void, + onFocus?: () => void, + onSearch?: (value: string) => void, + onSelect?: (value: T, option: React$Node) => void, + ... + }; + + declare export class Select extends React$Component> { + static Option: typeof SelectOption; + static OptGroup: typeof SelectOptGroup; + blur: () => void; + focus: () => void; + } + + declare export type SelectOptionProps = { + className?: string, + disabled?: boolean, + key?: string, + title?: string, + value?: string | number, + ... + }; + + declare class SelectOption extends React$Component {} + + declare export type SelectOptGroupProps = { + key?: string, + label?: string | React$Node, + ... + }; + + declare class SelectOptGroup extends React$Component {} + + declare export class Slider extends React$Component<{...}> {} + + declare export type SpinProps = { + delay?: number, + size?: "small" | "default" | "large", + spinning?: boolean, + tip?: string, + ... + }; + + declare export class Spin extends React$Component {} + + declare export class Step extends React$Component<{ + description?: React$Node, + icon?: React$Node, + status?: "wait" | "process" | "finish" | "error", + title?: React$Node, + ... + }> {} + + declare export class Steps extends React$Component<{ + current?: number, + direction?: "horizontal" | "vertical", + labelPlacement?: "horizontal" | "vertical", + progressDot?: + | boolean + | (( + iconDot: React$Node, + { + index: number, + status: "wait" | "process" | "finish" | "error", + title: React$Node, + description: React$Node, + ... + } + ) => React$Node), + size?: "default" | "small", + status?: "wait" | "process" | "finish" | "error", + ... + }> { + static Step: typeof Step; + } + + declare export class Switch extends React$Component<{...}> {} + + declare export class Table extends React$Component<{...}> {} + + declare export class Tabs extends React$Component<{...}> { + static TabPane: typeof TabsTabPane; + } + + declare export class TabsTabPane extends React$Component<{...}> {} + + declare export class Tag extends React$Component<{...}> {} + + declare export type TooltipProps = { title: React$Node | () => React$Node, ... } & TooltipSharedProps + + declare export class Tooltip extends React$Component {} + + declare export class TreeSelect extends React$Component<{...}> { + static TreeNode: typeof TreeSelectTreeNode; + } + + declare export class TreeSelectTreeNode extends React$Component<{...}> {} + + declare export class Upload extends React$Component<{...}> { + static Dragger: typeof UploadDragger; + } + + declare export class UploadDragger extends React$Component<{...}> {} + + + declare export type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'; + + declare export type NotificationConfigProps = { + top?: number, + bottom?: number, + duration?: number, + placement?: NotificationPlacement, + getContainer?: () => HTMLElement, + ... + } + + declare export type NotificationProps = { + message: React$Node, + description?: React$Node, + btn?: React$Node, + key?: string, + onClose?: () => void, + duration?: number | null, + icon?: React$Node, + placement?: NotificationPlacement, + style?: $Shape, + prefixCls?: string, + className?: string, + +type?: 'success' | 'info' | 'error' | 'warning', + onClick?: () => void, + top?: number, + bottom?: number, + getContainer?: () => HTMLElement, + ... + } + + declare export class notification { + static success: NotificationProps => void; + static error: NotificationProps => void; + static info: NotificationProps => void; + static warn: NotificationProps => void; + static warning: NotificationProps => void; + static open: NotificationProps => void; + static close: string => void; + static config: NotificationConfigProps => void; + static destroy: () => void; + } +} diff --git a/definitions/npm/antd_v3.x.x/flow_v0.201.x-/test_antd_v3.x.x.js b/definitions/npm/antd_v3.x.x/flow_v0.201.x-/test_antd_v3.x.x.js new file mode 100644 index 0000000000..ba383654df --- /dev/null +++ b/definitions/npm/antd_v3.x.x/flow_v0.201.x-/test_antd_v3.x.x.js @@ -0,0 +1,903 @@ +// @flow +import * as React from "react"; +import { describe, it } from "flow-typed-test"; +import { + Alert, + AutoComplete, + Avatar, + Badge, + Button, + Card, + Cascader, + Checkbox, + Col, + Collapse, + DatePicker, + Dropdown, + Form, + Icon, + Input, + Layout, + LocaleProvider, + Menu, + message, + Modal, + Pagination, + Popconfirm, + Popover, + Radio, + Row, + Select, + Slider, + Spin, + Steps, + Table, + Tabs, + Tag, + Tooltip, + TreeSelect +} from "antd"; + +const { RangePicker } = DatePicker; + +import type { WrappedFormUtils } from "antd"; + +describe("Alert", () => { + it("is a react component", () => { + const alert = ; + }); +}); + +describe("Avatar", () => { + it("is a react component", () => { + const avatar = ; + }); +}); + +describe("AutoComplete", () => { + it("is a react component", () => { + const autocomplete = ; + }); + + it("with prop allowClear", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + }); + + it("with prop autoFocus", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + }); + + it("with prop backfill", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + }); + + it("with prop defaultActiveFirstOption", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + }); + + it("with prop defaultValue", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + const autocomplete4 = ; + }); + + it("with prop disabled", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + }); + + it("with prop filterOption", () => { + const autocomplete1 = ; + const autocomplete2 = true} />; + }); + + it("with prop open", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + }); + + it("with prop optionLabelProp", () => { + const autocomplete = ; + }); + + it("with prop placeholder", () => { + const autocomplete = ; + }); + + it("with prop value", () => { + const autocomplete1 = ; + const autocomplete2 = ; + const autocomplete3 = ; + const autocomplete4 = ; + }); + + it("with prop onBlur", () => { + const autocomplete = undefined} />; + }); + + it("with prop onChange", () => { + const autocomplete1 = undefined} />; + const autocomplete2 = undefined} />; + const autocomplete3 = undefined} />; + const autocomplete4 = undefined} />; + const autocomplete5 = undefined} />; + }); + + it("with prop onDropdownVisibleChange", () => { + const autocomplete = undefined} />; + }); + + it("with prop onFocus", () => { + const autocomplete = undefined} />; + }); + + it("with prop onSearch", () => { + const autocomplete = undefined} />; + }); + + it("with prop onSelect", () => { + const autocomplete1 = undefined} />; + const autocomplete2 = undefined} />; + const autocomplete3 = undefined} />; + const autocomplete4 = undefined} />; + const autocomplete5 = undefined} />; + }); +}); + +describe("AutoComplete.Option", () => { + it("is a react component", () => { + const option = ; + }); +}); + +describe("AutoComplete.OptGroup", () => { + it("is a react component", () => { + const group = ; + }); +}); + +describe("Badge", () => { + it("is a react component", () => { + const badge = ; + }); +}); + +describe("Button", () => { + it("is a react component", () => { + const button =