diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index db2a749c4d8..efc45273b47 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1434,6 +1434,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let parent = node.parent; switch (parent.kind) { case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.AsExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.CallExpression: case SyntaxKind.CaseClause: diff --git a/tests/baselines/reference/asOperator4.js b/tests/baselines/reference/asOperator4.js new file mode 100644 index 00000000000..906b807fe73 --- /dev/null +++ b/tests/baselines/reference/asOperator4.js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/expressions/asOperator/asOperator4.ts] //// + +//// [foo.ts] + +export function foo() { } + +//// [bar.ts] +import { foo } from './foo'; + +// These should emit identically +foo; +(foo as any); + + +//// [foo.js] +function foo() { } +exports.foo = foo; +//// [bar.js] +var foo_1 = require('./foo'); +// These should emit identically +foo_1.foo; +foo_1.foo; diff --git a/tests/baselines/reference/asOperator4.symbols b/tests/baselines/reference/asOperator4.symbols new file mode 100644 index 00000000000..4ee5f6fe83f --- /dev/null +++ b/tests/baselines/reference/asOperator4.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/expressions/asOperator/foo.ts === + +export function foo() { } +>foo : Symbol(foo, Decl(foo.ts, 0, 0)) + +=== tests/cases/conformance/expressions/asOperator/bar.ts === +import { foo } from './foo'; +>foo : Symbol(foo, Decl(bar.ts, 0, 8)) + +// These should emit identically +foo; +>foo : Symbol(foo, Decl(bar.ts, 0, 8)) + +(foo as any); +>foo : Symbol(foo, Decl(bar.ts, 0, 8)) + diff --git a/tests/baselines/reference/asOperator4.types b/tests/baselines/reference/asOperator4.types new file mode 100644 index 00000000000..0dc6be46a2c --- /dev/null +++ b/tests/baselines/reference/asOperator4.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/expressions/asOperator/foo.ts === + +export function foo() { } +>foo : () => void + +=== tests/cases/conformance/expressions/asOperator/bar.ts === +import { foo } from './foo'; +>foo : () => void + +// These should emit identically +foo; +>foo : any +>foo : () => void + +(foo as any); +>(foo as any) : any +>foo as any : any +>foo : () => void + diff --git a/tests/cases/conformance/expressions/asOperator/asOperator4.ts b/tests/cases/conformance/expressions/asOperator/asOperator4.ts new file mode 100644 index 00000000000..33fcbf920a1 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator4.ts @@ -0,0 +1,11 @@ +//@module: commonjs +//@filename: foo.ts + +export function foo() { } + +//@filename: bar.ts +import { foo } from './foo'; + +// These should emit identically +foo; +(foo as any);