Commit Graph

4056 Commits

Author SHA1 Message Date
Mateusz Burzyński
16c695cdbb Improve uncalled function check related to parenthesized and binary expressions (#50756)
fixes https://github.com/microsoft/TypeScript/issues/37598
2023-01-17 13:22:16 -08:00
Mykola Basov
cb4c7689e6 Add Array.prototype.findLast() and Array.prototype.findLastIndex() (#49636)
Signed-off-by: mbasov2 <mbasov2@bloomberg.net>
2023-01-13 15:35:50 -08:00
Anders Hejlsberg
41e4139357 Only used cached undefined contextual type for requests with no flags (#52224) 2023-01-13 10:10:56 -08:00
Anders Hejlsberg
59e4e38d08 Don't widen when type parameter occurs at top level in type predicate (#52031) 2023-01-12 13:18:36 -08:00
Wesley Wigham
9da2a9aa84 Fix inferences between alias type arguments and defaulted alias type arguments (#51771) 2023-01-11 15:28:53 -08:00
Jake Bailey
28e4c81794 Tweak co/contra inference logic from #52123 (#52180) 2023-01-10 17:08:36 -08:00
Jake Bailey
b3eca6883c Suppress resolvedUsingTsExtension during loadModuleFromDirectory (#52189) 2023-01-10 16:05:44 -08:00
Mateusz Burzyński
32da8a2856 Add a test for indexed access on generic mapped type (#52069) 2023-01-10 13:46:20 -08:00
Mateusz Burzyński
48b6b8b1d9 Add a regression test for mapped type with as clause that bypassed interface extension check (#52070) 2023-01-10 13:45:38 -08:00
Mateusz Burzyński
94afa32925 Add an extra test case for circular base type (#52071) 2023-01-10 13:04:58 -08:00
Gabriela Araujo Britto
2082ef2e3f fix narrowTypeByDiscriminant for non null expression access (#52136) 2023-01-10 09:49:13 -08:00
Wesley Wigham
89e928e8b4 Add --allowArbitraryExtensions, a flag for allowing arbitrary extensions on import paths (#51435) 2023-01-09 17:12:42 -08:00
Mateusz Burzyński
9b718d0a70 Add tests for excess property check for intersection containing a recursive type (#52063) 2023-01-09 16:02:17 -08:00
Stephen Hicks
6bedd1c227 Allow indirect calls (#51989)
Co-authored-by: Klaus Meinhardt <klaus.meinhardt1@gmail.com>
2023-01-09 15:56:33 -08:00
Mateusz Burzyński
2c1fda249f Fixed false positive circular errors for await expressions with simple non-generic calls in CFA loops (#51126) 2023-01-09 13:56:52 -05:00
Wesley Wigham
00567618bd Reuse existing module specifiers in js declaration emit (#52089) 2023-01-09 10:15:42 -08:00
Wesley Wigham
11bc7b758d Issue error on export= in esm mode declaration file (#52109) 2023-01-09 10:15:23 -08:00
Gabriela Araujo Britto
e60c210c57 Improve JSX invalid children type error (#52105) 2023-01-06 10:26:53 -08:00
Anders Hejlsberg
400e2c2bd8 Defer conditional types with multi-element tuple types in extends clause (#52091) 2023-01-06 09:18:12 -08:00
Anders Hejlsberg
fc8538608b Improve logic that chooses co- vs. contra-variant inferences (#52123) 2023-01-06 07:56:51 -08:00
Mateusz Burzyński
31d1d63fc8 Infer fixed-size tuples from infer type parameters with extends clauses at variadic positions (#51157)
* Infer fixed-size tuples from infer type parameters with extends clauses at variadic positions

* Improve the fix to handle tuples with leading variadic elements

* Fixed indentation

* Infer rest element following a variadic element with a fixed-size constraint

* Infer rest element preceding a variadic element with a fixed-size constraint

* Rewrite the test to avoid accidental union reductions
2023-01-03 10:18:09 -08:00
Mateusz Burzyński
e9cd2e14db Allow forward references in computed properties of type declarations (#50824)
* Allow forward references in type declarations

* address PR feedback
2022-12-30 11:37:33 -08:00
Oleksandr T
44152bc22e fix(29648): Error message related to JSDoc for non-JSDoc syntax error (#50793)
* fix(29648): improve diagnostics of non-JSDoc syntax errors

* fix lint errors

* update tests

* change diagnostic type suggestion. fix QF for jsdoc nullable type

* move error handling from the parser to the checker

* change diagnostic message. remove speculative parsing

* update baseline
2022-12-29 16:50:57 -08:00
ronyhe
c7f49bceed Add undefined to JSON.stringify return type (#51897)
* First attempt

* Revert "First attempt"

This reverts commit 23f641cddb.

* Second try

* Accept baslines
2022-12-28 09:06:03 -08:00
Anders Hejlsberg
acf854b636 Keep track of multiple current inference contexts (#51978)
* Keep track of multiple current inference contexts

* Add regression test
2022-12-22 07:52:49 -10:00
Anders Hejlsberg
ba793e6069 Fix excess property checking for intersections with index signatures (#51894)
* Fix excess property checking for intersections with index signatures

* Add regression tests

* Limit check to only fresh object literals on the source side
2022-12-16 06:59:23 -08:00
Oleksandr T
fe185272cf feat(51000) - Flag Deprecation Plan (#51424)
* feat(51000): add ignoreDeprecations option

* use constants of versions

* change the ignoreDeprecations type to allow only one value - '5.0'

* add tests

* update baseline

* add typeScriptVersion to CreateProgramOptions

* update baseline

* change diagnostic message
2022-12-15 10:44:06 -08:00
Tomasz Lenarcik
aa2781d44f Add missing type argument constraints check (#51766)
* Add missing type argument constraints check

* Leverage existing routine for obtaining typeParameters
2022-12-14 11:20:57 -08:00
Tomasz Lenarcik
e4816ed44c JSDoc overload tag (#51234)
* Add support for JSDocOverloadTag

* Use overload tag to determine function type

* Update baselines

* Add new tests along with baselines

* Add tests for all @overload tags in one comment

* Add tests for find-all-ref and rename operations

* Add tests for alternative uses of @overload tag

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-12-13 15:10:40 -08:00
navya9singh
7267fcaeb9 Fix(29118): tsconfig.extends as array (#50403)
* tsconfig.extends as array

* Updated baselines

* Changes for pr

* Changes for pr comments

* Fixed formatting and edited a test

* Resolved errors after a merge conflict

* Added "string | list" type implentation

* Removed string | list type implementation

* Fixed formatting

* Added compiler test

* Resolving programUpdate errors

* Fixing commandLineParser error
2022-12-13 11:16:07 -08:00
Oleksandr T
708a522ddf fix(49080): --exactOptionalPropertyTypes seems to be ignored for JSDoc types (#49910)
* fix(49080): handle JSDocPropertyTag as optional prop

* move condition to utility function isOptionalDeclaration

* add additional tests

* update baseline
2022-12-12 15:03:49 -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
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
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
Wesley Wigham
e9e7a9d49a Fix #51623 (#51762)
* Fix #51623

* Revert newline changes
2022-12-05 12:48:11 -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
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
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
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
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
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
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