From 9ea7f6359ddd056fa3de5ceb2669f5c71d85cce5 Mon Sep 17 00:00:00 2001 From: Ahmed Mokhtar Date: Wed, 18 Sep 2019 19:13:18 +0200 Subject: [PATCH] fix: to prop mustn't be undefined in LinkProps (#38456) --- types/reach__router/index.d.ts | 49 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/types/reach__router/index.d.ts b/types/reach__router/index.d.ts index 1397283c00..fb77b7b3a9 100644 --- a/types/reach__router/index.d.ts +++ b/types/reach__router/index.d.ts @@ -1,18 +1,18 @@ // Type definitions for @reach/router 1.2 // Project: https://github.com/reach/router -// Definitions by: Kingdaro +// Definitions by: Kingdaro , A.Mokhtar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as React from "react"; -import { Location as HLocation } from "history"; -export type WindowLocation = Window["location"] & HLocation; +import * as React from 'react'; +import { Location as HLocation } from 'history'; +export type WindowLocation = Window['location'] & HLocation; -export type HistoryActionType = "PUSH" | "POP"; +export type HistoryActionType = 'PUSH' | 'POP'; export type HistoryLocation = WindowLocation & { state?: any }; export interface HistoryListenerParameter { - location: HistoryLocation; - action: HistoryActionType; + location: HistoryLocation; + action: HistoryActionType; } export type HistoryListener = (parameter: HistoryListenerParameter) => void; export type HistoryUnsubscribe = () => void; @@ -24,9 +24,7 @@ export interface History { navigate: NavigateFn; } -export class Router extends React.Component< - RouterProps & React.HTMLProps -> {} +export class Router extends React.Component> {} export interface RouterProps { basepath?: string; @@ -46,15 +44,12 @@ export type RouteComponentProps = Partial & { export type Omit = Pick>; export type AnchorProps = Omit< - React.DetailedHTMLProps< - React.AnchorHTMLAttributes, - HTMLAnchorElement - >, - "href" // remove href, as it's ignored by the router - >; + React.DetailedHTMLProps, HTMLAnchorElement>, + 'href' // remove href, as it's ignored by the router +>; export interface LinkProps extends AnchorProps { - to?: string; + to: string; replace?: boolean; getProps?: (props: LinkGetProps) => {}; state?: TState; @@ -67,7 +62,7 @@ export interface LinkGetProps { location: WindowLocation; } -export class Link extends React.Component> { } +export class Link extends React.Component> {} export interface RedirectProps { from?: string; @@ -77,16 +72,14 @@ export interface RedirectProps { replace?: boolean; } -export class Redirect extends React.Component>> { } +export class Redirect extends React.Component>> {} export interface MatchProps { path: string; children: MatchRenderFn; } -export type MatchRenderFn = ( - props: MatchRenderProps -) => React.ReactNode; +export type MatchRenderFn = (props: MatchRenderProps) => React.ReactNode; export interface MatchRenderProps { match: null | { uri: string; path: string } & TParams; @@ -94,7 +87,7 @@ export interface MatchRenderProps { navigate: NavigateFn; } -export class Match extends React.Component> { } +export class Match extends React.Component> {} export type NavigateFn = (to: string, options?: NavigateOptions<{}>) => void; @@ -107,29 +100,27 @@ export interface LocationProps { children: LocationProviderRenderFn; } -export class Location extends React.Component { } +export class Location extends React.Component {} export interface LocationProviderProps { history?: History; children?: React.ReactNode | LocationProviderRenderFn; } -export type LocationProviderRenderFn = ( - context: LocationContext -) => React.ReactNode; +export type LocationProviderRenderFn = (context: LocationContext) => React.ReactNode; export interface LocationContext { location: WindowLocation; navigate: NavigateFn; } -export class LocationProvider extends React.Component { } +export class LocationProvider extends React.Component {} export interface ServerLocationProps { url: string; } -export class ServerLocation extends React.Component { } +export class ServerLocation extends React.Component {} export const navigate: NavigateFn;