Previously this was only an error when useDefineForClassFields: true,
but now it's an error for all code. This is a rare mistake to make, and
usually only occurs in code written before `readonly` was available.
Codefix to come in subsequent commits.
Get the `declaration` container just once instead of in three places.
(Minor change: one place used to start looking from
`declaration.parent`, but that shouldn't make any difference.) Also,
don't pass it to the helper functions since they're local anyway.
This only applies in JS, where `@template` tags can apply to
initialisers of variable declarations:
```js
/**
* @template T
* @returns {(b: T) => T}
*/
const seq = a => b => b
```
Fixes#36201
* Consolidated extra property check with intersections
* Fix comment
* Add tests
* Properly propagate intersectionState
* Route property check through recursive type tracking logic
* Accept new baselines
* Skip check when apparent type of source is never
* Accept new baselines
* Only check when apparent type of source is a structured type
* Fix serialisation of static class members in JS
Previously static class members would be treated the same way as expando
namespace assignments to a class:
```ts
class C {
static get x() { return 1 }
}
C.y = 12
```
This PR adds a syntactic check to the static/namespace filter that
treats symbols whose valueDeclaration.parent is a class as statics.
Fixes#37289
* fix messed-up indent
* Extract function
* Fix crash for private identifier in expando assignments
It does this by disallowing private identifiers from expando assignments
entirely. I haven't thought of a scenario where they make sense, but I
haven't thought about it exhaustively either.
Fixes#37356
* Update baselines
I think the new error is probably better. It's certainly different!
* Elaborate on reasons for 'never' intersections
* Accept new API baselines
* Accept new baselines
* Add tests
* Accept new baselines
* Address CR feedback
Previously, spreading an optional any gave a bogus error when the name
conflicted with earlier properties in the object literal. Now the code
checks any types for optionality before issuing the error.
Fixes#37740
* stash
* add surmise for return type
* add support for more case
* add more test case
* add more testcase and fix all test
* fix changed diagnosis
* fix broken test case
* add more case
* rename quickfix
* fix conflict
* fix fix desc
* fix semi
* Avoid replace brace with paren
* Split fix all action
* Add return work in same line
* fix test cases
* rename baseline
* refactor and handle comment
* Support semi
* make helper internal
* Accept change
* Accept the huge set of ever so slightly changed baselines
* Update return type logic to only reuse nodes if original nodes share scope with current node, like property types, only reuse nodes if symbols referened are acessible, reuse nodes for property signatures, too
* Only reuse nodes when a context is provided (otherwise identifier printback may fail)
* Only track symbol if symbol is found and no error is recorded
* Fix type parameter reuse lookup
* Forbid cjs module.exports references in retained nodes
* Adjust check for cjs export references to not include bad module type in output
* Add symbol to all identifiers we see in existing nodes for quickinfo
* Accept fourslash baseline updates
* Accept slightly updated baseline post-merge
* Do not copy original nodes for error types, replace empty type references with any
* Explicitly merge module augmentation members into the exports added by export * declarations
* Use ?., add namespace merge test
* Add missing merged symbol call to handle enum/ns merges during entity name lookup
* Add test with error case
* Handle missing value declarations in more places, unify duplicate declaration error handling to improve assignment declaration duplicate errors
* Fix crash on bad namespace parse
`global` inside a class body is parsed as a module declaration, and in
the following example has no body:
```ts
class C {
global x
}
```
`x` is parsed as a separate ExpressionStatement. This caused a crash in
emit because the code didn't expect a module declaration with no body.
* inline node.body variable
* fix missed references to body