@xdc/todo
v1.0.2
Published
A type safe TDD/BDD helper for catching unimplemented TypeScript functions
Downloads
24
Maintainers
Readme
XDC TODO
Latest npm package
Master branch
Trap //TODO
functions in tests with TODO()
Ideal for use in boilerplate implementation code, replace //TODO comments in your new-function templates.
Installation:
npm i -D @xdc/todo
A type safe function implementation placeholder as an alternative to TODO comments for TDD and BDD coding sessions
Provides a TODO
function similar to Scala's ???
to call in a default function implementation when developing node modules in TypeScript. (also works in ES6)
This means you can then define new functions with explicit return types that won't cause compile errors (and IDE highlighting) but will still cause your tests to fail.
TODO
throws an error when called after importing, or when the module is require(...)
'd, and outputs the parent module's information and an optional string to specify a calling function's name.
// Use via an import
import TODO from '@xdc/todo'
//
// ... some more code ...
//
// this implementation is better than //TODO...
function someNewFunction(): SomeType {
return TODO('someNewFunction')
}
// you can omit the function name in the call
function someNewFunction(): SomeType {
return TODO()
}
// OR use via require(...)
// - even use a completely different function name
function someNewFunction(): SomeType {
require('@xdc/todo').
TODO('anotherFunctionName') // also works for import style calls
}
// OR just require the module without calling anything else
function someNewFunction(): SomeType {
require('@xdc/todo')
}