Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS losing optional properties when used with index signature and generics #9900

Closed
asvetliakov opened this issue Jul 22, 2016 · 0 comments · Fixed by #52149
Closed

TS losing optional properties when used with index signature and generics #9900

asvetliakov opened this issue Jul 22, 2016 · 0 comments · Fixed by #52149
Labels
Bug A bug in TypeScript
Milestone

Comments

@asvetliakov
Copy link

TypeScript Version: 2.0.0-beta

Code

Base code:

// A *self-contained* demonstration of the problem follows...
    interface Test {
        a?: number;
        b?: string;
    }
    interface TestWithStrictProp {
        a?: number;
        b?: string;
        c: string;
    }

    interface TestIndex {
        [key: string]: Test;
    }
    interface TestIndexWithStrict {
       [key: string]: TestWithStrictProp;
    }
    declare function testFunc<T extends TestIndex>(t: T): void;
    declare function testFuncStrict<T extends TestIndexWithStrict>(t: T): void;

Consumer code

testFunc({
  test: {
      // Compiler doesn't see properties here
  }
});

testFuncStrict({
  test: {
     // Compiler see a?, b? and c
  }
});

Expected behavior:
Completion in testFunc({ test: { ... } });

@RyanCavanaugh RyanCavanaugh changed the title TS loosing optional properties when used with index signature and generics TS losing optional properties when used with index signature and generics Jul 22, 2016
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jul 22, 2016
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.1 milestone Jul 22, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, Future Sep 29, 2016
asvetliakov added a commit to asvetliakov/TypeScript that referenced this issue Feb 21, 2017
@mhegazy mhegazy assigned ghost and unassigned yuit Nov 7, 2017
@RyanCavanaugh RyanCavanaugh unassigned ghost Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
4 participants