Commit graph

31881 commits

Author SHA1 Message Date
Anders Hejlsberg fbc9c942b2
Normalize target type after null-stripping unions in relationship checks (#43202)
* Normalize target type after null-stripping

* Add regression tests
2021-03-19 09:19:25 -07:00
Nathan Shively-Sanders 451d4354b9
Revert "Editor support for link tag (#41877)" (#43302)
This reverts commit ec77bff332.
2021-03-18 14:42:25 -07:00
Anders Hejlsberg a21f61f746
Fix narrowing of intersections of type variables and primitive types (#43131)
* Fix narrowing of intersections of type variables and primitive types

* Add tests
2021-03-18 08:55:50 -07:00
Nathan Shively-Sanders ec77bff332
Editor support for link tag (#41877)
* Initial scribbles

* Compiles but provides spans instead of location pairs

Probably need to fork the services/server types and provide a conversion
with Session.toFileSpan. Not sure where to put the conversion.

* Switch to DocumentSpan

In theory this is already better supported, but not sure practise bears
that out.

* Builds w/protocol types + conversions

* cleanup:better names and scrub TODOs

* fix test harness too

* Misc

1. Simplify protocol after talking to @mjbvz.
2. Add more tests.
3. Initial notes about where to add parsing.

* Parse and store links in the compiler

The text of the link is still stored in the comment text, but that's now
kept in an object instead of just a string. Each link has the parse for
the entity reference, if there is one.

Needs lots more tests -- this just makes all the existing jsdoc tests
pass.

* more tests and some fixes

* Fix other failing tests

* fix bad merge

* polish parser

* improve names and array types

* slight tweaks

* remove some done TODOs

* more tests + resulting fixes

* add+fix cross-module tests

* Support `@see {@link`

Plus find-all-refs support equivalent to @see's.

* add server test

* Make comments actually part of the AST

* Add span for link.name in language service/protocol

* Make checker optional in getJSDocTags

Also change to JSDocCommentText from JSDocCommentComment

* Use getTokenValue instead of getTokenText

Measure twice, slice once

* Add missing support for top-level links

The language service and protocol were missing support for top-level
links. This commit adds that plumbing.

* add string back to comment type in node constructors

* Full parse of link tags and jsdoc comment text

- Doesn't pass fourslash yet, I'm going to switch to baselines for
  failures there.
- Still needs some work on the protocol to convert file+offset to
  file+line+offset.

* fix lint

* Fix missing newlines in inferFromUsage codefix

* Parse jsdoc comments as text node/link array

And switch to line+character offsets in the protocol

* Fix fourslash tests

Mostly ones that can't be baselined, but I switched a couple more over
to baselines

* Improve types and documentation

* Test+fix @link emit, scrub other TODOs

* update API baselines

* test that goto-def works with @link

* Split link displaypart into 3

One for link prefix and suffix, one for link name, and one for link
text.

* update baselines

* Provide JSDocTagInfo.text: string to full clients by default

Instead of upgrading them to displayparts.

* Real server tests

* Disambiguate {@link} and @param x {type}

They are ambiguous; previously the parser preferred the type
interpretation, but will now look ahead and parse links instead when the
prefix is `{@link`.

* Add explanatory comment in test

* fix location in richResponse in protocol

* update API baseline

* Address PR comments

1. Add a cross-file goto-def test.
2. Switch from per-message args to UserPreference.

* use arraysEqual from core
2021-03-16 16:26:01 -07:00
Oleksandr T 3da5982c9a
fix(43254): show named tuple member type (#43273) 2021-03-16 12:56:12 -07:00
Andrew Casey ae884b1a38
Fix dump of tracing legend (#43263) 2021-03-16 10:57:10 -07:00
TypeScript Bot ea92e3f2a0 Update package-lock.json 2021-03-16 06:24:30 +00:00
Sheetal Nandi 53cbc046d2
Refactor the test for easy maintainability (#43262) 2021-03-15 18:04:30 -07:00
Armando Aguirre 322c70fd82
Fixed reporting error for type arity (#43111) 2021-03-13 01:01:04 -08:00
Armando Aguirre 36f7623225
Fix jsx formatting (#42671)
* Refactored scanJsxToken when is formatting

* Added bug regression test

* Simplify JsxText formatting

* Renamed isFormatting to allowMultilineJsxText

* Updated baselines
2021-03-13 01:00:42 -08:00
TypeScript Bot 1e9b21f702 Update package-lock.json 2021-03-13 06:24:50 +00:00
Sheetal Nandi d2cb05a6b5
Emit readable BuilderFileEmit kind (#43221) 2021-03-12 14:32:50 -08:00
Sheetal Nandi 82bfe5ad93
Fix issue with some baselines for tsbuildinfo not getting generated (#43218) 2021-03-12 12:28:20 -08:00
Sheetal Nandi 496a1d3caa
Improvements to dts emit for tsbuildinfo (#43205)
* Test update

* Use source file version as default signature for the file whenever there is no dts emit for the file

* json source files from project reference should be able to calculate the signature

* Dont emit declaration map when emitting dts files for force emit for signature
2021-03-12 09:44:22 -08:00
TypeScript Bot 9c73e048ae Update package-lock.json 2021-03-12 06:25:10 +00:00
Nathan Shively-Sanders 2ea2f4f9a0
Bigint constructor forbids object null undefined (#43204)
* Update es2020.bigint.d.ts

* Update es2020.bigint.d.ts

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* Update package-lock.json

* add a test

Co-authored-by: 龙腾道 <LongTengDao@LongTengDao.com>
Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-03-11 16:51:03 -08:00
Hai Lin Zhang e44d39d4eb
Updated error message for TS2539 (#39827)
* Updated error message for TS2539

* Switch to multiple error messages

* inline variable

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-11 15:51:15 -08:00
Sheetal Nandi 9933c8ac7d
Build info baseline improvements (#43200)
* Use ids as 1 based so we can specialize `0` to be some special meaning

* Baseline tsbuildinfo size in the readable baseline

* Baseline fileName and fileNames list as well in readable tsbuildinfo so that new additions are easy to recognize
2021-03-11 13:30:06 -08:00
Wesley Wigham 2643e65da4
Add missing relationship allowing a type to be assignable to a conditional when assignable to both branches (#30639)
* Finally add that missing relationship allowing a type to be assignable to both branches of a conditional

* Explicitly write out Ternary.Maybe

* Add slightly modified example from #25413

* fix sick sentence

* Loosen check to skip false branch constraint check to consider `infer` parameters as always satisfied in the extends clause

* Simplify things a bit, only instantiate once

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-11 11:56:55 -08:00
Nathan Shively-Sanders b2d1f537f1
Bloomberg computed property name fix (#43197)
* Fix property name bindings for class expr in loops

* Fix block-scope capturing with prop initializers

Co-authored-by: Joey Watts <joey.watts.96@gmail.com>
2021-03-11 10:32:42 -08:00
Mateusz Burzyński 998ecd9c06
Add a test for JSX namespace lookup with jsx: preserve, jsxImportSource (#41676)
* Add a test for JSX namespace lookup with `jsx: preserve, jsxImportSource`

* updated baselines

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-11 09:07:33 -08:00
Matthew Pietz dcaefe732e
Accept generics for defineProperty (#42424)
* Accept generics for defineProperty

Both `Object.defineProperty()` and `Object.defineProperties()` return their
first argument. Use a generic so that typings can be passed through.

* Update baselines

* update missed baseline

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-11 07:57:42 -08:00
Titian Cernicova-Dragomir 71661b932a
Fixed issue where non null assertion caused getFlowTypeOfReference to return the declared type if the type was already narrowed to never. (#35863)
This was caused by the fact that getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull) will return never both if resultType was already never and if resultType does not contain undefined or null. In the latter case returning the declaring type is correct, in the former case this causes something narrowed to never to still be typed as the original declared type.
2021-03-11 07:33:33 -08:00
Jack Williams 3d6650eb4f
Fix #38608 (#38610)
* Fix #38608

* Work for narrowed non-unions

* Add comment
2021-03-11 07:32:49 -08:00
Ryan Cavanaugh 79d3058b83
Don't crash when renaming a JS property declared via module.exports (#40297)
Fixes #38070

When the originating definition was of the form
```js
module.exports.foo = expr
```
we were incorrectly trying to call `resolveName` on just the `foo` portion to get the "local" symbol, which simply failed to resolve (or would have resolved to the wrong thing), but for this form, the local symbol is just the containing property access expression
2021-03-11 07:23:19 -08:00
Oleksandr T 3c576f108c
fix(41027): handle unused static members (#41103) 2021-03-11 06:39:20 -08:00
TypeScript Bot 5053b0b987 Update package-lock.json 2021-03-11 06:24:57 +00:00
Kagami Sascha Rosylight f4d0ea6539
Add target: ES2021 (#41239)
* Support `target: es2020`

* use CRLF

* update symbols

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-10 13:31:25 -08:00
Wenlu Wang b20331a4db
Fix missing func modifier (#40379)
* Fix missing function modifier

* Update src/services/refactors/convertArrowFunctionOrFunctionExpression.ts

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-03-10 09:34:31 -08:00
Oleksandr T b1f86eca3e
fix(42265): Error accessing abstract property in constructor via destructuring (#42276) 2021-03-10 07:26:50 -08:00
TypeScript Bot 2e49e286ae Update package-lock.json 2021-03-10 06:24:41 +00:00
Sheetal Nandi acc8f2fb05
Ensure that when new file affecting global scope is added, the signatures are updated (#43084)
* Ensure that when new file affecting global scope is added, the signatures are updated

* Update src/compiler/builder.ts

* Better comment
2021-03-09 17:40:02 -08:00
Sheetal Nandi 6e4456b3b4
Optimize the size for tsbuildinfo (#43155)
* Baseline readable buildinfo

* Use file names as index in file name list
This is extension of the idea given by @sokra to optimize size of tsbuildinfo

* Deduplicate reference map lists and use file name index to sort them
Different implementation of #43079 based on idea suggested by @sokra

* Minimal json.stringify for the tsbuildinfo
Again implementaion of suggestion by @sokra

* Update src/testRunner/unittests/tsbuild/helpers.ts

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>

* Readable version of buildinfo all the time

* Some renames for readability as per feedback

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2021-03-09 16:15:26 -08:00
Tarik Eshaq 626e78c959
Clearifies protected error message (#42599) 2021-03-09 15:58:31 -08:00
Nathan Shively-Sanders 3d53661605
Don't inherit jsdoc tags from overloaded signatures (#43165)
Previously, when getting jsdoc for signatures, the services layer would
get the jsdoc tags for the base symbol of a signature if it was
present. This is fine except when the base was overloaded. In that case,
the multiple signatures of the overload would all contribute jsdoc,
which is not correct.

A more correct fix would be to resolve overloads to the base, but
the compiler doesn't have this capability and adding it or jury-rigging
it seems like it would be complex, inappropriate for a fix to ship in a
patch version.

Co-authored-by: Orta Therox <git@orta.io>

Co-authored-by: Orta Therox <git@orta.io>
2021-03-09 12:28:36 -08:00
Ron Buckton ec4863cc0e
Fix37991 (#43166)
* Add failing test

* Fix tslib check errors for commonjs imports
2021-03-09 11:43:19 -08:00
Oleksandr T 9610c16cc8
fix(42380): include JSDoc comments in declarations for static/prototype methods (#42454) 2021-03-09 11:37:40 -08:00
TypeScript Bot d9f5a85d5b Update package-lock.json 2021-03-09 06:24:45 +00:00
TypeScript Bot 4d506240de Update package-lock.json 2021-03-08 06:24:47 +00:00
TypeScript Bot f7cd70291c Update package-lock.json 2021-03-07 06:24:13 +00:00
Anders Hejlsberg f918bd9c76
Exclude enum/number compatibility rule from comparable relation (#42472)
* Exclude old number/enum literal compatibility rule from comparable relation

* Add tests

* Accept new baselines
2021-03-06 06:52:00 -08:00
Anders Hejlsberg ba56fca0bf
Remove undefined from optional properties when inferring to index signatures (#43086)
* Remove undefined from optional properties when inferring to index signatures

* Add tests
2021-03-06 06:51:02 -08:00
TypeScript Bot 7394efc9be Update package-lock.json 2021-03-06 06:24:11 +00:00
Sang 612a96e161
Update parseInt parameter name and jsdoc (#42756)
* feat(lib): improve parseInt type definition and docstring

* Accepted baselines

* update tests
2021-03-05 11:23:08 -08:00
Jonas Hübotter 25375a2213
Unnecessary elaboration about not being assignable to type parameters (#42952) 2021-03-05 11:15:05 -08:00
Anders Hejlsberg 408c804103
Properly instantiate inferred constraints in conditional types (#42747)
* fix combined type mapper in getConditionalType

* Add regression tests
2021-03-05 07:26:27 -08:00
TypeScript Bot f0a72e2450 Update package-lock.json 2021-03-05 06:24:30 +00:00
Daniel Rosenwasser 9862b031b0
Relax requirements on index signatures to 'any' when a type also contains a string index signature to 'any' (#43065)
* Added test.

* Accepted baselines.

* Allow other index signatures to 'any' if there is a string index signature to 'any'.

* Accepted baselines.
2021-03-04 17:42:00 -08:00
Oleksandr T ca8d9e4402
fix(39836): allow type declaration/unknown type in catch arguments in JavaScript files (#42392) 2021-03-04 17:19:35 -08:00
Ron Buckton 38fdce9440
Expose 'reservedInNestedScopes' option when creating temp and loop variables (#43083) 2021-03-04 15:37:45 -08:00