Sorry in advance for any confusion, but I'll try my best to explain the issue at hand. Please bear with me.
I've developed a library that is then installed via npm into a typescript Vue project. However, despite having an index.d.ts file included, the types are not being imported correctly and I encounter a
Module '"../../node_modules/[library name]/dist"' has no exported member [exported member]
error.
I'm certain there's something off on my end, but I can't seem to pinpoint it. Any assistance would be greatly appreciated.
Below is the tsconfig.json for the library:
// Library tsconfig.json
{
"compilerOptions": {
"target": "ES2018",
"module": "esnext",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"strictPropertyInitialization": false,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"declaration": true,
"declarationDir": "dist",
"rootDir": "src",
"outDir": "dist"
},
"include": ["src/**/*", "node_modules/@types"],
"exclude": ["node_modules", "**/*.spec.ts"],
"typeRoots": ["src/types/**/*", "node_modules/@types"]
}
And here is the package.json configuration for the library
"name": "LIBRARY NAME",
"version": "1.0.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
...
}
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged && concurrently npm:test npm:lint"
}
},
"files": [
"dist/*"
],
"engines": {
"node": "^14.15.0",
"npm": "^6.14.0"
},
// dependencies and more