Commit Graph

16236 Commits

Author SHA1 Message Date
Anders Hejlsberg 787bb9ddb6 Improve support for numeric string types (#48837)
* Improve support for numeric string types

* Update test

* Add tests
2022-04-25 15:36:06 -07:00
Jake Bailey 07660c8307 Fix emit for undefined SourceFile (#48774)
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2022-04-22 11:18:53 -07:00
Mateusz Burzyński af30c79093 Fixed string literal completions for partially-typed strings when overload could get matched (#48811) 2022-04-22 08:36:14 -07:00
Oleksandr T d71dd1d912 fix(48556): throw an error on jsx spread attributes with an invalid type (#48570) 2022-04-21 16:31:16 -07:00
Sheetal Nandi 7a59e45f48 During emit, if shape signature for the file is same as version, then update it with emitted d.ts file (#48616)
* If we are writing dts file and have used file text as version, we can update the signature when doing actual emit

* Make WriteFileCallback Api ready for future

* Assert that there is only single source file when emitting d.ts file
2022-04-21 11:00:34 -07:00
Sheetal Nandi 45faac7e70 If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit (#48600)
* Add test

* Renames

* More refactoring

* If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit
Fixes #42769
2022-04-20 21:05:10 -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
Wesley Wigham ce487e4fd3 Fix meta property symbol lookup (#48773) 2022-04-19 17:57:06 -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
Anders Hejlsberg 65f6cb23d3 Constraints for mapped types with filtering 'as' clauses (#48699)
* Constraints for mapped types with filtering 'as' clauses

* Add regression test
2022-04-18 14:24:22 -07:00
Sheetal Nandi 56a4a93718 Instead of maintaining cache id etc, reset the "working" exports map cache. (#48579)
* Revert "Avoid no-op export map updates (#45238)"

This reverts commit 0f6e6efde0.

* Need to reset currentAffectedFilesExportedModulesMap after commiting to final exports map
2022-04-15 15:11:30 -07:00
Andrew Branch 8bd7ce6feb Find Source Definition (#48264)
* Prototype resolving to JS when go-to-def aliases all resolve to ambient declarations

* Add test infrastructure

* Start fleshing out test coverage

* Fix some go-to-def stuff

* Finish lodash test case

* Make go-to-implementation never return ambient results

* Build new functionality into go-to-implementation

* Update baselines

* Two more test cases

* Refine definition searches for unresolved imports

* Revert "Build new functionality into go-to-implementation"

This reverts commit 381799d0f1.

* Fix tests

* Revert go-to-implementation changes

* Wow a bunch of code was unnecessary

* Update baselines and go-to-def test

* Fix navigation on symbols that are not aliases but resolve through aliases in chain

* Temporarily replace go-to-def with new command implementation

* Revert "Temporarily replace go-to-def with new command implementation"

This reverts commit 34c6cfdebb.

* Revert "Wow a bunch of code was unnecessary"

This reverts commit 1cb2ba646c.

* Bring back some deleted code needed for a new test case

* Clean up a little

* Rename more stuff

* Update test

* Update API baseline

* Temporarily replace go-to-def with new command implementation

* PR review fixes

* Fix getTopMostDeclarationNamesInFile

* Rename local

* Use hash set

* Remove option from commandLineParser

* Keep noDtsResolution project around

* Handle AuxiliaryProject kind in ScriptInfo getDefaultProject etc.

* Do not run updateGraph in the background for AuxiliaryProject

* Don’t create auxiliary project outside of semantic mode

* No-op on scheduled invalidation

* Add comments to unit test

* Sync compiler options to auxiliary project

* Fix case sensitivity

* Update extensionIsOk with new file extensions

* PR feedback

* Update API baseline

* Mark scheduleInvalidateResolutionsOfFailedLookupLocations internal

* Use same heuristics on property accesses of loosely-resolvable aliases as unresolvable named imports

* Rename command, and no need to return the bound span

* Update API baseline
2022-04-14 15:44:19 -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
Anders Hejlsberg a027cfa8ac More permissive parsing of instantiation expressions (#48659)
* More permissive parsing of expressions with type arguments

* Add test
2022-04-13 09:16:43 -04:00
Sheetal Nandi 988fa85f88 Handle declaration file names consistently (#48647) 2022-04-12 11:43:57 -07:00
Anders Hejlsberg cce61d1b69 Variance annotations on class expressions + deferred valiation (#48645)
* Variance annotations on class expressions + deferred validation

* Add regression tests
2022-04-12 09:34:33 -04:00
Sheetal Nandi a1e77edfdf Fix the issue with not serializing impliedFormat when signature and version of the file are same (#48614)
* When checking for incremental correctness always calculate signature

* Fix the issue with not serializing impliedFormat when signature == version of the file
2022-04-11 12:39:57 -07:00
Sheetal Nandi 15c2120a95 Update affected files pending emit when emitting using SemanticDignosticsBuilderProgram (#48519)
* Update affected files pending emit when emitting using SemanticDignosticsBuilderProgram

* Saving of affected files pending emit is not needed any more

* PR feedback
2022-04-11 11:54:39 -07:00
Anders Hejlsberg a744862aa5 Explore fewer constraints in getResolvedBaseConstraint (#48613) 2022-04-09 10:06:01 -04:00
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