Typescript root imports


#1

Hi everyone,
i have a problem with the typescript compilers not recognizing root imports, like this :
import foo from '/imports/foo'
I must replace them with import foo from '../../../../../imports/foo' which is a PITA.
Any way to tell the compiler where to find root imports ?


#2

You may want to open a bug report on it. Typescript support seems to be lacking in general compared to the ecmascript


#3

Actually, after some googling it seems to be impossible to do with Typescript.
One way to do it would be to put common code in a npm module and to require it from there.
Requiring from “/imports” (or other absolute physical path) seems not a so good idea after all.


#4

I think it is still a good idea. Ecmascript allows for it. And eslint can have a custom resolver to allow it.


#5

@vjau: Have you found a solution for this? There seems to be some more configuration options for typescript by now, but I still cannot figure out if/how absolute paths can be resolved.


#6

I have recently given up on Typescript.
For me it introduces more problems than it solves.