mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge pull request #5009 from RyanCavanaugh/fix4832
Correctly emit 'as' operator left operand as expression
This commit is contained in:
commit
784fe58e7e
@ -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:
|
||||
|
||||
22
tests/baselines/reference/asOperator4.js
Normal file
22
tests/baselines/reference/asOperator4.js
Normal 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;
|
||||
16
tests/baselines/reference/asOperator4.symbols
Normal file
16
tests/baselines/reference/asOperator4.symbols
Normal 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))
|
||||
|
||||
19
tests/baselines/reference/asOperator4.types
Normal file
19
tests/baselines/reference/asOperator4.types
Normal 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
|
||||
|
||||
@ -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);
|
||||
Loading…
x
Reference in New Issue
Block a user