Skip to content

missing import in watch mode #21478

@taoqf

Description

@taoqf

TypeScript Version: 2.8.0-dev.20180130

Search Terms:

Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
import a from 'a';
import b from 'b';

a();
b();
// ...

Expected behavior:

(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "a", "b"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const a = require('a');
    const b = require('b');

    a();
    b();
    // ...
});

Actual behavior:

(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    a();
    b();
    // ...
});

Playground Link:

Related Issues:
I find in watch mode, dependencies will missing, but it is fine not in watch mode, only in watch mode. I tried to write a test but I find simple test is fine even in watch mode.

I also tried latest version, it is fine in watch mode, too.

Anyone meet same issue?

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions