Commit graph

32225 commits

Author SHA1 Message Date
csigs b9bf1a5938
LEGO: Merge pull request 44716
LEGO: Merge pull request 44716
2021-06-23 22:13:11 -07:00
Nathan Shively-Sanders aee779ac7d
Skip typedef in services getJSDocTags (#43677)
* Symbols in services skip @typedef/@callback in jsdoc

Fixes #43534

* comment text skips jsdocs that are typedef-only

* Skip comment text from typedef-only jsdocs

* Skip whole comments instead of individual tags

* add semicolons

* retain comments from @callback + better comments
2021-06-23 16:19:14 -07:00
csigs ece76e8a63
LEGO: Merge pull request 44714
LEGO: Merge pull request 44714
2021-06-23 16:13:19 -07:00
Zzzen ce8e873bf8
regard TemplateLiteral as discriminant property (#44569) 2021-06-23 15:48:39 -07:00
csigs 6452cfbad0
LEGO: Merge pull request 44707
LEGO: Merge pull request 44707
2021-06-23 10:13:36 -07:00
Tobias Koppers fd49b26025
json modules should not treated as affecting global scope (#44690) 2021-06-23 10:04:25 -07:00
csigs c29811ea26
LEGO: Merge pull request 44705
LEGO: Merge pull request 44705
2021-06-23 04:13:17 -07:00
csigs 36bc24219d
LEGO: Merge pull request 44704
LEGO: Merge pull request 44704
2021-06-22 22:12:52 -07:00
csigs 15b4b32b39
LEGO: Merge pull request 44703
LEGO: Merge pull request 44703
2021-06-22 16:18:32 -07:00
Anders Hejlsberg 61ccc49a7b
Fix check for overwritten properties in object spreads (#44696)
* Fix check for overwritten properties in object spreads

* Accept new baselines

* Add tests

* Accept new baselines
2021-06-22 14:39:33 -07:00
Tobias Koppers 22637a232b
avoid computing a full shape for indirectly invalidated files (#44090)
* add shape updates to baselines

* avoid computing a full shape for indirectly invalidated files

using file version as shape is enough to keep build info valid
and it's much cheaper
2021-06-22 10:33:54 -07:00
csigs e9a51b4010
LEGO: Merge pull request 44699
LEGO: Merge pull request 44699
2021-06-22 10:18:04 -07:00
Ron Buckton 711b4e778b
Indirect calls for imported functions (#44624)
* Indirect calls for imported functions

* Fix unit tests
2021-06-21 19:51:13 -07:00
Wenlu Wang fafe3ff0b4
Improve parsing in await and yield context (#44680)
* Improve parsing in await and yield context

* Avoid yield and await check in identifier

* Revert "Avoid yield and awaitt check in identifier"

This reverts commit 9644859f29.

* Add some comments
2021-06-21 17:30:55 -07:00
exoticknight 9708022537
Fix 'arguments' check in class field initializer or static initialization block (#44393)
* Fix 'arguments' check in class field initializer or static initialization block

* return errorType

* Merge branch 'master' of https://github.com/exoticknight/TypeScript

* use isInPropertyInitializer

fix Diagnostics message
2021-06-21 16:57:48 -07:00
csigs 15c9cc8a32
LEGO: Merge pull request 44687
LEGO: Merge pull request 44687
2021-06-21 15:49:15 -07:00
Jesse Trinity 753feb8707
importModuleSpecifierEnding changes .ts string completions to .js (#44602)
* don't add .ts extensions to imports

* Update src/services/stringCompletions.ts

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

* add other supported extension types

* add final newlines

* adress PR comment

* add unsupported extension test

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2021-06-21 14:43:33 -07:00
Josh Goldberg 0a9b218b11
Report exact position of invalid characters in scanner (#44671) 2021-06-21 14:23:14 -07:00
Anders Hejlsberg 0e905be42b
Index signatures for symbols and template literal strings (#44512)
* Switch index signature storage to 'indexInfos: IndexInfo[]' property

* Accept new baselines

* Remove another usage of IndexKind enum

* Update getIndexedAccessType and resolveMappedTypeMembers

* Accept new baselines

* Update grammar checking for index signatures

* Accept new baselines

* Consider all index signatures in mapped types and union types

* Accept new baselines

* Update getIndexType

* Accept new baselines

* Intersect multiple applicable index signatures

* Use getApplicableIndexInfo instead of hardwired string/number handling

* Update index signature relationship checking

* Report type for which index signature is missing

* Report type for which index signature is missing

* Accept new baselines

* Make 'number' index signatures consistently apply to numeric strings

* Accept new baselines

* Update fourslash test

* Revise index constraint checking

* Accept new baselines

* Update error messages

* Accept new baselines

* Update type inference from index signatures

* Update isKnownProperty

* Update contextual typing based on index signatures

* Accept new baselines

* Support union types in index signature declarations

* Accept new baselines

* Check duplicate index signatures / remove redundant template literals from unions with string

* Accept new baselines

* Include key type in diagnostic / check symbol-named properties

* Accept new baselines

* Minor fix

* Add tests

* Accept new baselines

* Add optimized findApplicableIndexInfoForName

* Accept new baselines

* Another place we don't need to obtain literal type for property name

* Accept new baselines

* Don't create literal types that are going to be discarded

* Individual maps for string, number, bigint, and enum literal types

* Remove ineffective optimizations

* Accept new baselines

* Permit intersections as key types in index signatures

* Index expression in element access is template literal context

* Add tests

* Accept new baselines

* Symbol index signatures from object literals with computed symbol properties

* Accept new baselines

* Add more tests

* Accept new baselines

* Implement Go To Definition for all applicable index signatures

* Add fourslash test

* Accept new API baselines
2021-06-21 11:25:42 -07:00
Oleksandr T b72f67f45c
fix(44676): fix constToLetQuickFix selection range (#44677) 2021-06-21 11:22:24 -07:00
Eli Barzilay 9e2845227c getEditsForFileRename: fix updateTsconfigFiles w/ empty include
Avoid the assumption that there are always include patterns: when there
are none (and therefore the renamed file didn't match anyway), just skip
the test for added include.

Also change the code to use `return` to make it flatter.

(Also get rid of a redundant type.)

Fixes #40386.
2021-06-21 13:38:54 -04:00
TypeScript Bot c786ad4071 Update package-lock.json 2021-06-20 06:06:13 +00:00
TypeScript Bot 9251304ba7 Update package-lock.json 2021-06-19 06:06:03 +00:00
Oleksandr T 0858933dce
fix(44637): add spaces between exports assignment equal token (#44655) 2021-06-18 16:37:41 -07:00
Oleksandr T 6e4b7308a3
fix(44465): remove only unused declarations instead of the entire line (#44490) 2021-06-18 16:20:34 -07:00
Oleksandr T f850470d18
fix(44377): omit type alias declarations from JavaScript (#44378) 2021-06-18 14:59:31 -07:00
Wenlu Wang 8d3125b78a
Allows plugin to register commands (#44291)
* Pass session into plugin

* Use unknown message type

* Add missing unknown

* use editor services insted of every project

* Fix baseline

* Add plugin test

* Avoid type parameter

* Accept baseline
2021-06-18 14:46:09 -07:00
Nathan Shively-Sanders 0f216f36ec
Forbid duplicates in baselines (#44652)
* Forbid duplicates in baselines

The check is case insensitive.

* Update baselines and add semi-colons

Gotta have those semicolons.
2021-06-18 11:40:25 -07:00
Nathan Shively-Sanders 580bb066c1
Make files safe for Windows (#44651)
* make typeofthis tests case-insensitive-safe

* shorten test case names

* correct way to change test directories

* update baselines
2021-06-18 09:06:51 -07:00
Ryan Cavanaugh 5afe42e14e
Rename strictOptionalProperties -> exactOptionalPropertyTypes and remove from strict family (#44626) 2021-06-17 15:12:19 -07:00
Eli Barzilay fad9122872 services/utilities/getMeaningFromLocation(): fix w/ export specifiers
Fixes 44167, but also two other things:

* On an import/export, climb upto the declaration, and use
  `SemanticMeaning.Type` if it's a `type` only import/export.

* Add a `test.rangesInFile()` to fourslash, so it is easy to do multiple
  files in one test without an awkward filter (which was done in one
  more test).
2021-06-17 14:19:03 -04:00
Oleksandr T eee34d539c
feat(28491): add QF to declare missing properties (#44576) 2021-06-17 11:12:29 -07:00
Andrew Casey 9549928ce9
Make export-module and reference maps invertible (#44402)
* Make export-module and reference maps invertible

Right now, we're enumerating all the entries to find out which keys map
to a corresponding value.  By maintaining a two-way map, we can convert
this linear search into a map lookup and skip allocation of many, many
iterator results.

* Fix lint error

* Add some explanatory comments

* Rename, drop type parameters, and add readonly variant

* Simplify member list

* Fold non-exporting behavior into custom map type
2021-06-17 11:06:42 -07:00
Zzzen 8dbb2cd5fb
allow this in typeQuery (#43898)
* allow `this` in typeQuery

* add tests

* get this type as expression

* handle nested nodes

* update baselines
2021-06-17 07:52:20 -07:00
Anders Hejlsberg d46d82c9bd
Slightly more conservative check in isConstraintPosition function (#44621)
* Slightly more conservative check in isConstraintPosition function

* Update comment

* Add tests
2021-06-16 17:16:32 -07:00
Anders Hejlsberg 97b4063d73
Don't attach declarations to symbols in mapped types with 'as XXX' clauses (#44609)
* Don't attach declarations to symbols in mapped types with 'as XXX' clauses

* Add test (and tweak comment)

Co-authored-by: Eli Barzilay <eli@barzilay.org>
2021-06-16 16:07:33 -07:00
Zzzen 4af8333a4e
support JSDoc comments inherited for parameter properties (#44329)
* support JSDoc comments inherited for parameter properties

* Update formats

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-06-16 14:46:49 -07:00
Anders Hejlsberg a3eadfe905
Skip base type checks that can cause circularities (#44615)
* Don't do base type checks that can cause circularities

* Add regression tests
2021-06-16 13:36:43 -07:00
Armando Aguirre d0159a8891
Fix late bound method name assignment, added tests (#43344)
* Fix late bound method name assignment, added tests

* Refactor bindDynamicallyNamedthisPropertyAssignment

* PR comments

* Rollback allowJscheck fix
2021-06-16 12:46:00 -07:00
Song Gao 971133d5d0
New command line help developer experience. (#44157)
* refactor help CLI output.

* fix typo and omit false condition boolean output.

* fix typo

* add line break

* add --plugins option to basic option category.

* add ts icon and remove old print help function.

* better command description for --jsx.

* Fix test

* fix lint

* Improvements to the UX

* Fix tests

* fix test.

* add missing help out.

* use environemnt variable to control test case.

* fix merge issues.

* No `No Category`

* make getWidthOfTerminal optional.

* fix test

* fix review.

* fix review.

* Update baselines

Co-authored-by: Orta <git@orta.io>
2021-06-16 14:18:00 +01:00
Anders Hejlsberg 6bb1f0792b
Fixes to inference and mapped types in --strictOptionalProperties mode (#44595)
* Fix Required<T> and inference to index signatures in --strictOptionalProperties mode

* Add tests

* Accept new baselines
2021-06-15 14:16:38 -07:00
Orta Therox b74b8977d5
Update descriptions for all compiler options (#44409)
* Add new descriptions to compiler options

* Update baselines
2021-06-15 21:20:14 +01:00
Nathan Shively-Sanders e53f19f8f2
Issue "Cannot find name did-you-mean" errors as suggestions in plain JS (#44271)
* Always issue cannot find name did-you-mean error

This PR issues "cannot find ${name}, did you mean ${name}" errors for
identifiers and propery access expressions in JS files *without*
`// @ts-check` and without `// @ts-nocheck`. This brings some benefits of
Typescript's binder to all Javascript users, even those who haven't
opted into Typescript checking.

```js
export var inModule = 1
inmodule.toFixed() // errors on exports

function f() {
    var locals = 2
    locale.toFixed() // errors on locals
}
var object = {
    spaaace: 3
}
object.spaaaace // error on read
object.spaace = 2 // error on write
object.fresh = 12 // OK, no spelling correction to offer
```

To disable the errors, add `// @ts-nocheck` to the file. To get the
normal checkJs experience, add `// @ts-check`.

== Why This Works ==

In a word: precision. This change has low recall &mdash; it misses lots
of correct errors that would be nice to show &mdash; but it has high
precision: almost all the errors it shows are correct. And they come
with a suggested correction.

Here are the ingredients:

1. For unchecked JS files, the compiler suppresses all errors except
two did-you-mean name resolution errors.
2. Did-you-mean spelling correction is already tuned for high
precision/low recall, and doesn't show many bogus errors even in JS.
3. For identifiers, the error is suppressed for suggestions from global files.
These are often DOM feature detection, for example.
4. For property accesses, the error is suppressed for suggestions from
other files, for the same reason.
5. For property accesses, the error is suppressed for `this` property
accesses because the compiler doesn't understand JS constructor
functions well enough.
In particular, it doesn't understand any inheritance patterns.

== Work Remaining ==

1. Code cleanup.
2. Fix a couple of failures in existing tests.
3. Suppress errors on property access suggestions from large objects.
4. Combine (3) and (4) above to suppress errors on suggestions from other, global files.
5. A little more testing on random files to make sure that precision
is good there too.
6. Have people from the regular Code editor meeting test the code and
suggest ideas.

* all (most?) tests pass

* NOW they all pass

* add tonnes of semi-colons

* restore this.x check+add a test case

* make ts-ignore/no-check codefix work in unchecked js

* Issues errors only in the language service

* add a few more tests

* fix incorrect parentheses

* More cleanup in program.ts

* Improve readability of isExcludedJSError

* make diff in program.ts smaller via closure

* Switch unchecked JS did-you-mean to suggestion

Instead of selectively letting errors through.

* undo more missed changes

* disallow ignoring suggestions

* Issue different messages for plain JS than others

Straw text for the messages, I just changed the modals to avoid name
collisions.
2021-06-15 08:54:08 -07:00
Eli Barzilay 5be0d7156d Fix bug due to sharing of .type.members
Function extraction failed when using two identical `TypeLiteral`s ---
the problem is that the parameters' `.type.members` are shared in their
two occurences in the resulting code, and when the formatter bangs
position properties on the second, it's actually changing the first too.

* `typeToAutoImportableTypeNode`: wrap in `getSynthesizedDeepClone` to
  avoid the offeding sharing.

* `getSynthesizedDeepCloneWorker`: add optional nodes/token visitors so
  it doesn't skip cloning the above.

* A few very minor tweaks which I saw when tracing this (comment update,
  two `!`s).

Fixes #44301
2021-06-14 10:46:07 -04:00
TypeScript Bot a875635ea7 Update package-lock.json 2021-06-14 06:06:06 +00:00
Anders Hejlsberg 5540364c12
Correct tuple relations in --strictOptionalProperties mode (#44568)
* Fix relations for optional elements in tuples with --strictOptionalProperties

* Accept new baselines

* Add regression test

* Address CR feedback
2021-06-13 12:53:13 -07:00
Anders Hejlsberg 6a1623d413
Ensure singleton types always compare identical (#44565)
* Singleton types should compare identical + fix boolean types

* Add tests

* Accept new baselines
2021-06-13 12:51:36 -07:00
TypeScript Bot 4829a7fedd Update package-lock.json 2021-06-12 06:05:58 +00:00
Ron Buckton a0c44b26b7
Improve __spreadArray perf, and other fixes related to SpreadElement (#44527)
* Improve __spreadArray perf, fix array packing and trailing omitted expressions

* Ensure __spreadArray is backwards-compatible

* Add signature restriction for __spreadArray

* Added reusable true/false literals
2021-06-11 16:21:55 -07:00
Andrew Casey cdd7ffdc56
Make handleDtsMayChangeOf void-returning (#44322)
* Make handleDtsMayChangeOf void-returning

Right now, it always returns false.  This seems important, since
otherwise it would stop graph traversals prematurely.  It took me a
while to figure that out though and I thought it might be clearer if it
were simply void-returning.

I've kept the behavior the same, except in
`forEachReferencingModulesOfExportOfAffectedFile`, where it seemed like
never enqueueing new references was a mistake.

* Make forEachFileAndExportsOfFile void-returning

As far as I can tell, it could only return `false`.
2021-06-11 14:52:52 -07:00