π Search Terms
declaration, widened, d.ts, destructuring
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries
β― Playground Link
https://www.typescriptlang.org/play?jsx=0&module=1&ts=5.1.6#code/GYVwdgxgLglg9mABMOcAUBKAXIg3gTxwEYBfPAKESsQCcBTKEGpXRQxIxE878ugDwAOcGlEQQEAZzGt8iALyIADFwXJUmANxA
π» Code
function foo(): {y: 1} {
return { y: 1 }
}
export const { y = 0 } = foo();
π Actual behavior
y is number in d.ts files, although the language service says y is 1|0
π Expected behavior
y is 1|0 in d.ts files.
Additional information about the issue
Without the = 0 assignment y properly becomes type 1 in d.ts
π Search Terms
declaration, widened, d.ts, destructuring
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?jsx=0&module=1&ts=5.1.6#code/GYVwdgxgLglg9mABMOcAUBKAXIg3gTxwEYBfPAKESsQCcBTKEGpXRQxIxE878ugDwAOcGlEQQEAZzGt8iALyIADFwXJUmANxA
π» Code
π Actual behavior
yisnumberind.tsfiles, although the language service saysyis1|0π Expected behavior
yis1|0ind.tsfiles.Additional information about the issue
Without the
= 0assignmentyproperly becomes type1in d.ts