import type { Node, Symbol, Type } from './ts-morph.ts'; export declare namespace Kind { /** Metadata present in all types. */ interface Shared { /** A stringified representation of the type. */ text: string; /** The path to the file where the symbol declaration is located. */ filePath?: string; /** The line and column number of the symbol declaration. */ position?: { start: { line: number; column: number; }; end: { line: number; column: number; }; }; } /** Metadata present in all type declarations. */ interface SharedDocumentable extends Shared { /** The name of the declaration. Implicit names will be undefined. */ name?: string; /** The description of the declaration if present. */ description?: string; /** JSDoc tags for the declaration if present. */ tags?: { name: string; text?: string; }[]; } interface String extends Shared { kind: 'String'; value?: string; } interface Number extends Shared { kind: 'Number'; value?: number; } interface Boolean extends Shared { kind: 'Boolean'; } interface Symbol extends Shared { kind: 'Symbol'; } interface Null extends Shared { kind: 'Null'; } interface Undefined extends Shared { kind: 'Undefined'; } interface BigInt extends Shared { kind: 'BigInt'; /** The literal value of the bigint if it is a bigint literal. */ value?: BigInteger; } interface TupleElement extends Shared { kind: 'TupleElement'; /** The label of the tuple element, e.g. `x` in `[x: number]`. */ name?: string; /** Element type or array element type for rest tuples. */ type: Type; /** Whether the element is written with a `...` rest prefix. */ isRest?: boolean; /** Whether the element has a question token, e.g. `[x?: number]`. */ isOptional?: boolean; /** Whether the element has a `readonly` modifier, e.g. `[readonly x: string]`. */ isReadonly?: boolean; } interface Tuple extends Shared { kind: 'Tuple'; /** The elements of the tuple. */ elements: TupleElement[]; /** Whether the tuple is readonly, e.g. `readonly [x: number]`. */ isReadonly?: boolean; } interface Object extends Shared { kind: 'Object'; } interface Void extends Shared { kind: 'Void'; } interface Any extends Shared { kind: 'Any'; } interface Unknown extends Shared { kind: 'Unknown'; } interface Never extends Shared { kind: 'Never'; } type MemberUnion = CallSignature | ConstructSignature | GetAccessorSignature | SetAccessorSignature | IndexSignature | MethodSignature | PropertySignature; interface TypeLiteral extends Shared { kind: 'TypeLiteral'; /** The member types of the type literal. */ members: Member[]; } interface IntersectionType extends Shared { kind: 'IntersectionType'; types: Type[]; } interface UnionType extends Shared { kind: 'UnionType'; types: Type[]; } interface MappedType extends Shared { kind: 'MappedType'; /** The type parameter e.g. `[Key in keyof Type]` for `{ [Key in keyof Type]: Type[Key] }`. */ typeParameter: TypeParameter; /** The resolved type e.g. `Type[Key]` for `{ [Key in keyof Type]: Type[Key] }`. */ type: TypeExpression; /** Whether the resolved keys are marked readonly. */ isReadonly?: boolean; /** Whether the resolved keys are marked optional. */ isOptional?: boolean; } interface ConditionalType extends Shared { kind: 'ConditionalType'; /** Left‑hand side of `Type extends Union ? … : …`. */ checkType: TypeExpression; /** Right‑hand side of the `extends` clause. */ extendsType: TypeExpression; /** Result when the `extends` test succeeds. */ trueType: TypeExpression; /** Result when the `extends` test fails. */ falseType: TypeExpression; /** * **`true`** when `checkType` is a *naked* type parameter * (e.g. `Type extends ...`) so the conditional will distribute over unions. * * **`false`** or `undefined` when `checkType` is wrapped * (e.g. `[Type]`, `Type[]`, `Promise`, `keyof Type`, etc.), which disables * distribution. */ isDistributive?: boolean; } interface InferType extends Shared { kind: 'InferType'; typeParameter: TypeParameter; } interface IndexedAccessType extends Shared { kind: 'IndexedAccessType'; /** The type of the object being indexed. */ objectType: TypeExpression; /** The type of the index. */ indexType: TypeExpression; } type IndexSignatureParameterType = Kind.String | Kind.Number | Kind.Symbol; interface IndexSignatureParameter extends Shared { kind: 'IndexSignatureParameter'; /** The name of the index signature parameter, e.g. `key` in `{ [key: string]: Type }`. */ name: string; /** The type of the index signature parameter, e.g. `string` in `{ [key: string]: Type }`. */ type: Type; } interface IndexSignature extends Shared { kind: 'IndexSignature'; parameter: IndexSignatureParameter; type: Type; isReadonly?: boolean; } interface EnumMember extends SharedDocumentable { kind: 'EnumMember'; /** The value of the enum member. */ value?: string | number; } interface Enum extends SharedDocumentable { kind: 'Enum'; members: EnumMember[]; } /** A function or method parameter. */ interface Parameter extends SharedDocumentable { kind: 'Parameter'; /** The type expression of the parameter. */ type: Type; /** The initialized value assigned to the parameter. */ initializer?: Initializer; /** Whether the parameter has an optional modifier or initialized value. If `isRest` is `true`, the parameter is always optional. */ isOptional?: boolean; /** Whether the parameter is a rest parameter, e.g. `...rest`. */ isRest?: boolean; } interface Class extends SharedDocumentable { kind: 'Class'; constructor?: ClassConstructor; accessors?: ClassAccessor[]; methods?: ClassMethod[]; properties?: ClassProperty[]; extends?: TypeReference | Any | Unknown; implements?: TypeReference[]; } interface ClassConstructor extends Shared { kind: 'ClassConstructor'; signatures: CallSignature[]; } interface SharedClassMember extends Shared { /** The name of the class member. */ name?: string; /** The scope modifier of the class member. If not provided, the member is related to the instance. */ scope?: 'abstract' | 'static'; /** The visibility modifier of the class member. If not provided, the member is assumed to be public. */ visibility?: 'public' | 'protected' | 'private'; /** Whether the property is an override of a base class property. */ isOverride?: boolean; } interface ClassGetAccessor extends SharedClassMember { kind: 'ClassGetAccessor'; /** The return type of the getter. */ returnType: TypeExpression; } interface ClassSetAccessor extends SharedClassMember { kind: 'ClassSetAccessor'; /** The parameter of the setter. */ parameter: Parameter; } type ClassAccessor = ClassGetAccessor | ClassSetAccessor; interface ClassMethod extends SharedClassMember { kind: 'ClassMethod'; signatures: CallSignature[]; } interface ClassProperty extends SharedClassMember { kind: 'ClassProperty'; /** The type of the class property. */ type: Type; /** The initialized value assigned to the property. */ initializer?: Initializer; /** Whether the property has a question token or initialized value. */ isOptional?: boolean; /** Whether the property has a readonly modifier. */ isReadonly?: boolean; } interface SharedCallable extends Shared { /** The parameters of the call signature. */ typeParameters?: TypeParameter[]; /** The type of `this` for the call signature. */ thisType?: TypeExpression; /** The return type of the call signature. */ returnType?: TypeExpression; /** Whether an async modifier is present or the return type includes a promise. */ isAsync?: boolean; /** Whether the call signature is a generator function. */ isGenerator?: boolean; } interface ConstructSignature extends SharedDocumentable, SharedCallable { kind: 'ConstructSignature'; parameters: Parameter[]; } interface CallSignature extends SharedDocumentable, SharedCallable { kind: 'CallSignature'; parameters: Parameter[]; } interface GetAccessorSignature extends SharedDocumentable, SharedCallable { kind: 'GetAccessorSignature'; /** The return type of the getter. */ returnType: TypeExpression; } interface SetAccessorSignature extends SharedDocumentable, SharedCallable { kind: 'SetAccessorSignature'; /** The parameter type of the setter. */ parameter: Parameter; } interface Function extends Shared { kind: 'Function'; /** The name of the function. */ name?: string; signatures: CallSignature[]; } interface FunctionType extends SharedCallable { kind: 'FunctionType'; parameters: Parameter[]; } type ComponentParameterTypeExpression = TypeLiteral | TypeReference; type ComponentParameter = Parameter | UnionType>; interface ComponentSignature extends SharedDocumentable, SharedCallable { kind: 'ComponentSignature'; parameter?: ComponentParameter; } interface Component extends SharedDocumentable { kind: 'Component'; signatures: ComponentSignature[]; } interface ComponentType extends SharedCallable { kind: 'ComponentType'; parameter?: ComponentParameter; } /** Represents a top-level `const`, `let`, or `var` statement. */ interface Variable extends SharedDocumentable { kind: 'Variable'; /** The annotated or inferred type of the variable. */ type: TypeExpression; } interface Interface extends SharedDocumentable { kind: 'Interface'; /** The member types of the interface. */ members: Member[]; /** The type parameters that can be provided as arguments to the type alias. */ typeParameters: TypeParameter[]; /** Base interfaces that this interface extends. */ extends?: TypeReference[]; } interface TypeParameter extends SharedDocumentable { kind: 'TypeParameter'; /** The constraint type of the type parameter. */ constraintType?: TypeExpression; /** The default type of the type parameter. */ defaultType?: TypeExpression; /** Whether the type parameter is an inferred type parameter. */ isInferred?: boolean; } /** Represents a type alias declaration e.g. `type Partial = { [Key in keyof Type]?: Type[Key] }`. */ interface TypeAlias extends SharedDocumentable { kind: 'TypeAlias'; /** The type expression. */ type: Type; /** The type parameters that can be provided as arguments to the type alias. */ typeParameters: TypeParameter[]; } interface TypeQuery extends Kind.Shared { kind: 'TypeQuery'; /** The name of the expression being queried, e.g. `getValue` in `typeof getValue`. */ name: string; /** The type arguments passed to the call site, e.g. `Type` in `typeof getValue`. */ typeArguments: TypeExpression[]; } /** Represents a type operator e.g. `keyof Type` or `readonly Type`. */ interface TypeOperator extends Kind.Shared { kind: 'TypeOperator'; /** The operator of the type operator e.g. `keyof` or `readonly`. */ operator: 'keyof' | 'readonly' | 'unique'; /** The type operand of the type operator e.g. `Type` in `keyof Type`. */ type: Type; } /** Represents when a type alias is used as a reference e.g. `Partial`. */ interface TypeReference extends Shared { kind: 'TypeReference'; /** The name of the referenced type. */ name?: string; /** The type arguments passed passed to the call site, e.g. `Type` in `Partial`. */ typeArguments?: TypeExpression[]; /** The module specifier where the referenced type is exported from (e.g. "react"). */ moduleSpecifier?: string; } /** An interface or type alias property signature. */ interface PropertySignature extends SharedDocumentable { kind: 'PropertySignature'; /** The type expression of the property signature. */ type: Type; /** Whether the property has an optional modifier. */ isOptional?: boolean; /** Whether the property has a readonly modifier. */ isReadonly?: boolean; } /** An interface or type alias method signature. */ interface MethodSignature extends SharedDocumentable { kind: 'MethodSignature'; signatures: CallSignature[]; } type TypeExpression = String | Number | Boolean | Symbol | BigInt | Object | Tuple | IntersectionType | UnionType | MappedType | ConditionalType | IndexedAccessType | FunctionType | ComponentType | TypeLiteral | TypeOperator | TypeQuery | TypeReference | InferType | Void | Null | Undefined | Any | Unknown | Never; interface Namespace extends SharedDocumentable { kind: 'Namespace'; /** All declarations exported from the namespace. */ types: Kind[]; } } export type Kind = Kind.TypeExpression | Kind.TupleElement | Kind.Class | Kind.ClassConstructor | Kind.ClassProperty | Kind.ClassMethod | Kind.ClassAccessor | Kind.Function | Kind.Component | Kind.Variable | Kind.Interface | Kind.Enum | Kind.EnumMember | Kind.TypeAlias | Kind.TypeParameter | Kind.CallSignature | Kind.ConstructSignature | Kind.GetAccessorSignature | Kind.SetAccessorSignature | Kind.ComponentSignature | Kind.MethodSignature | Kind.PropertySignature | Kind.IndexSignature | Kind.IndexSignatureParameter | Kind.Parameter | Kind.Namespace; export type TypeByKind = Type extends { kind: Key; } ? Type : never; export type TypeOfKind = TypeByKind; export type SymbolMetadata = ReturnType; export type SymbolFilter = (symbolMetadata: SymbolMetadata) => boolean; /** Describes one "include" rule. */ export interface FilterDescriptor { /** Package name that exported the type, e.g. `react`. Omit to match any package. */ moduleSpecifier?: string; /** One or more type selections. */ types: { /** Fully‑qualified name e.g. `React.ButtonHTMLAttributes`. */ name: string; /** Optional allowlist of property names for the matched type. */ properties?: string[]; }[]; } export type TypeFilter = FilterDescriptor | FilterDescriptor[]; declare module 'ts-morph' { namespace ts { interface Type { /** Internal compiler id. */ id: number; } } } export declare function withTypeResolutionMemoization(callback: () => Result): Result; /** Process type metadata. */ export declare function resolveType(type: Type, enclosingNode?: Node, filter?: TypeFilter, defaultValues?: Record | unknown, dependencies?: Set): Kind | undefined; export declare class UnresolvedTypeExpressionError extends Error { readonly type: Type; readonly enclosingNode?: Node; constructor(type: Type, enclosingNode?: Node); } declare function getSymbolMetadata(symbol?: Symbol, enclosingNode?: Node): { /** The name of the symbol if it exists. */ name?: string; /** Whether the symbol is exported. */ isExported: boolean; /** Whether the symbol is external to the current source file. */ isExternal: boolean; /** Whether the symbol is located in node_modules. */ isInNodeModules: boolean; /** Whether the symbol is global. */ isGlobal: boolean; /** Whether the node is generated by the compiler. */ isVirtual: boolean; /** Whether the symbol is private. */ isPrivate: boolean; /** The file path for the symbol declaration. */ filePath?: string; }; export {};