create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Is "app" folder name reserved when aliasing in typescript?

Open KishorShresthaGithub opened this issue 3 years ago • 1 comments
trafficstars

TS compiler says module not found when I added the app path alias in tsconfig file.

image

it works whenever there is no app folder in the paths.

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "baseUrl": "./src",
    "paths": {
      "modules/*": ["modules/*"], //works fine
      "app_core/*": ["app/core/*"], //does not work
      "core/*": ["core/*"] //works fine
    }
  },
  "include": ["src"]
}

when I use the app_core module the compiler says module not found

import TestModule from "app_core/test/Test.module"; //doesnot work
import TestModule1 from "core/test/Test.module"; //works fine

import PageModule from "modules/Page.module"; //works fine
import React from "react";
import "./App.css";

function App() {
  return (
    <div className="App">
      <TestModule />
      <TestModule1 />
      <PageModule />
    </div>
  );
}

export default App;

Edit:

Folder structure

image

I don't know if the folder name is reserved or something. Can someone help me out? Thank you in advance.

KishorShresthaGithub avatar May 09 '22 14:05 KishorShresthaGithub

There is currently an issue with path aliases 😔 Which means that react-scripts will ignore your paths configuration see #12047

RamonBalthazar avatar Jul 25 '22 22:07 RamonBalthazar