From b178bd8d493fba4092ae5c760ecae07445ae92b8 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 9 Mar 2024 15:46:56 -0500 Subject: [PATCH] feat: `TypeChecker.prototype.resolveName` --- deno/ts_morph.d.ts | 1 + deno/ts_morph.js | 4 ++++ packages/ts-morph/lib/ts-morph.d.ts | 1 + packages/ts-morph/src/compiler/tools/TypeChecker.ts | 5 +++++ 4 files changed, 11 insertions(+) diff --git a/deno/ts_morph.d.ts b/deno/ts_morph.d.ts index aaaf9635a..35780446c 100644 --- a/deno/ts_morph.d.ts +++ b/deno/ts_morph.d.ts @@ -9858,6 +9858,7 @@ export declare class TypeChecker { getTypeArguments(typeReference: Type): Type[]; /** Gets the shorthand assignment value symbol of the provided node. */ getShorthandAssignmentValueSymbol(node: Node): Symbol | undefined; + resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined; } export declare class Type { diff --git a/deno/ts_morph.js b/deno/ts_morph.js index d602fc99c..ea1e20cd2 100644 --- a/deno/ts_morph.js +++ b/deno/ts_morph.js @@ -17887,6 +17887,10 @@ class TypeChecker { const symbol = this.compilerObject.getShorthandAssignmentValueSymbol(node.compilerNode); return symbol ? this.#context.compilerFactory.getSymbol(symbol) : undefined; } + resolveName(name, location, meaning, excludeGlobals) { + const symbol = this.compilerObject.resolveName(name, location?.compilerNode, meaning, excludeGlobals); + return symbol ? this.#context.compilerFactory.getSymbol(symbol) : undefined; + } } class Program { diff --git a/packages/ts-morph/lib/ts-morph.d.ts b/packages/ts-morph/lib/ts-morph.d.ts index 3c2cb941a..0012b12f5 100644 --- a/packages/ts-morph/lib/ts-morph.d.ts +++ b/packages/ts-morph/lib/ts-morph.d.ts @@ -9858,6 +9858,7 @@ export declare class TypeChecker { getTypeArguments(typeReference: Type): Type[]; /** Gets the shorthand assignment value symbol of the provided node. */ getShorthandAssignmentValueSymbol(node: Node): Symbol | undefined; + resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined; } export declare class Type { diff --git a/packages/ts-morph/src/compiler/tools/TypeChecker.ts b/packages/ts-morph/src/compiler/tools/TypeChecker.ts index 4ca6bcb67..a36a3c977 100644 --- a/packages/ts-morph/src/compiler/tools/TypeChecker.ts +++ b/packages/ts-morph/src/compiler/tools/TypeChecker.ts @@ -271,4 +271,9 @@ export class TypeChecker { const symbol = this.compilerObject.getShorthandAssignmentValueSymbol(node.compilerNode); return symbol ? this.#context.compilerFactory.getSymbol(symbol) : undefined; } + + resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean) { + const symbol = this.compilerObject.resolveName(name, location?.compilerNode, meaning, excludeGlobals); + return symbol ? this.#context.compilerFactory.getSymbol(symbol) : undefined; + } }