* Refactor declaration emitter into declaration transformer
* Slight cleanup from code review feedback
* Incorporate fix for new test
* Swaths of PR feedback
* Merge public methods
* Per-file output
* Preserve input import ordering more often
* Unify jsdoc comment start detection under more lenient rule
* Move to per-file transformations to reduce the memory that msut be retained
* Fix typo
* No errr on unmatchable `@param` tags
Such as when the initializer is not a function, or when the function
mentions `arguments` in its body.
* Do not require dummy param for JS uses of arguments
1. JS functions that use `arguments` do not require a dummy parameter in
order to get a type for the synthetic `args` parameter if there is an
`@param` with a `...` type.
2.JS functions that use `arguments` and have an `@param` must have a
type that is a `...` type.
* Check for array type instead of syntactic `...`
* Address PR comments
* Update baselines
* Brackets and postfix= in `@param` add undefined
Previously they only added optionality.
Note that, unlike Typescript, when a parameter initializer is specified
in jsdoc, it does not remove undefined in the *body* of the function.
That's because TS will generate initialisation code, but JS won't, so
the author will have to manually write code to remove undefined from the
type.
```js
/** @param {number} [a=101] */
function f(a) {
// a: number | undefined here
if (!a) {
a = 101
}
// a: number here
}
```
Note that we don't check that
1. the initializer value is actually assigned to the parameter.
2. the initializer's type matches the declared type of the parameter.
Pretty much we just parse it and leave it alone.
* Address PR comments
* Add some new user tests to test salsa
* Use current latest, not "latest"
* Add other js user tests
* Add new baselines
* Fix new user tests' typeroot. Move github to octokit/rest
* Update baselines for user tests
* Add explicit indentation
* Fix https://github.com/Microsoft/TypeScript/issues/21355: Format `// @ts-ignore` added by quick fix
* Extract check to a separate function
* Consolidate checking for valid insert location
* Code review comments
* Do not return makeChange
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit