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

[Not Ready] [typespec-vscode] Add autocomplete of model properties for union type #5483

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mzhongl524
Copy link
Member

Fix : #4024

add code and tests

@mzhongl524 mzhongl524 added the ide Issues for VS, VSCode, Monaco, etc. label Jan 3, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Jan 3, 2025
@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 3, 2025

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/compiler
Show changes

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 3, 2025

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs 🛝 VSCode Extension

@@ -2617,7 +2617,7 @@ export function createChecker(program: Program, resolver: NameResolver): Checker

function getReferencedModel(
propertyNode: ObjectLiteralPropertyNode | ModelPropertyNode,
): Model | undefined {
): Model | Model[] | undefined {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if it's a model union with other type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More discussion is needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the parameter is a property, so the referenced type must be a model or some model, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use return Model[]

@RodgeFu RodgeFu self-assigned this Jan 13, 2025
@@ -2679,13 +2680,29 @@ export function createChecker(program: Program, resolver: NameResolver): Checker
) {
path.unshift({ propertyName: node.id.sv });
}
if (node.kind === SyntaxKind.ObjectLiteral) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler ide Issues for VS, VSCode, Monaco, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto complete of value/model properties not working when the type is a union
3 participants