What is the 'Double Assertion' pattern and when is it necessary?

Updated May 4, 2026

Short answer

Double assertion (expr as unknown as T) is used to force a type conversion between two types that have no overlap.

Deep explanation

TypeScript normally prevents assertions between types that it deems completely unrelated to prevent obvious bugs. However, in low-level library code, unit testing, or when dealing with legacy JS, you might know more than the compiler. By first asserting to unknown or any, you effectively 'reset' the type checking, allowing the final assertion to the target type.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More TypeScript interview questions

View all →