Skip to content
Merged
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
7 changes: 6 additions & 1 deletion tsc/internal/transformers/declarations/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -1791,12 +1791,17 @@ func (tx *DeclarationTransformer) transformTopLevelDeclaration(input *ast.Node)

func (tx *DeclarationTransformer) transformTypeAliasDeclaration(input *ast.TypeAliasDeclaration) *ast.Node {
tx.needsDeclare = false
t := tx.Visitor().Visit(input.Type)
if t == nil {
// stripInternal can elide an @internal type RHS; fall back like index signatures
t = tx.Factory().NewKeywordTypeNode(ast.KindAnyKeyword)
}
return tx.Factory().UpdateTypeAliasDeclaration(
input,
tx.ensureModifiers(input.AsNode()),
input.Name(),
tx.Visitor().VisitNodes(input.TypeParameters),
tx.Visitor().Visit(input.Type),
t,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//// [tests/cases/compiler/declarationEmitStripInternalTypeAliasRHS.ts] ////

//// [declarationEmitStripInternalTypeAliasRHS.ts]
interface Foo {}
export type T =
/** @internal */
Foo;


//// [declarationEmitStripInternalTypeAliasRHS.js]
export {};


//// [declarationEmitStripInternalTypeAliasRHS.d.ts]
export type T = any;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/declarationEmitStripInternalTypeAliasRHS.ts] ////

=== declarationEmitStripInternalTypeAliasRHS.ts ===
interface Foo {}
>Foo : Symbol(Foo, Decl(declarationEmitStripInternalTypeAliasRHS.ts, 0, 0))

export type T =
>T : Symbol(T, Decl(declarationEmitStripInternalTypeAliasRHS.ts, 0, 16))

/** @internal */
Foo;
>Foo : Symbol(Foo, Decl(declarationEmitStripInternalTypeAliasRHS.ts, 0, 0))

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [tests/cases/compiler/declarationEmitStripInternalTypeAliasRHS.ts] ////

=== declarationEmitStripInternalTypeAliasRHS.ts ===
interface Foo {}
export type T =
>T : Foo

/** @internal */
Foo;

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @declaration: true
// @stripInternal: true

interface Foo {}
export type T =
/** @internal */
Foo;
Loading