@hyrious/configs
v0.1.1
Published
Shared configs across my projects
Downloads
31
Readme
@hyrious/configs
Shared configs across my projects.
Usage
npm i -g @hyrious/configs
tsconfig.json
{ "extends": "@hyrious/configs/tsconfig.json" }
Default choice for normal projects.
{ "extends": "@hyrious/configs/tsconfig.strictest.json" }
The strictest
adds these configs aside from strict
:
- noFallthroughCasesInSwitch: true
- noImplicitOverride: true
- noPropertyAccessFromIndexSignature: true
- noUncheckedIndexedAccess: true
{ "extends": "@hyrious/configs/tsconfig.casual.json" }
Less strict mode, it alters these settings from strict
:
noImplicitAny: false
It allows you to writeglobalThis.debug = 1
without error.strictPropertyInitialization: false
It stops reporting error on uninitialized properties in constructor, which allows you to write aninitialize()
pattern of code.class Rectangle { x: number; y: number; width: number; height: number constructor() { this.initialize.apply(this, arguments) } initialize(x = 0, y = 0, width = 0, height = 0) { /* ... */ } }
Why this pattern? Because you can reuse other classes' constructors without hack.
// This is a valid and common usage of JavaScript. Rectangle.prototype.initialize.call(somethingNotRectangle, ...args)
useUnknownInCatchVariables: false
Make theerr
object in catch clause as type ofany
. Some people preferunknown
because it prevents stupid authors throwingnull
orundefined
which causeserr.message
become aTypeError: Cannot read properties of undefined
. But this is an insane idea and common codes just thrownew Error('message')
.noImplicitOverride: true
Must write anoverride
annotation before these methods. I just like this mark.useDefineForClassFields: false
class { foo = 1 }
becomesclass { constructor() { this.foo = 1 } }
.