@michaelfoidl/barrel-dts
Generates TypeScript declaration files for barrels.
Last updated a year ago by michaelfoidl .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @michaelfoidl/barrel-dts 
SYNC missed versions from official npm registry.

barrel-dts

barrel-dts is a simple command-line tool that generates TypeScript declaration files for barrels.

Usage

The following commands are supported:

  • -s, --source [sourceFile]: The barrel source file (defaults to index.ts).
  • -m, --module-name [moduleName]: The name of the module (defaults to myModule).
  • -t, --target [targetFileName]: The name of the target file (if moduleName is set, it defaults to it: myModule.d.ts).

Example

To clarify its usage even more, let us pretend we want to generate a .d.ts file for this barrel:

export { MyFirstClass } from './myFirstClass/MyFirstClass';
export { MySecondClass } from './mySecondClass/MySecondClass';

Simply generating declarations via setting the corresponding property in the tsconfig.json file puts out a simple copy of this file and results in us having to use the following syntax to import from our barrel:

import { MyFirstClass } from 'myModule/myModule';

This happens because the TypeScript compiler does not declare a module for our barrel. barrel-dts on the other hand does declare a module and we can now simply use this for our imports:

import { MyFirstClass } from 'myModule';

Hooray!

Version History

  • 1.0.0: Initial Release

Current Tags

  • 1.0.0                                ...           latest (a year ago)

1 Versions

  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |