@@ -163,26 +163,25 @@ var __importStar = (this && this.__importStar) || (function () {
163163 } ;
164164} ) ( ) ;
165165Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
166- var ts = __importStar ( require ( "typescript" ) ) ;
166+ const ts = __importStar ( require ( "typescript" ) ) ;
167167// excerpted from https://github.com/YousefED/typescript-json-schema
168168// (converted from a method and modified; for example, `this: any` to compensate, among other changes)
169169function parseCommentsIntoDefinition ( symbol , definition , otherAnnotations ) {
170- var _this = this ;
171170 if ( ! symbol ) {
172171 return ;
173172 }
174173 // the comments for a symbol
175- var comments = symbol . getDocumentationComment ( undefined ) ;
174+ let comments = symbol . getDocumentationComment ( undefined ) ;
176175 if ( comments . length ) {
177- definition . description = comments . map ( function ( comment ) { return comment . kind === "lineBreak" ? comment . text : comment . text . trim ( ) . replace ( / \r \n / g, "\n" ) ; } ) . join ( "" ) ;
176+ definition . description = comments . map ( comment => comment . kind === "lineBreak" ? comment . text : comment . text . trim ( ) . replace ( / \r \n / g, "\n" ) ) . join ( "" ) ;
178177 }
179178 // jsdocs are separate from comments
180- var jsdocs = symbol . getJsDocTags ( this . checker ) ;
181- jsdocs . forEach ( function ( doc ) {
179+ const jsdocs = symbol . getJsDocTags ( this . checker ) ;
180+ jsdocs . forEach ( doc => {
182181 // if we have @TJS -... annotations, we have to parse them
183- var name = doc . name , text = doc . text ;
184- if ( _this . userValidationKeywords [ name ] ) {
185- definition [ name ] = _this . parseValue ( text ) ;
182+ const { name, text } = doc ;
183+ if ( this . userValidationKeywords [ name ] ) {
184+ definition [ name ] = this . parseValue ( text ) ;
186185 }
187186 else {
188187 // special annotations
@@ -191,17 +190,16 @@ function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) {
191190 } ) ;
192191}
193192function getAnnotations ( node ) {
194- var _this = this ;
195- var symbol = node . symbol ;
193+ const symbol = node . symbol ;
196194 if ( ! symbol ) {
197195 return undefined ;
198196 }
199- var jsDocTags = symbol . getJsDocTags ( this . checker ) ;
197+ const jsDocTags = symbol . getJsDocTags ( this . checker ) ;
200198 if ( ! jsDocTags || ! jsDocTags . length ) {
201199 return undefined ;
202200 }
203- var annotations = jsDocTags . reduce ( function ( result , jsDocTag ) {
204- var value = _this . parseJsDocTag ( jsDocTag ) ;
201+ const annotations = jsDocTags . reduce ( ( result , jsDocTag ) => {
202+ const value = this . parseJsDocTag ( jsDocTag ) ;
205203 if ( value !== undefined ) {
206204 result [ jsDocTag . name ] = value ;
207205 }
@@ -215,13 +213,12 @@ function parseSpecificTags(node) {
215213 return ts . getJSDocParameterTags ( node ) ;
216214 }
217215 if ( node . kind === ts . SyntaxKind . FunctionDeclaration ) {
218- var func = node ;
216+ const func = node ;
219217 if ( ts . hasJSDocParameterTags ( func ) ) {
220- var flat = [ ] ;
221- for ( var _i = 0 , _a = func . parameters . map ( ts . getJSDocParameterTags ) ; _i < _a . length ; _i ++ ) {
222- var tags = _a [ _i ] ;
218+ const flat = [ ] ;
219+ for ( const tags of func . parameters . map ( ts . getJSDocParameterTags ) ) {
223220 if ( tags )
224- flat . push . apply ( flat , tags ) ;
221+ flat . push ( ... tags ) ;
225222 }
226223 return flat ;
227224 }
@@ -231,7 +228,7 @@ function getReturnTypeFromJSDoc(node) {
231228 if ( node . kind === ts . SyntaxKind . FunctionDeclaration ) {
232229 return ts . getJSDocReturnType ( node ) ;
233230 }
234- var type = ts . getJSDocType ( node ) ;
231+ let type = ts . getJSDocType ( node ) ;
235232 if ( type && type . kind === ts . SyntaxKind . FunctionType ) {
236233 return type . type ;
237234 }
@@ -240,11 +237,11 @@ function getAllTags(node) {
240237 ts . getJSDocTags ( node ) ;
241238}
242239function getSomeOtherTags ( node ) {
243- var tags = [ ] ;
240+ const tags = [ ] ;
244241 tags . push ( ts . getJSDocAugmentsTag ( node ) ) ;
245242 tags . push ( ts . getJSDocClassTag ( node ) ) ;
246243 tags . push ( ts . getJSDocReturnTag ( node ) ) ;
247- var type = ts . getJSDocTypeTag ( node ) ;
244+ const type = ts . getJSDocTypeTag ( node ) ;
248245 if ( type ) {
249246 tags . push ( type ) ;
250247 }
0 commit comments