TS2352
Suspicious type conversion
Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other.The compiler’s own words. Not translated — this is the string you pasted into a search box.
A type assertion jumps between unrelated types and would not perform the runtime conversion its spelling suggests.
Reproduction
const count = '12' as number
The build asserts this emits exactly this code.
Why the compiler says this
Assertions change the checker’s view, never the JavaScript value. A string asserted as `number` is still a string at runtime, so TypeScript blocks the most obviously unrelated jumps and asks you to make the intent explicit.
Fixes
- 01
const count = Number('12')
Perform a real runtime conversion when the value must become a number.
- 02
const input: unknown = '12' if (typeof input !== 'string') { throw new Error('Expected text') } const count = Number(input)
For external data, validate from `unknown` before converting it.
Takeaway
`as` is not a cast in the runtime sense. Parse or validate values; reserve assertions for information the compiler genuinely cannot observe.
