Skip to content

Commit

Permalink
fix: Reference types should always be given resolved symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Oct 25, 2020
1 parent cc9dc34 commit 1d6120f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/lib/converter/factories/reference.ts
Expand Up @@ -33,7 +33,11 @@ export function createReferenceType(
name = checker.symbolToString(symbol.parent) + "." + name;
}

return new ReferenceType(name, symbol, context.project);
return new ReferenceType(
name,
context.resolveAliasedSymbol(symbol),
context.project
);
}

export function createReferenceOrDeclarationReflection(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/plugins/DecoratorPlugin.ts
Expand Up @@ -92,7 +92,7 @@ export class DecoratorPlugin extends ConverterComponent {
if (type && type.symbol) {
info.type = new ReferenceType(
info.name,
type.symbol,
context.resolveAliasedSymbol(type.symbol),
context.project
);

Expand Down
22 changes: 17 additions & 5 deletions src/lib/converter/types.ts
Expand Up @@ -184,7 +184,7 @@ const exprWithTypeArgsConverter: TypeConverter<
node.typeArguments?.map((type) => convertType(context, type)) ?? [];
const ref = new ReferenceType(
targetSymbol.name,
targetSymbol,
context.resolveAliasedSymbol(targetSymbol),
context.project
);
ref.typeArguments = parameters;
Expand Down Expand Up @@ -358,7 +358,7 @@ const queryConverter: TypeConverter<ts.TypeQueryNode> = {
return new QueryType(
new ReferenceType(
node.exprName.getText(),
querySymbol,
context.resolveAliasedSymbol(querySymbol),
context.project
)
);
Expand All @@ -372,7 +372,11 @@ const queryConverter: TypeConverter<ts.TypeQueryNode> = {
)}. This is a bug.`
);
return new QueryType(
new ReferenceType(symbol.name, symbol, context.project)
new ReferenceType(
symbol.name,
context.resolveAliasedSymbol(symbol),
context.project
)
);
},
};
Expand All @@ -395,7 +399,11 @@ const referenceConverter: TypeConverter<
}
}

const type = new ReferenceType(name, symbol, context.project);
const type = new ReferenceType(
name,
context.resolveAliasedSymbol(symbol),
context.project
);
type.typeArguments = node.typeArguments?.map((type) =>
convertType(context, type)
);
Expand All @@ -410,7 +418,11 @@ const referenceConverter: TypeConverter<
return broken;
}

const ref = new ReferenceType(symbol.name, symbol, context.project);
const ref = new ReferenceType(
symbol.name,
context.resolveAliasedSymbol(symbol),
context.project
);
ref.typeArguments = type.aliasTypeArguments?.map((ref) =>
convertType(context, ref)
);
Expand Down

0 comments on commit 1d6120f

Please sign in to comment.