diff --git a/model-lowerings/src/org/jetbrains/dukat/commonLowerings/substituteTsStdLibEntities.kt b/model-lowerings/src/org/jetbrains/dukat/commonLowerings/substituteTsStdLibEntities.kt index 8c4b1d42c..178b9d061 100644 --- a/model-lowerings/src/org/jetbrains/dukat/commonLowerings/substituteTsStdLibEntities.kt +++ b/model-lowerings/src/org/jetbrains/dukat/commonLowerings/substituteTsStdLibEntities.kt @@ -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")), @@ -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 diff --git a/typescript/ts-converter/src/ExportContext.ts b/typescript/ts-converter/src/ExportContext.ts index ed8169541..ba61f0423 100644 --- a/typescript/ts-converter/src/ExportContext.ts +++ b/typescript/ts-converter/src/ExportContext.ts @@ -15,9 +15,9 @@ function resolveName(node: ts.Node): string | null { } export function resolveDeclarations(node: ts.Identifier, typeChecker: ts.TypeChecker): Array { - let symbolAtLocation = typeChecker.getSymbolAtLocation(node); - if (symbolAtLocation) { + const symbolAtLocation = typeChecker.getSymbolAtLocation(node); + if (symbolAtLocation) { if (symbolAtLocation.flags & ts.SymbolFlags.TypeParameter) { return []; } @@ -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; }