3940 Commits

Author SHA1 Message Date
Anders Hejlsberg
c7b2942acc Add regression test 2022-07-22 16:44:33 -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 17a29fff6c4ce48e9c3f13b55332ce3411c90dc4.

* 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
Wesley Wigham
bf5acb5c4d
Issue serialization error when attempting to serialize a late-bound name from a mapped type (#49221) 2022-05-31 15:36:13 -07:00
Andrew Branch
39f5dbff43
Fix index fallback of CJS package from ESM-mode import when main is present but does not resolve (#49327) 2022-05-31 14:10:17 -07:00
bentongxyz
3939b38aa1
fixes #48630 array binding pattern with only OmittedExpressions does not check RHS of for-of loop (#49008)
* fix RHS of for..of loop not evaluated when LHS is array binding element with OmittedExpression

* expand widened type check

* add more test cases

* update code with suggestions

* Make test target es2015

Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-05-31 11:06:19 -07:00
Andrew Branch
a2b785b6cb
Limit type argument inference from binding patterns (#49086)
* WIP

* Don’t widen literals based on bogus contextual type instantiation

* Split tests

* Skip unnecessary inference pass

* Accept test baselines

* Fix stray edit

* Fix type mapper combination

* Revert src/ of 7dc1952a82

* Make empty binding pattern provide no contextual type

* Add missed baseline
2022-05-24 09:05:34 -07:00
Wesley Wigham
194a2aea0d
Key validity of import=require in module: node off of module and not target (#49222) 2022-05-24 03:33:23 -07:00
Nathan Shively-Sanders
006ae339bf
Add es2018.intl ref to es2020.intl (#49152)
* Add es2018.intl ref to es2020.intl

es2020.intl refers to NumberFormatPartTypes declared in es2018.intl
as of #46508.

I'm not sure how to test this; it repros on Definitely Typed in
types/ndarray, but when I copy the same files into a compiler test it
passes without a problem.

* Add a test that shows the change works

It doesn't actually show that the original bug has been fixed,
though.
2022-05-20 11:04:34 -07:00
Andrew Branch
e56a067801
Fix uncalled function check usage detection for && expressions (#49157) 2022-05-18 13:58:06 -07:00
Oleksandr T
755d5ccad6
fix confused comment (#49094) 2022-05-16 15:26:26 -07:00
Nathan Shively-Sanders
95731f0397
No errors on apparent type of bigint or symbol, even for recent targets (#49104)
* Remove bigint from Object.freeze in es5.d.ts

`BigInt` isn't resolved whenever `lib < es2020`, but it's not an error
when `target < es2020`. I have a few ideas for improving this situation
but for the RC I'm going to remove `bigint` from Object.freeze's
signature.

* Update other baselines

* No errors for missing apparent type of bigint,symbol for any target

* Update test text
2022-05-16 09:14:00 -07:00
Jack Works
b689cd0aa9
feat: support error when comparing with object/array literals (#45978)
* feat: support error when comparing with object/array literals

* chore: include regexp, function and class literal

* chore: include regexp, function and class literal

* test: update baseline

* fix: baseline
2022-05-12 15:45:22 -07:00
Daniel Rosenwasser
3e24f14871
Merge pull request #49029 from DavidSouther/fix/44466-contextual-keyword-assertion
fix(44466): Fixes parsing contextual keyword casts as arrow functions
2022-05-10 16:37:49 -07:00
Mateusz Burzyński
9236e39374
Fixed an issue with contextual type for intersection properties (#48668)
* Add a failing test case for contextual type not provided for functions comming from a property with intersection type

* Fixed an issue with contextual type for intersection properties

* Fixed how type of a property of a contextual type is being computed when intersections with indexers are used
2022-05-09 16:03:48 -07:00
Wesley Wigham
f84ec3e8b4
Fix type parameter comparability to consistently allow comparisons on unconstrained type parameters (#48861)
* Fix type parameter comparability to consistently allow comparisons on unconstrained type parameters

* Less elaboration, non-strict-mode fix
2022-05-09 12:22:00 -07:00