Alon Alon - 4 months ago 64
TypeScript Question

Node.js reference path absolute

I have a Node.js project developed in WebStorm IDE

My project structure is:

A root folder named "root" that contains 2 folders: "main" and "typings". "main" contains one file named "foo.ts", "typings" contains one file named "bar.d.ts".

In foo.ts I added a reference path to bar.d.ts.

This works:

///<reference path="../typings/bar.d.ts" />

This does not work (getting "File not found"):

///<reference path="/typings/bar.d.ts" />

This does not work either:

///<reference path="/root/typings/bar.d.ts" />

How can I get rid of the 2 dots (..)?


How can I get rid of the 2 dots (..)

You can if you provide absolute path on disk. This is however not what you want.

If you want relative to project root, that isn't supported for reference tags.


Just use tsconfig.json and make sure it includes both foo and bar using e.g. files