Socket
Socket
Sign inDemoInstall

@total-typescript/ts-reset

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@total-typescript/ts-reset - npm Package Versions

23

0.6.1

Diff

Changelog

Source

0.6.1

Patch Changes

  • 757be40: Fixed a bug where creating an empty map would no longer infer types correctly.
mpocock
published 0.6.0 •

Changelog

Source

0.6.0

Minor Changes

  • 6574858: Added a rule, /map-constructor, to default Map to Map<unknown, unknown> when no arguments are passed to the constructor.

    Before, you'd get any for both key and value types. Now, the result of Map.get is unknown instead of any:

    const userMap = new Map();
    
    const value = userMap.get("matt"); // value: unknown
    

    This now is part of the recommended rules.

  • 5bf3a15: Added a rule, /promise-catch, to change the catch method to take unknown instead of any as an argument.

    const promise = Promise.reject("error");
    
    // BEFORE
    
    promise.catch((error) => {
      console.error(error); // error is any!
    });
    
    // AFTER
    
    promise.catch((error) => {
      console.error(error); // error is unknown!
    });
    

Patch Changes

  • 53cee4f: author: @none23

    Fixed a bug where running .filter on a union of arrays would not work.

mpocock
published 0.5.1 •

Changelog

Source

0.5.1

Patch Changes

  • Added homepage for npm purposes.
mpocock
published 0.5.0 •

Changelog

Source

0.5.0

Minor Changes

  • 49b8603: Added a rule, /session, to make sessionStorage and localStorage safer.

    // Is now typed as `unknown`, not `any`!
    localStorage.a;
    
    // Is now typed as `unknown`, not `any`!
    sessionStorage.abc;
    
  • 49b8603: Added a /dom entrypoint to allow users to import DOM-only rules.

mpocock
published 0.4.2 •

mpocock
published 0.4.1 •

Changelog

Source

0.4.1

Patch Changes

  • No changes, just pushing to fix the previous slightly borked release.
mpocock
published 0.4.0 •

Changelog

Source

0.4.0

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.
mpocock
published 0.3.7 •

Changelog

Source

0.3.7

Patch Changes

  • Added license and switched to MIT
mpocock
published 0.3.6 •

Changelog

Source

0.3.6

Patch Changes

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

Changelog

Source

0.3.5

Patch Changes

  • Another fix for deploy process.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc