Skip to content

Conversation

@mcmire
Copy link
Contributor

@mcmire mcmire commented Mar 30, 2022

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).

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).
@mcmire mcmire requested a review from a team as a code owner March 30, 2022 22:24
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcmire mcmire merged commit 5f2d51c into main Apr 5, 2022
@mcmire mcmire deleted the fix-tsconfig branch April 5, 2022 20:35
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
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).
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants