Closed
Description
Bug Report
🔎 Search Terms
typescript cannot get parameter object type when using template literal types
🕗 Version & Regression Information
- This is a bug
- I saw this bug when trying to create an object using template literal as keys by first parameter which is object.
⏯ Playground Link
💻 Code
const obj = {
name: 'Kadir',
age: 20
}
function listen<T extends {[key: string]: any}>(obj: T, events: {
[Key in `on${string & keyof T}`]?: Key
}) {
}
// Do CTRL + Space inside second parameter object and you will see
// autocompletion
listen(obj, {
})
// Do CTRL + Space inside second parameter
// you will not get any auto completion
listen({ age: 20 }, {
})
🙁 Actual behavior
If object is created in first parameter it won't give autocompletion but will give type errors.
🙂 Expected behavior
It should give autocompletion in second parameter object.