Skip to content

Commit

Permalink
feat: TypeChecker.prototype.resolveName (#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Mar 9, 2024
1 parent e8b5727 commit ca77636
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions deno/ts_morph.d.ts
Expand Up @@ -9860,6 +9860,7 @@ export declare class TypeChecker {
isTypeAssignableTo(sourceType: Type, targetType: Type): boolean;
/** 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<TType extends ts.Type = ts.Type> {
Expand Down
4 changes: 4 additions & 0 deletions deno/ts_morph.js
Expand Up @@ -17890,6 +17890,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 {
Expand Down
1 change: 1 addition & 0 deletions packages/ts-morph/lib/ts-morph.d.ts
Expand Up @@ -9860,6 +9860,7 @@ export declare class TypeChecker {
isTypeAssignableTo(sourceType: Type, targetType: Type): boolean;
/** 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<TType extends ts.Type = ts.Type> {
Expand Down
5 changes: 5 additions & 0 deletions packages/ts-morph/src/compiler/tools/TypeChecker.ts
Expand Up @@ -276,4 +276,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;
}
}

0 comments on commit ca77636

Please sign in to comment.