1.0.13 • Published 2 years ago
typescript-lib-enhancer v1.0.13
Enhance TypeScript lib.*.d.ts
Usage
Install and add to tsconfig.json types
{
"compilerOptions": {
"types": [
"typescript-lib-enhancer"
]
}
}this package includes
typed-query-selector/strictto enhancequerySelector()&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.asigntypestructuredCloneno functions allowElement.setAttributeallow number as value?Object.entrieskey typeArray.prototype.reduce&Array.prototype.reduceRightObject.keys&Object.entries&Object.values&Object.fromEntriesObject.isFrozen<T>(o: T): o is Readonly<T>Reflect.getdocument.getElementByIdadd genericArray.concatconcat\<K>(...items: K[]): (T | K)[]
Loose
parseIntallow number
Add error generic for Promise