Question: Am I missing some TS configuration, or some TS build step?
I have created a new npm package:
Custom-NPM-Package /
- src
-- index.js
-- index.d.ts
-- IType.ts
with this tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "CommonJS",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": false,
"declaration": true,
"declarationDir": "./dist",
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react",
"outDir": "./dist",
"rootDir": "./src",
"allowSyntheticDefaultImports": true,
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx",
"./src/**/*.jsx"
],
"exclude": [
"node_modules",
"dist"
]
}
The goal is to import the Types from other projects (React),
- Install the package:
npm install Custom-NPM-Package
- Import TS Type:
import { IType } from 'Custom-NPM-Package'
but I'm having an error:
./node_modules/Custom-NPM-Package/dist/index.js export 'IType' (reexported as 'IType') was not found in './IType' (possible exports: IType, __esModule)
typesortypingsfield set in its package.json?index.jsandindex.d.tsand in package.json i point to it like this :"types": "dist/index.d.ts", but my problem is that i have a types subfolder in each folder ex :src/stack/types/ITypeA.ts,src/stack/types/ITypeB.ts... so the error is only for thetsfiles and not thetsx