* Fixed tuple types indexed by a type parameter
* If only there was a tool to add that missing semicolon for me
* Rename to baseConstraint
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Fix missed errors in switch when using union of literal and non-literal types (#38686)
This commit makes it so we don’t use the base type of literals when checking comparability in switch. The comparability checks handle that case already, is my understanding, so we don’t need to clobber the type before actually doing the check, causing missed errors.
When comparing the types in switch, if a union with a literal and a non-literal was used, the compiler in `checker.ts` would automatically get the base type of all parts of the union, resulting in missed errors. For example, if the union of the non-literal `number` and literal `"hello"` was compared to the literal `"world"` in a switch case, the compiler would miss that they’re actually not comparable.
Maybe someone can tell me why we were getting the base type before checking comparability, rather than relying on the logic within the comparability checks to handle literal/base type comparability?
* Fix lint (whitespace) issue in checker.ts by running lint with fix flag.
* Fixed an issue with `in` not being able to be used on narrowed down expression of a generic nullable type
* Add another test case from a new issue
* Move the fix to `hasEmptyObjectIntersection`
* Refactor `Extensions`, fix lookup priorities
* Update baselines
* Clean up
* Temporarily apply same fix to `node` for testing
* Revert ancestor node_modules lookups back to two passes
* Revert "Temporarily apply same fix to `node` for testing"
This reverts commit 4014f3005a2a01a5c71a88e6418cc635498a83bc.
* Update baselines
* Add new test for node_modules searching behavior
* Update new baseline
* Add known keys of the mapped type constraint to its members
* Avoid second pass of adding known members by instead passing `noReductions` to `mapType`
This adds a "small" d.ts bundler script. This script is very basic,
using Node printing to produce its output. Generally speaking, this is
inadvisable as it completely disregards name shadowing, globals, etc.
However, in our case, we don't care about the globals, and we can opt to
restructure our codebase in order to avoid conflict, which we largely
had to do anyway when we were namespaces and everything was in scope.
* Fixed a regression with discriminating unions based on a union property against `undefined` with `strictNullChecks: false`
* Add additional test case from the issue comment
* fix(50551): handle destructuring variables used before assignment
* skip the error in binding elements that refer to the same destructuring
* fix binding element type
* Check nested weak types in intersections on target side of relation
* Add regression tests
* Move logic from isRelatedTo to structuredTypeRelatedTo
* Fix lint error
* Add additional test
* Include type parameter defaults in contextual typing
* Add tests
* Add additional an test for instantiating contextual signature using default type param (#51002)
* Update comment
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
* Remove language version check for extended escapes.
* Accepted baselines.
* Record whether nodes have extended Unicode escapes. Replace them in the es2015 transform.
* Accepted baselines.
* Move file to better-reflect generality of tests.
* Added tests for variables at the top level.
* Accepted baselines.
* Added test for extended astral character.
* Accepted baseline.
* Enable sourcemaps in tests.
* Accepted baselines.
* Call `setOriginalNode` on identifiers with extended escapes.
* `in` proves property presence only if property can't be undefined
* Accept new baselines
* Add tests
* Accept new baselines
* Properly compute SymbolFlags.Optional for intersected properties
* Accept new baselines
* Check optionality only for property-like declarations
* Add more tests
* Improve checking of `in` operator
* Accept new baselines
* Add tests
* Delete old and accept new baselines
* Disallow right operand of type '{}'
* Accept new baselines
* Support number and symbol literals
* Add tests
* Disallow {} typed right operand only in strictNullChecks mode
* Accept new baselines
* Detect {} resulting from intersections
* Accept new baselines
* Don't attempt to reduce intersections with Record<K, unknown>
* Accept new baselines
* Return undefined instead of unknownSymbol from getGlobalRecordSymbol()
* don't elide imports in JS files
* WIP: get rid of caching of resolved symbol, add transform tests
* get rid of caching only for resolver functions
* use getReferencedSymbol instead of getReferencedValueSymbol in module transform
* WIP: add reportErrors flag to resolveName
* Import transformations now work correctly
* don't emit diagnostics when looking up referenced symbol
* small fixes and get rid of unnecessary comments
* update tests
* clean up
* CR: use nameNotFoundMessage to decide whether to report errors in resolveName
* WIP
* implement typequery contains reference check + tests
* add unit test
* fix unit test
* use symbols in scope to check type query type parameter references
* remove comment on unit test
* remove comment
* use isNodeDescendantOf implementation to check scoping
* CR: small fixes
* treat the different kinds of type parameter declarations
* undo test change
* make `RegExpExecArray` always include index 0
* update baseline
* remove `BaseRegExpArray` interface
* add test
Co-authored-by: DetachHead <detachhead@users.noreply.github.com>