Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Setting paths in tsconfig.json does not work #98

Closed
@nareshbhatia

Description

@nareshbhatia

I am trying to set the src directory as a path so that modules can be imported with short absolute paths (without ../../ etc.). For example:

import { Titlebar } from 'core/components';

instead of

import { Titlebar } from '../core/components';

To accomplish this I added the following to tsconfig.json:

"baseUrl": ".",
"paths": {
  "*": [
    "*",
    "src/*"
  ]
}

However this is still not picking up imports with absolute paths. I get an error like this:

Module not found: Error: Can't resolve 'core/components' in '/Users/nbhati/projects/react-mobx-mui-ts-seed/src/features'

I have created a small example to demonstrate this problem. Please see my repository at https://github.com/archfirst/react-mobx-mui-ts-seed. The import shown above is here: https://github.com/archfirst/react-mobx-mui-ts-seed/blob/master/src/features/home-page.tsx#L9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions