Bug Report
Optional properties in inferred mapped type causes auto-completion to break.
🔎 Search Terms
Inferred mapped type with optional properties no auto-complete
🕗 Version & Regression Information
I believe it never worked.
⏯ Playground Link
https://tsplay.dev/mpnLBw
💻 Code
typeA1<Textendsobject>={[Kin(keyofT|'autoCompleteProp')]:
Kextends'autoCompleteProp'
? boolean
: KextendskeyofT
? T[K]extendsobject
? A1<T[K]>
: object
: never;}typeA2<Textendsobject>={[Kin(keyofT|'autoCompleteProp')]?: // <---- this is the only difference compared to A1Kextends'autoCompleteProp'
? boolean
: KextendskeyofT
? T[K]extendsobject
? A2<T[K]>
: object
: never;}functionmakeA1<TextendsA1<T>>(t: T){returnt;}functionmakeA2<TextendsA2<T>>(t: T){returnt;}makeA1({autoCompleteProp: true,// <-- you CAN autoComplete 'autoCompleteProp' herebla: {autoCompleteProp: true,// <-- you CAN autoComplete 'autoCompleteProp' hereblubb: {autoCompleteProp: false,// <-- you CAN autoComplete 'autoCompleteProp' herebleh: {// <-- you CAN autoComplete 'autoCompleteProp' here}},},});makeA2({autoCompleteProp: true,// <-- you CAN autoComplete 'autoCompleteProp' herebla: {// <-- you CAN'T autoComplete 'autoCompleteProp' hereblubb: {// <-- you CAN'T autoComplete 'autoCompleteProp' herebleh: {// <-- you CAN'T autoComplete 'autoCompleteProp' here},},},});🙁 Actual behavior
No auto-completion offered by editor or IDE in marked lines when pressing CTRL + SPACE or a
Edit: You can enter autoCompleteProp: '', in the lines where auto-completion fails. The compiler will complain that autoCompleteProp must be a boolean. Thus, the information about the optional property is there, it's just that it never appears in the auto-completion results.
🙂 Expected behavior
Auto-complete suggestion for "autoCompleteProp" in every line marked with <--
Bug Report
Optional properties in inferred mapped type causes auto-completion to break.
🔎 Search Terms
Inferred mapped type with optional properties no auto-complete
🕗 Version & Regression Information
I believe it never worked.
⏯ Playground Link
https://tsplay.dev/mpnLBw
💻 Code
🙁 Actual behavior
No auto-completion offered by editor or IDE in marked lines when pressing
CTRL + SPACEoraEdit: You can enter
autoCompleteProp: '',in the lines where auto-completion fails. The compiler will complain thatautoCompletePropmust be aboolean. Thus, the information about the optional property is there, it's just that it never appears in the auto-completion results.🙂 Expected behavior
Auto-complete suggestion for "autoCompleteProp" in every line marked with
<--