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

Autocomplete suggestions for missing properties when creating new objects/literals of an expected type #3074

Closed
niieani opened this issue Dec 23, 2016 · 4 comments

Comments

@niieani
Copy link

niieani commented Dec 23, 2016

TypeScript gives autocomplete suggestions for object properties and literals when a type is known at the time the object is being created / argument typed, i.e. explicitly declared, inferred or cast.

This is how it works:
screencast 2016-12-23 16-20-13

I've been a long time TypeScript user and have recently started contributing to a large project which is based on Flow and this is the single feature that I miss the most (right next to live-feedback). I have tried multiple Flowtype integrations (Atom/Nuclide, WebStorm, VSCode, SublimeText) and none of them offer this type of autocompletion, so I presume the problem is that the Flow server simply does not offer this information.

These are some of the scenarios that should be supported:

  1. explicitly declared
type Type = { a: string }
const a: Type = {
  // ... autocomplete all properties in Type
}
  1. type known through a nested definition
type OtherType = { a: string }
type Type = { a: OtherType }
const a: Type = {
  a: {
    // ... autocomplete all properties in OtherType
  }
}
  1. type inferred / expected
type Type = { a: string };
function example(param: Type) { };
example({ /* ... autocomplete all properties in Type */ });
  1. type declared indirectly
type Type = { a: string }
function example(): Type {
  return {
    // ... autocomplete all properties in Type
  }
}
  1. type cast
type Type = { a: string }
function example() {
  return ({
    // ... autocomplete all properties in Type
  } : Type)
}
@kof
Copy link
Contributor

kof commented May 8, 2017

Can we have a meaningful discussion about this topic? I would like to get this supported for cssinjs in order to autocomplete styles.

@niieani niieani changed the title Autocomplete suggestions for missing properties when creating new objects of an expected type Autocomplete suggestions for missing properties when creating new objects/literals of an expected type May 28, 2017
@sibelius
Copy link

sibelius commented Jun 7, 2018

any progress on this?

@niieani
Copy link
Author

niieani commented Jun 7, 2018

@calebmer mentioned last year in a tweet that he's going to focus on this and other IDE-related issues this year. Year hasn't ended yet, so I'm hopeful 😂.

@gkz
Copy link
Member

gkz commented Oct 5, 2021

This should now work (if not automatically, you can trigger automatically with CTR-space

@gkz gkz closed this as completed Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants