* Split getWidenedTypeFromJSSpecialPropertyDeclaration
1. Handle this-property assignments
2. Handle other special property assignment
I have only started simplifying [2].
* Split into two passes
1. Look for jsdoc
2. Look for type of initializers
Both can be broken into their own functions.
* Break into two functions
* Move back to original function and single loop
Then, convert the 2 extracted functions to reduce-style functions that
take state and return the updated state.
* Cleanup suggestions from review
* findAllReferences/rename: Search in all open projects
* Avoid needing a dummy location when location is unused
* Remove Program#getDeclarationEmitPath
* Only iterate over enabled projects
* Revert "Revert "Explicitly typed special assignments are context sensitive (#25619)""
This reverts commit 16676f2707.
* Revert "Revert "Explicitly typed prototype assignments are context sensitive (#25688)""
This reverts commit ff8c30d636.
* Initial, wasteful, solution
It burns a check flags. Probably necessary, but perhaps not.
I haven't accepted baselines, but they are a bit questionable. I'm not
sure the synthetic type is right, because I expected to see
{ "exports": typeof import("x") } but instead see { "x": typeof
import("x") }.
* Update some baselines
* module.exports= always uses lhs type
Conflicts between exports property assignments and exports assignments
should get a union type instead of an error.
* Fix lint and accept good user baselines
* Add tests based on user tests.
These currently fail.
* Fix all but 1 of user test bugs found by typing module.exports
Still quite messy and full of notes
* Follow merged symbols+allow any object type
This allows exports like `module.exports = new EE` to have properties
added to them.
Still messy, but I'm going to run user tests and look for regressions.
* Update improved user baselines
* Fix infinite recursion when checking module.exports
* Fix bogus use-before-def error
getExportSymbolOfValueSymbolIfExported should always merge its returned
symbol, whether it's symbol.exportSymbol or just symbol.
* Update user test baselines
* Cleanup
* More small cleanup
* Bind `module` of `module.exports` as a special symbol
Previously it was also special, but created during name resolution in
the checker. It made sense when there was only one special symbol for
all files, but now there is one `module` symbol per file.
* Fix parsing of parenthesized JSDoc parameters
Parenthesis can start a jsdoc function parameter since it is just a
type, and parenthesis can start a type:
```js
/** @type {function(((string))): void} */
```
However, this is not legal in other parameter lists:
```ts
function x((((a))): string) { }
```
This change makes jsdoc function parameter lists parse differently than
normal parameter lists by allowing parenthesis as a start character of
jsdoc parameters.
* Parse nested uses of jsdoc function types
* Fix test
* add grammar check for labeled function declaration
* fix debug failed on labeled class declaration
* move labeled statement check to binder and add more pattern for check
* update diagnostic message
* update baseline
Keep emit flags set on the original node on a namespace or enum node.
This prevents dropping flags like NoComments, which caused duplicated
comment emits.
Additionally, TypeScript would emit synthetic comments twice, once for
the variable declaration, once for the module statement. This explicitly
clears away synthetic comments on namespaces and enums if their
synthetic comments have already been emitted on the corresponding
variable statement.
Previously, TypeScript would only set the text range when transforming
import and export declarations, leading it to drop synthetic comments
and emit flags.
This commit sets the original node on the statements that contains the
generated `require()` call (or similar, depending on module system),
retaining emit flags and synthetic comments.
Variables that do not have a local variable created get transformed into
a single exports assignment expression. TypeScript previously just
created a new expression and set the text range to retain original
comments, but for synthetic comments, merging the emit nodes by setting
the original node is required.