Skip to content

Commit

Permalink
refactor: Add explicit types file
Browse files Browse the repository at this point in the history
Missing dev dependencies can cause issues on importing from package types, so we are adding an explicit declaration file for exported types
  • Loading branch information
nonara committed Aug 16, 2021
1 parent 3111a1d commit 83349e4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"version": "3.3.0",
"description": "Transforms module resolution paths using TypeScript path mapping and/or custom paths",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"types": "types/index.d.ts",
"scripts": {
"compile": "tsc",
"build": "yarn run clean && yarn run compile",
Expand Down Expand Up @@ -45,6 +45,7 @@
],
"files": [
"dist",
"types",
"README.md",
"CHANGELOG.md",
"register.js"
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"noErrorTruncation": false,
"incremental": true,
"declaration": false,

"lib": [ "esnext" ],
"target": "es2015",
Expand Down
36 changes: 36 additions & 0 deletions types/index.d.ts
@@ -0,0 +1,36 @@
import TSNode from 'ts-node'
import ts from 'typescript'

/* ****************************************************************************************************************** *
* Hardcoded declarations file for npm package
* ****************************************************************************************************************** */

export interface TsTransformPathsConfig {
readonly useRootDirs?: boolean;
readonly exclude?: string[];
readonly afterDeclarations?: boolean;
readonly tsConfig?: string;
readonly transform?: string
}

export interface TransformerExtras {
/**
* Originating TypeScript instance
*/
ts: typeof ts;
}

export function register(): TSNode.RegisterOptions | undefined

export default function transformer(
program?: ts.Program,
pluginConfig?: TsTransformPathsConfig,
transformerExtras?: TransformerExtras,
/**
* Supply if manually transforming with compiler API via 'transformNodes' / 'transformModule'
*/
manualTransformOptions?: {
compilerOptions?: ts.CompilerOptions;
fileNames?: string[];
}
): ts.CustomTransformer

0 comments on commit 83349e4

Please sign in to comment.