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 — Change in generic behavior between 3.0.1 and >=3.1.1 · Issue #27895 · microsoft/TypeScript Closed Labels BugA bug in TypeScriptA bug in TypeScriptDomain: Indexed Access TypesThe issue relates to accessing subtypes via index accessThe issue relates to accessing subtypes via index accessFixedA PR has been merged for this issueA PR has been merged for this issue Milestone DescriptionTypeScript Version: 3.2.0-dev.20181011 Search Terms: Code export interface Entity { id: number | string; } export type IdOf<E extends Entity> = E['id']; export interface EntityState<E extends Entity> { ids: IdOf<E>[]; entities: { [key: string]: E, [key: number]: E }; } export function getAllEntities<E extends Entity>(state: EntityState<E>): E[] { const { ids, entities } = state; return ids.map(id => entities[id]); } export function getEntity<E extends Entity>(id: IdOf<E>, state: EntityState<E>): E | undefined { const { ids, entities } = state; if (!ids.includes(id)) { return undefined; } return entities[id]; } For completeness, I'll just mention that I intend for users to create subinterfaces of interface Task extends Entity { id: string; due: Date; title: string; } interface TaskState extends EntityState<Task> { // Inherits EntityState#ids as string[] currentTask?: string; } Expected behavior: Actual behavior: Playground Link: Related Issues: Activity
MetadataMetadataAssigneesLabelsBugA bug in TypeScriptA bug in TypeScriptDomain: Indexed Access TypesThe issue relates to accessing subtypes via index accessThe issue relates to accessing subtypes via index accessFixedA PR has been merged for this issueA PR has been merged for this issue 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. |