UNPKG

typescript

Version:

TypeScript is a language for application scale JavaScript development

183 lines • 9.48 kB
import type { DiagnosticDirectivePolicy } from "../../enums/diagnosticDirectivePolicy.js"; import type { InternalSymbolName } from "../../enums/internalSymbolName.js"; import type { LanguageVariant } from "../../enums/languageVariant.js"; import type { NodeFlags } from "../../enums/nodeFlags.js"; import type { ScriptKind } from "../../enums/scriptKind.js"; import { SyntaxKind } from "../../enums/syntaxKind.js"; import type { AssertionExpression, BindingElement, CaseClause, ComputedPropertyName, Decorator, DefaultClause, DoStatement, EndOfFile, EntityName, EnumMember, Expression, ExpressionStatement, ForInStatement, ForOfStatement, ForStatement, Identifier, IfStatement, JsxAttribute, JsxExpression, JsxSpreadAttribute, KeywordSyntaxKind, ModifierSyntaxKind, ParameterDeclaration, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, PunctuationSyntaxKind, ReturnStatement, SatisfiesExpression, ShorthandPropertyAssignment, SpreadAssignment, Statement, SwitchStatement, TemplateSpan, ThisExpression, ThrowStatement, Token, VariableDeclaration, WhileStatement, WithStatement } from "./ast.generated.ts"; import type { SpanMap } from "./spanMap.ts"; export { SyntaxKind } from "../../enums/syntaxKind.js"; export { TokenFlags } from "../../enums/tokenFlags.js"; export * from "./ast.generated.ts"; export * as factory from "./factory.generated.ts"; declare const rootedPathBrand: unique symbol; declare const rootedFilePathBrand: unique symbol; declare const rootedDirectoryPathBrand: unique symbol; declare const pathKeyBrand: unique symbol; /** * A rooted, slash-normalized, lexically normalized path that may represent * either a file or a directory. It preserves path casing. * * Rooted path types and canonical path keys are related as follows: * * ```text * RootedFilePath * / * string --> RootedPath * \ * RootedDirectoryPath * * RootedPath + CaseSensitivity --> PathKey * ``` * * Use `toRootedPath`, `toRootedFilePath`, or `toRootedDirectoryPath` for a * path that may be relative and needs resolution against a current directory. * Use `rootedPathFromNormalized` only when the input is already rooted and * normalized. Use `pathKey` only when a canonical key is needed for a * comparison, set, or map lookup. */ export type RootedPath = string & { readonly [rootedPathBrand]: void; }; /** * A {@link RootedPath} intended to be used as a file path. It does not assert * that the path exists or is a file on a filesystem. */ export type RootedFilePath = RootedPath & { readonly [rootedFilePathBrand]: void; }; /** * A {@link RootedPath} intended to be used as a directory path. It does not * assert that the path exists or is a directory on a filesystem, and does not * guarantee a trailing directory separator. */ export type RootedDirectoryPath = RootedPath & { readonly [rootedDirectoryPathBrand]: void; }; /** * A canonical key for a rooted, normalized path under a caller-selected * `CaseSensitivity`. Keys are comparable only when they use the same * `CaseSensitivity`. A `PathKey` is for comparison and lookup, and must not be * used as a {@link RootedPath} because canonicalization may have changed its * casing. It does not assert that the path exists. */ export type PathKey = string & { readonly [pathKeyBrand]: void; }; /** * The escaped form of a symbol/identifier name. Internal compiler names are * prefixed with `__` (e.g. `__type`, `__call`), and user names that already * begin with `__` carry an extra leading underscore. Use * {@link unescapeLeadingUnderscores} to recover the display name and * {@link escapeLeadingUnderscores} to produce a key from a display name. */ export type __String = (string & { __escapedIdentifier: void; }) | InternalSymbolName; export interface TextRange { pos: number; end: number; } export interface ReadonlyTextRange { readonly pos: number; readonly end: number; } export interface NodeArray<T extends Node> extends ReadonlyArray<T>, ReadonlyTextRange { hasTrailingComma?: boolean; transformFlags: number; } export interface Node extends ReadonlyTextRange { readonly kind: SyntaxKind; readonly flags: NodeFlags; readonly parent: Node; readonly jsDoc?: readonly Node[] | undefined; childrenIter<TNext = void>(): Generator<Node, TNext | undefined, TNext>; forEachChild<T>(visitor: (node: Node) => T, visitArray?: (nodes: NodeArray<Node>) => T): T | undefined; getSourceFile(): SourceFile; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; getWidth(sourceFile?: SourceFile): number; getFullWidth(): number; getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): readonly Node[]; getFirstToken(sourceFile?: SourceFile): Node | undefined; getLastToken(sourceFile?: SourceFile): Node | undefined; } export interface FileReference extends TextRange { readonly fileName: string; readonly resolutionMode: number; readonly preserve: boolean; } export interface LineAndCharacter { /** 0-based line number. */ readonly line: number; /** 0-based character offset, in UTF-16 code units, from the start of the line. */ readonly character: number; } export interface MappedDiagnosticDirective { readonly originalRange: ReadonlyTextRange; readonly virtualRange: ReadonlyTextRange; readonly policy: DiagnosticDirectivePolicy; readonly unusedCode: number; } export interface SourceFile extends Node { readonly kind: SyntaxKind.SourceFile; readonly statements: NodeArray<Statement>; readonly endOfFileToken: EndOfFile; readonly text: string; readonly originalText: string; readonly spanMap: SpanMap | undefined; /** Identity of the content mapper that produced this source file. */ readonly contentMapper?: string; /** Filename used to determine the syntax and module semantics of the transformed content. */ readonly virtualFileName?: RootedFilePath; /** Framework-specific diagnostic directives applied to the transformed content. */ readonly diagnosticDirectives?: readonly MappedDiagnosticDirective[]; /** Compiler-assigned filenames of supplemental outputs associated with this canonical source file. */ readonly supplementalSourceFileNames?: readonly RootedFilePath[]; /** Canonical source filename associated with this supplemental output, if this is supplemental. */ readonly canonicalSourceFileName?: RootedFilePath; readonly fileName: RootedFilePath; readonly path: PathKey; readonly languageVariant: LanguageVariant; readonly scriptKind: ScriptKind; readonly isDeclarationFile: boolean; readonly referencedFiles: readonly FileReference[]; readonly typeReferenceDirectives: readonly FileReference[]; readonly libReferenceDirectives: readonly FileReference[]; readonly imports: readonly Node[]; readonly moduleAugmentations: readonly Node[]; readonly ambientModuleNames: readonly string[]; readonly externalModuleIndicator: Node | true | undefined; /** Returns the UTF-16 code unit offset of the start of each line. */ getLineStarts(): readonly number[]; /** Converts a UTF-16 code unit position into a 0-based line and character. */ getLineAndCharacterOfPosition(position: number): LineAndCharacter; /** Converts a 0-based line and character into a UTF-16 code unit position. */ getPositionOfLineAndCharacter(line: number, character: number): number; } export type PunctuationToken<TKind extends PunctuationSyntaxKind> = Token<TKind>; export type KeywordToken<TKind extends KeywordSyntaxKind> = Token<TKind>; export type ModifierToken<TKind extends ModifierSyntaxKind> = KeywordToken<TKind>; export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { readonly expression: EntityNameExpression; readonly name: Identifier; } export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { readonly expression: Identifier | ThisExpression | JsxTagNamePropertyAccess; } export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | EnumMember; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; export type HasIllegalExpressionInitializer = PropertySignatureDeclaration; export type HasExpression = ExpressionStatement | IfStatement | DoStatement | WhileStatement | ReturnStatement | WithStatement | SwitchStatement | CaseClause | DefaultClause | ThrowStatement | AssertionExpression | TemplateSpan | ComputedPropertyName | Decorator | JsxExpression | JsxSpreadAttribute | SpreadAssignment | SatisfiesExpression; export interface ObjectAssignmentInitializer extends ShorthandPropertyAssignment { readonly objectAssignmentInitializer: Expression; } //# sourceMappingURL=ast.d.ts.map