Can you setup a path alias for a reference outside the root directory

Viewed 105

I am working on a typescript project with the following directory structure

├── common
│   ├── tsconfig.json
│   ├── Schemas
│   └── Types
├── server
│   ├── tsconfig.json
│   ├── src
│   └── test
└── viewer
    ├── tsconfig.json
    ├── src
    └── tests

I have successfully setup a reference to the common directory in the server and viewer tsconfig.json this way

"references": [
    { "path": "../common" }
]

so I can include common files with

import EventListSchema from '../../../../common/Schemas/EventList';

However, I would like to setup a path alias like I have for src

"paths": {
    "@/*": [ "src/*" ],
    "common/*": [ "../common/*" ] // something like this
},

so I can include common files with a simpler path like

import EventListSchema from 'common/Schemas/EventList';

when I tried to add common to paths I get this error

error TS2307: Cannot find module 'common/Schemas/EventList' or its corresponding type declarations.

import EventListSchema from 'common/Schemas/EventList';

Is something like this possible? I am using tsc version 4.0.2

0 Answers
Related