Skip to content

Value tokens are not part of public API #823

@skynetigor

Description

@skynetigor

Is there a special reason why the public API does not export value tokens?
By being able to use these typings, we would be able to implement more robust completions, validations, etc.
It exports the union type ValueToken, but doesn't export every individual token. It turns out that ValueToken is not usable enough...

type ValueToken = RangeToken | LiteralToken | QuotedToken | PropertyAccessToken | NumberToken

For example, in my project I'm trying to implement input variables extraction (ones that come externally).
But for RangeToken I can't extract the range items and have to parse node text manually:

if (node.kind === TokenKind.Range) {
      const rangeText = node.getText();
      // Extract start and end from range like "(start..end)" or "1..5"
      const vars = rangeText
        .replace(/[()]/g, '')
        .split('..')
        .map((v) => v.trim())
        .filter(
          (v) => !/^\d+$/.test(v) && !stack.toReversed().some((frame) => frame.variables.has(v))
        );
      return vars;
    }

Although I do see that the data I need I can take from RangeToken (lhs, rhs):

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions