Miscellaneous notes #4
Replies: 2 comments 4 replies
-
Is there a standard way to write a TS interface so that names, types, defaults and descriptions can be parsed out in a robust manner? Creating TypeScript interfaces in a standardized way to facilitate parsing and extraction of names, types, default values, and descriptions can indeed enhance the robustness of the process. Here's a guideline for structuring TypeScript interfaces to make them more parser-friendly:
Example of a well-structured TypeScript interface: export interface ExampleInterface {
/**
* Description of stringProperty.
* @default "defaultString"
*/
stringProperty: string;
/**
* Description of optionalNumberProperty.
* @default 10
*/
optionalNumberProperty?: number;
/**
* Description of booleanProperty.
* @default false
*/
booleanProperty: boolean;
} This structure allows a parser to look for specific patterns, such as lines starting with Using a well-defined structure like this greatly improves the reliability of parsing, as it reduces ambiguities and variations in the format. However, it's important to ensure that everyone who contributes to the codebase adheres to these standards. Automated tools like linters can help enforce these conventions. |
Beta Was this translation helpful? Give feedback.
-
Parsing TypescriptIn order to get more single-source-of-truth in parameter information (in code, documentation, and python interfaces), I looked into TS parsers. I wrote jy.parse_ts to start this effort. It works partially only, but it is setup to easily be extendable (by just adding elements in the I managed to get something working with tree-sitter, along with tree-sitter-typescript, but to make it work, I had to downgrade tree-sitter to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
To record miscellaneous notes and ideas and resources and discuss them.
Beta Was this translation helpful? Give feedback.
All reactions