Commit Graph

3953 Commits

Author SHA1 Message Date
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 be387e3bbf.

* 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
Jake Bailey
3afe2d654e Resolve parsingContextErrors TODO (#50011)
* Add a test with broken code

* Resolve TODO
2022-07-26 08:59:06 -07:00
Anders Hejlsberg
4026c6fd80 Properly handle null and undefined in getCommonSupertype (#50021)
* Properly handle null and undefined in getCommonSupertype

* Add tests

* Add more tests
2022-07-24 08:09:14 -07:00
Andrew Branch
6aefc1dcea More fixes to uncalled function checks in && expressions (#49868) 2022-07-22 16:06:16 -07:00
Oleksandr T
5d2e62a810 fix(49854): fix start index to emit statements after super (#49858) 2022-07-20 16:02:30 -07:00
Oleksandr T
5702941c2f fix(49719): Incorrect error 2301 when using ES standard class properties (#49725)
* fix(49719): omit TS2301 error with enabled usedefineforclassfields

* show error for target lower than esnext with useddefineforclassfields enabled

* change target from esnext to es2022
2022-07-20 14:36:35 -07:00
Jake Bailey
05d20760af Don't leak EvolvingArray out of code flow (#49943) 2022-07-18 19:00:18 -07:00
Zzzen
efbe03a33c check base constraint when checking operand of plus (#49918) 2022-07-18 09:42:50 -07:00
Anders Hejlsberg
2c68ded954 Improve narrowing logic for instanceof, type predicate functions, and assertion functions (#49625)
* Improve narrowing logic for instanceof, type predicates, and assertions

* Accept new baselines

* Add tests

* Tweak algorithm

* Accept new baselines

* Optimize for discriminated unions
2022-07-15 14:01:55 -10:00
Jake Bailey
cf3af3febd Properly propagate ObjectFlags.NonInferrableType, clean up non-inferrable code paths (#49887) 2022-07-14 18:33:09 -07:00
Mateusz Burzyński
2ef3901940 Fixed initializaiton-time inference for class properties assigned through element access (#49374) 2022-07-13 14:43:23 -07:00
Oleksandr T
8ae1e9e7c7 fix(49685): omit incorrect visibility error when setter precedes getter (#49697) 2022-07-06 15:59:05 -07:00
Wesley Wigham
9872184483 Remove dependence on module compiler option to consider mts/cts files always modules (#49815) 2022-07-06 13:26:36 -07:00
Jake Bailey
af70f240a1 Always resetErrorInfo if structuredTypeRelatedTo succeeds (#49718) 2022-07-06 12:57:01 -07:00
Mateusz Burzyński
8687940398 Add visible alias statements for non-visible binding patterns when emitting declaration (#48869) 2022-07-06 10:08:17 -07:00
Wesley Wigham
0f868035af Constrain infer type parameters made to preserver distributivity for inlined homomorphic mapped types (#49793) 2022-07-06 09:32:37 -07:00
Jake Bailey
641ab8eb97 Infer rest type without using assignContextualParameterTypes (#49740) 2022-07-06 08:27:56 -07:00
iamharbie
1f0d0f7c66 Set Error.prototype.cause type to unknown (#70) (#49639)
Signed-off-by: Abdul-Azeez Lawal <abdul-azeez.lawal@outlook.com>
2022-07-05 15:43:43 -07:00
Ron Buckton
c6ff5f3b52 Fix for Awaited<T> inference (#49748) 2022-07-01 15:00:54 -07:00
Andrew Branch
f8aa570b23 Get type arguments lazily for instantiating inferred type parameter constraint (#49744)
* Get type arguments lazily for instantiating inferred constraint

* Use new deferred type mapper
2022-06-30 16:23:07 -07:00
Wesley Wigham
4c34f2c792 Fix mapper used to instantiate distributive conditional manufactured in declaration emit (#49737) 2022-06-30 15:03:25 -07:00
Mateusz Burzyński
bd11ce2aeb Fixed an issue with self-referential awaited union (#49677) 2022-06-29 13:01:36 -07:00
Jake Bailey
b379e7fc79 Pass contextFlags when getting contextual type of JSX elements/attributes (#49707) 2022-06-28 14:40:26 -07:00
Sheetal Nandi
7e91485bec Use value meaning for computed property name for visibility check (#49678)
* Test

* Use value meaning for computed property name
Fixes #49562
2022-06-27 15:16:33 -07:00
Jake Bailey
569cdf1b07 Disallow expression with type parameters as left side of property access (#49464) 2022-06-24 15:54:21 -07:00
Lawrence Craft
ad6d08675c Add case to capture enum subtype reduction
* Add case to capture enum subtype reduction
Signed-off-by: Lawrence Craft <lcraft6@bloomberg.net>
2022-06-24 13:04:44 -07:00
Oleksandr T
8636adbbb9 fix(49449): change error location when passing objects/arrays to an argument of type (#49593) 2022-06-22 10:06:01 -07:00
Jake Bailey
71b5bdf980 Ensure resolved signature is cached before processing call errors (#49598) 2022-06-21 13:15:03 -07:00
jordanmbell
db49c6c3ba Add fractionalSecond part type to DateTimeFormat().formatToParts (#49569)
* Add fractionalSecond part type to DateTimeFormat().formatToParts

This change adds the `fractionalSecond` part type as a valid part
to be returned from Intl.DateTimeFormat().formatToParts().

Fixes microsoft#48882

* fixup
2022-06-21 07:52:24 -07:00
Anders Hejlsberg
529ba99e29 Use separate marker types for variance annotation validation (#49616)
* Use separate marker types for variance annotation validation

* Add regression test
2022-06-21 06:42:10 -07:00
Wesley Wigham
eb4b8a4d2e Handle this in isEntityNameVisible (#49521) 2022-06-15 10:15:19 -07:00
uhyo
29dffc3079 Forbid unused property renaming in destructuring binding in function types (#41044)
* Forbid renaming a propertyin function type parameters

* add tests

* Remove renaming from declaration output

* accept baseline

* accept baseline

* renew tests (not very right now)

* get correct result

* update diagnostic text

* accept baseline

* add declaration emit test

* fix declaration emit

* fix formatting

* revert unnecessary change

* accept baseline

* extend tests

* Revert "revert unnecessary change"

This reverts commit 17a29fff6c.

* accept baseline

* Rename and refactor potentialAlways... stuff

* add non-identifier names

* extend check to non-identifier original property names

* update diagnostic message

* add related span

* accept baseline

* add symbol-keyed test case

* oops?

* workaround for unstable test

* fix suggested name

* add comment about non-identifier property names

* simplify isReferenced check

* accept baseline

* move it one step further
2022-06-14 12:13:49 -07:00
bentongxyz
dbab6eb898 fix #49235 Objects that pass the spread syntax can no longer be assigned to assignable types. (#49337)
* fix issue 49235

* update code with suggested changes

Co-authored-by: Benjamin Tong <benjamin.tong@iddy.ai>
2022-06-14 10:43:18 -07:00
Wesley Wigham
ce639352bb Serialize inaccessible class declarations the same as class expressions in declaration emit (#49440) 2022-06-08 16:33:09 -07:00
Wesley Wigham
86ff3f6fec Give cjs export assigned types an alias symbol (#49407) 2022-06-08 16:32:18 -07:00
Oleksandr T
2cb8ee27f0 fix(48653): throw an error on an invalid optional chain from new expression (#48656) 2022-06-02 14:21:36 -07:00
uhyo
f3d57ccea8 Remove undefined from source type of renaming destructuring assignment with default (#41042)
* Remove undefined from source type of destructuring assignment with renaming

* add a test

* add test case from original issue

* add test with undefined default value

* add more test cases with const declaration
2022-06-01 15:34:37 -07:00
Anders Hejlsberg
1beb1037c0 Fix check in isMappedTypeGenericIndexedAccess (#49341)
* Fix check in isMappedTypeGenericIndexedAccess

* Add regression tests
2022-06-01 10:01:56 -07:00
Anders Hejlsberg
3cdb8081f7 Use NonNullable<T> in more scenarios (#49330)
* Remove getFalsyFlags and improve getNonNullableType

* Apply getNonNullableType to left operand of || operator

* Accept new baselines

* Add tests
2022-05-31 17:05:33 -07:00
Harsheet Kakar
75f4e95e85 Fix46246 (#46357)
* changed error message for interface extending primitive type

* moved interface check to different function

* changed part of interface declaration to is extended by interface

Co-authored-by: harsheetkakar <harsheetkakar@bitbucket.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-05-31 16:47:07 -07:00