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.

Generation of d.ts signatures for CST Parsers

See original GitHub issue

Such a feature would more easily enable consuming a CST exported by a parser Rather than requiring a transformation to a more well defined AST kind of structure.

Example:


export interface IJsonValueChildren {
       StringLiteral?: IStringLiteral[]
}

export interface IJsonValue {
   name: "JsonValue"
   children: IJsonValueChildren 
}

export interface JsonCstVisitor<I, O> {
    visitJsonValue(ctx: IJsonValueChildren , param:I):O
}

Random Thoughts:

  • Could this signature generation be extensible?
    • e.g: to support customization of the CST by end users.
  • Does TypeScript support defining the dimension of arrays?
    •     StringLiteral?: IStringLiteral[1]
      
  • It should be possible to distinguish between optional (“?”) and mandatory properties on the CST.
    • If error recovery is enabled all children props are by definition optional.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
bd82commented, Jan 18, 2022
1reaction
bd82commented, Oct 9, 2021

The package to generate the signatures is available here:

Additional refactoring / docs is needed to export it from the root chevrotain package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generation of d.ts signatures for CST Parsers #851 - GitHub
Random Thoughts: Could this signature generation be extensible? e.g: to support customization of the CST by end users. Does TypeScript support ...
Read more >
Generation of TypeScript Declaration Files from JavaScript Code
This work presents dts-generate, a tool that generates. TypeScript declaration files for JavaScript libraries uploaded to the NPM registry.
Read more >
Documentation - Creating .d.ts Files from .js files - TypeScript
With TypeScript 3.7, TypeScript added support for generating .d.ts files from JavaScript using JSDoc syntax. This set up means you can own the...
Read more >
Type-Level GraphQL Parsing and Desirable Features for ...
The CAT option has the directive mean , which accepts no input. ... Moving parsing (for the sake of generating .d.ts) into the...
Read more >
CST | Chevrotain
See the full CstNode type signature open in new window · Explore it by running the CST creation example in the online playground...
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