What is the root of the absolute path when importing a module in typescript?

I am developing an application in typescript (in Visual Studio 2015) and have this basic file structure:

Solution AppProject Scripts framework Utils.ts app SomeApp.ts tsconfig.json 

Now in the application modules, I would like to refer to the modules of the structure with an absolute path, so I would do something like this:

 import { Utils } from '/Scripts/framework/Utils' 

However, this does not work .
I get a red string squiggly and "Can't find module" / Scripts / framework / Utils "

I work fine when I make a relative path, but the application is clearly more complex than shown, and I don't want to deal with the output of several levels for my relative path.

I am using typescript 1.8 using the node module resolution strategy.
And a web package for compiling and linking, if that matters

+2
source share
1 answer

Unfortunately, I could not find anything in the documents. Therefore, I tried to track the access to the file system executed by the compiler (TypeScript 2.5.2) while trying to allow import of the absolute path.

As a result, / always refers to the root of the file system . Regardless of compilerOptions like rootDir , rootDirs or baseUrl .

0
source

Source: https://habr.com/ru/post/1263993/


All Articles