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
6 changes: 3 additions & 3 deletions internal/printer/emitcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,11 +943,11 @@ func (c *EmitContext) VisitIterationBody(body *ast.Statement, visitor *ast.NodeV
}

func (c *EmitContext) VisitEmbeddedStatement(node *ast.Statement, visitor *ast.NodeVisitor) *ast.Statement {
embeddedStatement := visitor.VisitEmbeddedStatement(node)
if embeddedStatement == nil {
if node == nil {
return nil
}
if ast.IsNotEmittedStatement(embeddedStatement) {
embeddedStatement := visitor.VisitEmbeddedStatement(node)
if embeddedStatement == nil || ast.IsNotEmittedStatement(embeddedStatement) {
emptyStatement := visitor.Factory.NewEmptyStatement()
emptyStatement.Loc = node.Loc
c.SetOriginal(emptyStatement, node)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
typeOnlyExportAsIfBody.ts(1,11): error TS1233: An export declaration can only be used at the top level of a namespace or module.


==== typeOnlyExportAsIfBody.ts (1 errors) ====
if (true) export type {};
~~~~~~
!!! error TS1233: An export declaration can only be used at the top level of a namespace or module.

10 changes: 10 additions & 0 deletions testdata/baselines/reference/compiler/typeOnlyExportAsIfBody.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [tests/cases/compiler/typeOnlyExportAsIfBody.ts] ////

//// [typeOnlyExportAsIfBody.ts]
if (true) export type {};


//// [typeOnlyExportAsIfBody.js]
"use strict";
if (true)
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [tests/cases/compiler/typeOnlyExportAsIfBody.ts] ////

=== typeOnlyExportAsIfBody.ts ===

if (true) export type {};

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

=== typeOnlyExportAsIfBody.ts ===
if (true) export type {};
>true : true

4 changes: 4 additions & 0 deletions testdata/tests/cases/compiler/typeOnlyExportAsIfBody.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @module: esnext
// @moduleResolution: bundler

if (true) export type {};
Loading