• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* @internal */
2namespace ts.refactor {
3    /**
4     * Returned by refactor functions when some error message needs to be surfaced to users.
5     */
6    export interface RefactorErrorInfo {
7        error: string;
8    }
9
10    /**
11     * Checks if some refactor info has refactor error info.
12     */
13    export function isRefactorErrorInfo(info: unknown): info is RefactorErrorInfo {
14        return (info as RefactorErrorInfo).error !== undefined;
15    }
16
17    /**
18     * Checks if string "known" begins with string "requested".
19     * Used to match requested kinds with a known kind.
20     */
21    export function refactorKindBeginsWith(known: string, requested: string | undefined): boolean {
22        if(!requested) return true;
23        return known.substr(0, requested.length) === requested;
24    }
25}
26