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

Offer completions for model properties when model extends another model #3130

Closed
3 tasks done
bterlson opened this issue Apr 8, 2024 · 4 comments · Fixed by #3280
Closed
3 tasks done

Offer completions for model properties when model extends another model #3130

bterlson opened this issue Apr 8, 2024 · 4 comments · Fixed by #3280
Assignees
Labels
ide Issues for VS, VSCode, Monaco, etc. triaged:core
Milestone

Comments

@bterlson
Copy link
Member

bterlson commented Apr 8, 2024

Clear and concise description of the problem

model Foo {
  x: string;
  y: string;
}

model Bar extends Foo {
  // here I should get completions for members of Foo.
}

This would be very handy, especially when you are modelling complex data shapes with inheritance rather than templates.

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@markcowl markcowl added the ide Issues for VS, VSCode, Monaco, etc. label Apr 8, 2024
@markcowl markcowl added this to the [2024] May milestone Apr 8, 2024
@RodgeFu
Copy link
Contributor

RodgeFu commented Apr 23, 2024

it's also better to clarify these completions are for override scenario somehow so that they won't confuse people we are not using overrides.

@timotheeguerin timotheeguerin modified the milestones: [2024] May, Backlog Apr 24, 2024
@qiaozha
Copy link
Member

qiaozha commented Apr 28, 2024

I don't think currently we can override properties for now?
image

But for other usage like

model Bar extends Foo {
  z: Foo.x;
}

Maybe we should also consider offer completions for spread of alias or spread of models or other kinds of combination ?

@bterlson
Copy link
Member Author

You can override, but the type you override with has to be a subtype of the base. So in your example, if you set x to "someString" it would work.

it's also better to clarify these completions are for override scenario somehow so that they won't confuse people we are not using overrides.

Can you say more about what the potential confusion is?

@RodgeFu
Copy link
Contributor

RodgeFu commented Apr 30, 2024

Can you say more about what the potential confusion is?

I think it would be confusing for user who is new to typespec and not familiar with the property override feature. Like when I first look at the issue, I just wondered why the intellisense needs to suggest me with the properties of parent type? do i need to define them again in the subtype for things to work (like implement interface in ts)? i just didn't realize it's for override... (i guess it may also because i am used to c# and would think about override scenario only when I type override/new keyword...) thx

github-merge-queue bot pushed a commit that referenced this issue May 17, 2024
…odel (#3280)

add following feature
1. support completion when user typing model expression as decorator
argument value
2. support completion for extended model
3. support showing decorator model argument prop information when
hovering on model expression as decorator argument value

closes #3130, closes #2228, closes #1956

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
@RodgeFu RodgeFu self-assigned this May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ide Issues for VS, VSCode, Monaco, etc. triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants