Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ private fun TypeValueModel.createStdType(name: String): TypeValueModel {
private enum class SubstitutedEntities(val value: IdentifierEntity) {
NON_NULLABLE(IdentifierEntity("NonNullable")),
EXCLUDE(IdentifierEntity("Exclude")),
PICK(IdentifierEntity("Pick")),
REQUIRED(IdentifierEntity("Required")),
READONLY_ARRAY(IdentifierEntity("ReadonlyArray")),
TEMPLATE_STRINGS_ARRAY(IdentifierEntity("TemplateStringsArray")),
Expand All @@ -59,7 +60,13 @@ private enum class SubstitutedEntities(val value: IdentifierEntity) {
private fun TypeValueModel.resolveAsSubstitution(): TypeValueModel? {
val isLibReference = isLibReference()

return if (value == SubstitutedEntities.NON_NULLABLE.value || value == SubstitutedEntities.EXCLUDE.value || value == SubstitutedEntities.REQUIRED.value || value == SubstitutedEntities.OBJECT.value) {
return if (
value == SubstitutedEntities.NON_NULLABLE.value ||
value == SubstitutedEntities.EXCLUDE.value ||
value == SubstitutedEntities.PICK.value ||
value == SubstitutedEntities.REQUIRED.value ||
value == SubstitutedEntities.OBJECT.value
) {
if (isLibReference) {
createStdType("Any")
} else null
Expand Down
8 changes: 5 additions & 3 deletions typescript/ts-converter/src/ExportContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ function resolveName(node: ts.Node): string | null {
}

export function resolveDeclarations(node: ts.Identifier, typeChecker: ts.TypeChecker): Array<ts.Node> {
let symbolAtLocation = typeChecker.getSymbolAtLocation(node);
if (symbolAtLocation) {
const symbolAtLocation = typeChecker.getSymbolAtLocation(node);

if (symbolAtLocation) {
if (symbolAtLocation.flags & ts.SymbolFlags.TypeParameter) {
return [];
}
Expand All @@ -44,7 +44,9 @@ export function resolveDeclarations(node: ts.Identifier, typeChecker: ts.TypeChe
}
}

let symbol = typeChecker.getTypeAtLocation(node).symbol;
const type = typeChecker.getTypeAtLocation(node)
const symbol = type.aliasSymbol || type.symbol;

if (symbol && Array.isArray(symbol.declarations)) {
return symbol.declarations;
}
Expand Down