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

Property initializer should get the same completion as property assignment #15361

Closed
mjbvz opened this issue Apr 24, 2017 · 3 comments
Closed
Labels
Duplicate An existing issue was already created VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Apr 24, 2017

From @unional on April 22, 2017 9:12

  • VSCode Version: 1.11.2
  • OS Version: OSX
abstract class Foo {
  options: {
    x: string
  }
}

class Koo extends Foo { // already know options is missing x
  options = {
    // should get `x` as property
  }
  do() {
    this.options = {
      // does recognize `x` as property
    }
  }
}

image

image

Copied from original issue: microsoft/vscode#25181

@mjbvz mjbvz self-assigned this Apr 24, 2017
@mjbvz mjbvz removed their assignment Apr 24, 2017
@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Apr 24, 2017
@sandersn
Copy link
Member

sandersn commented Apr 24, 2017

Typescript sees Koo's options as distinct from Foo's options when declaring them. It just checks that Koo's options is assignable to Foo's options after it has been created.

In contrast, this.options is referring to something that is already declared. Note that if you provide a more specific type for Koo's options, like options = { x: "string literal type" }, then the completion for this.options in Koo will have that more specific type.

@sandersn
Copy link
Member

A full explanation of the approaches we have tried is at #6118. Both would provide completions here, but neither works well as part of the language.

@sandersn
Copy link
Member

Duplicate of #3667

@sandersn sandersn added the Duplicate An existing issue was already created label Apr 24, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

2 participants