-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add proper support for advanced typescript syntax
- Loading branch information
Showing
5 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# ============================================================================== | ||
# Functions with destructured parameters. | ||
# ============================================================================== | ||
Given typescript (functions with destructured parameters): | ||
class Test { | ||
@Test() | ||
@Test() | ||
test({ idUser, userModel }: { idUser: ObjectId, userModel: string }) {} | ||
|
||
@Test() | ||
async test(@Body() { idUser, userModel }: { error: string } & { idUser: ObjectId, userModel: string }): UserA & UserB {} | ||
} | ||
|
||
Do (trigger doge): | ||
:4\<CR> | ||
\<C-d> | ||
:13\<CR> | ||
\<C-d> | ||
|
||
Expect typescript (generated comment with a description, @param and @return tags): | ||
class Test { | ||
/** | ||
* [TODO:description] | ||
* | ||
* @param {[TODO:type]} [TODO:name] - [TODO:description] | ||
* @return {[TODO:type]} [TODO:description] | ||
*/ | ||
@Test() | ||
@Test() | ||
test({ idUser, userModel }: { idUser: ObjectId, userModel: string }) {} | ||
|
||
/** | ||
* [TODO:description] | ||
* | ||
* @async | ||
* @param {[TODO:type]} [TODO:name] - [TODO:description] | ||
* @return {UserA & UserB} [TODO:description] | ||
*/ | ||
@Test() | ||
async test(@Body() { idUser, userModel }: { error: string } & { idUser: ObjectId, userModel: string }): UserA & UserB {} | ||
} | ||
|
||
# ============================================================================== | ||
# Functions with destructured parameters. | ||
# ============================================================================== | ||
Given typescript (constructor with decorator and scoped parameters): | ||
class Test { | ||
constructor( | ||
@InjectModel(User.name) private readonly $model: Model<T>, | ||
@InjectModel('User') private readonly model: Model<T> | ||
) {} | ||
} | ||
|
||
Do (trigger doge): | ||
:2\<CR> | ||
\<C-d> | ||
|
||
Expect typescript (generated comment with a description, @param and @return tags): | ||
class Test { | ||
/** | ||
* [TODO:description] | ||
* | ||
* @param {Model<T>} $model - [TODO:description] | ||
* @param {Model<T>} model - [TODO:description] | ||
* @return {[TODO:type]} [TODO:description] | ||
*/ | ||
constructor( | ||
@InjectModel(User.name) private readonly $model: Model<T>, | ||
@InjectModel('User') private readonly model: Model<T> | ||
) {} | ||
} |