typescript-plugin-unassert
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

typescript-plugin-unassert

CircleCI

Motivation

Assertion Functions is available from TypeScript 3.7, but assertion functions are called and processed always, even in production codes.

This plugin eliminates all of assert and assertIsDefined calls, that are introduced at the official page.

Getting Started

npm install --save-dev typescript-plugin-unassert ts-loader
# or
yarn add --dev typescript-plugin-unassert ts-loader

Write following lines in your webpack.config.json.

const unassertTransformer = require('typescript-plugin-unassert')
 
// snip
 
module.exports = {
  // snip
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        options: {
          getCustomTransformers: () => ({
            before: [unassertTransformer],
          }),
        },
        exclude: /node_modules/,
      },
    ],
  },
  // snip
}

Make sure to specify something except for "CommonJS" for the "module" property in tsconfig.json if you need tree shaking.

See example dir which is minimum usage.

Readme

Keywords

none

Package Sidebar

Install

npm i typescript-plugin-unassert

Weekly Downloads

25

Version

1.0.3

License

MIT

Unpacked Size

133 kB

Total Files

16

Last publish

Collaborators

  • januswel