Skip to content

Commit 5f2d51c

Browse files
authored
Fix inclusion of module-augmenting .d.ts's (#761)
A previous commit updated the TypeScript configuration so TypeScript would better recognize type definition files whose purpose was to backfill types for existing packages. After testing, this revealed a misunderstanding of the `paths` option in `tsconfig.json`. It turns out that `paths` completely overrides how TypeScript resolves modules and locates type definition files for modules. The consequence of this option is that if a module includes type definitions, but we also supply type definitions for that module in `types/`, then our type definitions will win. This degrades the developer experience: sometimes, a package already has types, but we merely need to *augment* those types in some way. The `paths` option makes it impossible to do this. This commit keeps the `types/` directory (as it'll be important later) but informs TypeScript about the type definition files here by adding them to the `include` option in `tsconfig.json` (which was the original strategy).
1 parent 6f3808b commit 5f2d51c

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

tsconfig.build.json

-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
"outDir": "./dist",
77
"rootDir": "./src"
88
},
9-
"include": ["./src/**/*.ts"],
109
"exclude": ["**/*.test.ts"]
1110
}

tsconfig.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
"inlineSources": true,
66
"module": "commonjs",
77
"moduleResolution": "node",
8-
"paths": {
9-
"*": ["./types/*"]
10-
},
118
"sourceMap": true,
129
"strict": true,
1310
"target": "es6"
14-
}
11+
},
12+
"include": ["./types/**/*.d.ts", "./src/**/*.ts"]
1513
}

0 commit comments

Comments
 (0)