Skip to content

Binary operator after TypeScript as assertion causes wrong SyntaxError #11446

@woongsikchoi

Description

@woongsikchoi

Bug Report

Current Behavior

If a bianry operator like >= appears directly after TypeScript as assertion, a wrong SyntaxError occurs.

Input Code

function foo(x: any) {
	return x as number >= 0;
}

The above code causes the following SyntaxError:

{ SyntaxError: test.ts: Unexpected token (2:22)
  1 | function foo(x: any) {
> 2 |   return x as number >= 0;
    |                       ^
  3 | }
  4 | 

Expected behavior/code

No SyntaxError should occur.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: .babelrc
{
  "presets": ["@babel/preset-typescript"]
}

Environment

  System:
    OS: Linux 4.4 Ubuntu 14.04.5 LTS, Trusty Tahr
  Binaries:
    Node: 10.15.1 - ~/local/lib/node-v10.15.1-linux-x64/bin/node
    Yarn: 1.22.4 - ~/local/lib/node-v10.15.1-linux-x64/bin/yarn
    npm: 6.9.0 - ~/local/lib/node-v10.15.1-linux-x64/bin/npm
  npmPackages:
    @babel/cli: ^7.8.4 => 7.8.4 
    @babel/core: ^7.9.0 => 7.9.0 
    @babel/preset-typescript: ^7.9.0 => 7.9.0 

Metadata

Metadata

Assignees

Labels

area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions