Skip to content

Invalid output of dynamic import with template string argument in ES5. #16886

Closed
@odensc

Description

@odensc

TypeScript Version: 2.4.1 / nightly (2.5.0-dev.20170629)

Code

import(`./${"module"}`)

Expected behavior:
Output of:

import("./" + "module");

Actual behavior:
Output of:

(import)("./" + "module");

Using "target": "es5" and "module": "esnext", TypeScript outputs invalid syntax for the dynamic import expression, wrapping it in parentheses.

Using a target of es2015 or higher, TypeScript outputs valid syntax with no parentheses.

This is only happens if import is given a template string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions