Skip to content

export default for unresolved import gets elided #8507

@billti

Description

@billti

For the below code:

import {Subscription} from 'rxjs/Subscription';
class Foo {
    sayHi(name) {
        return `Hi ${name}, welcome!`;
    }
}
export let sqr = x => x * x;
export default Subscription;

If `rxjs/Subscription' import does not resolve, then the emit is:

"use strict";
var Foo = (function () {
    function Foo() {
    }
    Foo.prototype.sayHi = function (name) {
        return "Hi " + name + ", welcome!";
    };
    return Foo;
}());
exports.sqr = function (x) { return x * x; };

Notice that the import and export default has been elided.

This can be resolved by setting isolatedModules, or by referencing a property on Subscription (even if that could be a type on a namespace also - e.g. export default Subscription.IFoo).

This is especially an issue for Salsa when the input is JavaScript rather than TypeScript, as there are no errors/warning for unresolved modules/types (and the reference can't be to a type).

Spoke with Mohamed, and he agrees this should be fixed (and should be easy).

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