Commit graph

32256 commits

Author SHA1 Message Date
Eli Barzilay f47ddbc3b0 Fix bad line number assertion in ScriptInfo.positionToLineOffset
This is the line number side of ecddf8468f (from #21924, fixing #21818).
But the code is slightly improved for both cases: instead of testing
that `leaf` is defined, check whether `lineCount` is zero, and if it is,
return `〈1,0〉` for the one-based line and zero-based column numbers.
(The requirement of `lineCount > 0` is also seen in the fact
that `lineNumberToInfo` expects a "*One*BasedLine" argument.)

I've stared at this code way too much, since I think that there is
something more fundamentally wrong here.  E.g., `EditWalker` only
`push`es to `startPath` but never pops even a `children`-less node that
is left after deleting the whole contents.  But I can't figure out the
overall structure, which is also why the test that I added is not
great (see the comment there; also, #21924 is dealing with the same
problem and didn't add a test).

Fixes #44518.
2021-06-29 14:13:44 -04:00
TypeScript Bot 5cea46c537 Update package-lock.json 2021-06-29 06:05:59 +00:00
Anders Hejlsberg 5f8a9e5181
Fix constant reference check in CFA (#44762)
* Check entire access path is constant when narrowing by inlining

* Add tests

* Accept new baselines

* Added test cases for parameter properties.

* Accepted baselines.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-06-28 16:41:17 -07:00
Andrew Casey c0d5c29080
Reduce exceptions (#44710)
* Don't visit non-existent basePaths

* Stop trying to add file watchers after hitting the system limit

* Update tests
2021-06-28 15:45:35 -07:00
Oleksandr T 066796be54
feat(44736): add go-to-definition on overridden members (#44740) 2021-06-28 14:58:06 -07:00
Andrew Branch 54b913cf31
Issue unawaited promise error on symbol-less expressions (#44491)
* Issue unawaited promise error on symbol-less expressions

* Use same behavior for call expressions

* Revert "Use same behavior for call expressions"

This reverts commit 60d58132e4.
2021-06-28 12:35:58 -05:00
csigs 4890312ad8
LEGO: Merge pull request 44791
LEGO: Merge pull request 44791
2021-06-28 10:13:00 -07:00
TypeScript Bot 6824480de8 Update package-lock.json 2021-06-28 06:06:29 +00:00
csigs a6c914e55d
LEGO: Merge pull request 44780
LEGO: Merge pull request 44780
2021-06-27 22:13:03 -07:00
csigs 67357cdb4f
LEGO: Merge pull request 44776
LEGO: Merge pull request 44776
2021-06-27 16:13:07 -07:00
csigs 3b2bc85594
LEGO: Merge pull request 44770
LEGO: Merge pull request 44770
2021-06-27 10:13:36 -07:00
TypeScript Bot a7a0d258cf Update package-lock.json 2021-06-27 06:06:02 +00:00
csigs 5dbb7d313c
LEGO: Merge pull request 44766
LEGO: Merge pull request 44766
2021-06-26 22:12:53 -07:00
csigs 0b3a15414b
LEGO: Merge pull request 44763
LEGO: Merge pull request 44763
2021-06-26 16:14:05 -07:00
csigs 8c8d22db0f
LEGO: Merge pull request 44757
LEGO: Merge pull request 44757
2021-06-26 10:13:11 -07:00
TypeScript Bot 11b38676b0 Update package-lock.json 2021-06-26 06:05:58 +00:00
Nathan Shively-Sanders 1ae6b8bfb5
Forbid duplicate tests only in compiler+fourslash runner (#44752)
* Forbid duplicate tests only in compiler runner

Not in fourslash, user, docker, etc.

* Include fourslash, but exempt shims and server
2021-06-25 17:33:31 -07:00
Wenlu Wang dc237b317e
Change static fields emits (#43114)
* use emit into iife

* Update emit

* Revert un-related changes

* Allow super in static context

* Allow this and super in static property declaration

* Add more tests

* Avoid errors

* Accept baseline

* Accept baseline

* Add decorated classes test

* Add errors

* Avoid this in emitter

* make lint happy

* Add class expression tests

* Add computed name test

* Avoid super if target below es6

* Adjust function boundary

* Add internal

* Fix minor CR issues

* accept baseline

* Update behavior

* Avoid spaces

* Make lint happy

* Avoid function boundary utils

* Update baseline

* Avoid errors

* Accept baseline

* Accept baseline

* Accept baseline

* Accept baseline

* Use substitutions

* Full coverage for super, this, merge static and private context

* Fix use-before-def in static fields

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-06-25 15:49:27 -07:00
Andrew Branch 328e888a9d
Resolve module specifiers for auto imports in completion list (in incomplete chunks) (#44713)
* Enable module specifiers for all auto imports

* Use isIncomplete

* isIncomplete continuation

* Lots of fixes

* Merged/transient symbol fixes, resolve all ambient module specifiers up front, pull as many as we want from cache

* Fix existing tests

* Start testing

* Add more tests

* Set cache attempt limit, update API baseline

* Fix a few tests

* Fix contextToken

* Split getModuleSpecifiers

* Unexport function

* Clean up importFixes

* Clean up completions

* Delete transient symbol assertion - fixing later
2021-06-25 17:26:53 -05:00
Oleksandr T 7c47be76b0
fix(44738): fix eslint rules (#44739) 2021-06-25 14:50:19 -07:00
Orta Therox 9ebe11c2d3
Migrate latest dom types into libdom.d.ts (#44684)
* Add the types_web dom dts

* Update

* Adds new DTS

* Update baselines
2021-06-25 14:25:30 -07:00
Anders Hejlsberg 8058619aed
Control flow analysis of aliased conditional expressions and discriminants (#44730)
* CFA inlining of conditional expressions referenced by const variables

* Accept new baselines

* Add tests

* Accept new baselines

* Increase inlining limit to 5 levels per design meeting discussion
2021-06-25 13:59:58 -07:00
Wenlu Wang 906cbd2715
Proposal class static block support (#43370)
* Class static block (#9)

* Add types factory and parser

* Add some case

* Make class static block as a container

* Update cases

* Add visitor

* Add emitter and more compile target

* Check boundary of break and continue

* Add basic transformer

* Fix emit behavior

* Add more tests

* Add friend tests

* Update baseline

* Fix cr issues

* Accept baseline

* Add decorator and modifier check

* Add functional boundary check

* Fix conflict

* Fix computed prop name within context

* Add more tests

* Update baseline

* Avoid invalid test baseline

* Support use before initialize check

* wip

* Fix class static block context

* Fix checks

* Fix missing case

* Improve assert message

* Accept baseline

* Avoid new context

* Update diagnostic message

* Fix name collision

* Fix targets

* Avoid unnecessary files

* Add more case

* Add more test cases

* Fix strict mode function declaration

* Avoid private fields initializer if no private identifier references

* Avoid private fields and add more test case

* Add more case

* Add tests and support for related services functionality

* Fix this reference in static block

* Split parser diagnostic and binder diagnostic

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-06-25 09:24:05 -07:00
csigs 1694c77060
LEGO: Merge pull request 44741
LEGO: Merge pull request 44741
2021-06-25 04:18:35 -07:00
Wenlu Wang 66b4ba4b35
Add inlay hints support (#42089)
* Add signature arguments label support

* Support rest parameters and destruction

* make lint

* Fix tuple rest parameters

* Adjust name styles

* Rename to inline hints

* Partition inline hints

* Adjust range pred

* Add function expression like hints

* Support configure inline hints

* Display hints in single line

* Add test suits and tests

* Add range tests

* Support more hints

* Add more options

* Fix logical

* Add more cases

* Support call chains

* Rename options

* Match lastest protocol

* Update protocol changes

* Support context value and hover message

* Revert "Support context value and hover message"

This reverts commit 37a7089633.

* Revert "Update protocol changes"

This reverts commit e5ca31bc30.

* Add hover message

* Accept baseline

* Update src/services/inlineHints.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Update src/services/inlineHints.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Cache across the program

* Fix possible undefined

* Update protocol changes

* Fix missing property

* Make lint happy

* Avoid call chain hints

* I'm bad

* Add whitespace before type

* Add more tests

* Should care about jsdoc

* Support complex rest parameter

* Avoid module symbol  hints

* Care about leading comments

* Fix CR issues

* Avoid changes

* Simplify comments contains

* Fix CR issues

* Accept baseline

* Check parameter name before create regex

* Rename option

* Avoid makers

* Skip parens for argument

* Fix CR issues

* Fix enums

* Accept baseline

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-06-24 23:06:34 -07:00
TypeScript Bot 2767ab3e3e Update package-lock.json 2021-06-25 06:06:02 +00:00
csigs c83a430a5f
LEGO: Merge pull request 44737
LEGO: Merge pull request 44737
2021-06-24 16:13:19 -07:00
Andrew Branch 2b421bfc5d
Fix auto imports in opening JSX tag (#44724) 2021-06-24 17:14:54 -05:00
csigs baff2f8f97
LEGO: Merge pull request 44728
LEGO: Merge pull request 44728
2021-06-24 10:13:16 -07:00
csigs b43bc957bf
LEGO: Merge pull request 44717
LEGO: Merge pull request 44717
2021-06-24 04:15:51 -07:00
TypeScript Bot 6459ee4e4a Update package-lock.json 2021-06-24 06:05:48 +00:00
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