Skip to content

Import assignment does not emit import statement in ESNEXT #19500

Closed
@janv

Description

@janv

TypeScript Version: 2.7.0-dev.201xxxxx

Contrary to the documentation (https://www.typescriptlang.org/docs/handbook/modules.html), using import assignment when targeting ES2015/ES6/ESNEXT does NOT emit import statements in the generated JS.

Code

This is my input file:

import m = require('m')
m('123')

$ tsc -t ESNEXT index

Expected behavior:

import * as m from "m"
m('123')

As described by the documentation

Actual behavior:

m('123')

See also this playground (this is 2.4.2, but I tested locally with @latest)

The import is completely omitted


Background info: I am depending on JS libraries which module.exports = someFunction and have the matching declaration file. All this feeds into webpack, which could take care of the module compatibility issues later.

But the import statement is just omitted completely

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions