mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
Read symbol declarations directly in code added after the checker helpers were removed
#1399 removed CheckerFacade.declarationsOf and valueDeclarationOf. #1407 and #1351 merged after it with calls to them, so main does not type-check. Read symbol.declarations and symbol.valueDeclaration instead, as the rest of the compiler does.
This commit is contained in:
@@ -153,7 +153,7 @@ function returnsThis(
|
||||
const name = callee.name.text;
|
||||
const symbol = lowerer.checker.getSymbolAtLocation(callee.name);
|
||||
if (symbol === undefined) return false;
|
||||
const methods: ts.Node[] = [...lowerer.checker.declarationsOf(symbol)];
|
||||
const methods: ts.Node[] = [...symbol.declarations];
|
||||
if (receiver === ts.SyntaxKind.ThisKeyword) {
|
||||
const pending = [...info.subclasses];
|
||||
while (pending.length > 0) {
|
||||
|
||||
@@ -2085,7 +2085,7 @@ function javaScriptAnyOrigin(lowerer: Lowerer, node: ts.Expression, depth: numbe
|
||||
: expr.expression;
|
||||
if (!ts.isIdentifier(callee)) return false;
|
||||
const symbol = lowerer.resolveValueSymbol(callee);
|
||||
const declarations = symbol ? lowerer.checker.declarationsOf(symbol) : [];
|
||||
const declarations = symbol ? symbol.declarations : [];
|
||||
return (
|
||||
declarations.length > 0 &&
|
||||
declarations.every((d) => isJsSourceFile(d.getSourceFile()) && ts.isFunctionLike(d))
|
||||
@@ -2093,7 +2093,7 @@ function javaScriptAnyOrigin(lowerer: Lowerer, node: ts.Expression, depth: numbe
|
||||
}
|
||||
if (ts.isIdentifier(expr) && depth === 0) {
|
||||
const symbol = lowerer.resolveValueSymbol(expr);
|
||||
const declaration = symbol ? lowerer.checker.valueDeclarationOf(symbol) : undefined;
|
||||
const declaration = symbol ? symbol.valueDeclaration : undefined;
|
||||
return (
|
||||
declaration !== undefined &&
|
||||
ts.isVariableDeclaration(declaration) &&
|
||||
|
||||
@@ -3195,8 +3195,7 @@ export class Lowerer {
|
||||
const symbol = part.getSymbol();
|
||||
return (
|
||||
(symbol?.name === "WeakMap" || symbol?.name === "WeakSet") &&
|
||||
this.checker
|
||||
.declarationsOf(symbol)
|
||||
symbol.declarations
|
||||
.some((d) => ts.isInterfaceDeclaration(d) && this.isStdlibFile(d.getSourceFile()))
|
||||
);
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ export function refuseModuleMemberThis(
|
||||
if (symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0)
|
||||
symbol = lowerer.checker.getAliasedSymbol(symbol);
|
||||
if (symbol === undefined) return;
|
||||
for (const decl of lowerer.checker.declarationsOf(symbol)) {
|
||||
for (const decl of symbol.declarations) {
|
||||
const fn = exportedFunction(decl);
|
||||
if (fn === null || !readsOwnThis(fn)) continue;
|
||||
lowerer.unsupported(
|
||||
|
||||
@@ -1360,8 +1360,7 @@ export function mapAsyncGeneratorAnnotation(type: ts.Type, ctx: TypeMapperCtx):
|
||||
if (
|
||||
!symbol ||
|
||||
!["AsyncIterator", "AsyncIterableIterator", "AsyncIterable"].includes(symbol.name) ||
|
||||
!checker
|
||||
.declarationsOf(symbol)
|
||||
!symbol.declarations
|
||||
.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(d.getSourceFile()))
|
||||
)
|
||||
return null;
|
||||
@@ -2505,8 +2504,7 @@ function mapTypeInner(type: ts.Type, ctx: TypeMapperCtx): IrType | null {
|
||||
if (
|
||||
psym &&
|
||||
WEBCRYPTO_DYN_TYPES.has(psym.name) &&
|
||||
checker
|
||||
.declarationsOf(psym)
|
||||
psym.declarations
|
||||
.some(
|
||||
(d) =>
|
||||
(ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) &&
|
||||
|
||||
Reference in New Issue
Block a user