From b73b4426dd1cd78b7ddf4f4d1cc5b6316fd6956f Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 24 Apr 2018 17:44:50 -0700 Subject: [PATCH] compatibility fix for keyof T in ts 2.9 --- types/aphrodite/index.d.ts | 8 +------- types/dispatchr/addons/createStore.d.ts | 3 +-- .../google-cloud__datastore-tests.ts | 3 +-- types/google-cloud__datastore/index.d.ts | 10 ++++++---- types/grid-styled/index.d.ts | 5 +---- types/mirrorx/index.d.ts | 3 +-- types/react-autosuggest/index.d.ts | 6 +----- types/react-bootstrap-table/index.d.ts | 2 +- types/react-bootstrap/index.d.ts | 3 +-- types/react-dynamic-number/index.d.ts | 6 +----- types/react-geosuggest/index.d.ts | 7 +------ types/react-i18next/src/translate.d.ts | 7 +++---- types/react-redux/index.d.ts | 3 +-- types/react-relay/index.d.ts | 4 +--- types/react-router/index.d.ts | 3 +-- types/recompose/index.d.ts | 3 +-- types/redux-form/index.d.ts | 3 +-- 17 files changed, 24 insertions(+), 55 deletions(-) diff --git a/types/aphrodite/index.d.ts b/types/aphrodite/index.d.ts index 583e84e996..a82ec2f36b 100644 --- a/types/aphrodite/index.d.ts +++ b/types/aphrodite/index.d.ts @@ -12,13 +12,7 @@ type FontFamily = | BaseCSSProperties['fontFamily'] | CSS.FontFace; -// Replace with Exclude once on 2.8+ -type Diff = ( - & { [P in T]: P } - & { [P in U]: never } - & { [x: string]: never } -)[T]; -type Omit = Pick>; +type Omit = Pick; type CSSProperties = Omit & { fontFamily?: FontFamily | FontFamily[]; diff --git a/types/dispatchr/addons/createStore.d.ts b/types/dispatchr/addons/createStore.d.ts index 86a1f24fbb..bf576156fc 100644 --- a/types/dispatchr/addons/createStore.d.ts +++ b/types/dispatchr/addons/createStore.d.ts @@ -1,7 +1,6 @@ import { StoreClass, Store } from '../index'; -type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; -type Omit = Pick>; +type Omit = Pick; interface StoreOptions { storeName: string; diff --git a/types/google-cloud__datastore/google-cloud__datastore-tests.ts b/types/google-cloud__datastore/google-cloud__datastore-tests.ts index 3093a8256a..cb723d0d5b 100644 --- a/types/google-cloud__datastore/google-cloud__datastore-tests.ts +++ b/types/google-cloud__datastore/google-cloud__datastore-tests.ts @@ -14,8 +14,7 @@ interface TestEntity { name?: string; location?: string; symbol?: string; - - [keySymbol: string]: any; + [Datastore.KEY]?: any; } const kind = 'Company'; diff --git a/types/google-cloud__datastore/index.d.ts b/types/google-cloud__datastore/index.d.ts index 8c9cdd23c3..f864f965c9 100644 --- a/types/google-cloud__datastore/index.d.ts +++ b/types/google-cloud__datastore/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/googleapis/nodejs-datastore // Definitions by: Antoine Beauvais-Lacasse // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 2.7 /// @@ -36,7 +36,7 @@ declare module '@google-cloud/datastore' { class Datastore extends DatastoreRequest_ { constructor(options: InitOptions); - readonly KEY: KEY_SYMBOL; + readonly KEY: typeof Datastore.KEY; readonly MORE_RESULTS_AFTER_CURSOR: MoreResultsAfterCursor; readonly MORE_RESULTS_AFTER_LIMIT: MoreResultsAfterLimit; readonly NO_MORE_RESULTS: NoMoreResults; @@ -81,7 +81,7 @@ declare module '@google-cloud/datastore' { } namespace Datastore { - const KEY: KEY_SYMBOL; + const KEY: unique symbol; const MORE_RESULTS_AFTER_CURSOR: MoreResultsAfterCursor; const MORE_RESULTS_AFTER_LIMIT: MoreResultsAfterLimit; const NO_MORE_RESULTS: NoMoreResults; @@ -93,6 +93,8 @@ declare module '@google-cloud/datastore' { } declare module '@google-cloud/datastore/entity' { + import Datastore = require("@google-cloud/datastore"); + interface DatastoreInt { value: string; } @@ -133,7 +135,7 @@ declare module '@google-cloud/datastore/entity' { parent?: DatastoreKey; } - type KEY_SYMBOL = symbol; + type KEY_SYMBOL = typeof Datastore.KEY; interface DatastorePayload { key: DatastoreKey; diff --git a/types/grid-styled/index.d.ts b/types/grid-styled/index.d.ts index 8cce111478..0006be1db8 100644 --- a/types/grid-styled/index.d.ts +++ b/types/grid-styled/index.d.ts @@ -5,10 +5,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 -export type Diff = ({ [P in T]: P } & - { [P in U]: never } & { [x: string]: never })[T]; - -export type Omit = Pick>; +export type Omit = Pick; import { ComponentClass } from "react"; import { StyledComponentClass } from "styled-components"; diff --git a/types/mirrorx/index.d.ts b/types/mirrorx/index.d.ts index b4bebc9cea..3e7090eab2 100644 --- a/types/mirrorx/index.d.ts +++ b/types/mirrorx/index.d.ts @@ -11,8 +11,7 @@ import * as React from 'react'; import { Connect } from 'react-redux'; import { match } from "react-router"; -export type Diff = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T]; -export type Omit = Pick>; +export type Omit = Pick; export interface model { name: string; diff --git a/types/react-autosuggest/index.d.ts b/types/react-autosuggest/index.d.ts index b78ee34ab8..ab91481925 100644 --- a/types/react-autosuggest/index.d.ts +++ b/types/react-autosuggest/index.d.ts @@ -22,11 +22,7 @@ declare namespace Autosuggest { */ /** @internal */ - type Diff = ({ [P in T]: P } & - { [P in U]: never } & { [x: string]: never })[T]; - - /** @internal */ - type Omit = Pick>; + type Omit = Pick; interface SuggestionsFetchRequestedParams { value: string; diff --git a/types/react-bootstrap-table/index.d.ts b/types/react-bootstrap-table/index.d.ts index 6e9fd1dea8..d98dac1c44 100644 --- a/types/react-bootstrap-table/index.d.ts +++ b/types/react-bootstrap-table/index.d.ts @@ -1022,7 +1022,7 @@ export interface Options { * The function allows you to make further modifications to the cell value prior to it being saved. You need to * return the final cell value to use. */ - onCellEdit?(row: TRow, fieldName: K, value: TRow[K]): TRow[K]; + onCellEdit?(row: TRow, fieldName: K, value: TRow[K]): TRow[K]; /** * Custom message to show when the InsertModal save fails validation. * Default message is 'Form validate errors, please checking!' diff --git a/types/react-bootstrap/index.d.ts b/types/react-bootstrap/index.d.ts index 45a645fc32..6a78dcbb1a 100644 --- a/types/react-bootstrap/index.d.ts +++ b/types/react-bootstrap/index.d.ts @@ -17,8 +17,7 @@ import * as React from 'react'; -export type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; -export type Omit = Pick>; +export type Omit = Pick; export type Sizes = 'xs' | 'xsmall' | 'sm' | 'small' | 'medium' | 'lg' | 'large'; diff --git a/types/react-dynamic-number/index.d.ts b/types/react-dynamic-number/index.d.ts index c1ffdc229d..559d0c9d01 100644 --- a/types/react-dynamic-number/index.d.ts +++ b/types/react-dynamic-number/index.d.ts @@ -6,11 +6,7 @@ import * as React from 'react'; -/** - * remove Diff & Omit when in will be placed in TS from scratch - */ -export type Diff = ({[P in T]: P} & {[P in U]: never} & {[x: string]: never})[T]; -export type Omit = {[P in Diff]: T[P]}; +export type Omit = Pick; export type BaseInputProps = Partial< Omit< diff --git a/types/react-geosuggest/index.d.ts b/types/react-geosuggest/index.d.ts index 344e768b08..2d31ba4d6d 100644 --- a/types/react-geosuggest/index.d.ts +++ b/types/react-geosuggest/index.d.ts @@ -17,12 +17,7 @@ export default class Geosuggest extends Component { } // Replace with Exclude once on 2.8+ -export type Diff = ( - & { [P in T]: P } - & { [P in U]: never } - & { [x: string]: never } -)[T]; -export type Omit = Pick>; +export type Omit = Pick; export interface GeosuggestProps extends Omit, 'style'> { placeholder?: string; diff --git a/types/react-i18next/src/translate.d.ts b/types/react-i18next/src/translate.d.ts index 0711d3895d..0383ee1ead 100644 --- a/types/react-i18next/src/translate.d.ts +++ b/types/react-i18next/src/translate.d.ts @@ -20,8 +20,7 @@ export interface TranslateHocProps { } // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 -type Diff = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T]; -type Omit = Pick>; +type Omit = Pick; type InjectedProps = InjectedI18nProps & InjectedTranslateProps; @@ -32,11 +31,11 @@ export interface WrapperComponentClass

