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

Typescript error on optional type. #54

Closed
MadsKelberg opened this issue Dec 20, 2022 · 4 comments
Closed

Typescript error on optional type. #54

MadsKelberg opened this issue Dec 20, 2022 · 4 comments

Comments

@MadsKelberg
Copy link

A typescript error is generated when using the v1.SubjectFilter type for the SubjectFilter.
Property 'optionalSubjectId' is missing in type '{ subjectType: string; }' but required in type 'SubjectFilter'.ts(2741) permission_service.d.ts(115, 5): 'optionalSubjectId' is declared here.

The type in question that makes the issue is the optionalSubjectId, that is not optional according to the interface generated for v1.SubjectFilter.

There is a workaround by disabling semantic checks by using // @ts-nocheck at the beginning of the file. However this kind of defeats the purpose of using typescript.

@josephschorr
Copy link
Member

Related to #53

@samkim
Copy link
Member

samkim commented Dec 28, 2022

@MadsKK Are you using .create to construct the v1.SubjectFilter message instances? That helper method allows you to omit optional fields when creating messages. Unfortunately, there is a disconnect between the name of that field and the semantics of the ts code generator.

See this comment for more context #33 (comment)

@MadsKelberg
Copy link
Author

@samkim Okay, that seems to fix the problem.
I was setting subjectFilter as a variable instead of setting it directly inside the .create function.
It seems that everything just has to be created inside the .create function.

Thanks for the clarification :)

@samkim
Copy link
Member

samkim commented Jan 4, 2023

No problem, glad that worked!

@samkim samkim closed this as completed Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants