From 71140e70b8b2273e653c6896f4db75dbe1b48983 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 Update packages/useful-types/CHANGELOG.md Co-authored-by: Ben Scott <227292+BPScott@users.noreply.github.com> pr comments --- packages/useful-types/CHANGELOG.md | 8 ++++++++ packages/useful-types/src/types.ts | 28 ---------------------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/packages/useful-types/CHANGELOG.md b/packages/useful-types/CHANGELOG.md index a67ff62c79..6b62c4f6c7 100644 --- a/packages/useful-types/CHANGELOG.md +++ b/packages/useful-types/CHANGELOG.md @@ -7,6 +7,14 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +### Breaking Change + +- `Omit` has been removed. Remove any `import { Omit } from '@shopify/useful-types';` and use the built-in [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys) type +- `ThenType` has been removed. You should use the built-in `Awaited` type instead +- `Arguments`, `ArgumentsAtIndex` and `FirstArgument` have been removed. Replace usage of `Arguments` with the built-in [`Parameters`](https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype) type. Replace usage of `ArgumentAtIndex` with `Parameters[i]` and `FirstArgument` with `Parameters[0]`. +- `ConstructorArguments`, `ConstructorArgumentAtIndex` and `FirstConstructorArgument` have been removed. Replace usage of `ConstructorArguments` with the built-in [`ConstructorParameters`](https://www.typescriptlang.org/docs/handbook/utility-types.html#constructorparameterstype) type. Replace usage of `ConstructorArgumentAtIndex` with `ConstructorParameters[i]` and `FirstConstructorArgument` with `ConstructorParameters[0]` +- `MaybeFunctionReturnType` has been removed. Replace usage of `MaybeFunctionReturnType` with the built-in `ReturnType` type + ## 3.1.0 - 2022-02-09 ### Added 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