Commit Graph

11186 Commits

Author SHA1 Message Date
Armando Aguirre
7b86a65f22 Removed replacement from jsx completions (#46767)
* Removed replacement from jsx completions

* Fixed tests
2021-11-10 18:18:15 -08:00
Oleksandr T
b12d5c5dc5 fix(46605): show completions in object literal parameters (#46743) 2021-11-09 14:50:26 -08:00
Gabriela Araujo Britto
e5a6ae397d Fix extra newline in class member snippet completions (#46737)
* fix extra newline

* fix test
2021-11-09 12:03:07 -08:00
Oleksandr T
a05d851dc3 fix(45907): don't use static member name to inherit JSDocs from instance members (#46274) 2021-11-08 15:05:08 -08:00
Oleksandr T
3ef3cdddb3 fix(45692): merge non-primitive in spread-union (#45729) 2021-11-05 15:41:06 -07:00
Oleksandr T
0a628ff0c9 fix(44059): omit duplicate types (#45739) 2021-11-05 15:36:08 -07:00
Oleksandr T
2d4b243195 fix(33325): allow extract refactoring on selected statement without trailing semicolon (#45765) 2021-11-05 10:00:31 -07:00
Oleksandr T
4fca1e1fcd fix(46666): add outlining spans for comments preceding call expressions (#46682) 2021-11-04 12:43:01 -07:00
Kagami Sascha Rosylight
ae582a22ee Add target: "es2022" (#46291)
* Add `target: "es2022"`

* Add Object.hasOwn

* formatToParts is es2018

* ref update

* optional parameter

* Revert "optional parameter"

This reverts commit e67d6e5f60.

* undefined

* error cause

* Lint fix

Co-authored-by: Orta <git@orta.io>
2021-11-04 10:55:11 -07:00
Oleksandr T
ff75b8a180 fix(46615): remove useless assertion. change error suggestion for rest params (#46628) 2021-11-03 14:11:39 -07:00
Wesley Wigham
d53630fac3 Make specifier generation from export map information conditional on module resolution mode (#46670) 2021-11-03 13:10:44 -07:00
Oleksandr T
7264cf7db5 fix(46589): omit ? in method signature completion for optional methods (#46594) 2021-11-03 12:56:17 -07:00
Anders Hejlsberg
831b770b95 Control flow analysis for destructured discriminated unions (#46266)
* CFA for dependent variables destructured from discriminated union

* Accept new baselines

* Add tests

* Limit calls to isSymbolAssigned

* Fix wrong operator
2021-11-02 15:48:13 -07:00
Wesley Wigham
de23842e45 Allow import assertions on esm imports under module: nodenext (#46630)
* Allow import assertions on esm imports under module: nodenext

* Changes to copy

Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-11-02 15:34:37 -07:00
Oleksandr T
b8f8fd7a3e fix(46512): allow to use tag names containing keywords with - (#46546) 2021-11-02 15:12:10 -07:00
Anders Hejlsberg
33fe1b6ffc Fix contextual typing for symbol-named properties (#46558)
* Properly handle symbol-named properties in contextual types

* Update index signature in PropertyDescriptorMap

* Add regression tests
2021-11-02 14:05:41 -07:00
Anders Hejlsberg
56f81075f9 Properly check whether union type contains only primitive types (#46645)
* Properly check whether union type contains only primitive types

* Add regression test

* Remove 'export' modifier from test
2021-11-02 12:46:26 -07:00
Anders Hejlsberg
7cbcfeea99 Exclude identity relation from mapped type relation check (#46632)
* Exclude identity relation from mapped type relation check

* Add regression test
2021-11-02 06:54:35 -07:00
Oleksandr T
5142e37f2d fix(43292): forbid highlighting multiline template strings (#46531) 2021-11-01 14:21:38 -07:00
Daniel Rosenwasser
6d33d8797b Check for type parameters on original type when getting type argument completions (#46614)
* Add failing test.

* Check for type parameters on the original type when asking for the type argument constraint.

* Update tests/cases/fourslash/stringLiteralTypeCompletionsInTypeArgForNonGeneric1.ts
2021-11-01 11:41:43 -07:00
Gabriela Araujo Britto
6b1e8f7baf remove placeholders in class member snippets (#46598) 2021-10-29 16:55:59 -07:00
Andrew Branch
7742cf2180 Set hasAddedOrRemovedSymlinks when discovering an existing file by its link (#46569)
* Set hasAddedOrRemovedSymlinks when discovering an existing file by its link

* Make it optional
2021-10-29 15:47:48 -07:00
Andrew Branch
eeaa595196 Enable auto imports in member snippet completions (#46592) 2021-10-29 14:43:32 -07:00
Anders Hejlsberg
b0ab2a54bb Fix mapped type instantiation circularity (#46586)
* Don't obtain constraint if doing so would cause circularity

* Add regression test

* Address CR feedback
2021-10-29 14:01:27 -07:00
Jack Bates
9b1ba8f1e3 Fix react-jsx spread children invalid emit (#46565)
* Fix react-jsx spread children invalid emit

* Update Baselines and/or Applied Lint Fixes

* Change childrenLength parameter -> isStaticChildren

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-10-29 10:54:46 -07:00
Gabriela Araujo Britto
9cdbb7248b Improve errors on module: node12 and extensionless relative imports (#46486)
* add new error + suggestions

* push down assert defined

* remove comment

* fix esm module import detection, update baselines

* add and update new tests

* fix review comments

* remove renamed baseline references

* update node modules test baselines

* fix error message, add new tests

* update old tests with new error message
2021-10-29 10:25:03 -07:00
Gabriela Araujo Britto
fd620c93f6 Add method signature completions (#46370)
* prototype creation for method override completion snippet

* WIP: start using codefix `addNewNodeForMemberSymbol` to create method decl node

* update type of addNewNodeForMemberSymbol

* add more tests and support more cases

* add more tests and fix some details

* wip: more fixes and tests

* expose check override modifier in checker

* fix test

* WIP: add snippet support

* WIP: snippet support on emitter, adding snippets in completions

* make add snippets work with overloads (not synced)

* fix snippet adding

* rebase

* WIP: try to add snippet escaping in emitter

* support escaping in snippets

* small fixes; fixed tests

* more tests and fixes

* fix new tests

* fix modifier inheritance for overloads

* merge conflict fixes; remove comments

* throw error if setOptions is called but not implemented

* fix newline handling

* fix weird stuff

* fix tests

* fix more tests

* Fix unbound host.getNewLine

* fix isParameterDeclaration changes

* rename diagnostic to status and remove snippets from public api

* rename emitter functions + fix indentation

* check completion kind before calling isclasslikemembercompletion

* fix missing type parameters

* Revert "fix missing type parameters"

This reverts commit 7bdeaa86da.

* add isAmbient flag to addNewNodeForMemberSymbol

* add test for abstract overloads

* refactor snippet escaping support

* add user preference flag for enabling class member snippets

* update API baseline

* update tabstop order

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2021-10-28 16:05:36 -07:00
Daniel Rosenwasser
f494742ce9 Check for array types when instantiating mapped type constraints with any (#46218)
* Added/updated tests.

* Accepted baselines.

* Update test.

* Update instantiateMappedType to work specially when 'any' replaced an array.

* Accepted baselines.

* Ensure check works when constraint is a union of arrayish types, just like in `Promise.all`.

* Accepted baselines.

* Update test for indirect instantiation of a mapped type.

* Accepted baselines.

* Update test comment.

* Accepted baselines.

* Added tuple test case.

* Accepted baselines.

* Don't add special behavior for tuples.

* Accepted baselines.

* Revert "Don't add special behavior for tuples."

This reverts commit f01ae16e65.

* Accepted baselines.
2021-10-27 15:03:01 -07:00
Wesley Wigham
abfd537503 Support resolveJsonModule in new module modes (#46434)
* Support resolveJsonModule in new module modes

* Formatting feedback
2021-10-27 12:30:06 -07:00
Zzzen
8a68c8616d allow typeof this after for-loops (#46181) 2021-10-27 10:26:05 -07:00
Anders Hejlsberg
f424dfc18a Slightly less conservative check in isConstraintPosition (#46526)
* Slight adjustment to check in isConstraintPosition

* Add regression test
2021-10-26 11:54:46 -07:00
Anders Hejlsberg
44c63a757e Always cache relations involving intersection types (#46523)
* Always cache relations involving intersection types

* Accept new baselines

* Add regression test
2021-10-26 09:36:19 -07:00
Anders Hejlsberg
658764e499 Bypass caching in removeStringLiteralsMatchedByTemplateLiterals (#46525)
* Bypass caching in removeStringLiteralsMatchedByTemplateLiterals

* Add regression test
2021-10-26 09:34:15 -07:00
Andrew Branch
3519af0bab Fix crash pulling on global types before they're initialized (#46471)
* Add failing test

* Dumb fix

* Compute error message info more lazily

* One more laziness
2021-10-25 10:53:41 -07:00
Adam Burgess
61f5ceb832 Fix isNewIdentifierLocation after generator (#46491) 2021-10-24 23:49:31 -07:00
Andrew Branch
907fc72db4 Fix auto import crash on weird JS aliasing (#46490)
* Fix auto import crash on weird JS aliasing

* Comment up the weird test

* Fix setting members on union/intersection type, happens later
2021-10-22 16:09:32 -07:00
Daniel Rosenwasser
334b8eaa57 Bind assignments to 'this' within static blocks in JS files (#46472)
* Add failing test case.

* Handle 'this' assignments on class static blocks in JavaScript.

* Accepted baselines.
2021-10-22 15:44:35 -07:00
Andrew Branch
de1ac8191e Fix isNewIdentifierLocation after async (#46485) 2021-10-22 12:28:04 -07:00
Oleksandr T
ce676d0963 fix(46433): forbid using keywords as parameter names (#46459) 2021-10-22 09:58:01 -07:00
Oleksandr T
bd12ae2454 fix(46466): add missing async keyword before type parameters (#46467) 2021-10-21 15:56:45 -07:00
Andrew Branch
22f37cda85 Fix ordering of module specifiers based on package.json presence (#46437)
* Add failing test

* Fix ordering of module specifiers based on package.json presence
2021-10-21 11:43:57 -07:00
Nathan Shively-Sanders
f2e5947935 @link parses trailing <...> as part of linkName (#46450)
Similar to #46428.

Fixes #44818
2021-10-20 17:01:01 -07:00
Nathan Shively-Sanders
98b4ac2cde @link: format trailing () as part of linkName (#46428)
Parsing separates the identifier part of the link tag from its text, but
the editor should present an identifier followed by `()` as a single
identifier since people use that syntax as a function sigil.

I prefer `#'` personally, you know, xkcd 297, nudge nudge.
2021-10-20 08:36:40 -07:00
Anders Hejlsberg
56b6279818 Improve logic for choosing between co- and contra-variant inferences (#46392)
* Improve logic for choosing between co- and contra-variant inferences

* Add tests
2021-10-19 09:58:10 -07:00
Nathan Shively-Sanders
8d715ff53e Error on mapped type w/properties (#46346)
* Error on mapped types with properties

1. Error on properties of type literals with computed properties whose name is a
binary expression with `in`, because that's a good sign of a mapped
type.
2. Parse following properties on mapped types, and error on them.
3. Stop checking computed property names in (1) to avoid producing
errors based on misinterpreting mapped type syntax as an expression.

* add comment in types.ts

* Update API again

* Check interfaces and classes too

* Add missed check in updateMappedTypeNode
2021-10-18 09:00:00 -07:00
Sidharth Vinod
dfb40549fc fix: ES6 Modules => ES Modules in error messages (#46378)
* fix: ES6 Modules => ES Modules in error messages

* chore: Rename test file names

* chore: Rename function names
2021-10-15 14:51:14 -07:00
Nathan Shively-Sanders
6a75689a25 Import assertion: do no parse } if { is not present (#46388)
Previously, import assertion parsing would try to parse both { and },
even if both were missing. If both were missing, the error for } could
occur past the end of the file, causing an assertion.

Fixes #46364
2021-10-15 13:26:46 -07:00
Oleksandr T
7582b1bbae fix(45799): skip checking arguments used as a key in object literals (#45814) 2021-10-15 10:34:57 -07:00
Andrew Branch
b1f39a705e Fix React auto-import blocking component imports in --preserve (#46368) 2021-10-15 09:31:47 -07:00
Wesley Wigham
2c7b13b830 Fix explainFiles on files under nodenext with types references (#46367)
* Fix explainFiles on files under nodenext with types references

* Fix explainFiles crash on module nodenext
2021-10-14 17:00:55 -07:00