Commit Graph

11568 Commits

Author SHA1 Message Date
Mateusz Burzyński bd11ce2aeb Fixed an issue with self-referential awaited union (#49677) 2022-06-29 13:01:36 -07:00
Wesley Wigham 52f4055174 For missing constraint quickfix insert position, Use node name end rather than related span end (#49673) 2022-06-29 11:46:42 -07:00
Nathan Shively-Sanders cba184f69b Demote priority of JS completions (#49716)
* Demote priority of JS completions

Fixes #48498

Unchecked JS files gather identifier-based completions. Currently, this search
happens instead of `getCompletionEntriesFromSymbols` for TS/checked JS
files. However, identifier-based completions are much lower quality and
can be ignored by some editors.

Identifier-based completions should be gathered last, after gathering
other completions. That's what this PR does.

* Invert isUncheckedFile to avoid double negative

* dedupe calls to getCompletionEntriesFromSymbols

* Stop re-creating list of entry names

* more deduping + fix lint
2022-06-29 11:05:50 -07:00
Jake Bailey b379e7fc79 Pass contextFlags when getting contextual type of JSX elements/attributes (#49707) 2022-06-28 14:40:26 -07:00
Sheetal Nandi 7e91485bec Use value meaning for computed property name for visibility check (#49678)
* Test

* Use value meaning for computed property name
Fixes #49562
2022-06-27 15:16:33 -07:00
Jake Bailey 569cdf1b07 Disallow expression with type parameters as left side of property access (#49464) 2022-06-24 15:54:21 -07:00
Lawrence Craft ad6d08675c Add case to capture enum subtype reduction
* Add case to capture enum subtype reduction
Signed-off-by: Lawrence Craft <lcraft6@bloomberg.net>
2022-06-24 13:04:44 -07:00
bentongxyz b24b6a1125 fixes #49491 (#49493) 2022-06-22 13:25:01 -07:00
Oleksandr T 8636adbbb9 fix(49449): change error location when passing objects/arrays to an argument of type (#49593) 2022-06-22 10:06:01 -07:00
Jake Bailey 71b5bdf980 Ensure resolved signature is cached before processing call errors (#49598) 2022-06-21 13:15:03 -07:00
jordanmbell db49c6c3ba Add fractionalSecond part type to DateTimeFormat().formatToParts (#49569)
* Add fractionalSecond part type to DateTimeFormat().formatToParts

This change adds the `fractionalSecond` part type as a valid part
to be returned from Intl.DateTimeFormat().formatToParts().

Fixes microsoft#48882

* fixup
2022-06-21 07:52:24 -07:00
Anders Hejlsberg 529ba99e29 Use separate marker types for variance annotation validation (#49616)
* Use separate marker types for variance annotation validation

* Add regression test
2022-06-21 06:42:10 -07:00
Oleksandr T 74d76e93b3 fix(49546): create computed property name for symbol props (#49554) 2022-06-20 13:46:47 -07:00
Oleksandr T c01afb5ef3 fix(49548): show completions after keywords in block (#49600) 2022-06-20 12:52:28 -07:00
Jake Bailey d7e58c8ea9 Fix arrow expressions in conditional expressions, take N+1 (#49531) 2022-06-17 16:34:27 -07:00
Andrew Branch 7e7c53961a Add TS Server option to exclude files from auto-imports (#49578)
* Basic functionality

* Add tests

* Add test for ambient modules

* Add to protocol
2022-06-17 14:39:51 -07:00
Andrew Branch 1213c35d57 Add error when importing/exporting types in JS files (#49580)
* Add error when importing/exporting types in JS files

* Ignore type-only imports, update other baselines

* Clean up
2022-06-17 14:39:24 -07:00
Wesley Wigham 5c4caafc2a Allow nongeneric string mapping types to exist (#47050)
* Allow nongeneric string mapping types to exist

* Accept baseline

* Recusive membership testing function

* Fix lint

* Add @DanielRosenwasser's comment
2022-06-16 17:02:31 -07:00
Gabriela Araujo Britto 86d5040031 Fix renaming of node_modules (#49568)
* add bug repro test

* add test and start fix implementation

* adjust for useAlias preference

* fix existing renaming test

* refactor to get rid of options

* fix named bindings & other imports cases

* fix eslint error

* address cr comments

* hopefully actually fix eslint

* clean up stale baseline

* make API change non-breaking

* add/fix comments
2022-06-16 17:01:44 -07:00
Oleksandr T f83ce9bd9c fix(49566): Implicit this.property completions not returned while writing property (#49574)
* fix(49566): show this.prop completions in class scoped property declaration

* remove duplicate default value
2022-06-16 12:43:50 -07:00
Oleksandr T 180bc4cbea feat(49385): forbid inlay hints for some kind of initialized declarations (#49412)
.
2022-06-15 15:34:57 -07:00
Anders Hejlsberg 18ac37221b Properly re-scan > token in type argument list determination logic (#49560)
* Properly re-scan '>' token in type argument list determination logic

* Add regression test
2022-06-15 12:06:08 -07:00
Wesley Wigham ccd8b1d27e Allow exports map entries to point at .ts source files (#48563)
* Probably works

* Add tests

* Update baselines for module option rename
2022-06-15 11:23:26 -07:00
Wesley Wigham ba38fe1df2 Expand constraint suggestion related span and add quick fix (#49481)
* Expand constraint suggestion related span and add quick fix

* Remove circular constraint suggestions

* Add error code

* Style feedback and new error code in quickfix
2022-06-15 10:35:51 -07:00
Wesley Wigham eb4b8a4d2e Handle this in isEntityNameVisible (#49521) 2022-06-15 10:15:19 -07:00
Oleksandr T 0ada54c006 fix(49483): throw error on await inside non-async function (#49496) 2022-06-14 16:08:25 -07:00
uhyo 29dffc3079 Forbid unused property renaming in destructuring binding in function types (#41044)
* Forbid renaming a propertyin function type parameters

* add tests

* Remove renaming from declaration output

* accept baseline

* accept baseline

* renew tests (not very right now)

* get correct result

* update diagnostic text

* accept baseline

* add declaration emit test

* fix declaration emit

* fix formatting

* revert unnecessary change

* accept baseline

* extend tests

* Revert "revert unnecessary change"

This reverts commit 17a29fff6c.

* accept baseline

* Rename and refactor potentialAlways... stuff

* add non-identifier names

* extend check to non-identifier original property names

* update diagnostic message

* add related span

* accept baseline

* add symbol-keyed test case

* oops?

* workaround for unstable test

* fix suggested name

* add comment about non-identifier property names

* simplify isReferenced check

* accept baseline

* move it one step further
2022-06-14 12:13:49 -07:00
bentongxyz dbab6eb898 fix #49235 Objects that pass the spread syntax can no longer be assigned to assignable types. (#49337)
* fix issue 49235

* update code with suggested changes

Co-authored-by: Benjamin Tong <benjamin.tong@iddy.ai>
2022-06-14 10:43:18 -07:00
Anders Hejlsberg dc6a80bd00 Fresh {} is subtype of object (#49503)
* Fresh {} is subtype of object

* Add regression test
2022-06-13 12:21:51 -07:00
Oleksandr T 806a710470 fix(49478): add return type to method signature (#49482) 2022-06-10 14:14:36 -07:00
Anders Hejlsberg e6808c4290 Instantiation expression can be followed by line break or binary operator (#49353)
* Allow instantiation expression to be followed by let or interface on new line

* Add tests

* Update src/compiler/parser.ts

* Instantiation expressions followed by line breaks or binary operators

* Add more tests

* Accept new baselines

* Fix lint error

* Update fourslash test

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-06-10 10:26:42 -07:00
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
Anders Hejlsberg 7e4a96e2fa Revise and simplify CFA for typeof check expressions (#49422)
* Revise and simplify CFA for `typeof` check expressions

* Accept new baselines

* Add regression test

* Slight change to preserve type when related in both directions

* Add regression test

* Explain reasons for exact sequence of type checks
2022-06-08 11:30:28 -07:00
Gabriel Grubba 4c5060181f Fix(49198): Added missing definition for Atomics.waitAsync and es2022 sharedmemory file (#49204)
* feat(sharedmemory): Added file waitAsync function

* fix: Adjusted promise return type

* Fix(sharedmemory): Addressed PR comments

* Fix: Removed unused @see at sharedmemory

* Feat: Added tests to shared memory

* Fix: fixed ordering in libs.json

* Feat: Added shared memory to line parser

* Update tests es2022SharedMemory.ts as sugested

Co-authored-by: Eyal Halpern Shalev <eyalsh@gmail.com>

* Update es2022SharedMemory.ts

* feat: Accepted baselines

* fix: Adjusted grammar changes in jsdoc

* fix(47821): skip nodes with export modifiers (#47829)

* Use symbolic GitHub Actions Node.js versions (#49403)

* update baselines

Co-authored-by: Eyal Halpern Shalev <eyalsh@gmail.com>
Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
Co-authored-by: Jack Bates <jack@nottheoilrig.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-06-07 08:46:23 -07:00
Oleksandr T 2f13eba42c fix(47821): skip nodes with export modifiers (#47829) 2022-06-06 10:49:55 -07:00
Anders Hejlsberg 565249fbbe Fix definite assignment analysis issue caused by x !== null checks (#49387)
* Check for non-intersected `undefined` type in definite assignment analysis

* Add regression test
2022-06-06 09:51:13 -07:00
Oleksandr T 62668c6c1d feat(47558): check JSDoc link tags in TypeScript/JavaScript files (#47822) 2022-06-06 09:04:18 -07:00
Wesley Wigham 19b22844d8 Use node's algorithm for calculating the longest matching export/import pattern (#49361) 2022-06-02 15:43:26 -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
TRCYX 44b9745942 fix(49151): format type parameters/arguments (#49165)
Before, the formatter did not consider these constructs as comma
separated lists in general, leading to wrong indentation of '>' after
the list.
2022-05-31 16:03:17 -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
Oleksandr T 3da165e3df fix(49178): check expression with type arguments in inlay hints (#49179) 2022-05-31 15:22:16 -07:00
Nathan Shively-Sanders a5b1f95c23 Allow accessors to override non-class or abstract properties (#41994)
* remove too-late fix

* Allow any property from a mapped type

* turn off error for any non-class base

* Also handle synthetic properties more laxly

Originally from #42635, but this version is simpler.

* update baselines

* Update baselines

* createUnionProperty of accessors creates an accessor

Seems simple and doesn't break much. I need to double-check the few test
failures, however.

* Fix computation of write type of accessors

* Calculate property-vs-accessor in existing loop

Instead of looping over the props list 3 more times.

* Undo synthetic accessor change

* Minimise diff
2022-05-31 14:51:08 -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