typescript.el
typescript.el copied to clipboard
Support for inserting jsdoc-like comments
As far as I know, TypeScript tends to be documented like this:
/**
* Run the provided promise, and call process.exit with an appropriate code.
*/
export function runPromise<T>(promise: Promise<T>): void {
In js2-mode
, I can type:
/**
and press C-M-j
, to get:
/**
*
*/
with point at the end of the second line. This would be a nice feature to have in typescript.el
, as well.
From the docs:
C-M-j runs the command indent-new-comment-line (found in global-map), which is an alias for ‘comment-indent-new-line’ in ‘newcomment.el’.
Running this command anywhere in typescript-mode gives mixed results:
var x;
|<- newline here
//
//|<- newline here
/*
/*|<- newline here
/**
/*|<- newline here
If we're going to override this command with a custom command for typescript-mode, we should properly address all these comment-styles.
I wonder whether we should rebind M-j
to c-indent-new-comment-line
by default. It seems to work better than indent-new-comment-line
from my minimal testing.
That's a good idea, and leaves us reinventing fewer wheels than we need to.
Have you experienced any cases where that does anything which is explicitly wrong?
It might also be relevant to ask @dgutov if there is a reason that js2-mode
doesn't do this, and instead implements its own js2-line-break
function.
Have you experienced any cases where that does anything which is explicitly wrong?
It's not as good as js2-mode, but better than what we have. I never encountered any case so far where indent-new-comment-line is better
In js2-mode, it's wasn't a particular decision to write js2-line-break
instead of using c-indent-new-comment-line
.
Before I got to it, js2-line-break
was a command js2-enter-key
bound to RET
. So using a custom 'comment-line-break-function
function provides some continuity.
So c-indent-new-comment-line
might be a good choice of you, except it's tying you to CC Mode a bit, and will probably require you to set a few related variables.
FYI tide-jsdoc-template
can insert now