kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

Structurize BigInt #35

Closed kungfooman closed 10 months ago

kungfooman commented 10 months ago

Example:

/** @typedef {1n | 2n} BigIntOneOrTwo */

For example in Babel-TS the AST of 1n is:

        {
          "type": "BigIntLiteral",
          "start": 0,
          "end": 2,
          "loc": {
            "start": {
              "line": 1,
              "column": 0,
              "index": 0
            },
            "end": {
              "line": 1,
              "column": 2,
              "index": 2
            }
          },
          "extra": {
            "rawValue": "1",
            "raw": "1n"
          },
          "value": "1"
        }

Boiling the crucial information down, we can have this JSON:

{
  "type": "bigint",
  "literal": "1"
}

Whereas the simple bigint keyword turns into:

{
  "type": "bigint"
}