From 1f05f13784504f022df435e1dd6b5128b8c32abc Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 30 Mar 2022 15:56:49 -0600 Subject: [PATCH] Fix inclusion of module-augmenting .d.ts's 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). --- tsconfig.build.json | 1 - tsconfig.json | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tsconfig.build.json b/tsconfig.build.json index 70df21e1651..e2c5987c4b7 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -6,6 +6,5 @@ "outDir": "./dist", "rootDir": "./src" }, - "include": ["./src/**/*.ts"], "exclude": ["**/*.test.ts"] } diff --git a/tsconfig.json b/tsconfig.json index 2887202355a..de3572e5f74 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,11 +5,9 @@ "inlineSources": true, "module": "commonjs", "moduleResolution": "node", - "paths": { - "*": ["./types/*"] - }, "sourceMap": true, "strict": true, "target": "es6" - } + }, + "include": ["./types/**/*.d.ts", "./src/**/*.ts"] }