Commit Graph

11788 Commits

Author SHA1 Message Date
Sheetal Nandi
3172629f21 Add new option to cacheResolution (No actual functionality yet) 2022-12-09 14:49:18 -08:00
Oleksandr T
1f32fef5a2 fix(51077): skip insertText for jsx attribute with existing initializer (#51093) 2022-12-09 08:38:08 -08:00
Josh Goldberg
f3d55db45a Fixed tuple types indexed by a type parameter (#51037)
* 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>
2022-12-09 07:59:40 -08:00
George Manning
65bf850a20 Fix #51437 Duplicate "Duplicate identifier" errors (#51594)
* retroactive approach to remove duplicate diagnostics

* use code instead of messageText, update test

* use existing de-dupe function

* rename test and baselines

* add fourslash test for better assertion of fix

* review feedback: move deduplicate to getDiagnosticsHelper

* accept baseline with sorted diagnostics

* remove newline
2022-12-08 19:21:41 -08:00
Oleksandr T
e087992134 feat(47977): show completion in jsdoc extends/implements tags (#51028) 2022-12-08 17:10:00 -08:00
Oleksandr T
8f2ee38b52 fix(50888): Organize Imports may delete preceding comments when all members of all import statements are unused (#50983)
* fix(50888): preserve preceding comments of the deleted import

* update tests
2022-12-08 17:05:12 -08:00
Ryan Cavanaugh
a3dbe7dc70 Update default target from ES3 to ES5 (#51731)
* Change the default emit target to ES5

* Add baseline update

* Remove tests with a hardcoded sourcemap in it

* Update hardcoded tests

* Merge with main

* Restore tests
2022-12-08 16:43:47 -08:00
Anders Hejlsberg
b9d0e17298 Ignore switch statement bypass control flows that produce never (#51703)
* Ignore switch statement bypass control flows that produce 'never'

* Add regression test
2022-12-07 16:19:09 -08:00
Anders Hejlsberg
d43112a75b Use missingType in --noUncheckedIndexedAccess mode (#51653)
* Use missingType in noUncheckedIndexedAccess mode

* Accept new baselines

* Add tests

* Optimizing searching for undefinedType and missingType
2022-12-07 13:38:33 -08:00
Anders Hejlsberg
91f89b94e4 Visit child nodes in checkExpressionWithTypeArguments (#51804)
* Visit child nodes in checkExpressionWithTypeArguments

* Accept new baselines

* Add tests
2022-12-07 10:06:12 -08:00
Mateusz Burzyński
6684e3d527 Fixed substition types for non-generic indexed accesses (#51621) 2022-12-07 07:47:32 -08:00
Andrew Branch
dc3daa6644 Fix namespace import update bug, simplify, comment, and rename (#51797) 2022-12-06 16:38:33 -08:00
Gabriela Araujo Britto
a1536358f7 fix & test (#51792) 2022-12-06 16:18:01 -08:00
Jake Bailey
703652cebf Remove some files from the repo root (#51446) 2022-12-06 13:42:54 -08:00
Eric Ferreira
af1d91d9d9 Fix missed errors in switch when using union of literal and non-literal types (#38686) (#51373)
* 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.
2022-12-06 10:50:21 -08:00
Isabel Duan
ae9c671d59 (fix #50725, #50710) add file extensions in import statements (#51702)
* fixes #50725

* fixed 50710

* fixed broken test

* clean up

* variable rename

* rename variable to newFileBaseName
2022-12-06 09:28:10 -08:00
Oleksandr T
0eca6b0edc fix(40365): handle deprecated properties of merged interfaces (#51640) 2022-12-05 15:06:18 -08:00
Wesley Wigham
e9e7a9d49a Fix #51623 (#51762)
* Fix #51623

* Revert newline changes
2022-12-05 12:48:11 -08:00
Lyu, Wei-Da
0c09d2f172 quick fix for a nullable missing callback function (#51743) 2022-12-05 12:23:59 -08:00
Anders Hejlsberg
c07f51242c Fix narrowing by typeof applied to discriminant property (#51720)
* Fix narrowing by typeof applied to discriminant property

* Include effects of getReferenceCandidate

* Add tests
2022-12-05 11:51:54 -08:00
Gabriela Araujo Britto
6a3c9ea125 Exhaustive case completion for switch statements (#50996)
* fix services' type's isLiteral

* update literal completions tests

* initial prototype

* use symbol to expression. TODO: filter existing, replace import nodes

* WIP

* WIP

* remove booleans from literals

* trigger at case keyword positions

* clean up tests

* fix element access expression case

* refactor dealing with existing values into a tracker

* fix merge errors

* cleanup and more tests

* fix lint errors

* more merge conflict fixes and cleanup

* use appropriate quotes

* small indentation fix

* refactor case clause tracker

* experiment: support tabstops after each case clause

* address small CR comments

* fix completion entry details; add test case

* fix lint errors

* remove space before tab stops; refactor
2022-12-01 16:48:32 -08:00
Eyal Halpern Shalev
5435efbf37 Fixed method signature of Atomics.waitAsync (#51602)
* Added method overloading for Atomics.waitAsync(Int32Array, number, number, number)

* fixed types

* fixed types

* fixed line ending

* CR fix

* Forgot the baseline
2022-12-01 16:41:28 -08:00
Oleksandr T
1b75edcec6 fix(51053): Extract type on JSDoc causes an assertion failure (#51056)
* fix(51053): allow extract type from the jsdoc without a host

* change diagnostic message
2022-12-01 16:09:31 -08:00
Ryan Cavanaugh
9089d5390a Unconditionally call checkExpression from checkSatisfiesExpression (#51704)
* Unconditionally call `checkExpression` in `checkSatisfiesExpression`

* A testcase
2022-12-01 09:11:37 -08:00
Anders Hejlsberg
8036b149a4 Fix isUnitLikeType to (again) handle tagged literal types (#51545)
* Fix isUnitLikeType to (again) handle tagged literal types

* Add regression test
2022-11-30 13:30:52 -08:00
Anders Hejlsberg
cee6366c48 Fix isTypeDerivedFrom to properly handle {} and intersections (#51631)
* Fix isTypeDerivedFrom to properly handle {} and intersections

* Add tests
2022-11-29 08:29:35 -08:00
Andrew Branch
e6d7b526c8 Fix multiline import specifier sorting (#51634)
* Fix multiline import specifier sorting

* Update baselines

* Switch to EmitFlag, set hasTrailingComma on original node array

* Update API baseline

* Update baselines
2022-11-28 15:35:32 -08:00
Mateusz Burzyński
5cd2d975c3 Fixed an issue with in not being able to be used on narrowed down expression of a generic nullable type (#51502)
* 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`
2022-11-22 07:03:58 +01:00
Wesley Wigham
b4024a5506 Preserve input key style when writing mapped type keys in declaration emit (#50781) 2022-11-18 12:54:12 -08:00
Wesley Wigham
a3092c798a Preserve alias symbols on references to type aliases via imports (#51152)
* Preserve alias symbols on references to type aliases via imports

* Fix lint
2022-11-17 21:25:31 -08:00
Andrew Branch
89ce16ccfd Fix auto-import when paths points to project reference redirect (#51492)
* Fix auto-import when `paths` points to project reference redirect

* Put paths specifiers to redirects in lower priority bucket
2022-11-15 14:19:15 -08:00
Andrew Branch
3fcd1b51a1 Refactor module resolution Extensions, fix lookup priorities (#51471)
* 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 4014f3005a.

* Update baselines

* Add new test for node_modules searching behavior

* Update new baseline
2022-11-15 14:18:11 -08:00
Jonathan Kingston
c0f8d1cf75 fix(51277): Array find thisArg fix from being void (#51278) 2022-11-14 16:49:11 -08:00
Oleksandr T
5016d13f8d fix(51112): skip checking binding parameters for functions that contains arguments (#51258) 2022-11-14 16:32:36 -08:00
Jake Bailey
9f64a3a58c Remove ts.{Map,Set,ESMap,Iterator} and associated types (#51439) 2022-11-09 15:06:31 -08:00
Mateusz Burzyński
39ccac654c Add known keys of the mapped type constraint to its members (#50081)
* Add known keys of the mapped type constraint to its members

* Avoid second pass of adding known members by instead passing `noReductions` to `mapType`
2022-11-07 16:22:27 -08:00
Jake Bailey
c65142244c Add dts bundling
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.
2022-11-07 13:35:48 -08:00
Jake Bailey
36e29448e9 Get codebase building pre bundling
This isn't totally complete, but enough to get everything building and
tests running manually. The next commit will make the build work fully.
2022-11-07 13:34:44 -08:00
Mateusz Burzyński
a329210166 Fixed a regression with discriminating unions based on a union property against undefined with strictNullChecks: false (#49648)
* Fixed a regression with discriminating unions based on a union property against `undefined` with `strictNullChecks: false`

* Add additional test case from the issue comment
2022-11-07 12:17:59 -08:00
Oleksandr T
fa4b49d541 fix(51374): ts(80004): Quick fix... > Annotate with type from JSDoc :: object types (#51378)
* fix(51374): transform JSDocTypeLiteral

* add additional tests

* add additional tests
2022-11-07 11:35:08 -08:00
Anders Hejlsberg
f0216e3421 Improve reduction of similar intersections in type inference (#51405)
* Change criteria for reducing intersections in type inference

* Add regression test
2022-11-04 17:04:05 -07:00
Anders Hejlsberg
7cf842b42b Enum unification and improvements (#50528)
* Fix enum classification and evaluation

* References in literal enums must be to other enum members

* Accept new baselines

* Unify enum types + template literal constant expressions

* Accept new baselines

* Fix fourslash tests

* Fix new compiler errors

* Fix lint error

* Accept new API baselines

* Fix test

* Better error message + consistently check enum initializers

* Accept new baselines
2022-11-03 11:05:42 -07:00
Zzzen
6017625ad5 do not report use-before-declaration error in async IIFE initializer (#50199) 2022-11-02 11:41:04 -07:00
Mateusz Burzyński
46b015f2bf Fixed the issue with some longer variadic tuples with any rest being incorrectly assignable to shorter variadic tuples (#50218) 2022-11-02 11:35:17 -07:00
Gabriela Araujo Britto
fdcb2ffd1b Fix services' type's isLiteral implementation (#50929)
* fix services' type's isLiteral

* update literal completions tests

* remove booleans from literals
2022-11-02 11:28:10 -07:00
Wesley Wigham
4d15bb16e1 Fix #50869, only cache calculated type for non-context sensitive parameters (#50976)
* Fix #50869, only cache calculated type for non-context sensitive parameters

* Simplify check, update comment
2022-10-31 17:24:51 -07:00
Ron Buckton
7f8426f4df fix for-in enumeration containing yield in generator (#51295) 2022-10-28 15:09:10 -04:00
Jake Bailey
3d2b4017eb Fix assertion functions accessed via wildcard imports (#51324)
* Add test

* Resolve alias of property in getTypeOfDottedName

* Always resolve

* Update tests
2022-10-27 20:27:53 -07:00
Oleksandr T
64d0d5ae14 fix(51301): Fixing an unused import at the end of a line removes the newline (#51320)
* fix(51301): keep the line break after removing the unused identifier

* preserve line breaks in import specifiers

* preserve line breaks in parameters and destructuring elements

* remove preserveLineBreak option
2022-10-27 17:27:36 -07:00
Oleksandr T
d4f26c840b fix(51245): Class with parameter decorator in arrow function causes "convert to default export" refactoring failure (#51256)
* fix(51245): don't rely on parent nodes in formatting rules

* check existing parent node
2022-10-26 16:59:44 -04:00