Gathering detailed insights and metrics for dts-bundle-generator
Gathering detailed insights and metrics for dts-bundle-generator
Gathering detailed insights and metrics for dts-bundle-generator
Gathering detailed insights and metrics for dts-bundle-generator
npm install dts-bundle-generator
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
770 Stars
604 Commits
40 Forks
6 Watching
4 Branches
18 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
TypeScript (90.16%)
JavaScript (9.84%)
Cumulative downloads
Total Downloads
Last day
4.9%
15,825
Compared to previous day
Last week
10.9%
81,822
Compared to previous week
Last month
41.2%
287,805
Compared to previous month
Last year
68.8%
2,095,141
Compared to previous year
2
Small tool to generate a dts bundle from your ts code.
For example:
1// a.ts 2export class A {}
1// b.ts 2export class B {}
1// entry.ts 2import { A } from './a'; 3import { B } from './b'; 4 5declare function makeA(): A; 6export function makeB(): B { 7 makeA(); 8 return new B(); 9}
When you run dts-bundle-generator -o my.d.ts entry.ts
in my.d.ts
you will get the following:
1declare class B { 2} 3export declare function makeB(): B;
Install the package from npm
:
1npm install --save-dev dts-bundle-generator
or
1npm install -g dts-bundle-generator
Enable declaration
compiler option in tsconfig.json
Usage: dts-bundle-generator [options] <file(s)>
Options:
--help Show help [boolean]
--out-file, -o File name of generated d.ts [string]
--verbose Enable verbose logging [boolean] [default: false]
--silent Disable any logging except errors [boolean] [default: false]
--no-check Skip validation of generated d.ts file [boolean] [default: false]
--fail-on-class Fail if generated dts contains class declaration
[boolean] [default: false]
--external-inlines Array of package names from node_modules to inline typings from.
Used types will be inlined into the output file [array]
--external-imports Array of package names from node_modules to import typings from.
Used types will be imported using "import { First, Second } from
'library-name';".
By default all libraries will be imported (except inlined libraries
and libraries from @types) [array]
--external-types Array of package names from @types to import typings from via the
triple-slash reference directive.
By default all packages are allowed and will be used according to
their usages [array]
--umd-module-name Name of the UMD module. If specified then `export as namespace
ModuleName;` will be emitted [string]
--project Path to the tsconfig.json file that will be used for the
compilation [string]
--sort Sort output nodes [boolean] [default: false]
--inline-declare-global Enables inlining of `declare global` statements contained in files
which should be inlined (all local files and packages from
`--external-inlines`) [boolean] [default: false]
--inline-declare-externals Enables inlining of `declare module` statements of the global
modules (e.g. `declare module 'external-module' {}`, but NOT
`declare module './internal-module' {}`) contained in files which
should be inlined (all local files and packages from inlined
libraries) [boolean] [default: false]
--disable-symlinks-following (EXPERIMENTAL) Disables resolving of symlinks to the original path.
See https://github.com/timocov/dts-bundle-generator/issues/39 for
more information [boolean] [default: false]
--respect-preserve-const-enum Enables stripping the `const` keyword from every direct-exported
(or re-exported) from entry file `const enum`. See
https://github.com/timocov/dts-bundle-generator/issues/110 for more
information [boolean] [default: false]
--export-referenced-types By default all interfaces, types and const enums are marked as
exported even if they aren't exported directly. This option allows
you to disable this behavior so a node will be exported if it is
exported from root source file only. [boolean] [default: true]
--config File path to the generator config file [string]
--no-banner Allows remove "Generated by dts-bundle-generator" comment from the
output [boolean] [default: false]
--version Show version number [boolean]
To generate a dts bundle for a single entry file:
1./node_modules/.bin/dts-bundle-generator -o my.d.ts path/to/your/entry-file.ts
To generate a dts bundle for multiple entry files:
1./node_modules/.bin/dts-bundle-generator path/to/your/entry-file.ts path/to/your/entry-file-2.ts
To generate a dts bundle for a single entry file with external inlines and imports:
1./node_modules/.bin/dts-bundle-generator \ 2 --external-inlines=@mycompany/internal-project \ 3 --external-imports=@angular/core rxjs \ 4 -- path/to/your/entry-file.ts
[!NOTE] Note that, as in the above example, the arguments accepting arrays (like
--external-inlines
or--external-imports
) accept multiple values separated by spaces. Since the input file(s) are positional arguments, you need to put the--
separator before it when it is preceded by an argument that accepts multiple values. Otherwise you will get an error (Error: No input files specified
).
To generate a dts bundle for a single entry file with external types:
1./node_modules/.bin/dts-bundle-generator --external-types=jquery path/to/your/entry-file.ts
It is unnecessary, but you can use config file for the tool. See config documentation for more information.
If you have modules then you can create definitions by default using tsc
, but tsc
generates them for each module separately.
Yeah, you can use outFile
(for amd
and system
), but generated code looks like this:
1declare module "a" { 2 export class A { 3 } 4} 5declare module "b" { 6 export class B { 7 } 8} 9declare module "entry" { 10 import { B } from "b"; 11 export function makeB(): B; 12}
but:
A
is not used at all and most probably you do not want to export it.a
or b
(actually entry
too) in the resulting file.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
2 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 4
Reason
SAST tool is not run on all commits -- score normalized to 3
Details
Reason
Found 2/19 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More