-
Notifications
You must be signed in to change notification settings - Fork 514
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
Add support for typeof
keyword in type parameters
#1753
base: master
Are you sure you want to change the base?
Conversation
typeof
keyword in typestypeof
keyword in type parameters
@WoH can you take a look at this when you get a chance? |
I'll get to it over the weekend! It looks good from slimming the code, but I'll try to play around with it a bit |
@@ -0,0 +1,512 @@ | |||
import { expect } from 'chai'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if you could integrate the tests in this file with the existing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec Generators Tests most likely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really about spec-generation though. These tests are about type resolution. The spec generation tests are relevant after a type has already been resolved. None of them use the type resolver.
Currently the testing for type resolution is spread across the controller/method/parameter generator specs, but those are higher order integration tests than what I'm testing here.
If we were going to merge them with existing tests, it would be somewhere in those.
In my opinion the lack of easy testability for type resolutions is one of the reasons that there are quite a few type resolution bugs outstanding for the repo. This test may make it easier for folks to identify and fix those in a much more narrow focus area.
}; | ||
|
||
const typeProperties: ts.Symbol[] = this.current.typeChecker.getPropertiesOfType(this.current.typeChecker.getTypeAtLocation(initializer)); | ||
const properties: Tsoa.Property[] = typeProperties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of the property management should already exist in checker based resolutions.
Ideally we can merge them together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on what you mean? Do you mean putting this code in a location that can be shared across other places where we do property management in this file?
All Submissions:
References Issue
This attempts to fix at least one of the sub issues related to the ability to use Zod's
z.infer
that was identified in #1256#1256 (comment)
Test plan
Adds a test case to the metadata / parameter resolver for
typeof
types as a parameter or return typeAdds an (expensive) unit test for TypeResolver to explicitly enumerate all of the type combinations that the resolver supports in a clean room environment. Open to suggestions on making this more efficient by combining into a single virtual source file, but the context of type right next to test is very valuable imo.
I've also included some types in this test that still fail (currently skipped) and are related to the other issues identified in #1256