Skip to content

Why these import/export statements behave differently...? #4770

Closed
@iam3yal

Description

@iam3yal

Why these import/export statements behave differently? I mean I understand they were originated in two different specs but should they behave differently?

What bothers me is that when I'm using the ES6 style to import the class I need to access it through another scope (module/namespace), is there a way to avoid it? or should I just use CommonJS modules style?

It was probably fine if I could import many classes/modules to the same scope.

// a1.ts
export class A {
}

// b1.ts
import * as A from "./a1.ts";

class B extends A.A {
}

Just another variation with modules.

// a1.ts
export module C {
    export class A {
    }
}

// b1.ts
import * as D from "./a1.ts";

export module C {
    class B extends D.C.A {
    }
}

Versus the following statement:

// a2.ts
class A {
}

export = A;

// b2.ts
import A = require("./a2");

class B extends A {
}

I'm not sure what the following does but it compiles, is it a bug?

// a3.ts
class A {
}

export = A;

// b3.ts
import * as A from "";

class B extends A {
}

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