typescript-json-schema: Typing to integer ignored

It seems integer typing is broken currently; the following code (‘foo.ts’)

/**
 * @minimum 1
 * @TJS-type integer
 */
export type natural = number;

class Foo {
  bar: natural;
}

results in the following JSON schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
        "bar": {
            "minimum": 1,
            "type": "number"
        }
    },
    "type": "object"
}

bar should be an integer, but it gets casted to number.

We’ve confirmed this behaviour happening on multiple systems running MacOS, on different versions of this package.

This was working as intended at least 3 months ago (or so), perhaps sooner.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I had the same issue (but on an interface property). Apparently using @type instead of @TJS-type works with typescript 3.7