Commit Graph

2802 Commits

Author SHA1 Message Date
Andy
16af96b006 moveToNewFile: Format the new file (#24379) 2018-05-24 11:08:32 -07:00
Andy
bc570cd85f moveToNewFile: Respect UserPreferences#quote (#24365) 2018-05-24 09:36:37 -07:00
Mohamed Hegazy
dd6dc5e27a Merge pull request #24328 from Microsoft/getEditsForFileRename_oldFileStillPresent
getEditsForFileRename: Handle old file still being present
2018-05-23 16:16:00 -07:00
Wenlu Wang
4606709672 add code fix convert to mapped object type (#24286)
* add code fix convert to mapped object type

* add support for type literal and improve test

* fix typo

* add support for heritageClauses

* only determine declaration is not class
2018-05-23 14:09:49 -07:00
Andy
fb4caadaec Support signature help for partially-filled-in type arguments f< (#24138)
* Support signature help for partially-filled-in type arguments `f<`

* Use `isPossiblyTypeArgumentPosition` and support new expressions
2018-05-23 08:28:09 -07:00
Sheetal Nandi
16d7f4c103 Merge pull request #24348 from Microsoft/findRefInJson
Fix getter of local symbol for export= when it is json module
2018-05-22 20:15:59 -07:00
Sheetal Nandi
a0d4e4f059 Fix getter of local symbol for export= when it is json module
Fixes #24341
2018-05-22 17:10:56 -07:00
Andy
aed0eb6693 Improve verify.codeFixAvailable (#24325)
* Improve verify.codeFixAvailable

* Revert change to `verify.not.codeFixAvailable()`, and use `assertObjectsEqual` for better errors
2018-05-22 16:04:39 -07:00
Andy
ba63f49513 moveToNewFile: Don't provide refactor if selection is just imports (#24336) 2018-05-22 15:21:04 -07:00
Andy
5622bc2dd6 moveToNewFile: Support selecting the name of a declaration (#24331) 2018-05-22 14:00:29 -07:00
Andy
9cda2bdba0 Support recommended completion for union (#24326)
* Support recommended completion for union

* Fix for empty enum, which is not a union
2018-05-22 13:38:28 -07:00
Andy
694a985b49 For completions, treat a '// @ts-check' file like a TypeScript one (#24321) 2018-05-22 13:06:59 -07:00
Armando Aguirre
b5d882ebd6 Merge pull request #24262 from armanio123/FixObjectLiteralExpression
Fix issue with formatting object literal csharp style
2018-05-22 12:39:14 -07:00
Andy Hanson
46eaf62abb getEditsForFileRename: Handle old file still being present 2018-05-22 12:20:34 -07:00
Mohamed Hegazy
9d57903630 Merge pull request #24312 from Kingwl/multiline-type-literal-formatter
fix wrong formatting with multiline type literals with IntersectionTy…
2018-05-22 10:06:24 -07:00
Andy
982c8d0af9 Add suggestion diagnostics for unused label and unreachable code (#24261)
* Add suggestion diagnostics for unused label and unreachable code

* Always error on unused left hand side of comma
2018-05-22 07:56:29 -07:00
王文璐
4b47c0cb82 fix wrong formatting with multiline type literals with IntersectionType and UnionType 2018-05-22 14:01:04 +08:00
Armando Aguirre
0b18bdf590 Added tests 2018-05-21 18:22:13 -07:00
Andy
802dc2bb9b fixUnusedIdentifier: If every VariableDeclaration is unused, remove the VariableStatement (#24231) 2018-05-21 15:54:33 -07:00
Andy
440291e316 Fix bug: Get merged module symbol in forEachExternalModule (#24295) 2018-05-21 10:48:50 -07:00
Andy
c09cc70ebe Fix bug: VariableDeclaration initializer may be undefined (#24256) 2018-05-21 07:58:33 -07:00
Daniel Rosenwasser
3563a0576d Use single quotes around 'typeof' in message. 2018-05-18 23:44:38 -07:00
Andy
3eb66da155 Add code fix to remove unused label (#24037)
* Add code fix to remove unused label

* Test with trivia and fix indentation with dedented label
2018-05-18 15:25:24 -07:00
Sheetal Nandi
3bb9ccfa8e Merge pull request #24234 from Microsoft/unusedIdentifierCorrectFile
Unused variable error reporting needs to handle nodes that could not belong to current source file
2018-05-18 13:25:19 -07:00
Mohamed Hegazy
8c2ed976a5 Merge pull request #24187 from Kingwl/disallow-in-function-like-initializer
disallow acesssor generate in function like initializer
2018-05-17 19:41:01 -07:00
王文璐
45c06cfd11 only allow refactor if selected span overlaps name declaration 2018-05-18 10:07:45 +08:00
Sheetal Nandi
52e8c2d663 Unused variable error reporting needs to handle nodes that could not belong to current source file
Eg. when resolving module, the another file gets checked and its locals are added to potentiallyUnused list
Fixes #24215
2018-05-17 16:27:08 -07:00
Wesley Wigham
d82d35c7f5 Set startPos at EOF in jsdoc token scanner so node end positions for nodes terminated at EoF are right (#24184)
* Set startPos at EOF in jsdoc token scanner to node end positions for nodes terminated at EoF are right

* More complete nonwhitespace token check, fix syntactica jsdoc classifier

* Use loop and no nested lookahead

* Do thigns unrelated to the bug in the test

* Fix typo move return

* Patch up typedef end pos

* Fix indentation, make end pos target more obvious
2018-05-17 15:16:18 -07:00
Andy
d579793d0a moveToNewFile: Fix bug for missing importClause (#24224) 2018-05-17 14:32:12 -07:00
Andy
75ab60f199 Improve ChangeTracker#deleteNodeInList (#24221) 2018-05-17 14:31:58 -07:00
Andy
08c364d258 fixUnusedIdentifier: Don't delete node whose ancestor was already deleted (#24207) 2018-05-17 14:08:58 -07:00
Andy
09b9ec43e3 moveToNewFile: Fix bug for VariableDeclaration missing initializer (#24214) 2018-05-17 12:38:20 -07:00
Andy
176e35b9c3 moveToNewFile: Don't move imports (#24177) 2018-05-17 09:54:47 -07:00
Nathan Shively-Sanders
aa7e2b0f07 Add callback tag, with type parameters (#23947)
* Add initial tests

* Add types

* Half of parsing (builds but does not pass tests)

* Parsing done; types are uglier; doesn't crash but doesn't pass

* Bind callback tag

Builds but tests still don't pass

* Only bind param tags inside callback tags

* Fix binding switch to only handle param tags once

* Checking is 1/3 done or so.

Now I'm going to go rename some members to be more uniform. I hate
unnnecessary conditionals.

* Rename typeExpression to type (for some jsdoc)

(maybe I'll rename more later)

* Rename the rest of typeExpressions

Turns out there is a constraint in services such that they all need to
be named the same.

* Few more checker changes

* Revert "Rename the rest of typeExpressions"

This reverts commit f41a96b24d.

* Revert "Rename typeExpression to type (for some jsdoc)"

This reverts commit 7d2233a00e.

* Finish undoing typeExpression rename

* Rename and improve getTypeParametersForAliasSymbol

Plus some other small fixes

* Core checking works, but is flabbergastingly messy

I'm serious.

* Callback return types work now

* Fix crash in services

* Make github diff smaller

* Try to make github diff even smaller

* Fix rename for callback tag

* Fix nav bar for callback tag

Also clean up some now-redundant code there to find the name of typedefs.

* Handle ooorder callback tags

Also get rid of redundant typedef name code *in the binder*. It's
everywhere!

* Add ooorder callback tag test

* Parse comments for typedef/callback+display param comments

* Always export callbacks

This requires almost no new code since it is basically the same as
typedefs

* Update baselines

* Fix support for nested namespaced callbacks

And add test

* Callbacks support type parameters

1. Haven't run it with all tests
2. Haven't tested typedef tags yet
3. Still allows shared symbols when on function or class declarations.

* Template tags are now bound correctly

* Test oorder template tags

It works.

* Parser cleanup

* Cleanup types and utilities

As much as possible, and not as much as I would like.

* Handle callback more often in services

* Cleanup of binder and checker

* More checker cleanup

* Remove TODOs and one more cleanup

* Support parameter-less callback tags

* Remove extra bind call on template type parameters

* Bind template tag containers

Doesn't quite work with typedefs, but that's because it's now stricter,
without the typedef fixes. I'm going to merge with jsdoc/callback and
see how it goes.

* Fix fourslash failures

* Stop pre-binding js type aliases

Next up, stop pre-binding js type parameters

* Further cleanup of delayed js type alias binding

* Stop prebinding template tags too

This gets rid of prebinding entirely

* Remove TODO

* Fix lint

* Finish merge with use-jsdoc-aliases

* Update callback tag baselines

* Rename getTypeParametersForAliasSymbol

The real fix is *probably* to rename Type.aliasTypeArguments to
aliasTypeParameters, but I want to make sure and then put it in a
separate PR.
2018-05-17 09:28:11 -07:00
王文璐
5d233054c3 add quick fix for import type missing typeof 2018-05-17 16:35:20 +08:00
王文璐
755b443b6d disallow acesssor generate in function like initializer 2018-05-17 10:18:20 +08:00
Mohamed Hegazy
21acf4f783 Merge pull request #24136 from Microsoft/inferFromUsageFixes
Remove assert in `symbolToParameterDeclaration`
2018-05-16 14:15:37 -07:00
Wesley Wigham
d70da6478a Use newer signature help check (#24179) 2018-05-16 13:53:40 -07:00
Wesley Wigham
e01c7d23e1 Correctly show instantiated signatures for JSX element signature help and quick info (#23492)
* Correctly show instantiated signatures for JSX element signature help

* Also bundle fix for quickinfo

* Use more complete cache to avoid duplicate errors
2018-05-16 13:09:54 -07:00
Wesley Wigham
5bf6e30f8e Use jsdoc aliases if visible when printing types (#24153)
* Use jsdoc aliases if visible when printing types

* Modify implementation a bit, add test that aughta change in the new future

* Accept baselines- hold off on typedef template lookup change
2018-05-16 12:58:36 -07:00
Andy
424dba1d69 codeFixInferFromUsage: Avoid duplicate fix for variable declaration (#24169)
* codeFixInferFromUsage: Avoid duplicate fix for variable declaration

* Include VariableDeclaration initializer as a candidate type
2018-05-16 12:28:27 -07:00
Mohamed Hegazy
13ac88647f Merge pull request #24162 from Kingwl/fix-generate-accessor-starting-underscore
fix generate accessor if starting with underscore
2018-05-16 12:06:15 -07:00
王文璐
b7f725d1b8 fix generate accessor if starting with underscore 2018-05-16 15:34:11 +08:00
王文璐
0fde07f1c5 fix trailing comma in accessor generator 2018-05-16 14:47:44 +08:00
Mohamed Hegazy
6f4ed3afa6 Handel synthetic rest parameter declarations 2018-05-15 22:08:01 -07:00
Andy
b4ca23d8f9 Fix bug: Converting 'module.exports = {...}' to ES6 doesn't introduce a default export (#24141) 2018-05-15 16:22:58 -07:00
Andy
d4a3c9c61a Fix placement of indent for @ts-ignore comment (#24143) 2018-05-15 16:21:15 -07:00
Nathan Shively-Sanders
339a56fbf0 Avoid duplicates when finding jsdoc (#24086)
* Avoid duplicates when finding jsdoc

1. Add a cheap assert for detecting duplicates. getJSDocTags must find
either [1] 0 or 1 comments or [2] the first two comments must not be
identical. This does not always find duplicates for nodes with 3 or more
comments, but these nodes are exceptionally rare.

This assert fired for over 20 of the around 250 tests we have that
retrieve JSDoc at all. So I fixed the asserts in [2] and [3].

2. There were overlapping cases from calls to getSourceOfAssignment and
getSpecialPropertyAssignment. getSpecialPropertyAssignment is too
restrictive, but was in the correct location (parent vs parent.parent),
so I removed the getSourceOfAssignment call and replaced the
getSpecialPropertyAssignment calls with a less restrictive check.

3. When a node's parent is a PropertyDeclaration,
getJSDocCOmmentsAndTags would check the parent for jsdoc. But when the
*node* is a PropertyDeclaration, getJSDocCommentsAndTags would use the
jsdoc from the initializer. This second case is useful to make sure that
property declarations get all their jsdoc, but results in duplicates for
their initializers. I couldn't think of a better fix than tracking the
previous node in the recursive lookup of getJSDocCommentsAndTags, which
is a little clunky.

* Fix lint; remove new context parameter

* Update importJsNodeModule3 with fix
2018-05-15 15:12:29 -07:00
Andy
e1f22ac568 Combine signatureHelp testing methods (#24132) 2018-05-15 12:34:53 -07:00
Mohamed Hegazy
0bda862cca Remove assert 2018-05-14 22:49:50 -07:00