Commit Graph

11706 Commits

Author SHA1 Message Date
Andrew Branch
fbfe9340a9 Fix comparability between type parameters related by a union constraint (#50978) 2022-09-28 10:06:13 -07:00
Oleksandr T
c81bf4d8b0 fix(49594): Typescript 4.7.3 bracketed class property compilation error strictPropertyInitialization:true (#49619)
* fix(49594): allow enum members in computed properties

* add additional tests

* handle enum members without initializers

* update tests
2022-09-26 09:50:02 -07:00
navya9singh
bc9cbbef42 Merge pull request #49912 from microsoft/fix/47508
fix(47508): noUncheckedIndexedAccess with enums Type narrowed
2022-09-26 09:47:33 -07:00
Jake Bailey
645d1cd7c1 Fix assert in addIndirectUser in FAR (#50905) 2022-09-22 16:47:27 -07:00
Andrew Branch
221cf55a21 package.json exports should have priority over typesVersions (#50890)
* package.json `exports` should have priority over `typesVersions`

* Test some versioned conditions too
2022-09-21 17:21:51 -07:00
Oleksandr T
7a3de819bf fix(49993): skip the quick fix for an expression with an enum type (#50625) 2022-09-21 16:59:17 -07:00
Oleksandr T
2644f28677 fix(49200): skip duplicated method declarations (#50609) 2022-09-21 16:05:40 -07:00
Oleksandr T
4d91204c9d fix(37030): Expand Selection in function and arrow function skips body block (#50711)
* fix(37030): include curly braces from function body in the selection

* add missed sourceFile argument
2022-09-21 10:47:24 -07:00
Oleksandr T
1d9ab83914 fix(50866): emit modifiers from export declarations (#50874) 2022-09-21 09:59:15 -07:00
Anders Hejlsberg
01054e05ab Consistently add undefined/missing to optional tuple element types (#50831)
* Consistently add undefined/missing type to optional tuple elements

* Accept new baselines

* Add regression test
2022-09-20 18:14:20 -07:00
Daniel Rosenwasser
d90795e799 Improve escape sequence handling in private names (#50856)
* Add tests for identifiers and private identifiers with escape sequences.

* Accepted baselines.

* Store the tokenValue instead of tokenText on PrivateIdentifiers, since the latter can contain escapes and lead to semantic discrepancies.

* Accepted baselines.

* Check for leading escape sequences in PrivateIdentifiers.

* Accepted baselines.

* Fix lints.
2022-09-20 15:00:39 -07:00
Andrew Branch
938a69a526 Fix import statement completions followed by interface declaration (#50350)
* Fix import statement completions followed by interface declaration

* Fix stuff

* Linty

* Fix when named imports is missing closing brace
2022-09-20 13:29:06 -07:00
Oleksandr T
e002159ad1 feat(49962): Disallow comparison against NaN (#50626)
* feat(49962): disallow comparison against NaN

* change diagnostic message

* use global NaN symbol for NaN equality comparisons
2022-09-20 13:16:44 -07:00
Oleksandr T
23746af766 fix(50591): RangeError: Maximum call stack size exceeded (#50594) 2022-09-20 11:03:18 -07:00
Andrew Branch
168186f93d Allow a union property of a private/protected member and an intersection property including that same member (#50328) 2022-09-20 10:28:48 -07:00
Anders Hejlsberg
a11c41621b Improve checking of in operator (#50666)
* 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()
2022-09-19 14:16:01 -07:00
Gabriela Araujo Britto
3014dec887 Don't elide imports when transforming JS files (#50404)
* 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
2022-09-19 11:36:08 -07:00
Gabriela Araujo Britto
48a8e8953a Improve check of whether type query node possibly contains reference to type parameter (#50070)
* 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
2022-09-18 21:13:30 -07:00
Mateusz Burzyński
a8e13f7340 Fixed an issue with destructured bindings from a generic union constraint not being narrowed correctly (#50221) 2022-09-17 14:47:57 -07:00
Daniel Rosenwasser
0df46e8733 Fix test around RegExp match vs. exec results (#50813)
* Fix up test.

* Accepted baselines.
2022-09-16 16:47:33 -07:00
DetachHead
2970c5d167 make RegExpExecArray always include index 0 (#50713)
* make `RegExpExecArray` always include index 0

* update baseline

* remove `BaseRegExpArray` interface

* add test

Co-authored-by: DetachHead <detachhead@users.noreply.github.com>
2022-09-16 15:28:26 -07:00
magic-akari
01cae69e34 fix(50796): omit questionToken in object literal method completions (#50802) 2022-09-16 10:06:03 -07:00
Anders Hejlsberg
3b84f76fb2 Fix crash caused by incorrect bounds check (regression in 4.8) (#50797)
* Fix bounds check

* Add regression test
2022-09-16 07:14:14 -07:00
Alexis Cheron
8b35c1300e The error "Object is possibly null or undefined" is ambiguous. (#49797)
* added object name to TS2571, 2531, 2532 and 2533

* updated localized diagnostic messages

* updated baseline to fit diagnostic message change

* Revert "updated localized diagnostic messages"

This reverts commit 738cf094bd.

* specialized the error to EntityNameExpression

* updated baseline to fit new changes

* added multiline undefined access test

* added TS18049 - value cannot be used here

* adjusted baseline

* corrected a small linting issue

* Update error numbers after merge from main

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-09-15 16:13:53 -07:00
Jake Bailey
ec6ae1c4d0 Partially revert #41044, restoring parameter destructurings in d.ts files (#50779) 2022-09-15 10:24:43 -07:00
Anders Hejlsberg
4110b80fbb Fix equality narrowing and comparable relation for intersections with {} (#50735)
* Fox equality narrowing and comparable relation for intersections with {}

* Accept new baselines

* Add tests

* Accept new baselines
2022-09-14 09:19:36 -07:00
Oleksandr T
08b91f6b82 fix(50717): tsc crashes when it sees a JSDoc tag inside an @override annotation (#50724) 2022-09-13 12:51:17 -07:00
Anders Hejlsberg
60963d7216 Discriminant of type never should never be matched (#50755)
* Discriminant of type 'never' should never be matched

* Add tests
2022-09-13 10:29:50 -07:00
Jake Bailey
f5f2923c7d Revert removal of nonInferrableAnyType (#50691) 2022-09-12 15:10:29 -07:00
Ron Buckton
a4cabe725b Support for auto-accessor fields from the Stage 3 Decorators proposal (#49705)
* Support for auto-accessor fields

* Add tests, ensure accessors are initialized in ctor

* classFields cleanup and PR feedback
2022-09-12 15:12:11 -04:00
Jake Bailey
eb40134373 Don't leave space for property access on non-integer literals (#50703) 2022-09-09 14:36:39 -07:00
Anders Hejlsberg
a70bb9d3ff Preserve special intersections in mapped types (#50704)
* Preserve special intersections in mapped types

* Add regression test
2022-09-09 12:09:50 -07:00
Jake Bailey
1a1c271675 Don't remove space before dot if in property access on numeric literal (#50695)
* Add failing test

* Don't remove space before dot if in property access on numeric literal
2022-09-08 19:08:51 -07:00
Andrew Branch
bb6f36f7c8 Forward intersection state flag to conditional type target check (#50620) 2022-09-07 10:07:24 -07:00
Will Nayes
fd3a84c3f0 Report every instance of TS1208 (#50101)
* Report every instance of TS1208

* Test case for multiple cases of TS1208

* Add test case for isolatedModules with moduleDetection forced
2022-09-02 13:44:47 -07:00
Andrew Branch
856c7c5fdd Allow {} to narrow in same special cases as unknown (#50601) 2022-09-02 09:47:27 -07:00
Anders Hejlsberg
854d448e5c in operator shouldn't narrow {} originating in unknown (#50610)
* 'in' operator shouldn't narrow {} originating in unknown

* Add regression test
2022-09-02 09:30:17 -07:00
Oleksandr T
bcf994996e fix(50079): show deprecated on JSX attributes (#50084) 2022-09-01 16:59:29 -07:00
Andrew Branch
5df09a514c Use bidirectional comparability in narrowing (#50592)
* Use bidirectional comparability (aka comparability) in narrowing

* Rename test, check other CFA branch, test without strictNullChecks
2022-09-01 14:26:48 -07:00
Anders Hejlsberg
6db2c882f3 {} & null and {} & undefined should always be never (#50553)
* {} & null and {} & undefined should be never in non-strictNullChecks mode

* Add tests

* Address code review feedback

* Accept new baselines
2022-09-01 12:37:13 -07:00
Mateusz Burzyński
238c341701 Defer distributing index over generic object types (#50540)
* Defer distributing index over generic object types

* Only check if the index type should be deferred for intersection types

* Add an additional test case
2022-09-01 07:28:13 -07:00
Oleksandr T
a9797d218d fix(50340): typeof ... === "undefined" check on discriminated union of undefined and object type doesn't narrow correctly (#50344)
* fix(50340): narrow type by discriminant in typeof

* add additional test cases
2022-08-31 15:00:50 -07:00
Wesley Wigham
488d0eebd0 Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword (#50537)
* Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword

* Accept baselines

* Remove out of date file
2022-08-30 09:03:02 -07:00
Anders Hejlsberg
6d170b490d Handle intersections in isGenericTypeWithoutNullableConstraint (#50497)
* Handle intersections in isGenericTypeWithoutNullableConstraint

* Add regression test
2022-08-29 09:24:13 -07:00
Joost Koehoorn
71b2ba6111 Reuse computed type of condition expressions (#49881) 2022-08-27 01:40:13 -07:00
Oleksandr T
4579245f36 fix(50427): allow convert function expressions (#50430) 2022-08-26 15:43:19 -07:00
Oleksandr T
bb3a7aec11 fix(50415): Language server debug failure - Did not expect GetAccessor to have an Identifier in its trivia (#50470)
* fix(50415): clone props for get/set accessors

* add additional tests

* create helpers to create name, body, modifiers, typeName

* cleanup
2022-08-26 14:33:23 -07:00
Oleksandr T
164dddc48e feat(7481): Operator to ensure an expression is contextually typed by, and satisfies, some type (#46827)
* feat(7481): add explicit type compatibility check with 'satisfies' expression

* Add failing test for lack of intersectioned contextual type

* Implement the behavior

* Add test corresponding to the 'if'

* Add test based on defined scenarios

* remove isExpression in favor of using type casting

* move tests from compiler to conformance folder

* update baseline

* add missing contextFlags argument

* use asserted type

* accept baseline

Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
2022-08-26 10:05:52 -07:00
Andrew Branch
38076df346 Fix auto import crash due to difference in paths handling (#50419) 2022-08-25 13:02:48 -07:00
Oleksandr T
12eb519b3f fix(50435): Duplicate seeming Code Actions for convert const to let (#50442)
* fix(50435): omit fix all in constToLet QF

* add FixAll action
2022-08-25 13:01:46 -07:00