dtsgenerator-optional-as-null

0.1.3 • Public • Published

dtsgenerator-optional-as-null

This is a dtsgenerator plugin.

Transform all the typescript optional fields to a union with the original type and null as members.

Install

npm install dtsgenerator-optional-as-null

Usage

dtsgen.json

{
  "plugins": {
    "dtsgenerator-optional-as-null": true
  }
}

or

{
  "plugins": {
    "dtsgenerator-optional-as-null": {
      "keepOptionals": true,
      "exclude": [
        "patterns",
        "to",
        "exclude"
      ]
    }
  }
}

Configuration

  • the type of configuration
type Config = {
  exclude: string[]; // list of regex patterns of filenames to exclude
  keepOptionals: boolean; // if optionals should be kept, defaults to `false`
};
  • Example
{
  "keepOptionals": true,
  "exclude": [
    "Petstore",
    "(Corp|Internal)Api"
  ]
}

Development

npm run build
npm test

Stacks

  • TypeScript
  • eslint
  • prettier

Files

  • index.ts: plugin main file
  • test/snapshot_test.ts: test main file. should not edit this file.
  • test/post_snapshots/: post process test patterns.

npm scripts

main scripts

  • npm run build: transpile this plugin. This command need before publishing this plugin.
  • npm test: test this plugin with coverage.
  • npm run clean: remove all compiled files.

sub scripts

  • npm run watch: watch editing files for compile.
  • npm run lint:fix: fix lint error automatically.
  • npm run test:update-snapshot: update snapshot files for unit test.
  • npm run coverage: report to coveralls. Need coveralls configuration file.

/dtsgenerator-optional-as-null/

    Package Sidebar

    Install

    npm i dtsgenerator-optional-as-null

    Weekly Downloads

    2

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    18.9 kB

    Total Files

    7

    Last publish

    Collaborators

    • rokkie