I'll preface this question by saying I'm using Intellij IDEA.
Following this question: If external typescript modules don't have a module name, how do you avoid naming conflicts?
This is all fine and well, but let's say I'm have two Rectangle classes in two Rectangle.ts files, but in different packages, say src/utils/geom
and src/utils/ui
, or something like that.
src/utils/geom/Rectangle.ts
has calculateSurface()
as its only method and src/utils/ui/Rectangle.ts
has display()
as its only method.
Now if I call them both in a single file, I'll get both methods as possible calls in the type-hinting.
import GeomRectangle = require();
import UiRectangle = require();
var geom: GeomRectangle = new GeomRectangle();
var ui: UiRectangle = new UiRectangle();
// Now both those are valid
ui.calculateSurface();
ui.display();
I'm thinking it's because I'd have both Rectangle.ts files have a exports = Rectangle
, since that's the name of the class and Intellij IDEA must use this export statement to determine what it'll suggest to you.
Am I wrong in my assumption? And is there any way to have type-hinting that won't trip on itself when using external modules with, sometimes, classes having the same name as each other?