heavenshell / vim-jsdoc

Generate JSDoc to your JavaScript code.
BSD 3-Clause "New" or "Revised" License
452 stars 44 forks source link

Typescript support #60

Closed iscekic closed 8 years ago

iscekic commented 8 years ago

It'd be nice if the plugin had typescript support (automatically detect types for parameter and return value, if specified).

heavenshell commented 8 years ago

Yeah, currently I'm working to support TypeScript.

heavenshell commented 8 years ago

@Torwori Could you try https://github.com/heavenshell/vim-jsdoc/tree/feature_typescript branch?

iscekic commented 8 years ago

I'll check it out tomorrow after work, sorry for the delay.

On Tue, Aug 30, 2016, 16:39 Shinya Ohyanagi notifications@github.com wrote:

@Torwori https://github.com/Torwori Could you try https://github.com/heavenshell/vim-jsdoc/tree/feature_typescript branch?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/heavenshell/vim-jsdoc/issues/60#issuecomment-243461968, or mute the thread https://github.com/notifications/unsubscribe-auth/AD38HFJeNxiNzw2vzrOaHbK64KzkZQ-Yks5qlEC7gaJpZM4Ju7d5 .

iscekic commented 8 years ago

Hey, just tried it out, seems to be working ok. :+1:

It would be even better if it automatically read types from the function signature, but if that's too much of a hassle then this is good enough.

heavenshell commented 8 years ago

@Torwori Thx for your feedback!

It would be even better if it automatically read types from the function signature,

Could you explain me more?

function foo(foo: string): string {
  return 'foo'
}

This would be like following.

/**
 * foo
 *
 * @param {string} foo
 * @returns {string}
 */
function foo(foo: string): string {
  return 'foo'
}

{string} are read from signature.

iscekic commented 8 years ago
let g:jsdoc_allow_input_prompt = 1
let g:jsdoc_input_description = 1
let g:jsdoc_additional_descriptions = 1
let g:jsdoc_access_descriptions = 2
let g:jsdoc_underscore_private = 1
let g:jsdoc_enable_es6 = 1

These are the settings I used, I had to enter the types manually.

heavenshell commented 8 years ago

@Torwori Thx. I'll start investigation.

heavenshell commented 8 years ago

@Torwori

let g:jsdoc_enable_es6 = 1
let g:jsdoc_allow_input_prompt = 1
let g:jscoc_return = 1
let g:jsdoc_input_description = 1
let g:jsdoc_access_descriptions = 2
let g:jsdoc_underscore_private = 1
function foo(foo: string = 'foo', bar: number = 1): string {
  return 'foo'
}
/**
 * Foo
 *
 * @public
 * @param {string} foo foo description
 * @param {number} bar bar description
 * @returns {string} foo string
 */
function foo(foo: string = 'foo', bar: number = 1): string {
  return 'foo'
}

Looks good to me.

Hit tab key when Argument "foo" type: shows then output typed candidates.

iscekic commented 8 years ago

Ah, I didn't know you could press tab. :+1:

heavenshell commented 8 years ago

@Torwori Thx. Merged to master.

xahon commented 7 years ago

JsDoc doesn't appear if cursor on line like public someFunc() : void

heavenshell commented 7 years ago

@xahon https://github.com/heavenshell/vim-jsdoc/blob/master/test/test.ts#L36 open above file and execute :JsDoc.

  /**
   * baz
   *
   * @param {string} [arg1='foo']
   * @param {number} [arg2=100]
   * @returns {void}
   */
  public baz(arg1: string = 'foo', arg2: number = 100): void {
  }

It seems works fine.