Commit Graph

7729 Commits

Author SHA1 Message Date
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
2200c94a43 Fix unused diagnostic for rename-destructuring { a: b } (#24145) 2018-05-15 16:22:13 -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
Sheetal Nandi
77168e5d50 Merge pull request #24112 from Microsoft/packageJsonWithMainInSubDirectory
Resolve using package json's "main" field when resolving typescript extensions
2018-05-15 14:18:27 -07:00
Nathan Shively-Sanders
0ba8998c82 Fix stack overflow in merge symbol (#24134)
* JS initializers use original valueDecl, not mutated

target's valueDeclaration is set to the source's if it is not present.
This makes it incorrect to use getJSInitializerSymbol because it relies
on the symbol's valueDeclaration.

This fix just saves the original valueDeclaration before mutating and
uses that.

* Compare merged targetInitializer to target

Instead of the unmerged one

* Add test of stack overflow
2018-05-15 12:49:54 -07:00
Andy
e1f22ac568 Combine signatureHelp testing methods (#24132) 2018-05-15 12:34:53 -07:00
Wesley Wigham
5756ae1fd8 External runner fixes (#24115)
* Add missing @types/node dep to so many projects, rename parent node_modules dirs so they dont participate in tests, sort errors

* Accept new baselines

* Satisfy linter
2018-05-15 11:15:08 -07:00
Sheetal Nandi
7be85958a1 Add test for module resolution with package json containing main field referencing js file in sub directory 2018-05-14 13:06:34 -07:00
Wesley Wigham
ba4bf21ead Cache simplified indexed accesses to better handle circularly constrained indexed acceses (#24072) 2018-05-14 12:54:26 -07:00
Andy
7e3af08a09 Don't add a suggestion to convert to an es6 module if no commonjs import/export appears at top-level. (#24101) 2018-05-14 12:00:40 -07:00
Wesley Wigham
b58e4e1fa1 Reduce aggression of parenthesis removal in ts transform (#24073) 2018-05-14 11:20:04 -07:00
Nathan Shively-Sanders
dfef2fa9a2 Add another test of js special assignment merging (#24070) 2018-05-11 16:24:42 -07:00
Mohamed Hegazy
cc36cfc834 Merge pull request #24050 from Microsoft/fix-js-initializer-merging
Fix js initializer merging
2018-05-11 10:45:20 -07:00
Nathan Shively-Sanders
2792ff97dd Add fourslash test case 2018-05-11 09:51:12 -07:00
Andy
2be6aaf813 Support '/' as a trigger character in path completions (#24042) 2018-05-10 16:50:26 -07:00
Andy
6ae4d3a516 Add code fix to remove unreachable code (#24028)
* Add code fix to remove unreachable code

* Code review

* Preserve more kinds of statements
2018-05-10 16:44:48 -07:00
Andy
fd17f77cc9 Improvements to find-all-references for import types (#23998)
* Improvements to find-all-references for import types

* Add JS test
2018-05-10 15:31:06 -07:00
Andy
61a2949051 Don't count '/' in division as a completions trigger (#24038) 2018-05-10 14:59:33 -07:00
Ron Buckton
f7311ef84a Merge pull request #23956 from Kingwl/emit-var-at-top
emit temporary vars at the top of the scope
2018-05-10 12:20:13 -07:00
Andy
7271ec1240 Add 'move to new file' refactor (#23726)
* Add 'move to new file' refactor

* Code review, and support commonjs

* Compute movedSymbols completely before using, and support `export import`

* Fix assertion error: sort empty change before non-empty change

* Remove extra newline

* Add allowTextChangesInNewFiles preference

* Add the new file to 'files' in tsconfig

* Avoid parameter initializer

* Update API baselines

* Use path relative to tsconfig.json

* Code review

* Fix error where node in tsconfig file was missing a source file
2018-05-10 11:17:04 -07:00
Wesley Wigham
6149b41469 Generate names for type parameter declarations in inferred types (#23902)
* Generate names for type parameter declarations in inferred types

* Fix lint

* Merge functions, make overload private

* Handle some edge cases better (nodes in differing files than current emit)

* Account for transformed nodes
2018-05-10 11:16:27 -07:00
Mohamed Hegazy
1b796ed04d Merge pull request #23954 from Kingwl/readonly-getter-support
add support for readonly modifier
2018-05-10 11:10:03 -07:00
王文璐
ad5a4c7097 add prependRange and move more variable declaration 2018-05-10 15:54:51 +08:00
Wesley Wigham
20f9493f04 Allow all private declarations to be emitted in declaration output (#23351)
* Mostly functional WIP

* Fix accessors, symbol stringification

* Accept/update changed baselines

* Move type definition so file build order doesnt matter

* Accept post-merge test update

* Rename function, add doc
2018-05-09 19:53:44 -07:00
Andy
da413d6fef Remove unnecessary filtering of tsx completions (#24004) 2018-05-09 15:18:45 -07:00
Mohamed Hegazy
6f9dc2f976 Merge pull request #23923 from Zzzen/master
Document highlights on async/await keywords should highlight other oc…
2018-05-09 09:51:04 -07:00
Nathan Shively-Sanders
e27fb0651b Fix crash in recursive declared type resolution (#23950)
When one type has a type parameter with a default
2018-05-09 09:25:00 -07:00
Zen
91a15dc609 improve performance 2018-05-09 22:42:44 +08:00
王文璐
8414a962ba update all reference in constructor 2018-05-09 18:41:46 +08:00
Andy
01ae7f1798 Rename test (#23978) 2018-05-08 15:07:55 -07:00
Andy
5725428f2d fixUnusedIdentifier: Handle destructure with all bindings unused (#23805)
* fixUnusedIdentifier: Handle destructure with all bindings unused

* Add parameters test

* Add test for 'for' loop
2018-05-08 13:33:55 -07:00
Anders Hejlsberg
40e0ab72d2 Merge pull request #23966 from Microsoft/fixIndexedAccessAnyConstraint
Fix indexed access with 'any' constraint
2018-05-08 12:21:00 -07:00
Andy
ccfd3bf603 Handle BindingElement in fixUnusedIdentifier (#23819)
* Handle BindingElement in fixUnusedIdentifier

* Add array destructure tests
2018-05-08 11:23:01 -07:00
Anders Hejlsberg
238177657f Add regression test 2018-05-08 09:42:21 -07:00
王文璐
88bf9277ff add support for readonly modifier 2018-05-08 12:26:34 +08:00
Andy
123ae530a7 convertToEs6Module: Replace 'module.exports =' with 'export default' without replacing nodes (#23948) 2018-05-07 15:45:43 -07:00
Andy
a50001c9da Treat 'import("")' as a module reference (#23949) 2018-05-07 15:42:36 -07:00
Sheetal Nandi
8fc4242097 Merge pull request #23915 from Microsoft/jsonCompletions
Suggest json files in completion when resolveJsonModule is set and module resolution is node
2018-05-07 12:53:09 -07:00
Andy
004a558125 Avoid unnecessary newline when inserting node at start of class (#23935) 2018-05-07 12:40:33 -07:00
Andy
2604bb4dd3 Add 'string' ScriptElementKind (#23821) 2018-05-07 12:39:00 -07:00
Mohamed Hegazy
e39e6fc780 Merge pull request #23894 from Microsoft/importOutlining
Add outlining spans for Import declarations
2018-05-07 12:08:11 -07:00
Andy
a05feed839 generateGetAccessorAndSetAccessor: Preserve a parameter property declaration (#23318) 2018-05-07 11:33:00 -07:00
Andy
d6701d3987 Replace verify.rangesReferenceEachOther with verify.singleReferenceGroup (#23933) 2018-05-07 11:06:21 -07:00
Andy
7fa5f70b9a Remove verify.referencesAre, verify.referencesOf, verify.rangesReferenceEachOther (#23900) 2018-05-07 10:08:38 -07:00
Zzzen
34323b69fb Document highlights on async/await keywords should highlight other occurrences in the same body fix #22944 2018-05-06 12:27:10 +08:00
Mohamed Hegazy
64d6b24c87 Code review comments 2018-05-05 13:22:48 -07:00
Mohamed Hegazy
12ed49bada Revert adding named import binding list outlining spans 2018-05-05 12:04:12 -07:00
Sheetal Nandi
e8cd6b1111 Suggest json files in completion when resolveJsonModule is set and module resolution is node
Fixes #23899
2018-05-04 17:10:48 -07:00
Andy
cecad27662 findAllReferences: Treat a nested property in a jsdoc type literal as a definition (#23901)
* findAllReferences: Treat a nested property in a jsdoc type literal as a definition

* Fix lint
2018-05-04 16:58:07 -07:00