DTS generator plugin that turns optional fields into nullable fields
npm install dtsgenerator-optional-as-nullThis 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`json`
{
"plugins": {
"dtsgenerator-optional-as-null": true
}
}`
orjson`
{
"plugins": {
"dtsgenerator-optional-as-null": {
"keepOptionals": true,
"exclude": [
"patterns",
"to",
"exclude"
]
}
}
}
- the type of configuration
`tsfalse
type Config = {
exclude: string[]; // list of regex patterns of filenames to exclude
keepOptionals: boolean; // if optionals should be kept, defaults to `
};
- Example
`json`
{
"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.
-