question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typing to integer ignored

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kszilagyiOTcommented, Nov 26, 2019

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

0reactions
dobesvcommented, Dec 5, 2019

I used typescript 3.5.3. It does seem that in TypeScript 3.7 the annotations are parsed differently, so the code has to be updated. I opened a PR for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python cannot ignore str when input is int() - Stack Overflow
I want the program to ignore any str that it can't convert to an int. I tried declaring a variable that said type(input)....
Read more >
Fix text-formatted numbers by applying a number format
On the menu, click Convert to Number. (If you want to simply get rid of the error indicator without converting the number, click...
Read more >
Strict mode - Ajv JSON schema validator
Type "number" can be narrowed to "integer", the opposite would violate strictTypes . # Require applicable types. This simple JSON Schema is valid,...
Read more >
Ignore Types Or Values — DeepDiff 6.2.2 documentation
Ignore type changes between members of groups of types. For example if you want to ignore type changes between float and decimals etc....
Read more >
Common issues and solutions - mypy 0.991 documentation
A # type: ignore comment at the top of a module (before any statements, including imports or docstrings) has the effect of ignoring...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found