Skip to content

Use @ts-ignore instead of @ts-expect-error#612

Merged
hansott merged 3 commits intomainfrom
optional-types
May 26, 2025
Merged

Use @ts-ignore instead of @ts-expect-error#612
hansott merged 3 commits intomainfrom
optional-types

Conversation

@hansott
Copy link
Member

@hansott hansott commented May 19, 2025

/** TS_EXPECT_TYPES_ERROR_OPTIONAL_DEPENDENCY **/
import type { Express, Router } from "express";

We replace TS_EXPECT_TYPES_ERROR_OPTIONAL_DEPENDENCY with @ts-expect-error in our build script. We expect an error if e.g. express is installed (since we expose middleware for a few frameworks).

If the user has "skipLibCheck": true in their tsconfig.json, TypeScript won't type check our library declaration files.

When the user has express installed and skipLibCheck is false, there is no error but since TypeScript expects an error...

That's why I replaced @ts-expect-error with @ts-ignore

hansott added 2 commits May 19, 2025 12:29
Import type { Express, Router } from "express";
                                      ^^^^^^^

We reference express types, but we don't have it as a dependency in our
library

However, when the user uses the middleware, express will be installed...
@codecov
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@hansott hansott merged commit f52256c into main May 26, 2025
14 checks passed
@hansott hansott deleted the optional-types branch May 26, 2025 11:55
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.

2 participants