Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@asvetliakov

Description

@asvetliakov
Issue body actions

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: { ... } });

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.