Skip to content

Commit 83349e4

Browse files
committed
refactor: Add explicit types file
Missing dev dependencies can cause issues on importing from package types, so we are adding an explicit declaration file for exported types
1 parent 3111a1d commit 83349e4

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "3.3.0",
44
"description": "Transforms module resolution paths using TypeScript path mapping and/or custom paths",
55
"main": "dist/index.js",
6-
"types": "dist/index.d.ts",
6+
"types": "types/index.d.ts",
77
"scripts": {
88
"compile": "tsc",
99
"build": "yarn run clean && yarn run compile",
@@ -45,6 +45,7 @@
4545
],
4646
"files": [
4747
"dist",
48+
"types",
4849
"README.md",
4950
"CHANGELOG.md",
5051
"register.js"

tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"compilerOptions": {
33
"noErrorTruncation": false,
44
"incremental": true,
5+
"declaration": false,
56

67
"lib": [ "esnext" ],
78
"target": "es2015",

types/index.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import TSNode from 'ts-node'
2+
import ts from 'typescript'
3+
4+
/* ****************************************************************************************************************** *
5+
* Hardcoded declarations file for npm package
6+
* ****************************************************************************************************************** */
7+
8+
export interface TsTransformPathsConfig {
9+
readonly useRootDirs?: boolean;
10+
readonly exclude?: string[];
11+
readonly afterDeclarations?: boolean;
12+
readonly tsConfig?: string;
13+
readonly transform?: string
14+
}
15+
16+
export interface TransformerExtras {
17+
/**
18+
* Originating TypeScript instance
19+
*/
20+
ts: typeof ts;
21+
}
22+
23+
export function register(): TSNode.RegisterOptions | undefined
24+
25+
export default function transformer(
26+
program?: ts.Program,
27+
pluginConfig?: TsTransformPathsConfig,
28+
transformerExtras?: TransformerExtras,
29+
/**
30+
* Supply if manually transforming with compiler API via 'transformNodes' / 'transformModule'
31+
*/
32+
manualTransformOptions?: {
33+
compilerOptions?: ts.CompilerOptions;
34+
fileNames?: string[];
35+
}
36+
): ts.CustomTransformer

0 commit comments

Comments
 (0)