Asserting type with help of TypeScript compiler
npm install static-type-assertAsserting type with help of TypeScript compiler
* Node.js ≥ 8.9.0
* TypeScript ≥ 3.0.0
Example: pass.ts
``typescript
import assert from 'static-type-assert'
// Comma-separated parameters
assert
assert
// Curry function calls
assert<'abc' | 'def' | 123 | 456>('abc')(123)('def')(456)
// Combine
assert
`
Example: fail.ts
`typescript`
import assert from 'static-type-assert'
assert
`sh`
tsc --noEmit
Example: pass.ts
`sh`
tsc --noEmit pass.ts # Expects to pass (no errors)
Example: fail.ts
`sh``
tsc --noEmit fail.ts # Expects errors