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 3.5 regression casting object to { [key: string]: unknown }; #31381

Closed
mjbvz opened this issue May 13, 2019 · 1 comment
Closed

TS 3.5 regression casting object to { [key: string]: unknown }; #31381

mjbvz opened this issue May 13, 2019 · 1 comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@mjbvz
Copy link
Contributor

mjbvz commented May 13, 2019

TypeScript Version: 3.5.0-dev.20190507

Search Terms:

  • index signature
  • unknown

Code

export interface I { 
    foo(): { [key: string]: unknown };
}

export class B implements I {
    foo(): object {
        return {};
    }
}

Expected behavior:
This code compiles without errors in TS 3.4.5

Actual behavior:
In 3.5@next, there is the error:

Property 'foo' in type 'B' is not assignable to the same property in base type 'I'.
  Type '() => object' is not assignable to type '() => { [key: string]: unknown; }'.
    Type 'object' is not assignable to type '{ [key: string]: unknown; }'.
      Index signature is missing in type '{}'.

This may be by design but I'm not sure which issue tracks the change.

We hit this issue in the vscode codebase

Playground Link:

Related Issues:

@ahejlsberg
Copy link
Member

This is an intended effect of #30637. See rationale here.

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants