Skip to content

Commit 105d239

Browse files
committed
Default to unknown instead of any where possible
1 parent 1a91ef0 commit 105d239

File tree

8 files changed

+743
-9518
lines changed

8 files changed

+743
-9518
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ See [server demo](example) and [browser demo](https://github.com/bcherny/json-sc
8989
| enableConstEnums | boolean | `true` | Prepend enums with [`const`](https://www.typescriptlang.org/docs/handbook/enums.html#computed-and-constant-members)? |
9090
| ignoreMinAndMaxItems | boolean | `false` | Ignore maxItems and minItems for `array` types, preventing tuples being generated. |
9191
| style | object | `{ bracketSpacing: false, printWidth: 120, semi: true, singleQuote: false, tabWidth: 2, trailingComma: 'none', useTabs: false }` | A [Prettier](https://prettier.io/docs/en/options.html) configuration |
92+
| unknownAny | boolean | `true` | Use `unknown` instead of `any` where possible |
9293
| unreachableDefinitions | boolean | `false` | Generates code for `definitions` that aren't referenced by the schema. |
9394
| strictIndexSignatures | boolean | `false` | Append all index signatures with `| undefined` so that they are strictly typed. |
9495
| $refOptions | object | `{}` | [$RefParser](https://github.com/BigstickCarpet/json-schema-ref-parser) Options, used when resolving `$ref`s |
95-
| unknownAny | boolean | `false` | Converts all `any` types into `unknown`'s |
9696
## CLI
9797

9898
A CLI utility is provided with this package.

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ Boolean values can be set to false using the 'no-' prefix.
164164
Prepend enums with 'const'?
165165
--style.XXX=YYY
166166
Prettier configuration
167-
--unreachableDefinitions
168-
Generates code for definitions that aren't referenced by the schema
169167
--unknownAny
170168
Output unknown type instead of any type
169+
--unreachableDefinitions
170+
Generates code for definitions that aren't referenced by the schema
171171
`
172172
)
173173
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const DEFAULT_OPTIONS: Options = {
8383
useTabs: false
8484
},
8585
unreachableDefinitions: false,
86-
unknownAny: false
86+
unknownAny: true
8787
}
8888

8989
export function compileFromFile(filename: string, options: Partial<Options> = DEFAULT_OPTIONS): Promise<string> {

0 commit comments

Comments
 (0)