This is a dtsgenerator plugin.
Transform all the typescript optional fields to a union with the original type and null as members.
npm install dtsgenerator-optional-as-null
dtsgen.json
{
"plugins": {
"dtsgenerator-optional-as-null": true
}
}or
{
"plugins": {
"dtsgenerator-optional-as-null": {
"keepOptionals": true,
"exclude": [
"patterns",
"to",
"exclude"
]
}
}
}- 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"
]
}npm run build
npm test
- TypeScript
- eslint
- prettier
index.ts: plugin main filetest/snapshot_test.ts: test main file. should not edit this file.test/post_snapshots/: post process test patterns.
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.
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.