Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
use typescript native types
Browse files Browse the repository at this point in the history
changelog

remove homemade types

also this one

reword changelog

add breaking changes to changelog
  • Loading branch information
m4thieulavoie committed Feb 22, 2022
1 parent 3f69023 commit 2c91049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
9 changes: 9 additions & 0 deletions packages/useful-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- ## Unreleased -->

### 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<T>[i]` and `FirstArgument<T>` by `Parameters<T>[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<T>[i]` and `FirstConstructorArgument<T>` by `ConstructorParameters<T>[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

Expand Down
28 changes: 0 additions & 28 deletions packages/useful-types/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
export type ThenType<T> = T extends Promise<infer U> ? U : T;

export type Arguments<T> = T extends (...args: infer U) => any ? U : never;
export type ArgumentAtIndex<
Func,
Index extends keyof Arguments<Func>
> = Arguments<Func>[Index];
export type FirstArgument<T> = ArgumentAtIndex<T, 0>;

export type MaybeFunctionReturnType<T> = T extends (...args: any[]) => infer U
? U
: never;

export type ArrayElement<T> = T extends (infer U)[] ? U : never;

export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
? DeepPartial<U>[]
Expand Down Expand Up @@ -67,19 +52,6 @@ export type NonReactStatics<T> = Pick<T, Exclude<keyof T, ReactStatics>>;

export type ExtendedWindow<T> = Window & typeof globalThis & T;

export type ConstructorArguments<T> = T extends {
new (...args: infer U): any;
}
? U
: never;

export type ConstructorArgumentAtIndex<
T,
I extends keyof ConstructorArguments<T>
> = ConstructorArguments<T>[I];

export type FirstConstructorArgument<T> = ConstructorArgumentAtIndex<T, 0>;

// Reference https://stackoverflow.com/questions/55539387/deep-omit-with-typescript
type Primitive =
| string
Expand Down

0 comments on commit 2c91049

Please sign in to comment.