1.0.13 • Published 7 months ago

typescript-lib-enhancer v1.0.13

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

Enhance TypeScript lib.*.d.ts

Usage

Install and add to tsconfig.json types

{
  "compilerOptions": {
    "types": [
      "typescript-lib-enhancer"
    ]
  }
}

this package includes typed-query-selector/strict to enhance querySelector() & querySelectorAll() & closest()

Features

EnhanceObject.hasOwn to narrow types just like key in obj

declare const value: { a: number } | { b: number }

// before 
if (Object.hasOwn(value, 'a')) {
  // Errot: Property 'a' does not exist on type '{ b: number; }'
  value.a = 12
}

// after
if (Object.hasOwn(value, 'a')) {
  value.a = 12 // OK
  value.b = 12 // Error as expect
} else {
  value.b = 12 // OK
}

TODO

  • Object.asign type
  • structuredClone no functions allow
  • Element.setAttribute allow number as value?
  • Object.entries key type
  • Array.prototype.reduce & Array.prototype.reduceRight
  • Object.keys & Object.entries & Object.values & Object.fromEntries
  • Object.isFrozen <T>(o: T): o is Readonly<T>
  • Reflect.get
  • document.getElementById add generic
  • Array.concat concat\<K>(...items: K[]): (T | K)[]

Loose

  • parseInt allow number

Add error generic for Promise

1.0.9

10 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.13

7 months ago

1.0.12

9 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago