Commit Graph

3910 Commits

Author SHA1 Message Date
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
David Souther
958adfc9d8 Use all modifiers test 2022-05-09 10:41:02 -07:00
David Souther
3dd9ef43ce fix(44466): Fixes parsing contextual keyword casts as arrow functions 2022-05-09 10:22:22 -07:00
Jake Bailey
8d0393d227 Fix missing parsingContext restore at return in parseDelimitedList (#48999) 2022-05-06 13:36:27 -07:00
Wesley Wigham
8e433cda3d Allow export map entries to remap back to input files for a program (#47925)
* Allow export map entries to remap back to input files for a program

* Fix file casing issues on windows

* Implement abiguity error, doesnt quite work

* Refine selection logic in error case to use getCommonSourceDirectory, add more tests
2022-05-05 12:53:56 -07:00
Daniel Rosenwasser
5f9c9a6ccf Start Node ESM stable version at Node16 (#48879)
* Remove Node12, add Node16.

* Accepted baselines.

* Refactor checking for top-level await, give a better error message in CJS files.

* Accepted baselines.

* Stop erroring on JSON module imports in node ESM since they're no longer experimental.

* Accepted baselines.

* More refactoring, do the same checks for for-await loops.

* Accepted baselines.

* Adjust phrasing to permit for-await on CJS error.

* Accepted baselines.

* Accepted baselines.

* Fix lints.
2022-05-03 16:29:40 -07:00
John Lusty
273a567617 Fix handling of prologue statements when there are parameter property declarations (#48775) 2022-04-20 08:49:22 -07:00
Andrew Branch
d81a976c14 Ensure enum aliases referenced in other enum members do not get marked as referenced (#48770)
* Add test

* Ensure enum aliases referenced in other enum members do not get marked as referenced
2022-04-19 15:23:25 -07:00
Patrick Szmucer
2e619fdc80 Fix transformed constructor code when there is code between prologue statements and super call (#48765) 2022-04-19 09:19:25 -07:00
Jake Bailey
d3943fc86f Disallow line break between entity name and type arguments in typeof expression (#48755) 2022-04-18 16:18:31 -07:00
Josh Goldberg
fa2515ecd9 Fixed multiple prologue directives with parameter properties (#48687) 2022-04-14 09:29:15 -07:00
Oleksandr T
73c93eec5c fix(48657): allow JSXElement names to be IdentifierNames (#48661) 2022-04-13 12:32:10 -07:00
LowR
b45cf0d694 disentangle the meaning of SymbolLinks.target (#47098) 2022-04-07 15:40:39 -07:00
jihndai
b18141b0bc Do not reset control flow analysis on index signatures (#48427)
* do not flag index signatures as a control flow container

* add tests and baselines
2022-04-07 13:29:07 -07:00
Wesley Wigham
4d2fb5407c Preserve the distributivity of inlined conditional types in declaration emit (#48592) 2022-04-06 17:21:46 -07:00
Wesley Wigham
94d33ba85d Ensure late painted statements are only transformed once, so inner substitutions are consistently read (#48558)
* Ensure late painted statements are only transformed once, so inner substitutions are consistently read

* PR suggestion

* Fix lint
2022-04-06 16:36:42 -07:00
Zzzen
370d34cdca narrow type for generic variables inside TypeQuery (#48434) 2022-04-05 09:33:19 -07:00
Jake Bailey
276719753e Allow arrow function parameter parsing to bail out during speculation, redo (#48493)
* Allow arrow function parameter parsing to bail out during speculation, redo

* Add correct baselines

* Allow await/yield keywords for more graceful error reporting

* Add test for other parser issue

* Address some PR feedback

* Add extra comment

* Add async variants
2022-04-04 16:57:26 -07:00
Gabriela Araujo Britto
99ea99b386 Properly check singleton labeled tuple before unwrapping (#48554)
* properly check if singleton labeled tuple has optional element

* also check if labeled element is rest
2022-04-04 15:53:41 -07:00
Anders Hejlsberg
3f483d87b4 No contextual typing from return types for boolean literals (#48380)
* No contextual typing from return types for boolean literals

* Accept new baselines

* Add regression tests
2022-03-30 16:32:24 -07:00
Adam Foxman
41aca7c337 Add a new compiler option moduleSuffixes to expand the node module resolver's search algorithm (#48189)
* Add moduleSuffixes compiler option and related tests. Update baselines for compiler options tests.

* Add a flag to the command-line parser which allows "list" params to preserve "falsy" values such as empty strings. Falsy values are normally stripped out.

* Add tests. Rework resolver logic to only run module-suffix code when needed.

* PR feedback

* Add test

* Remove unnecessary conditional.
2022-03-30 15:23:26 -07:00
Anders Hejlsberg
df7ed82dd5 Revise accessor resolution logic and error reporting (#48459)
* Revise accessor resolution logic and error reporting

* Accept new baselines

* Update isTypeElement

* Add tests
2022-03-28 10:44:11 -07:00
Oleksandr T
c720ad6ffb fix(48166): skip checking module.exports in a truthiness call expression (#48337) 2022-03-28 08:23:20 -07:00
Oleksandr T
f4d76e5b93 fix(48031): show circularity error for self referential get accessor annotations (#48050) 2022-03-25 15:36:22 -07:00
Andrew Casey
e7426251b0 Revert "Fix contextual discrimination for omitted members (#43937)" (#48426)
This reverts commit 751c114126, which caused check time for our MUI benchmark to increase by ~25%.
2022-03-25 13:09:19 -07:00
Mateusz Burzyński
3ec1b04808 Add explicit tests for unconstrained type param not being assignable to {} and Record<string, any> (#48421) 2022-03-25 05:36:02 -07:00
islandryu
bf0eef4353 fix(48034): Get a literal string of type intersection in a template literal type (#48044) 2022-03-22 13:38:24 -07:00
Andrew Branch
df1faa09b8 Add isolatedModules error for ambiguous imports referenced in decorator metadata (#42915)
* Add isolatedModules error for ambiguous imports referenced in decorator metadata

* Improve test and accept baselines

* Error only for es2015+

* Add namespace import to error message as workaround

* Add codefix

* Fix merge fallout
2022-03-17 12:00:23 -07:00
Wesley Wigham
7f652509b6 Handle JS synthetic rest args in contextual parameter assignment (#48263)
* Handle JS synthetic rest args in contextual parameter assignment

* Limit fixing to only unannotated js rest parameters

* Minimize test

* Add annotated version

* Remove explicit CheckFlags.RestParameter check since apparently not all rest parameters are CheckFlags.RestParameter
2022-03-16 11:04:07 -07:00
Wesley Wigham
92bc2ddc3c Consistently avoid pulling on the source return type when the target return type is any (#47306) 2022-03-15 18:16:05 -07:00
Anders Hejlsberg
8e5a84a696 Exclude mapped types with optionality modifiers and 'as' clauses from constraint logic (#48273)
* Exclude mapped types with optionality modifiers and 'as' clauses

* Add regression tests
2022-03-15 17:37:46 -07:00