Merge pull request #5009 from RyanCavanaugh/fix4832

Correctly emit 'as' operator left operand as expression
This commit is contained in:
Ryan Cavanaugh 2015-09-29 11:14:52 -07:00
commit 784fe58e7e
5 changed files with 69 additions and 0 deletions

View File

@ -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:

View File

@ -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
<any>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;

View File

@ -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
<any>foo;
>foo : Symbol(foo, Decl(bar.ts, 0, 8))
(foo as any);
>foo : Symbol(foo, Decl(bar.ts, 0, 8))

View File

@ -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
<any>foo;
><any>foo : any
>foo : () => void
(foo as any);
>(foo as any) : any
>foo as any : any
>foo : () => void

View File

@ -0,0 +1,11 @@
//@module: commonjs
//@filename: foo.ts
export function foo() { }
//@filename: bar.ts
import { foo } from './foo';
// These should emit identically
<any>foo;
(foo as any);