ts-todo
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

TODO for TypeScript

Utility function to indicate unfinished code by throwing with a message of "Not yet implemented".

This can be useful if you are prototyping and are just looking to have your code typecheck.

The difference between unimplemented and todo is that while todo conveys an intent of implementing the functionality later and the message is "Not yet implemented", unimplemented makes no such claims. Its message is "Not implemented".

Advantages over simply throwing an error:

  • You can easily search your codebase for todo()
  • The error thrown will have the code ERR_TODO
  • Very clear what intentions it conveys

Installation

npm install --save ts-todo

Usage

import todo from 'ts-todo'

// Here's an example of some in-progress code. We have a interface Foo:
interface Foo {
  bar(): string
  baz(): number
}

// We want to implement Foo on one of our types, but we also want to work on just bar() first.
// In order for our code to compile, we need to implement baz(), so we can use todo:
class MyClass implements Foo {
  bar () {
    return 'test'
  }

  baz () {
    return todo()
  }
}

Related Packages

Prior Art

/ts-todo/

    Package Sidebar

    Install

    npm i ts-todo

    Weekly Downloads

    5

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    2.14 kB

    Total Files

    4

    Last publish

    Collaborators

    • linusu