Fixes#41586Fixes#41588
1. For binary expressions, if the immediate parent is an IfStatement,
then check the body of the if statement. I didn't walk upward to find an
IfStatement because in my experimentation I found that binary expression
uncalled-function errors are only issued when the expression is on the left of the
top-most binary expression.
2. For property accesses with interspersed calls, I added a
CallExpression case. In fact, any expression could appear here, but I
only want to fix calls for now since that's all we've observed in
Definitely Typed, and we didn't see anything else in the user tests or RWC
tests. I also didn't examine parameters of the intermediate call
expressions, but I don't think it's needed since the intent is to avoid
false positives.
* Use stricter types for tracing event arguments
In local development, I've routinely passed the wrong local and ended up
having JSON.stringify throw.
* Make the type recursive
Courtesy of @rbuckton
* Fix lint error
Future versions of node will be able to return undefined, rather than
allocating and throwing an exception, when a file is not found.
See https://github.com/nodejs/node/pull/33716
* Remove-all-unused-identifiers skips assigned identifiers
Previously, fixUnusedIdentifier worked the same in fix-all mode as for a
single fix: identifiers with assignments would be deleted:
```ts
function f(a) { }
f(1)
```
becomes
```ts
function f() { }
f()
```
But any kind of argument will be deleted, even one with side effects.
For a single codefix invocation, this is probably OK.
But for fix-all, this could lead to multiple changes
spread throughout a large file.
Now fix-all will only delete parameters and variable declarations with
no assignments:
```ts
function f(a) { }
function g(a) { }
f(1)
g
let x = 1
let y
```
becomes
```
function f(a) { }
function g() { }
f(1)
g
let x = 1
```
* Don't remove assigned parameters for single codefix either
* add optional parameter test case
* Skip initialised params and binding elements
Based on PR feedback from @amcasey
* fixAll removes unused binding patterns completely
* Fixes from comments
Thanks @amcasey for the thorough review
* fix trailing space lint
* correctly remove-all array binding
* Unuse Identifier codefix understands constructors
Previously, it did not look for `super()` and `new this()` calls when
determining whether a constructor parameter could be deleted.
* better names, fix off-by-1 bug
* Codefix understands super methods now too
This unifies the code, changing it considerably.
* Add actual baselines for a problem with global namespace being preferred over config & pragma implicit ones
* Fixed an issue with global React namespace being preferred over config & pragma implicit ones
* Do not try to mark JSX classic runtime symbols as used when automatic runtime is used
* Add tracing support to tsserver
Read the `TSS_TRACE` environment variable to determine which directory
trace files should be written to.
Notable changes from tsc tracing:
1) Drop all tracepoints that depend on type IDs
2) Write output to trace.PID.json
3) New, server-specific events (request/response, cancellation, etc)
* Drop try-finally blocks that aren't strictly necessary
* Fix lint error
* Trace background work (for diagnostics)
* Move try-finally blocks into session so tsc doesn't use them
* Add missing try-finally
* Use consistent capitalization
* Inline canPop call where underlying variable is available
* Clarify comments
* Include PID in build-mode file names
* Introduce more efficient popAll function
* Trace throwIfCancellationRequested rather than isCancellationRequested
* Remove unnecessary try-finally blocks
* Add a command-line argument for consistency with logging
* Fix rebase issues
* Address PR feedback
* Rename completionEvents to eventStack
* Drop assertStackEmpty as hard-to-maintain and marginally valuable
* Rename stepCancellation to stepCanceledEarly
* Rename stepEarlyCancellation to stepCanceled and use flag instead
* Check correct variable on exit