Skip to content

Commit 234757c

Browse files
dobesvdomoritz
andauthored
Document integer type alias feature (#328)
Co-authored-by: Dominik Moritz <[email protected]>
1 parent 3ad43e7 commit 234757c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ Translation:
223223

224224
This same syntax can be used for `contains` and `additionalProperties`.
225225

226+
### `integer` type alias
227+
228+
If you create a type alias `integer` for `number` it will be mapped to the `integer` type in the generated JSON schema.
229+
230+
Example:
231+
232+
```typescript
233+
type integer = number;
234+
interface MyObject {
235+
n: integer;
236+
}
237+
```
238+
239+
Note: this feature doesn't work for generic types & array types, it mainly works in very simple cases.
240+
226241
## Background
227242

228243
Inspired and builds upon [Typson](https://github.com/lbovet/typson/), but typescript-json-schema is compatible with more recent Typescript versions. Also, since it uses the Typescript compiler internally, more advanced scenarios are possible. If you are looking for a library that uses the AST instead of the type hierarchy and therefore better support for type aliases, have a look at [vega/ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator).

0 commit comments

Comments
 (0)