typescript_parser.py
Module for parsing TypeScript interfaces and types.
- class ts_backend_check.parsers.typescript_parser.TypeScriptInterface(name: str, properties: list[str], optional_properties: list[str], parents: list[str])[source]
Represents a TypeScript interface with its properties and parent interfaces.
- class ts_backend_check.parsers.typescript_parser.TypeScriptParser(concatenated_types_file: str)[source]
Parser for TypeScript interface files.
- Parameters:
- concatenated_types_filestr
The file path for the TypeScript file to parse.
- parse_interfaces() dict[str, TypeScriptInterface][source]
Parse TypeScript interfaces from the file.
- Returns:
- dict[str, TypeScriptInterface]
The interface parsed into a dictionary for future processing.
- get_ignored_fields() set[str][source]
Extract fields marked as ignored in comments.
- Returns:
- set[str]
The field names that are marked with a ts-backend-check ignore identifier.
- static _extract_properties(interface_body: str) list[str][source]
Extract both real properties and ‘ignored’ comment backend fields from interface bodies.
- Parameters:
- interface_bodystr
A string representation of the interface body of the model.
- Returns:
- list[str]
The property names from the model interface body.