-
Notifications
You must be signed in to change notification settings - Fork 475
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
Referenced TypeAliases #505
Conversation
b347d52
to
05bb851
Compare
Changed target to 3.x 🎆 |
ed25b41
to
2c5c7fb
Compare
a379fa2
to
1e7e025
Compare
@dgreene1 I don't wanna bother you with this, but I'd like to rebase this with master and cut a 3.0-alpha1 so users can give feedback. Wdyt? |
@WoH that’s fine with me as long as I don’t have to publish a new version— users just npm install the branch. Is that acceptable to you? |
Well that's exactly what I had in mind though. I unfortunately don't have npm access or I'd offer to do it myself. |
Luke and I decided that it’s best to have only one person who can deploy the new packages so that we don’t get overlaps. As for getting feedback, if users want to try out the v3 branch, they can do that explicitly. I don’t see any disadvantage for having them do However, there are disadvantages of having a I truly feel very bad/guilty about not being able to give this PR the review attention it deserves. My plan was to actually merge this PR into master once the lingering v2 issues are resolved. Those lingering issues (for me) are the middleware issue, the security middleware issue, and the file response issue. I feel like that covers the 3 major items that users have been asking about. But maybe it makes more sense to keep this all simple and to just accept that if users want those three major features they would have to get it by upgrading to the new major version. I honestly don’t know what’s best. But for now I do know that there are no disadvantages to asking interested users to install the specific branch. |
The problem with the installation from github is that versioning is completely void and I may accidentally break builds with commits, making it even more unstable and probably completely unusable in any real scenario.
I'm not sure what you mean by security middleware, but I can assure you (properly swagger-aware) middleware is complicated enough to justify bumping another major. As for the others I'll gladly take a look, but I think at this point it'd be easier to backport 2 PRs (that don't even exist yet) to 2.x than port 20 to 3.x, so I'd urge you to consider that aswell. |
So @WoH are you saying that it might be better to just create the v3 branch now? I could be okay with that. It might be the only solution that doesn’t involve me slowing you down. |
Just wanted to follow up @WoH. I think we can do this. I was just reading this documentation: https://medium.com/@kevinkreuzer/publishing-a-beta-or-alpha-version-to-npm-46035b630dd7 It doesn't look too hard. So tell me if I understand the process properly:
Of course, the alternative is to just say "screw it" and we just merge this into master and publish tsoa package I'm looking for your advice. Thank you for your patience. If I was still using tsoa for my day job then this would be more on my mind. But I'm busy having to learn how .NET Core works. 🤕 |
The idea of the next tag is to have a way to install a version that is not yet released. E: Rebased I think this should be good to go as a first alpha, my plan would be to work on extractEnum + TS 3.7 compat for a2 |
This fixes an issue when you'd have a type like let x: ForwardGenericAlias<number, number> where type ForwardGenericAlias<_T, U> = GenericAlias<U>; where type GenericAlias<T> = T; The name created for GenericAlias<U> would be created incorrectly, because the context for GenericAlias<T> created would only contain T -> number, //forward referenced by FGA to GA making it impossible to resolve it to the proper name: GenericAlias_number_ If we build the context for this instance of GenericAlias<T> after naming, the context still contains _T -> number, U -> number and the name resloves properly.
Right now, type U = A | B would be cast as any before resolving the union could happen.
Since we don't have to extract literals from behind an alias reference, we can avoid a lot of unsafe special cases
@WoH just a heads up, I'm going to call the tag |
Sounds good |
@WoH the new tag should be out there. You can see it here: https://www.npmjs.com/package/tsoa Note: Yarn doesn't support loose semver so I couldn't make the version
|
Have you tried
Maybe the . instead of the - is the issue? I've prepped a little bit of text if you want to create a beta release for the changelog on GH: 3.0.0-alpha0Welcome to the first prerelease in the 3.0 alpha cycle. New Features:Support for type aliasesThis release comes with proper support for type alias definitions. They can range from simple scenarios /**
* A Word shall be a non-empty sting
* @minLength 1
*/
type Word = string; to more complex scenarios like unions and intersections of aliases type IntersectionAlias = { value1: string; value2: string } & TypeAliasModel1;
// or
type OneOrTwo = TypeAliasModel1 | TypeAliasModel2; or even generic type aliases: type GenericAlias<T> = T | string;
type ForwardGenericAlias<T, U> = GenericAlias<U> | T; Please note that this means that tsoa does not only generate the specification (OpenAPI v3 and Swagger2*), but will also validate the input against the types including the jsDoc annotations. * There may be certain scenarios where we may not be able to generate Swagger 2 from your TypeScript, tsoa will log warnings to infor you about any issues we are aware of. Support for mapped types
tsoa now works with the ts type checker to resolve mapped types. We will actively try to support all cases, however the test suite for now only covers the utility mapped types typescript ships with, like: /**
* Make all properties in T optional
*/
type Partial<T> = {
[P in keyof T]?: T[P];
};
/**
* Make all properties in T required
*/
type Required<T> = {
[P in keyof T]-?: T[P];
};
/**
* Make all properties in T readonly
*/
type Readonly<T> = {
readonly [P in keyof T]: T[P];
};
/**
* From T, pick a set of properties whose keys are in the union K
*/
type Pick<T, K extends keyof T> = {
[P in K]: T[P];
}; One of the types currently not covered yet is the Support for conditional typesAs of version 2.8, TypeScript supports conditional types. The syntax is very close to the ternary operator and enables expression of 2 (or more) different types based on a condition. Please refer to the TypeScript Handbook for details. type Diff<T, U> = T extends U ? never : T; // Remove types from T that are assignable to U tsoa now works with the ts type checker to resolve conditional types. We will actively try to support most cases, however the test suite for now only covers the utility types typescript ships with, like: /**
* Exclude from T those types that are assignable to U
*/
type Exclude<T, U> = T extends U ? never : T;
/**
* Extract from T those types that are assignable to U
*/
type Extract<T, U> = T extends U ? T : never;
/**
* Exclude null and undefined from T
*/
type NonNullable<T> = T extends null | undefined ? never : T; Support for combinations and utility typesThe combination of mapped and conditional types allow for powerful utility types like the
Again, experimental, there may be issues, please report. Breaking changesIn order to support type aliases and avoid name clashes, the names for the generated component schemas / definitions may have changed (generic interfaces are affected mostly). Because tsoa supported some type aliases in the past and now generated definitions differently, this may break your code. I (@WoH, on behalf of the maintainers) am are excited for your feedback! ETA?Feel free to follow the progress of the 3.0.0 release here. Installation
|
Thanks for these release notes @WoH. They were super duper helpful!!!! :) |
All Submissions:
Closing issues
Closes #204, closes #429, closes #470
If this is a new feature submission:
Potential Problems With The Approach
Test plan
For each of these:
Update:
Update 2 (out of scope for now):
This is why this will probably take me a long time and I'd be super grateful if someone could contribute parts of that.