I need to share some functions between Node projects, so I created a private repository in my Github account, then I added it to a new project with:
$ yarn add git+ssh://[email protected]:my_gh/my-api-types.git --dev
I can see the code in node_modules/my-api-types directory and I can import the code with:
import { AccountResolvers } from "my-api-types";
VS Code doesn't send any error message and actually the IDE display properly the methods inside AccountResolvers. But when I want to compile the project I'm getting:
ERROR in /home/manuel/customer-service/tsconfig.json
[tsl] ERROR
TS6307: File '/home/manuel/customer-service/node_modules/my-api-types/src/features/account/account.graphql.ts'
is not in project file list. Projects must list all files or use an 'include' pattern.
The error address to my tsconfig.json but I've being using the same file with other projects without problem:
{
"compilerOptions": {
"composite": true,
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"outDir": "./dist/",
"noImplicitAny": true,
"skipLibCheck": true,
"jsx": "react",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noUnusedLocals": true
}
}
UPDATE
The problem is gone when the option "composite" is set as "false", the help doc says:
Referenced projects must have the new composite setting enabled. This setting is needed to ensure TypeScript can quickly determine where to find the outputs of the referenced project. Enabling the composite flag changes a few things:
rootDir setting, if not explicitly set, defaults to the directory containing thetsconfig fileinclude pattern or listed in the files array. If this constraint is violated, tsc will inform you which files weren’t specifieddeclaration must be turned onIn tsconfig.json set composite=true
Referenced projects must have the new composite setting enabled.
This setting is needed to ensure TypeScript can quickly determine where to find the outputs of the referenced project. Enabling the composite flag changes a few things:
When this setting is on: >>>
The rootDir setting, if not explicitly set, defaults to the directory containing the tsconfig.json file.
All implementation files must be matched by an include pattern or listed in the files array. If this constraint is violated, tsc will inform you which files weren’t specified.
declaration defaults to true
source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With