extends React.Comp // Injects props and removes them from the prop requirements. // Adds the new properties t (or whatever the translation function is called) and i18n if needed. export type InferableComponentEnhancerWithProps = -

(component: React.ComponentClass

| React.StatelessComponent

) => +

(component: React.ComponentClass

| React.StatelessComponent

) => React.ComponentClass & TranslateHocProps>; export type InferableComponentEnhancerWithPropsAndRef = -

(component: React.ComponentClass

| React.StatelessComponent

) => +

(component: React.ComponentClass

| React.StatelessComponent

) => WrapperComponentClass, P>; export interface Translate { diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index bc16194f0c..33b31051a5 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -30,8 +30,7 @@ type Dispatch = Redux.Dispatch; type ActionCreator = Redux.ActionCreator; // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 -type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; -type Omit = Pick>; +type Omit = Pick; export interface DispatchProp { dispatch?: Dispatch; diff --git a/types/react-relay/index.d.ts b/types/react-relay/index.d.ts index ae5d6e8f37..35a194b0e7 100644 --- a/types/react-relay/index.d.ts +++ b/types/react-relay/index.d.ts @@ -24,9 +24,7 @@ import * as RelayRuntimeTypes from "relay-runtime"; // Taken from https://github.com/pelotom/type-zoo // tslint:disable-next-line:strict-export-declare-modifiers -type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; -// tslint:disable-next-line:strict-export-declare-modifiers -type Omit = Pick>; +type Omit = Pick; export type RemoveRelayProp

= Omit

; diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 01654c8304..23f2f4f78a 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -102,8 +102,7 @@ export interface match

{ } // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 -export type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; -export type Omit = Pick>; +export type Omit = Pick; export function matchPath

(pathname: string, props: RouteProps): match

| null; diff --git a/types/recompose/index.d.ts b/types/recompose/index.d.ts index 222f0ed539..0c7b9089c6 100644 --- a/types/recompose/index.d.ts +++ b/types/recompose/index.d.ts @@ -20,8 +20,7 @@ declare module 'recompose' { type predicateDiff = (current: T, next: T) => boolean // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 - type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; - type Omit = Pick>; + type Omit = Pick; interface Observer{ next(props: T): void; diff --git a/types/redux-form/index.d.ts b/types/redux-form/index.d.ts index 3ecfe65cd4..8ee5fa9698 100644 --- a/types/redux-form/index.d.ts +++ b/types/redux-form/index.d.ts @@ -39,8 +39,7 @@ export interface RegisteredFieldState { type: FieldType; } -export type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; -export type Omit = Pick>; +export type Omit = Pick; export * from "./lib/reduxForm"; export * from "./lib/Field";