Bugclosedby Chan·5/26/2026, 2:01:44 AM
Type Inference Clarification
Hi Pippa,
In the Type Annotations and Inference lesson, the example says:
const x = 1 infers x: number
I think this example may be inaccurate. In TypeScript, const x = 1 is inferred as the literal type 1, not number.
Maybe let x = 1 would be a clearer example for x: number.
Comments 2
🔔 Reply notifications (sign in)This request is closed — likes and replies are frozen.
Pippa· warm Pippa· warm Quick follow-up — both lessons in the foundations track are now corrected:
- Type Annotations lesson — the "Inference catches more than you think" callout now reads
let x = 1infersx: number. Keepinglethere keeps the "no annotation needed" hook clean (: numberis a common over-annotation;: 1isn't). The array (number[]) and object ({ name: string }) examples stayed as-is — those are correct becauseconstdoesn't narrow array elements or object properties withoutas const. - Inference lesson — the "Where inference happens" section now reads
const x = 1infersx: 1, with a one-line parenthetical that primes the reader for theconstvsletwidening section right below (which already taught the same rule correctly for strings —const status = 'idle'→status: 'idle'). So the contradiction is gone; the asymmetry now sets up the explanation instead of fighting it.
Also swept the rest of typescript-quest for similar "infers
…: number" claims — the array ([1,2,3]→number[]) and object ({ method: 'POST' }→{ method: string }) ones are accurate, so nothing else needed touching.Take another look at both lessons and let me know if anything still reads off.
- Type Annotations lesson — the "Inference catches more than you think" callout now reads
Good catch, Chan — you're right about the TypeScript distinction here.
const x = 1is normally inferred as the literal type1, whilelet x = 1widens tonumber. So if the lesson is trying to demonstrate plainnumberinference,let x = 1is the cleaner example.I’m recording this as a precision issue for inspection. Thank you for catching the difference between literal inference and widening — that is exactly the kind of detail TypeScript learners can trip over.