Commit Graph

16214 Commits

Author SHA1 Message Date
Andrew Branch
af3e1d4dfd Reuse type nodes from optional parameters even when not written as a union with undefined (#48605)
* Reuse type nodes from optional parameters and properties even when not written as a union with `undefined`

* Remove newly unneeded NodeBuilderFlag

* Update public API

* Update baselines from main
2022-04-08 14:28:36 -07:00
Oleksandr T
3b2fa50a14 fix(48487): allow using private names as the self-assignment entity name (#48496) 2022-04-08 10:48:28 -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
Anders Hejlsberg
8f6e626d1c Permit type alias variance annotations only for certain object types (#48589)
* Permit type alias variance annotations only for certain object types

* Accept new baselines
2022-04-06 14:04:42 -07:00
Anders Hejlsberg
a3c22187c9 Improve inference for context sensitive functions in object and array literal arguments (#48538)
* Use intra-expression inference sites in type argument inference

* Accept new baselines

* Add tests
2022-04-05 13:08:59 -07:00
Ron Buckton
7da80d79e2 Add 'extends' clause to 'infer' type (#48112)
* Add 'extends' clause to 'infer' type

* Revise parse for infer..extends, improve parenthesizer

* More aggressive parens to match existing DT tests

* tests 'infer' constraint using outer type parameter

* Adds a test showing 'infer' cannot reference other 'infer' in same 'extends'

* Emit extends clause for synthetic infer typesduring declaration emit
2022-04-05 12:35:28 -07:00
David Sherret
f654f18d86 fix: ensure ts source file with no-default-lib that augments the global scope gets emitted with incremental program (#48412)
* fix: do not classify non-declaration files as default library source files

* Add test.
2022-04-05 10:00:37 -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
Oleksandr T
e5ca3e4386 fix(48406): resolve JSDoc host of property signature (#48407) 2022-04-04 14:42:50 -07:00
Pablo Sabater Jiménez
3b12284fc4 fixed code duplication (#48425)
* fixed code duplication

* updated baselines
2022-04-04 14:16:21 -07:00
Wesley Wigham
9d2f72b285 Remove nightly-only flagging for nodenext features (#48555) 2022-04-04 14:07:32 -07:00
magic-akari
99620117be Fix crash when circular reference in variance annotations (#48539)
* Fix crash when circular reference in variance annotations

* chore: clean code
2022-04-04 08:33:47 -07:00
Wesley Wigham
54fa69cb47 Fix API under exactOptionalPropertyTypes (#48505) 2022-03-31 21:45:34 -07:00
Oleksandr T
9cfa6e25af fix(48405): emit dummy members from a mapped type (#48481) 2022-03-31 10:15:12 -07:00
Anders Hejlsberg
fd601ddf20 CFA for dependent parameters typed by generic constraints (#48411)
* Obtain apparent type in parameter destructuring check

* Add regression test
2022-03-30 16:33:01 -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
Jake Bailey
3c6c2799b6 Ensure that we copy empty NodeArrays during transform (#48490) 2022-03-30 15:33:51 -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
Gabriela Araujo Britto
f57bdaa097 Add label details to completion entry (#48429)
* add label details to completion entry

* Use label details for obj literal method completions

* add label details support flag

* add label details support to fourslash

* support both label details and non-label details in object literal method snippets

* CR fixes

* fixes after rebasing

* fix tsserver tests
2022-03-30 12:45:56 -07:00
Gabriela Araujo Britto
e25f04a30f Enable method signature completion for object literals (#48168)
* skeleton of new feature

* working prototype

* refactor print and format code into its own function

* minor changes; don't support overloads

* have two completion entries

* get rid of accessor support

* add snippet support

* add formatting

* add trailing comma

* add sourcedisplay

* support auto-imports via completion details

* add user preference option and fix ordering of entries

* cleanup

* don't return code actions for no import fixes

* make sortText lower priority for snippets

* get rid of flag

* use optional member sort text

* update baselines

* don't collect method symbols if insert text is not supported

* remove comment

* return undefined if type is not function type

* only slice if needed

* use union reduction; more test cases

* WIP: modify sort text system

* Improve new sort text system

* add signature and union type check

* re-add flag

* fix tests

* rename sort text helper

* fix test and code for union case

* add new flag to protocol type

* fix spaces

* CR: minor fixes

* CR: more fixes

* CR: restructure main flow

* minor fix
2022-03-29 17:19:02 -07:00
Andrew Branch
7ec7d6d8e0 Fix string literal completions when a partially-typed string fixes inference to a type parameter (#48410)
* Add failing test

* Fix string literal completions when a partially-typed string fixes inference to a type parameter
2022-03-29 09:07:38 -07:00
Oleksandr T
bf7bfa1b3f fix(48445): show errors on type-only import/export specifiers in JavaScript files (#48449) 2022-03-29 08:38:58 -07:00
Wesley Wigham
a5dae37943 Prevent looking up symbol for as const from triggering an error (#48464) 2022-03-28 12:53:36 -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
Wesley Wigham
8cd4b7a5da Make the unconstrained type parameter and {} assignability rule not apply under strictNullChecks (#48366)
* Make the unconstrained type parameter and {} assignability rule not apply under strictNullChecks

* Fix lint, PR feedback
2022-03-23 16:22:40 -07:00
Wesley Wigham
b5a3a058f5 Merge diagnosticsProducing and nonDiagnosticsProducing checkers into a single checker supporting lazy diagnostics (#36747)
* Merge diagnosticsProducing and nonDiagnosticsProducing checkers into a single checker supporting lazy diagnostics

* Fix lint
2022-03-23 16:21:06 -07:00
Zzzen
20c01cdd3f align ClassStaticBlockDeclaration with IIFE in CFA (#44969)
* align ClassStaticBlockDeclaration with IIFE in CFA

* isIIFELike => isImmediatelyInvoked

* fix unexpected used-before-assignment errors

* update baseline
2022-03-23 15:47:29 -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
Anders Hejlsberg
6cb58d382f Optional variance annotations (#48240)
* Simplify getVariancesWorker and associated logic

* Accept new API baselines

* Add 'in' and 'out' modififers / add modifiers to type parameters

* Check variance annotations

* Update test runner

* Accept new API baselines

* Allow variance annotations only on certain type parameters

* Add deprecated implementation of createTypeParameterDeclaration

* Accept new API baselines

* Report variance markers as 'sub-XXX' and 'super-XXX'

* Add tests

* Accept new baselines
2022-03-22 11:31:08 -07:00
Pablo Sabater Jiménez
50a4b92bca fix(48053) Description of tsBuildInfoFile is misleading in generated tsconfig.json (#48072)
* add check for path default value

* fix wrong tsBuildInfoFile description

* updated files to file
2022-03-22 10:35:47 -07:00
Andrew Casey
073ac920ad Add server tracepoints (#48282)
* Trace project creation, loading, and updateGraph

* Drop generic event tracing

* Make argument names more consistent

* Trace diagnostics to make steps easier to interpret

* Fill an unexplained gap in updateGraph

* Move updateGraph tracing into base type

* Fill the gaps in updateGraph
2022-03-17 14:56:42 -07:00
Oleksandr T
c1cf901997 fix(48291): omit jsdoc modifiers (#48304) 2022-03-17 13:44:42 -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
Oleksandr T
546a87fa31 feat(48231): allow unique symbol for constant variables (#48270) 2022-03-16 17:00:27 -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
Jesse Trinity
111ca92646 Fix parser regression for bad related diagnostic on missing matching brackets (#44158)
* Revert "Revert #43460 and #40884 (#44175)"

This reverts commit 5770434891.

* fix missing opening brace match error

* refactor parseExpectedMatchingBrackets

* use getNodePos

* accept baselines

* delete mistakenly added files

* Revert getNodePos addition

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-03-15 17:29:41 -07:00
Anders Hejlsberg
8c060eecaa Exclude mapped types with 'as' clauses from certain checks (#47889)
* Exclude mapped types with 'as' clauses from certain checks

* Add tests
2022-03-15 17:01:33 -07:00
Wenlu Wang
5f017df609 Fix top level logical assignment leak (#40536)
* Fix leaking top level logical assignment

* Fix leaking top level logical assignment
2022-03-14 10:48:31 -07:00
Oleksandr T
4a58fbce17 fix(48081): omit error on importing variables defined with require() (#48115) 2022-03-14 09:55:12 -07:00
Andrew Casey
ce9657d5e2 Introduce set with custom equals and getHashCode (#48169)
* Implement set with custom equals and getHashCode

* Adopt custom set in session

* Add doc comment

* Initially store buckets as non-arrays
2022-03-11 16:17:54 -08:00