#How to re-export type in npm module?

8 messages · Page 1 of 1 (latest)

floral crescent
#

I have a npm package I publish. It depends on another package, but it's not a peerdepdency.

In my own library, I have

import { parser } from 'peggy';
export type GlslSyntaxError = parser.SyntaxError;

But this doesn't work in a user's install of my parser, because they don't have peggy so Typescript can't resolve the type.

I could hand-copy the type into my file but that is silly. Any suggestions?

whole inlet
#

Peggy should be a dependency in your package then it sounds like

floral crescent
#

@whole inlet peggy is a parser generator - it generates the parser as a js file that I export. I don't need any of peggy's parser generator in my package, just this type, since peggy generates javascript code that uses this type

ancient chasm
floral crescent
#

It is a dev dependency, but that does not solve the issue

ancient chasm
#

hmmm... i guess this just isn't something that TS felt it needed to support

#

or rather, something that it can support

#

you can't both avoid the dependency (because otherwise how does TS find peggy's .d.ts) file, and have the types