#Include types from subfolder of library

8 messages · Page 1 of 1 (latest)

coarse vale
#

Hey there!, I am using an npm dependency that exports types in multiple subfolders.

The structure looks like this:

node_modules/
├─ lib1/
│  ├─ dist/
│  │  ├─ types/
│  │  │  ├─ subfolder1/
│  │  │  │  ├─ OtherType1.d.ts
│  │  │  ├─ index.d.ts

I cannot import them from my project as I can only reference the root, is there some flag in tsconfig that allows this? (Tried with "moduleResolution" but that didn't work)

smoky swan
#

you can't import them if they aren't exported

#

try checking that library's package.json to see if they have subpath exports

coarse vale
#

Ah okay, what I noticed is that vs code thinks that i can import it from
lib1/dist/types/hooks/HookOverlayOptions whereas I expected lib1/hooks/HookOverlayOptions to work (its werid to see the dist & types folders), also using that recommened import, it fails when running the program

but yeah I just checked the package.json and it only sets the "types" field to the index without other exports

smoky swan
#

make sure you have moduleResolution node

coarse vale
#

!resolved