Skip to content

Commit

Permalink
fix: fixed handle empty types while class functions converting
Browse files Browse the repository at this point in the history
  • Loading branch information
ariansobczak-rst committed Jan 20, 2022
1 parent eac1043 commit 0f9a25b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions typescript/type-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const appendComment = (commentBlock, toAppend) => {
* @returns {string} node type
*/
const getTypeName = (type, src) => {
if(!type) { return ''}
if (type.typeName && type.typeName.escapedText) {
const typeName = type.typeName.escapedText
if(type.typeArguments && type.typeArguments.length) {
Expand Down Expand Up @@ -213,10 +214,14 @@ module.exports = function typeConverter(src, filename = 'test.ts') {
memberComment = appendComment(memberComment, `@type {${type}}`)
}
if (member.type && ts.isFunctionLike(member)) {
memberComment = appendComment(memberComment, '@method')
memberComment = convertParams(memberComment, member, src)
memberComment = convertMembers(memberComment, member.type, src)
memberComment = appendComment(memberComment, `@return {${getTypeName(member.type, src)}}`)
try {
memberComment = appendComment(memberComment, '@method')
memberComment = convertParams(memberComment, member, src)
memberComment = convertMembers(memberComment, member.type, src)
memberComment = appendComment(memberComment, `@return {${getTypeName(member.type, src)}}`)
} catch (error) {
console.log(error);
}
}
if (modifiers.find((m => m === 'static'))) {
memberComment += '\n' + `${className}.${getName(member, src)}`
Expand Down

0 comments on commit 0f9a25b

Please sign in to comment.