cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Support type / interface fields in typescript

Open pokey opened this issue 4 years ago • 5 comments

The problem

For example in the following code:

interface Foo {
   bar: Bar;
   baz: Baz;
}

If your cursor was before bar, then "take field" would select bar: Bar

Approach

Look for the property_signature node type

A couple options:

  • Introduce a new term "prop". We may also want it to select property accesses (eg foo.bar), and class property definitions
  • Modify "state" to target this scope type. I guess technically these aren't considered statements, but that seems a bit subtle to me
  • Modify "item" to target this scope type

First raised in #24 by @brxck

pokey avatar Jun 30 '21 09:06 pokey

I think this is fixed

AndreasArvidsson avatar Dec 11 '21 15:12 AndreasArvidsson

Really? I don't see a field scope type. What am I missing?

pokey avatar Dec 14 '21 14:12 pokey

Why use a new scope and not just item?

AndreasArvidsson avatar Dec 14 '21 14:12 AndreasArvidsson

Oh does that work?

pokey avatar Dec 14 '21 14:12 pokey

Also, I'm not sure "item" is what I'd use for that. I could see reusing an existing scope type, but I think I'd lean towards "statement", because although technically not a statement, it sure looks and feels a lot like one

For me, "item" is something in a comma-separated list

pokey avatar Dec 14 '21 14:12 pokey