3994 Commits

Author SHA1 Message Date
Jake Bailey
8af9a936b5
Use typescript.d.ts in APISample tests (#51061) 2022-10-04 15:00:35 -07:00
Anders Hejlsberg
96894db6cb
Include type parameter defaults in contextual typing (#50994)
* 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>
2022-09-30 07:02:22 -07:00
Daniel Rosenwasser
0d0a793714
Allow Unicode extended escapes in ES5 and earlier (#50918)
* 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.
2022-09-30 01:22:01 -07:00
Anders Hejlsberg
ecf50e81a7
Properly compute SymbolFlags.Optional for intersected properties (#50958)
* `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
2022-09-29 15:18:21 -07:00
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
Oleksandr T
2644f28677
fix(49200): skip duplicated method declarations (#50609) 2022-09-21 16:05:40 -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
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
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
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
Jake Bailey
ec6ae1c4d0
Partially revert #41044, restoring parameter destructurings in d.ts files (#50779) 2022-09-15 10:24:43 -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
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
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
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
Joost Koehoorn
71b2ba6111
Reuse computed type of condition expressions (#49881) 2022-08-27 01:40:13 -07:00
Oleksandr T
5969ae9ef7
fix(50075): do not strip undefined from the function class properties (#50169) 2022-08-19 09:34:42 -07:00
Wesley Wigham
05d7d6bb12
Unify default import resolution across specifier target codepaths (#49814)
* Unify default import resolution across specifier target codepaths

* Use differing type aliases, per request
2022-08-19 02:25:41 -07:00
DetachHead
3b80ddca21
fix first match in RegExpMatchArray being possibly undefined when noUncheckedIndexedAccess is enabled (#49682)
* fix first match in `RegExpMatchArray` being possibly undefined when `noUncheckedIndexedAccess` is enabled

* fix tests

* add test

Co-authored-by: DetachHead <detachhead@users.noreply.github.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-08-16 10:12:12 -07:00
Andrew Branch
4e33e0eb6c
Make literal types not comparable to weak object types without property overlap (#49865) 2022-08-15 17:10:11 -07:00
Andrew Branch
64ee1e88e0
Strip literal freshness of contextually typed literals (#49884)
* Strip literal freshness of contextually typed literals

* Add more tests
2022-08-15 17:04:09 -07:00
Wesley Wigham
e989d840f1
Forward intersectionState flag when comparing indexed access constraints (#50261) 2022-08-15 16:10:32 -07:00
Ryan Cavanaugh
adf26ffa4b
Revert "Fixed an issue with contextual type for intersection properties (#48668)" (#50279)
This reverts commit 9236e39374c0ec9a1e3f9894af4fb9eb34ba0021.
2022-08-12 10:24:50 -07:00
Jake Bailey
5fbf3b04dc
Don't treat object properties as potential JS contructors without JSDoc class tag (#49735) 2022-08-10 11:19:19 -07:00
Jack Works
382f0c3af3
fix: crashes when JSX.IntrinsicClassAttributes is an alias type close GH-50254 (#50257) 2022-08-10 10:41:12 -07:00
Nathan Shively-Sanders
dd98c17b10
Merge multiple symbols even when re-exported (#49987)
* Merge multiple symbols even when re-exported

As far as I remember, the target of `mergeSymbol` needs to be a merged
symbol, not a symbol with a mergeId that points to mergedSymbol.
However, mergeSymbolTable didn't check for this.

I can't remember if symbol tables may contain
symbols-with-mergeId. If they can, then mergeSymbolTable needs to call
getMergedSymbol on the individual targets of the merge. That's what I
did in this PR.

* Call getMergeSymbol eagerly

On the source, not target, of mergeSymbolTable's contents
2022-08-09 16:36:53 -07:00
magic-akari
abc2a350e6
Fix System module export import = (#49788)
* Add more SystemJS test case

* Fix System module `export import =`

* Update test case
2022-08-09 16:31:02 -07:00
Mateusz Burzyński
0e17dc7769
Fixed a false positive related to binding patterns and spread expressions (#49684)
* Fixed a false positive related to binding patterns and spread expressions

* Improve ancestor lookup when checking if an expression is spread into an object

* Fixed ancestor lookup for more node types

* Remove equality check for contextual types

* Reformat code

* Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal

* Revert "Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal"

This reverts commit be387e3bbf8a5cce2bc4c31fd77b061ea6cf8e0b.

* Expand on the existing comment
2022-08-08 17:01:50 -07:00
Gabriela Araujo Britto
bdb8514b82
Fix contextual typing on yield and return expressions in generator function (#49736)
* add tests and initial fix

* fix contextual return type in generator funcs

* fix return statement contextual typing

* filter using getiterationtypeofgeneratorfunctionreturntype

* update baselines
2022-08-05 11:24:43 -07:00
Jack Bates
040c1216ff
Better typings for Promise.resolve(), like #31117 (#33074)
* Better typings for Promise.resolve(), like #31117

* Add tests

* Update to Awaited<T>

* Fix issue with Awaited affecting jQuery, additional tests

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2022-08-02 13:39:50 -04:00
Ron Buckton
55f2c0cb49
No synthetic Awaited for unconstrained type when not a type variable (#50100) 2022-08-01 17:19:15 -04:00
Mateusz Burzyński
5374fd924e
Add an additional test for favoring the asserted type in type predicate narrowing (#50065)
* Add an additional test for favoring the asserted type in type predicate narrowing

* Add requested test cases
2022-07-29 12:12:33 -07:00
Sheetal Nandi
5b0eea48e9
Report error only on local declaration with additional related information (#49746)
* Add test where the errors are reported in different file
Test for #49739

* Report error only on local declaration with additional related information
Fixes #49739

* Handle existing tests
2022-07-27 15:31:45 -07:00
Jake Bailey
8d0c72d5e0
Normalize effective constraint intersection before checking if source is a part of it (#49956) 2022-07-27 10:06:01 -07:00