# TypeScript: 解決 Type 'unknown' is not assignable to type 'never'.ts(2322) 的問題 ```typescript interface Profile { name: string, age: number } const profile: Profile = { name: 'abc', age: 18 } // Wrong function setValueWrong (key: keyof Profile, value: any) { const foo = profile[key] // `foo` is typed here profile[key] = value // but why is it `never` } // Correct function setValue <Key extends keyof Profile>(key: Key, value: Profile[Key]) { profile[key] = value } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up