Commit Graph
11183 Commits
Author SHA1 Message Date
TypeScript BotandJake Bailey c5ce1706f4 Cherry-pick PR #47500 into release-4.5 (#47514)
Component commits:
43c3f45fd0 Modify debug assertion to avoid crashing on SyntaxList

9570a59da4 PR changes

e9a2355e80 More PR feedback

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2022-01-19 15:05:28 -08:00
TypeScript BotandDaniel Rosenwasser 84509012f3 Cherry-pick PR #47433 into release-4.5 (#47515)
Component commits:
fce282b5bd Add failing test.

ea2c290ba8 Update failing test.

d954948394 Finalized failing test case.

f476e8426b Separate our usages of utilities that expect variables initialized to require(...) and require(...).foo.

9f0810c26d Renamed types and utilities, removed accidental indentation.

bf708bfde7 Renamed both utilitiy functions uniformly.

Co-authored-by: Daniel Rosenwasser <drosen@microsoft.com>
2022-01-19 15:05:16 -08:00
Jake Bailey 8a8048fb62 Rewrite logic for JSX attribute completion detection [4.5 cherry pick] (#47413) 2022-01-14 10:15:58 -08:00
TypeScript BotandDaniel Rosenwasser 14016a7851 Cherry-pick PR #47395 into release-4.5 (#47421)
Component commits:
f230a5af47 Add failing test.

3ba84692c6 Guard against undefined module bodies in navbar/navtree.

Co-authored-by: Daniel Rosenwasser <drosen@microsoft.com>
2022-01-13 12:16:36 -08:00
TypeScript BotandAndrew Branch 0854a93040 Cherry-pick PR #47136 into release-4.5 (#47379)
Component commits:
e61702c7df Fix extract type crash

Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-01-12 11:26:13 -08:00
TypeScript BotandAndrew Branch a5ebd5382b Cherry-pick PR #47348 into release-4.5 (#47349)
Component commits:
755e1cbc88 Add minimal failing test

d52b9d3cee Fix checker initialization crash with esModuleInterop global merges resolving to ImportEquals aliases

Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-01-12 11:20:19 -08:00
TypeScript BotandJake Bailey 1d4ec40130 Cherry-pick PR #47096 into release-4.5 (#47105)
Component commits:
191aa682f8 Disable JSX attribute snippet if attribute is acutally the HTML tag

1786d5e278 Add more tests of text before and after

7ac5e596ce Big comment

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2021-12-10 15:47:23 -08:00
d710e39921 🤖 Pick PR #47007 (Use features for selected module re...) into release-4.5 (#47016)
* Cherry-pick PR #47007 into release-4.5

Component commits:
48b9027927 Use features for selected module resolution rather than all features for type reference directives, since they can add restrictions to resolutions

* Update baselines for error in stable release versions

Co-authored-by: Wesley Wigham <t-weswig@microsoft.com>
Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-12-07 15:16:18 -08:00
TypeScript BotandRon Buckton c1758b555d Cherry-pick PR #46951 into release-4.5 (#47058)
Component commits:
e19aed36d8 Fix Awaited<T> for onfulfilled callbacks with more than one argument

f4b3ef2f95 Merge branch 'main' into fix46934

Co-authored-by: Ron Buckton <rbuckton@microsoft.com>
2021-12-07 15:15:57 -08:00
TypeScript BotandArmando Aguirre ec158f913c Cherry-pick PR #46767 into release-4.5 (#46769)
Component commits:
1c07983418 Removed replacement from jsx completions

20c24b970c Fixed tests

Co-authored-by: Armando Aguirre <armando.aguirre@microsoft.com>
2021-11-11 09:05:39 -08:00
TypeScript BotandGabriela Araujo Britto 32786412de Cherry-pick PR #46737 into release-4.5 (#46742)
Component commits:
74cd7a5c6c fix extra newline

8df5bef4bd Merge branch 'main' into gabritto/issue46609

67d631cb28 fix test

Co-authored-by: Gabriela Araujo Britto <gabrielaa@microsoft.com>
2021-11-09 12:10:03 -08:00
TypeScript BotandWesley Wigham 2857273281 Cherry-pick PR #46670 into release-4.5 (#46671)
Component commits:
615a82c6b9 Make specifier generation from export map information conditional on module resolution mode

Co-authored-by: Wesley Wigham <t-weswig@microsoft.com>
2021-11-04 17:13:44 -07:00
Daniel RosenwasserandAnders Hejlsberg b8ee3307b2 [release-4.5] Exclude identity relation from mapped type relation check (#46635)
* Exclude identity relation from mapped type relation check

* Add regression test

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
2021-11-04 17:13:04 -07:00
TypeScript BotandOleksandr T df53f4def2 Cherry-pick PR #46628 into release-4.5 (#46676)
Component commits:
9f9f3edc60 fix(46615): remove useless assertion. change error suggestion for rest params

Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
2021-11-03 15:08:09 -07:00
TypeScript BotandDaniel Rosenwasser 0651bd3ada Cherry-pick PR #46614 into release-4.5 (#46675)
Component commits:
e77514a53b Add failing test.

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

e7c8095935 Update tests/cases/fourslash/stringLiteralTypeCompletionsInTypeArgForNonGeneric1.ts

Co-authored-by: Daniel Rosenwasser <drosen@microsoft.com>
2021-11-03 15:07:23 -07:00
TypeScript BotandOleksandr T e4a2494065 Cherry-pick PR #46594 into release-4.5 (#46667)
Component commits:
cd33fc8c27 fix(46589): omit ? in method signature completion for optional methods

Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
2021-11-03 14:08:49 -07:00
Andrew BranchandAnders Hejlsberg 9b802322da Properly check whether union type contains only primitive types (#46645) (#46649)
* Properly check whether union type contains only primitive types

* Add regression test

* Remove 'export' modifier from test

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
2021-11-02 17:20:45 -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 BatesandTypeScript Bot 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 BrittoandAndrew Branch 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
Nathan Shively-Sanders d16d7779a8 No error for markdown links in @see (#46348)
This only shows up in checkJS files, but should still be ignored.
2021-10-14 15:22:59 -07:00
Oleksandr T 80e1a29248 fix(46305): omit converting jsx (react-jsx) spread attributes to Object.assign for ES2018 and up (#46317) 2021-10-14 14:23:50 -07:00
Anders Hejlsberg 8718df3dc1 Fix stack overflow in JSX discriminated union logic (#46354)
* Use getContextFreeTypeOfExpression to avoid circularities

* Add regression test
2021-10-14 10:11:44 -07:00