Skip to content

Releases: DetachHead/ts-helpers

12.0.0

24 Jul 12:48
Compare
Choose a tag to compare

What's Changed

Full Changelog: https://github.com/DetachHead/ts-helpers/commits/12.0.0

11.2.0

25 Jun 15:38
Compare
Choose a tag to compare

What's Changed

Full Changelog: 11.1.0...11.2.0

11.1.0

19 Apr 11:49
Compare
Choose a tag to compare

What's Changed

Full Changelog: v11.0.0...11.1.0

11.0.0

19 Apr 06:05
Compare
Choose a tag to compare

What's Changed

Full Changelog: 10.0.0...11.0.0

10.0.0

18 Oct 14:40
Compare
Choose a tag to compare

What's Changed

Full Changelog: 9.0.0...10.0.0

9.0.0

13 Oct 02:28
Compare
Choose a tag to compare

What's Changed

Full Changelog: 8.2.0...9.0.0

8.2.0

30 Sep 10:51
Compare
Choose a tag to compare
  • the exactly type testing function now correctly works on intersections - see microsoft/TypeScript#27024 (comment)
  • add OnlyInfer type for generics
  • add castArray function and CastArray type
  • some other fixes and stuff

8.1.2

03 Aug 14:48
Compare
Choose a tag to compare

fixed issue where it was always installing dev dependencies

8.1.1

03 Aug 12:48
00aecd5
Compare
Choose a tag to compare

Type Testing

With the exactly function you can test if types or values are an exact match to a type

const a: 1 | 2 = 1
//values (also does a runtime assertion on the values)
exactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`
exactly(1 as number, a as number) // no error
exactly(1 as 1 | 2, a) // no error

// mixed
exactly<number>()(a) // error as `1 | 2` is not an exact match of `number`
exactly<number>()(a as number) // no error
exactly<1 | 2>()(a) // no error

// types
type Foo = 1 | 2
exactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`
exactly<1 | 2, Foo>() // no error

The Equals type allows you to check if two types are equal at the type level

Equals<number, 1 | 2> // false
Equals<any, 10> // false
Equals<unknown, never> // false

thanks to @KotlinIsland for helping out with this