From d2a963766c57c7c03f18f39775d2242ad0405627 Mon Sep 17 00:00:00 2001 From: Matt Lavoie Date: Mon, 7 Feb 2022 18:58:13 -0500 Subject: [PATCH] use typescript native types changelog remove homemade types also this one reword changelog add breaking changes to changelog --- packages/useful-types/CHANGELOG.md | 9 +++++++++ packages/useful-types/src/types.ts | 28 ---------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/packages/useful-types/CHANGELOG.md b/packages/useful-types/CHANGELOG.md index a67ff62c79..e5a40c0cf9 100644 --- a/packages/useful-types/CHANGELOG.md +++ b/packages/useful-types/CHANGELOG.md @@ -7,11 +7,20 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +### Breaking Change + +- `Omit` has been removed. You should be able to remove any `import { Omit } from '@shopify/useful-types';` and it should fallback on `Omit` from Typescript directly +- `ThenType` has been removed. You should use the native `Awaited` type from Typescript instead +- `Arguments` has been removed. You should replace any of its usage in your project with the native `Parameters` from Typescript. On the same note, replace `ArgumentAtIndex` by `Parameters[i]` and `FirstArgument` by `Parameters[0]`. +- `ConstructorArguments` has been removed. You should replace any of its usage in your project with the native `ConstructorParameters` from Typescript. On the same note, replace `ConstructorArgumentAtIndex` by `ConstructorParameters[i]` and `FirstConstructorArgument` by `ConstructorParameters[0]`. +- `MaybeFunctionReturnType` has been removed. Each usage should be replaced by the native `ReturnType` of Typescript + ## 3.1.0 - 2022-02-09 ### Added - Added `PartialSome` and `RequireSome` types to set specified fields of a property to optional or required +- Deprecate `ThenType`, `Omit`, `Arguments`, `ArgumentAtIndex`, `FirstArgument`, `MaybeFunctionReturnType`, `ConstructorArguments`, `ConstructorArgumentAtIndex` and `FirstConstructorArgument` in favour of their Typescript counterparts ## 3.0.7 - 2022-02-01 diff --git a/packages/useful-types/src/types.ts b/packages/useful-types/src/types.ts index fd04b8b784..c54d8bd5b2 100644 --- a/packages/useful-types/src/types.ts +++ b/packages/useful-types/src/types.ts @@ -1,20 +1,5 @@ -export type ThenType = T extends Promise ? U : T; - -export type Arguments = T extends (...args: infer U) => any ? U : never; -export type ArgumentAtIndex< - Func, - Index extends keyof Arguments -> = Arguments[Index]; -export type FirstArgument = ArgumentAtIndex; - -export type MaybeFunctionReturnType = T extends (...args: any[]) => infer U - ? U - : never; - export type ArrayElement = T extends (infer U)[] ? U : never; -export type Omit = Pick>; - export type DeepPartial = { [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial[] @@ -67,19 +52,6 @@ export type NonReactStatics = Pick>; export type ExtendedWindow = Window & typeof globalThis & T; -export type ConstructorArguments = T extends { - new (...args: infer U): any; -} - ? U - : never; - -export type ConstructorArgumentAtIndex< - T, - I extends keyof ConstructorArguments -> = ConstructorArguments[I]; - -export type FirstConstructorArgument = ConstructorArgumentAtIndex; - // Reference https://stackoverflow.com/questions/55539387/deep-omit-with-typescript type Primitive = | string