Having an issue with enums when symlinking a common enums and interfaces directory (named common, symlinked within src/ folder). For some reason, importing interfaces from this folder doesn't trigger an error, but importing the enum files does trigger an error!
Things that might help: (1) importing modules from outside the src folder. CRA with typescript only transpiles folders under src/, so I symlinked the folder to be inside src. (2) I can make a copy of those exact enums, declare them in a separate file within src/, run yarn start, and no error is thrown! It must be some odd interaction between the symlinked folder and CRA.
Notice, using a monorepo with typescript, create-react-app with typescript template for the frontend. Again I can import interfaces from the symlinked common folder with no errors, only when I import the enums do I have a problem.
Here's the code for the ../common/enums/Subject.ts file:
enum Subject {
Biology = 'BIOLOGY',
Chemistry = 'CHEMISTRY',
Earth = 'EARTH',
Energy = 'ENERGY',
General = 'GENERAL',
Math = 'MATH',
Physics = 'PHYSICS',
Space = 'SPACE'
}
export default Subject;
And for good measure (maybe it's my tsconfig.json??) Here's my tsconfig.json for the frontend:
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"es6"
],
"target": "es6",
"baseUrl": "src",
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"strict": true,
},
"include": [
"src",
"src/**/*.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx"
]
}
I do have a tsconfig.json for the common folder, but not sure that woud be causing the issue. here's the structure of the common folder and tsconfig.json file for it.
export enum Subject {
– Amboexport default Subject;
at the bottom of that file) – Marcel