Gathering detailed insights and metrics for @rushstack/typings-generator
Gathering detailed insights and metrics for @rushstack/typings-generator
Gathering detailed insights and metrics for @rushstack/typings-generator
Gathering detailed insights and metrics for @rushstack/typings-generator
Monorepo for tools developed by the Rush Stack community
npm install @rushstack/typings-generator
Typescript
Module System
Node Version
NPM Version
TypeScript (95.75%)
JavaScript (3.94%)
SCSS (0.15%)
Shell (0.05%)
HTML (0.04%)
CSS (0.03%)
Sass (0.03%)
Batchfile (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
6,232 Stars
22,499 Commits
636 Forks
53 Watchers
103 Branches
286 Contributors
Updated on Jul 15, 2025
Latest Version
0.14.40
Package Id
@rushstack/typings-generator@0.14.40
Unpacked Size
251.05 kB
Size
35.23 kB
File Count
19
NPM Version
10.8.2
Node Version
20.19.2
Published on
Jun 21, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
npm install @rushstack/typings-generator --save-dev
This is a utility for generating typings for non-TS files. It can operate in either a single-run mode or
a watch mode. It is designed to generate .d.ts
files with a specified generation function for all files matching
specified file extensions, with an option to ignore individual files.
1import { TypingsGenerator } from '@rushstack/typings-generator';
2
3const typingsGenerator: TypingsGenerator = new TypingsGenerator({
4 srcFolder: '/repo/package/src',
5 generatedTsFolder: '/repo/package/temp/generated-typings',
6 fileExtensions: ['file-extension'],
7 parseAndGenerateTypings: (fileContents: string, filePath: string) => {
8 const parsedFile = parseFile(fileContents);
9 const typings: string = generateTypings(parsedFile);
10 return typings;
11 }
12});
13
14// To run once before a compilation:
15await typingsGenerator.generateTypings();
16
17// To start a watcher:
18await typingsGenerator.runWatcher();
1import { TypingsGenerator } from '@rushstack/typings-generator';
2
3const assetTypingsGenerator: TypingsGenerator = new TypingsGenerator({
4 srcFolder: '/repo/package/src',
5 generatedTsFolder: '/repo/package/temp/generated-typings',
6 fileExtensions: ['.jpg'],
7 parseAndGenerateTypings: (fileContents: false, filePath: string) => {
8 const parsedFile = parseFile(fileContents);
9 const typings: string = 'declare const path: string;\nexport default path;';
10 return typings;
11 },
12 // Don't read files at all
13 readFile: (filePath: string, relativePath: string) => false
14});
15
16// To run once before a compilation:
17await typingsGenerator.generateTypings();
18
19// To start a watcher:
20await typingsGenerator.runWatcher();
srcFolder = '...'
This property is used as the source root folder for discovery of files for which typings should be generated.
generatedTsFolder = '...'
This property specifies the folder in which .d.ts
files should be dropped. It is recommended
that this be a folder parallel to the source folder, specified in addition to the source folder in the
rootDirs
tsconfig.json
option.
The folder specified by this option is emptied when the utility is invoked.
fileExtensions = [...]
This property enumerates the file extensions that should be handled.
parseAndGenerateTypings = (fileContents: TFileContents, filePath: string, relativePath: string) => string | Promise<string>
This property is used to specify the function that should be called on every file for which typings are being generated. In watch mode, this is called on every file creation and file update. It should return TypeScript declarations for the file it is called with.
readFile = (filePath: string, relativePath: string) => TFileContents | Promise<TFileContents>
This property allows customizing the process by which files are read from the specified paths. Use cases include:
terminal
Optionally provide a Terminal object for logging. If one isn't provided, logs will go to the console.
globsToIgnore
Optionally, provide an array of globs matching files that should be ignored. These globs are evaluated
under srcFolder
StringValuesTypingsGenerator
There is an extension of this utility specifically for file types where typings should be a simple
set of exported string values. This is useful for file types like CSS and RESX. This class takes
the same options as the standard TypingsGenerator
, with one additional option (exportAsDefault
) and a different return value for parseAndGenerateTypings
.
parseAndGenerateTypings = (fileContents: string, filePath: string) => { typings: ({ exportName: string, comment?: string })[] } | Promise<{ typings: ({ exportName: string, comment?: string })[] }>
This function should behave the same as the parseAndGenerateTypings
function for the standard
TypingsGenerator
, except that it should return an object with a typings
property, set to
an array of objects with an exportName
property and an optional comment
property.
See the example below.
1{ 2 typings: [ 3 { 4 exportName: 'myExport' 5 }, 6 { 7 exportName: 'myOtherExport', 8 comment: 'This is the other export' 9 } 10 ] 11}
1// This file was generated by a tool. Modifying it will produce unexpected behavior 2 3export declare const myExport: string; 4 5/** 6 * This is the other export 7 */ 8export declare const myOtherExport: string; 9
exportAsDefault = true | false
If this option is set to true
, the typings will be exported wrapped in a default
property. This
allows the file to be imported by using the import myFile from './myFile.my-extension';
syntax instead of
the import { myExport } from './myFile.my-extension';
or the import * as myFile from './myFile.my-extension';
syntax. This style of export is not recommended as it can prevent tree-shaking optimization.
exportAsDefaultInterfaceName = true | false
When exportAsDefault
is true, this optional setting determines the interface name
for the default wrapped export. For example, in the Sass Typings plugin, the interface name
is set to IExportStyles
. If not specified, the interface name will be IExport
.
(This setting is ignored when exportAsDefault
is false).
@rushstack/typings-generator
is part of the Rush Stack family of projects.
No vulnerabilities found.
Reason
30 commit(s) and 10 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 13/30 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
37 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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