I’m writing a webpack loader which for the example here processes *.foo
files. I want to create typescript typings for it as follows:
// index.d.ts
declare module "*.foo" {
const bar: string;
export default bar;
}
I’d like to publish this loader as a npm package foo-loader
and when someone adds a dependency to foo-loader
, I would like it to resolve import foobar from './foo.bar';
as a string like declared above. I currently cannot get it to work.
I’ve tried adding the module declaration in my index.d.ts
file which is referenced in my package.json:
// package.json
{
"types": "index.d.ts"
}
in addition i’ve tried adding foo-loader
into the types
option in ts-config.json
with no success.
How do I get it so that my d.ts file gets read automatically once it’s added as a dependency. Is it possible to do so without an @types/...
package?