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

Update packages/useful-types/CHANGELOG.md

Co-authored-by: Ben Scott <227292+BPScott@users.noreply.github.com>

pr comments
  • Loading branch information
m4thieulavoie committed Feb 23, 2022
1 parent 80ef152 commit 71140e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
8 changes: 8 additions & 0 deletions packages/useful-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- ## Unreleased -->

### 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<T>[i]` and `FirstArgument<T>` with `Parameters<T>[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<T>[i]` and `FirstConstructorArgument<T>` with `ConstructorParameters<T>[0]`
- `MaybeFunctionReturnType` has been removed. Replace usage of `MaybeFunctionReturnType` with the built-in `ReturnType` type

## 3.1.0 - 2022-02-09

### Added
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 71140e7

Please sign in to comment.