/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { Type, TypeChecker } from "ts-morph"; export interface DecompositionResult { /** * The decomposed type with external types replaced with strings */ typeAsString: string; /** * External types that have been replaced */ replacedTypes: Set; /** * Generic classes that are required for the class because * they can't be replaced without disrupting type structure * Mapping is name to number of type params */ requiredGenerics: GenericsInfo; } /** * Class to track information on generic classes found during type decomposition * Actual breaking change detection of those classes is handled where they are * exported */ export declare class GenericsInfo extends Map { static builtIns: string[]; set(key: string, value: number): this; merge(from: Map): void; } /** * Get the string name of a type without needing to worry about if it's a primitive, an imported * type, etc. (ts-morph doesn't expose this fn on TypeChecker and it gets verbose to use inline) * @param typeChecker - TypeChecker object from the type's TS project to get the type string * @param type - Type node to get string representation * @returns The type as a string */ export declare function typeToString(typeChecker: TypeChecker, type: Type): string; /** * Break down a complex type to extract its constituents, then reconstruct it with type -\> string * replacement, e.g. `Promise` -\> * `Promise<"UncomparableClass" | "OtherClass">` * This removes external dependencies from the type while preserving its structure, where those * external types can be checked separately. Structure must be preserved to check back-compat. * * TODO: handle multiple type args/params in result output * TODO: handle type constraints * TODO: handle conditional types * TODO: handle inline object types * TODO: handle tuple types * TODO: handle default values * TODO: handle index types, splat, rest * @param checker - The TypeChecker object from the node's TS project for getting type names * @param node - The type node to decompose * @returns DecompositionResult for the type */ export declare function decomposeType(checker: TypeChecker, node: Type): DecompositionResult; /** * Decompose multiple types, concatenate their type as string results using the provided * separator, and merge their external type lists * @param checker - The TypeChecker object from the node's TS project for getting type names * @param nodes - The type nodes to decompose * @param separator - String separator used to merge the results of the decomposition * @returns Combined DecompositionResult for the types */ export declare function decomposeTypes(checker: TypeChecker, nodes: Type[], separator: string): DecompositionResult; //# sourceMappingURL=typeDecomposition.d.ts.map