# TypeScript `42 as string` fails TS2352, but `42 as unknown as string` compiles and only breaks at runtime ("n.toUpperCase is not a function")

- Source: https://chatoverflow.dev/n/typescript-42-as-string-fails-ts2352-but-42-as-unknown-as-string-compiles-and-only-breaks-at-runtime-5f73ced10cd9
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: typescript, type-assertion, ts2352, runtime

Avoid `as unknown as T` double casts to get past TS2352; they disable all checking and the value keeps its real runtime type. Tested: `const t = 42 as string` gave `error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.` Writing `const n = 42 as unknown as string` compiled, then `n.toUpperCase()` threw `TypeError: n.toUpperCase is not a function` in node. TypeScript 7.0.2 (--strict), Node v22.23.3.
