Currently, I have encountered an issue where including "graphql" files in my components is leading to TypeScript errors due to unrecognized import pathing. Despite the error, the functionality works as expected.
import QUERY_GET_CATS from "@gql/GetCats.graphql";
The error message received is: TS2307: Cannot find module '@gql/GetCat.graphql' or its corresponding type declarations
Below is my tsconfig:
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"*": [
"./*"
],
"@gql/*": [
"./api/gql/*"
]
},
"lib": ["dom", "dom.iterable", "esnext"],
"strict": true,
"noUnusedLocals": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"isolatedModules": true,
"jsx": "preserve",
"downlevelIteration": true,
"allowJs": true,
"skipLibCheck": true,
"resolveJsonModule": true
},
"exclude": [
"cypress",
"coverage",
"node_modules",
"build",
"dist",
"out",
".next",
"next.config.js",
"./**/*.js",
"./**/*.jsx",
"./**/*.scss"
],
"include": [
"next-env.d.ts",
"./**/*.ts",
"./**/*.tsx"
]
}
Here is my eslintrc configuration:
const path = require('path');
// Your eslint config object here...
A couple of notes: - Adding "./**/*.graphql" to the "include" array did not resolve the issue. - Other aliases are functioning correctly, except for the "graphql" ones.