I am working on lets say package A that is intended to be used in another package B (sort of as a plugin) but my package A depends on the types defined in package B. I am using Typescript 4.3.4
My initial thought was to import just the types from package B into package A but that presented me with the following problem:
I installed types to
node_modules/@types/packageAinside packageB and when I tried to import withimport { someType } from '@types/packageA'and build I got the following error:TS6137: Cannot import type declaration files.Now if I instead installed types to
node_modules/packageA-typesinside packageB and import withimport { someType } from 'packageA-types'it works and I do not get the error when I build.
Why does the first method fail and why does the second method work?
I read a few other stackoverflow posts that talked about normal/local vs global/ambient Typescript modules but I didn't quite understand how that played into this situation.