* Emit buildinfo when there are errors with noEmitOnError?
TODO: --build mode
* Always emit tsbuild info even if there are non syntax errors in tsc --build mode
* Sort affectedFilesPendingEmit for consistent build info text
* add skeleton
* add getAvailableActions
* add working getEditsForAction
* add multi vardecl
* fix multi decl bug
* change refactor name
* add tests for ToAnon, ToArrow and available arrow
* add tests for ToNamed and available anon
* add tests for ReturnType and available Arrow as FnParam
* fix bug modifiers by toNamed
* add tests for modifiers
* fix for tslint error
* adapt one test case
* refactor getInfo getAvailableActions
* refactor small progress
* extract creation of block
* extract creation of funcDeclaration
* make guideline compliant
* apply feedback from pr
* add testcase and apply feedback from pr
* apply feedback from pr
* add newline
* rename testcases
* Make conditions more expressive
* fix for unnecessary duplication of comment
* apply feedback from pr
* update getAvailableActions
* check if functionExpression name is used
* add more testcases
* do not provide refactoring when it contains this
because this behaves differently in arrow than in function
* exclude nested functions and classes at containingThis check
* fix linting error
* fix line endings
Co-authored-by: BigAru <arooran@indikon.ch>
Co-authored-by: bigaru <bigaru@users.noreply.github.com>
Co-authored-by: Jesse Trinity <42591254+jessetrinity@users.noreply.github.com>
Co-authored-by: Jesse Trinity <jetrinit@microsoft.com>
* fix: range of ts2657 (jsx expr must have parent) and remove 2695 (LHS expr of comma has no side effects)
* feat: add code fix for 2657
* fix: resolve review
* chore: hoist a var
* chore: add test for skipTrivia
* fix: rebase error
* Update src/compiler/diagnosticMessages.json
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
* Update src/services/codefixes/wrapJsxInFragment.ts
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Andrew Branch <andrew@wheream.io>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
1. Switch to isSymbolAccessible for both types and values, then unify to
a single function.
2. Remove inaccesible base error. We can put it back after making
@implements type reference lookup looser (which may or may not happen).
* Initial draft of named tuple members
* Show tuple labels and documentation in completions
* Swap allowed syntax to parameter-like
* Add quickfix for labeled tuple syntax mistakes
* Add refactoring to convert list of signatures to single overload
* Fix small bug in visitor verification
* Signature help for rest parameters which are unions of tuples are displayed as seperate entries now
* Expand sanity check test cases in conformance suite
* Add tests and code for preserving tuple names through spreads where possible
* More refactoring tests, some comment preservation and some fixed formatting of multiline tuples
* Handle missing parameter named in isValidDeclarationForTupleLabel
* Minor text fixes
This problem was introduced in 70399e146e (from PR #23801), which added
a `visitTaggedTemplateExpression` case for `TaggedTemplateExpression`,
before that, it would fallback to the default of `visitNode`. So re-add
that happen in `processTaggedTemplateExpression`.
Since it doesn't hurt, I left a `Debug.checkDefined(property.name)`
instead of `!`-ing it.
Fixes#38558.
* Improve assert message in binder
Looking at the code, I don't think the assert can ever fire, but it
clearly does, or did in the past. This will make it easier for people to
create a repro.
* fix lint
* Use BindableStaticNameExpression not BindableStaticAccessExpression
This type does allow identifiers, but those are ruled out earlier, so I added
an assert for that case.
* feat(37782): add quick-fix action to declare a private method for names that start from underscore
* better merge order in messages json
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Allowed comment directives to be multiline
* Added tests, and perhaps fixed a test runner bug?
* I think it's going to need a consistent variable to loop over
* Used dynamically computed indexes in verifies
* Added multiline tests
* Increased flexibility for multiline comment parsing
* Undid a couple of formatting changes; removed backslashes from multiline regexp
* Added baseline tests for multiline comment skipping
Co-authored-by: Orta Therox <orta.therox@gmail.com>
* Fix `updateBinary` `operator` parameter
There is an issue in `updateBinary` where attempting to update
`operator` without updating `left` or `right` results in a silent no-op.
* Use defaulted parameter in `updateBinary`
* Adds support for looking up past Blocks in expando objects
* Adds JS tests to validate the JS parsing also works
* Get the top level block expando tests green
* Shared early couldContainTypeVariables check in instantiateType
* Defer creation of map object in createUnionOrIntersectionProperty
* Types with top-level non-generic type alias reference no type variables
* Use CFA to determine types of properties declared by this.xxx assignments
* Accept new baselines
* Also use CFA in constructor functions
* Accept new baselines
* Fix lint error
* Only widen fresh literal types in CFA of assignment to auto-typed
* Auto-typing for declared properties with no type annotation or initializer
* Add optionality if declaration includes '?' modifier
* Always use CFA for properties with no initializer in .js files
* Small fix
It's always supposed to have been this way, but I was worried about how
breaky the change would be when adding globalThisType. This PR is
experiment to see how much.
Fixes#35882 maybe
initialiser. But this is only correct when the initialiser is for a
parameter. For example:
```ts
declare let x: { s: string } | undefined;
const { s } = x;
```
This PR removes undefined from the type of a binding pattern only when
the binding pattern's parent is a parameter. This fixes the regression
from 3.8. However, it's still not the ideal fix; we should be able to
use control flow to solve this problem. Consider:
```ts
const { s }: { s: string } | undefined = { s: 'hi' }
declare function f({ s }: { s: string } | undefined = { s: 'hi' }): void
```
Neither line should have an error, but the first does in 3.8 and after
this change.
* Remove superCallShouldBeFirst error
It seems redundant since TS gives an error on any use of `this` before
super, and non-`this` uses before `super` should be fine.
Fixes#37371
* Revert "Remove superCallShouldBeFirst error"
This reverts commit 3c09153c8a.
* error except for target:"esnext" && useDefineForClassFields
* Fix use-before-def with methods on esnext+useDefineForClassFields
It was incorrectly flagging methods as used before their definition, but
this is allowed under any emit.
* Add instance function test case
* Propagate nonInferrableType in &&, || and ?? operators
* Add regression test
* Simpler solution: getTypeFacts(neverType) should return TypeFacts.None
* Add fastpath to isRelatedTo for type references
* Do not check intersections or unions to ignore propegating reference flags, properly set comparing jsx flag
* Re-remove unneeded check
* Just check for TypeFlags.Object
* Remove else clause
* Error on missing BigInt in ES2020 too.
Previously it was only on ESNext, but bigint ships in ES 2020.
There are no tests for this; passing `false` doesn't cause any tests to
fail at least.
* add tests
* Avoid circular reference in this-property assignments
To do this, don't check this-property assigments that have the
this-property of the lhs appearing somewhere on the rhs:
```js
class C {
m() {
this.x = 12
this.x = this.x + this.y
}
}
```
I tried suppressing the circularity error, but because we cache the
first type discovered for a property, this still results in an implicit
any for `x` in the previous example. It just doesn't have an error.
Fixes#35099
* Add test case + rename function
* Use isMatchingReference
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
Extends the fix of #36108 so that the simple example gets correct emit;
the complex test case I came up with still doesn't work correctly, but
the actual code froma #35228 is fixed.
* Special-case window, self, global, globalThis methods
* Disambiguate global and this property completions in details requests
* Hide the Map<boolean> implementation
* Update old tests
* Replace SymbolOriginKind stringification with dedicated enum
* Make never rest type top-like
* Add higher-order test
* properly support types which reduce to never
Co-authored-by: Wesley Wigham <wwigham@gmail.com>
* Add Advanced Compile Options to --init command
* removed advanced options and descriptioncolumn
* tests: fix tsconfig.json baselines
* tests: fix failing tests
* feat: adjusted link to specification
* fix: removed duplicate increment flag
* chore: moved position back
* return of the comments
* fix for missalignment
* return of the comment