@@ -4,7 +4,7 @@ import * as opts from './options';
44import { CodeWriter , TextWriter , NameUtility , CodeWriterUtility } from '@yellicode/core' ;
55import { TypeNameProvider } from '@yellicode/elements' ;
66import { TypeScriptTypeNameProvider } from './typescript-type-name-provider' ;
7- import { ClassDefinition , InterfaceDefinition , EnumDefinition , PropertyDefinition , FunctionDefinition , ParameterDefinition , DecoratorDefinition , VariableDefinition } from './model' ;
7+ import { ClassDefinition , InterfaceDefinition , EnumDefinition , PropertyDefinition , FunctionDefinition , ParameterDefinition , DecoratorDefinition , VariableDefinition , HasJsDocTags } from './model' ;
88import { DefinitionBuilder } from './definition-builder' ;
99
1010/**
@@ -145,8 +145,7 @@ export class TypeScriptWriter extends CodeWriter {
145145 */
146146 public writeVariableDeclaration ( definition : VariableDefinition , kind : 'const' | 'let' ) : this {
147147 if ( definition . description ) {
148- // Yes, variables can have docs!
149- this . writeJsDocLines ( definition . description ) ;
148+ this . writeJsDocLines ( definition . description ) ; // Yes, variables can have docs!
150149 }
151150 this . writeIndent ( ) ;
152151 if ( definition . export ) {
@@ -214,9 +213,8 @@ export class TypeScriptWriter extends CodeWriter {
214213 }
215214 else definition = cls ;
216215
217- if ( definition . description ) {
218- this . writeJsDocLines ( definition . description ) ;
219- }
216+ this . writeJsDocLines ( definition . description , definition ) ;
217+
220218 if ( definition . decorators ) {
221219 this . writeDecorators ( definition . decorators , false ) ;
222220 }
@@ -270,9 +268,7 @@ export class TypeScriptWriter extends CodeWriter {
270268 }
271269 else definition = iface ;
272270
273- if ( definition . description ) {
274- this . writeJsDocLines ( definition . description ) ;
275- }
271+ this . writeJsDocLines ( definition . description , definition ) ;
276272 this . writeIndent ( ) ;
277273 if ( definition . export ) {
278274 this . write ( `export ` ) ;
@@ -341,9 +337,8 @@ export class TypeScriptWriter extends CodeWriter {
341337 const hasDefaultValue = t !== 'undefined' ; // '!== undefined' to allow for empty strings and explicit null
342338
343339 // Description
344- if ( definition . description ) {
345- this . writeJsDocLines ( definition . description ) ;
346- }
340+ this . writeJsDocLines ( definition . description , definition ) ;
341+
347342 // Start a new, indented line
348343 this . writeIndent ( ) ;
349344
@@ -439,9 +434,7 @@ export class TypeScriptWriter extends CodeWriter {
439434 }
440435 else definition = enumeration ;
441436
442- if ( definition . description ) {
443- this . writeJsDocLines ( definition . description ) ;
444- }
437+ this . writeJsDocLines ( definition . description , definition ) ;
445438 this . writeIndent ( ) ;
446439 if ( definition . export ) {
447440 this . write ( `export ` ) ;
@@ -460,9 +453,7 @@ export class TypeScriptWriter extends CodeWriter {
460453 this . increaseIndent ( ) ;
461454 for ( let i = 0 , len = definition . members . length ; i < len ; i ++ ) {
462455 const member = definition . members [ i ] ;
463- if ( member . description ) {
464- this . writeJsDocLines ( member . description ) ;
465- }
456+ this . writeJsDocLines ( member . description , member ) ;
466457 this . writeIndent ( ) ;
467458 this . write ( member . name ) ;
468459 if ( member . value || member . value === 0 ) {
@@ -782,9 +773,19 @@ export class TypeScriptWriter extends CodeWriter {
782773 return this ;
783774 }
784775
785- public writeJsDocLines ( lines : string [ ] ) : this {
786- if ( lines . length === 0 )
776+ public writeJsDocLines ( lines : string [ ] ) : this;
777+ public writeJsDocLines ( lines : string [ ] | undefined , taggedSymbol : HasJsDocTags | undefined ) : this;
778+ public writeJsDocLines ( lines : string [ ] | undefined , taggedSymbol ?: HasJsDocTags ) : this {
779+ lines = lines || [ ] ;
780+
781+ if ( taggedSymbol ) {
782+ if ( taggedSymbol . deprecated ) {
783+ lines . push ( `@deprecated ${ taggedSymbol . deprecated } ` ) ;
784+ }
785+ }
786+ if ( lines . length === 0 ) {
787787 return this ;
788+ }
788789
789790 this . writeLine ( '/**' ) ;
790791
0 commit comments