risen228 / craco-alias

A craco plugin for automatic aliases generation for Webpack and Jest
MIT License
109 stars 11 forks source link

"Could not find a declaration file" when aliasing the package #7

Closed risen228 closed 4 years ago

risen228 commented 4 years ago
{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@my-react": ["./node_modules/react/"]
    }
  }
}

TS cannot find types declaration file for @my-react, even when @types/react is installed.

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@file-alias": ["./src/file.ts"],
      "@folder-alias/*": ["./src/folder/*", "./src/folder/"],
      "@my-react": ["./node_modules/react/"],
      "@types/@my-react": ["./node_modules/@types/react/"]
    }
  }
}

Types aliasing makes no sense too.

risen228 commented 4 years ago

Got it working using this configuration:

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@app/*": ["src/*", "src/"],
      "@my-react": ["./node_modules/react/", "./node_modules/@types/react/"]
    }
  }
}