0.1.3 • Published 3 years ago
dtsgenerator-optional-as-null v0.1.3
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-nullUsage
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 testStacks
- TypeScript
- eslint
- prettier
Files
index.ts: plugin main filetest/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.