3256 Commits

Author SHA1 Message Date
Daniel Rosenwasser
38f3b05cb1
31304 - Autocomplete for enum values fails when typing "/" (#31362)
31304 - Autocomplete for enum values fails when typing "/"
2019-05-24 16:17:25 -07:00
Andrew Branch
7359ff8158
Add test 2019-05-23 13:33:38 -07:00
Andrew Branch
f97f57c155
Fix containsPrecedingToken for tokens whose preceding token is a missing node 2019-05-23 12:15:50 -07:00
Sheetal Nandi
38f689d19e
Merge pull request #31484 from microsoft/completionsSorting
Add sortText depending scope of symbols
2019-05-21 12:59:01 -07:00
Wesley Wigham
07d850cf1c
Prevent type parameter printing from recuring on the same symbol (#31453) 2019-05-20 16:43:55 -07:00
Sheetal Nandi
00cea41b65 Add sortText depending scope of symbols
Fixes #15024
2019-05-20 15:53:51 -07:00
Nathan Shively-Sanders
9052804576
Test docCommentTemplate for prototype methods (#31477)
This works in 3.5, but didn't in 3.2. Adding a test to make sure it
stays working.
2019-05-20 12:50:29 -07:00
Andrew Branch
15daf42b2c
Merge pull request #31028 from andrewbranch/feature/smart-select
Smart Select language service API
2019-05-16 09:45:05 -07:00
Daniel Rosenwasser
d484163d0f
Merge pull request #31262 from rpgeeganage/new_keyword_consistent_resolve
Quick info on 'new' keyword should be the same as that of resolved expression
2019-05-15 00:36:38 -07:00
Anders Hejlsberg
a65f35b5fb Remove fourslash test 2019-05-13 12:42:44 -07:00
Alexander
8965650bc3 ignore trigger chars within a string literal 2019-05-12 23:14:18 +03:00
Wenlu Wang
714821fc97 add refactor of extract type (#30562)
* add basically implement

* add rename location and add testcase

* collection type arguments

* disallow infer type

* add support for typedef convert

* refactor info to make type safe

* disallow type pred

* avoid unnecessary branch

* disallow type query

* haha😂

Co-Authored-By: Kingwl <kingwenlu@gmail.com>

* Update src/services/refactors/extractType.ts

Co-Authored-By: Kingwl <kingwenlu@gmail.com>

* Update src/services/refactors/extractType.ts

Co-Authored-By: Kingwl <kingwenlu@gmail.com>

* add more tests

* add template tag support in jsdoc

* add support of type parameters constraint

* add more tests

* merge branch

* add more tests

* refactor and update function name
2019-05-07 08:26:53 -07:00
rpgeeganage
8f209be149 fixed the comments 2019-05-06 21:21:37 +02:00
rpgeeganage
9959ce449e added test 2019-05-05 19:01:14 +02:00
amaksimovich2
5b79b942e8 add action for enabling experimentalDescorators option in user config… (#30484)
* add action for enabling experimentalDescorators option in user config file, change error message for this case #29035

* add missing changes in tests

* Add "experimental decorators" tests for jsconfig file
2019-04-25 14:55:04 -07:00
Andy Hanson
6e4c150d6b When function parameters span multiple lines, make the function span start at the ( (#26907)
* When function parameters span multiple lines, make the function span start at the `(`

* Undo unnecessary change
2019-04-25 10:53:39 -07:00
Andrew Branch
e28b9b2ba2
Copy smartSelect tests to fourslash 2019-04-23 16:41:59 -07:00
Andrew Branch
6fc2e4a32e
Add custom baseline format for smart selection 2019-04-23 15:34:01 -07:00
Wenlu Wang
27075555c8 fix generate typenode from negative numerical literal (#30610) 2019-04-23 14:20:53 -07:00
Ryan Cavanaugh
885d4d63c8
Remove "generate types" code (#31075) 2019-04-23 13:51:47 -07:00
Andrew Branch
cd56398a53
Merge pull request #30743 from andrewbranch/bug/30675
Make anonymous function formatting apply to anonymous generators too
2019-04-23 09:35:35 -07:00
Nathan Shively-Sanders
c3a9429420
Handle JSDoc backticks in the parser, not scanner (#30939)
* Scan backticks in jsdoc as a single token less often

Previously, matching backticks in jsdoc would always be scanned as one
token to aid parsing incorrect jsdoc that uses backticks for parameter
names:

``js
/** @param {string} `nope`
 * @param {number} `not needed`
 */
```

However, this is wrong for code fences, which use triple backticks. This
fix parses a single backtick as a single token if it's immediately
followed by another backtick or by a newline. It retains the
questionable tokenisation of backticks-as-pairs in other cases, however.
A better fix might be to have the parser ignore backticks in jsdoc
instead.

* Add test case

* Handle jsdoc backticks in the parser, not scanner

Previously, the jsdoc scanner had ad-hoc handling of backticks that was
similar in structure to the normal scanner's handling, but much simpler.
This was a smaller code change, but is handled backwards: the special
case of backtick-quoted parameter names was handled in the scanner
instead of in the jsdoc identifier parsing code. That made it overapply
and block correct handling of asterisks across newlines, which was most
obvious in code fences inside jsdoc, as in #23517.

Fixes #23517

* More cleanup
2019-04-18 09:35:40 -07:00
Adam Postma
e951455215 Update misspelling 'identifer' to 'identifier' (#30894)
* fix typo - identifer to identifier

* fix typo - identifer to identifier
2019-04-12 13:29:00 -07:00
Nathan Shively-Sanders
ff959096df
Fix some bad jsdoc comment indent (#30838)
* First draft

Solves the initial problem but breaks commentCommentParsing. I also
found a couple more interesting cases.

* Add more tests and fix their bugs

* Another test case

* Some cleanup

I may try do a little more; `margin += tag.end - tag.pos` bothers me a
bit.

* More cleanup
2019-04-10 08:22:09 -07:00
Wesley Wigham
16450a027a
Change the default type parameter constraints and defaults to unknown from {} (#30637)
* Change the default type parameter constraint and default to unknown from {}

* Relax unknown checking outside of strictNullChecks a bit

* Increase strictness on index signatures with type `unknown` so inference doesnt change surprisingly

* Remove redundant switch
2019-04-04 12:25:15 -07:00
Andrew Branch
45ed0186a1
Make anonymous function formatting apply to anonymous generators too 2019-04-03 17:21:20 -07:00
Sheetal Nandi
17ceddaa1a
Merge pull request #29493 from Kingwl/avoid-quickfix-for-declaration-file
avoid add missing member in declaration file
2019-03-29 11:58:08 -07:00
Gabriela Araujo Britto
bb5eb025a8
Handle imports and exports in 'convert parameters to destructured object' (#30475)
* add test for imported function

* start to implement import references check

* fix imported function test

* skip alias when looking for symbol target

* recognize ES6 imports

* recognize some export syntax

* add tests for imports/exports

* add test for imported function

* start to implement import references check

* fix imported function test

* skip alias when looking for symbol target

* recognize ES6 imports

* recognize some export syntax

* add tests for imports/exports

* add test for imported function

* start to implement import references check

* fix imported function test

* recognize ES6 imports

* recognize some export syntax

* add mode import/export syntax cases

* fix entryToFunctionCall to deal with new calls through property/element access expressions

* add more tests for imports/exports

* allow function and class declarations that have no name but have a default modifier

* rename tests

* fix conflict

* fix tests

* add test for nameless class

* rename function

* minor refactor

* remove old tests

* delete old test

* refactor as suggested

* use getContainingFunctionDeclaration
2019-03-28 13:34:29 -07:00
王文璐
9050d0fdf8 update external files api 2019-03-27 19:06:21 +08:00
王文璐
6bc5ef3474 Merge branch 'master' into avoid-quickfix-for-declaration-file 2019-03-27 18:36:56 +08:00
Nathan Shively-Sanders
32054f1c31
Forbid accessing block-scoped variables on globalThis (#30510)
* Forbid accessing const & let on globalThis

It's just an error; you still get the type of the property.

* Disallow access of blockscoped vars on globalThis

Also change Array, Function, String, et al from `const` to `var` so that
they remain accessible via `globalThis.String`.

* Update baselines after lib.d.ts change

Note especially the change in redefineArray, which is now allowed as
long as you provide a type that is assignable to ArrayConstructor.

* Remove blockscoped vars from typeof globalThis

Unlike forbidding them, this removes the properties entirely.

Unfortunately, this means that accessing these properties is only an
error with noImplicitAny, and that error is quite confusing.

Let's discuss our options. I see 3:

1. Forbid access of block-scoped vars as properties (in all flag
settings), but leave them on the type. Simple to implement.
2. Remove block-scoped vars from the globalThis type. Has the bad
error/flag behaviour described above, but simple to implement.
3. Remove block-scoped vars from the globalThis type. Also, forbid
accessing them by executing another resolveName lookup for failed
property accesses on globalThisSymbol. If the second lookup returns a
blockscoped var, issue an error instead of falling back to the index
signature. This seems too complex to me.

* Update baselines

* Better error for block-scoped usage on globalThis

So that value-space references have as clear an error as type-space
references.

* Update fourslash tests

* Fix semi-colon lint

* Don't copy so much when filtering blockscoped vars
2019-03-25 14:07:48 -07:00
Gabriela Araujo Britto
0f6f3b79b5
Fix find all references of inherited constructor (#30514)
* recursively look for inherited constructor references

* add test

* remove outdated comment

* add tests

* move function

* improve tests

* minor refactor

* fix convert params refactoring to deal with inherited constructor calls

* simplify refactor test
2019-03-22 15:17:50 -07:00
Sheetal Nandi
800f7a3447
Merge pull request #30414 from Microsoft/jsSyntaxCompletions
Filter ts only keywords from js file completion
2019-03-20 10:38:11 -07:00
Gabriela Araujo Britto
84087d0e0a
Use shorthand property assignment in convert parameters to object (#30468)
* create shorthand property assignment in argument object when possible

* add shorthand property assignment test

* don't offer refactor on jsdoc comment

* add jsdoc test

* improve jsdoc test

* use crlf
2019-03-19 09:28:09 -07:00
Gabriela Britto
10b9051624
Fix convert to named parameters rest parameter tuple (#30286)
* check if rest parameter is of tuple type in isOptionalParameter

* expose isArrayType and isTupleType in checker

* don't offer refactor if rest parameter type is neither array nor tuple type

* add tests for rest parameters

* fix tests for renamed refactor

* remove unnecessary conditional operator
2019-03-18 10:31:38 -07:00
Anders Hejlsberg
d0646a629a
Merge pull request #30084 from dragomirtitian/GH-26563
Improved argument description for parameters originating from tuples
2019-03-18 06:14:52 -10:00
Nathan Shively-Sanders
658798032b
Fix globalThis completions (#30441)
* Fix, but with test not quite right

* Add missing completions to test

* Remove out-of-date comment
2019-03-15 19:10:39 -07:00
Sheetal Nandi
f829f958a2 Filter ts only keywords from js file completion
Fixes #29212
2019-03-14 15:52:50 -07:00
Gabriela Britto
1c8a359914
rename convert to named parameters (#30401) 2019-03-14 13:41:29 -07:00
Gabriela Britto
7824fbc395
Merge pull request #30383 from Microsoft/fixFindAllRefsOfDefaultExport
Fix find all refs of default export
2019-03-14 09:39:06 -07:00
Sheetal Nandi
8b04143675
Merge pull request #30380 from Microsoft/completionsWhileWritingSpread
Fix completions when writing spread expression
2019-03-14 09:38:50 -07:00
Sheetal Nandi
526eda8f18 Add extends of type parameter as type only location for completions
Fixes #28511
2019-03-13 15:22:33 -07:00
Gabriela Araujo Britto
66e2c54fe5 add tests for finding references of named and default exports 2019-03-13 15:11:33 -07:00
Sheetal Nandi
12d736f0a4 Fix completions when writing spread expression
Fixes #29234
2019-03-13 14:25:43 -07:00
Collins Abitekaniza
7b55d1846b Giving too many arguments should error on the first argument that exceeds arity (#27982)
* span on first arg that exceeds arity

* refactor baseline

* handle cases for spread arguments

* refactor + add coverage for tuple spread cases

* create diagnostic on NodeArray of exceeding args

* test function overloading
2019-03-12 15:57:12 -07:00
Titian Cernicova-Dragomir
88babf2a90 Merge remote-tracking branch 'remotes/origin/master' into GH-26563 2019-03-11 02:31:07 +02:00
Gabriela Britto
d2364f555f
Merge pull request #30089 from Microsoft/convert-to-named-parameters
Convert to named parameters
2019-03-06 09:33:01 -08:00
Gabriela Araujo Britto
8c4ab69d09 add test for non-transient symbol 2019-03-04 09:34:04 -08:00
Nathan Shively-Sanders
be2db9db12
Add globalThis (#29332)
* Restore original code from bind-toplevel-this

With one or two additional comments

* Working in JS, but the symbol is not right.

Still need to

1. Make it work in Typescript.
2. Add test (and make them work) for the other uses of GlobalThis:
window, globalThis, etc.

* Check in TS also; update some tests

Lots of tests still fail, but all but 1 change so far has been correct.

* Update baselines

A couple of tests still fail and need to be fixed.

* Handle type references to globalThis

The type reference must be `typeof globalThis`. Just `globalThis` will
be treated as a value reference in type position -- an error.

* Restore former behaviour of implicitThis errors

I left the noImplicitThis rule for captured use of global this in an
arrow function, even though technically it isn't `any` any more --
it's typeof globalThis.  However, you should still use some other method
to access globals inside an arrow, because captured-global-this is super
confusing there.

* Test values with type globalThis

I ran into a problem with intersecting `Window & typeof globalThis`:

1. This adds a new index signature to Window, which is probably not
desired. In fact, with noImplicitAny, it's not desired on globalThis
either I think.
2. Adding this type requires editing TSJS-lib-generator, not this repo.

So I added the test cases and will probably update them later, when
those two problems are fixed.

* Add esnext declaration for globalThis

* Switch to symbol-based approach

I decided I didn't like the import-type-based approach.

Update baselines to reflect the difference.

* Do not suggest globals for completions at toplevel

* Add tests of element and property access

* Look up globalThis using normal resolution

globalThis is no longer constructed lazily. Its synthetic Identifier
node is also now more realistic.

* Update fourslash tests

* Add missed fourslash test update

* Remove esnext.globalthis.d.ts too

* Add chained globalThis self-lookup test

* Attempt at making globalThis readonly

In progress, had to interrupt for other work.

* Add/update tests

* Addres PR comments:

1. Add parameter to tryGetThisTypeAt to exclude globalThis.
2. Use combined Module flag instead combining them in-place.
3. SymbolDisplay doesn't print 'module globalThis' for this expressions
anymore.
2019-02-27 14:14:34 -08:00
王文璐
4d7ec380a9 check completions with assignable rather than identity 2019-02-26 10:54:01 +08:00