Skip to content

Releases: mattpocock/ts-reset

v0.4.2

08 Mar 17:47
Compare
Choose a tag to compare

0.4.2

Minor Changes

  • ce9db42: Added support for widening in Array.lastIndexOf, Array.indexOf, ReadonlyArray.lastIndexOf and ReadonlyArray.indexOf.

  • 107dfc2: Changed the array.includes on readonly arrays to NOT be a type predicate. Before this change, this perfectly valid code would not behave correctly.

    type Code = 0 | 1 | 2;
    type SpecificCode = 0 | 1;
    
    const currentCode: Code = 0;
    
    // Create an empty list of subset type
    const specificCodeList: ReadonlyArray<SpecificCode> = [];
    
    // This will be false, since 0 is not in []
    if (specificCodeList.includes(currentCode)) {
      currentCode; // -> SpecificCode
    } else {
      // This branch will be entered, and ts will think z is 2, when it is actually 0
      currentCode; // -> 2
    }

    Removing the type predicate brings ts-reset closer towards correctness.

  • 4765413: author: @mefechoel

    Added the Map.has rule.

    Similar to .includes or Set.has(), Map.has() doesn't let you pass members that don't exist in the map's keys:

    // BEFORE
    const userMap = new Map([
      ["matt", 0],
      ["sofia", 1],
      [2, "waqas"],
    ] as const);
    
    // Argument of type '"bryan"' is not assignable to
    // parameter of type '"matt" | "sofia" | "waqas"'.
    userMap.has("bryan");

    With the rule enabled, Map follows the same semantics as Set.

    // AFTER
    import "@total-typescript/ts-reset/map-has";
    
    const userMap = new Map([
      ["matt", 0],
      ["sofia", 1],
      [2, "waqas"],
    ] as const);
    
    // .has now takes a string as the argument!
    userMap.has("bryan");

Patch Changes

  • b15aaa4: Fixed an oversight with the initial set-has implementation by adding support to ReadonlySet.

v0.3.7

20 Feb 22:26
Compare
Choose a tag to compare

Patch Changes

  • Added license and switched to MIT

v0.3.6

20 Feb 19:12
Compare
Choose a tag to compare

Patch Changes

  • d3ddefa: Changed the exports map so "types" appears top

v0.3.5

20 Feb 16:19
Compare
Choose a tag to compare

Patch Changes

  • Another fix for deploy process.

v0.3.4

20 Feb 16:15
Compare
Choose a tag to compare

Patch Changes

  • Fixed an issue where dist folder was not deployed.

v0.3.3

20 Feb 12:06
Compare
Choose a tag to compare

Patch Changes

  • Fixed a bug where 0n was not being filtered out by filter-boolean

v0.3.2

19 Feb 21:26
Compare
Choose a tag to compare

Patch Changes

  • Removed the ability to use Set.has as a type predicate. This ensures that Set.has never sets the checked element to never.

v0.3.1

19 Feb 21:13
Compare
Choose a tag to compare

Patch Changes

  • Fixed a bug where Array.includes was returning a predicate, which gave false positives.

v0.3.0

19 Feb 21:08
Compare
Choose a tag to compare

Minor Changes

  • ed9edc1: Added improved typings for Set.has

Patch Changes

  • d27e819: Fixed issue where webpack wasn't recognizing the exports map

v0.2.1

19 Feb 20:26
Compare
Choose a tag to compare

Patch Changes

  • Readme tweak