GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Generic return type (T[K]) is intersection among all properties of T instead of union · Issue #54901 · microsoft/TypeScript Closed Labels Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug DescriptionBug Report🔎 Search Termsconditionally generic return type, union vs intersection, valueof etc 🕗 Version & Regression Information
⏯ Playground LinkPlayground link with relevant code 💻 Codeexport interface ConfigA { user: string } export interface ConfigB { [key: string]: number | string | boolean } export interface Config { A?: ConfigA B?: ConfigB } export class ConfigClass { config: Config = {} get(key: keyof Config) { return this.config[key] } } type ValueOf<T> = T[keyof T] const config = new ConfigClass() function a<K extends keyof Config>(key: K): Config[K] { return config.get(key) } 🙁 Actual behaviorType 'ConfigA | ConfigB | undefined' is not assignable to type 'Config[K]'. 🙂 Expected behaviorI would expect no error of returning Activity
MetadataMetadataAssigneesLabelsWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |