3061 Commits

Author SHA1 Message Date
Wesley Wigham
69b1cb5bac
Add new special assignment kinds for recognizing Object.defineProperty calls (#27208)
* Add new special assignment kinds for recognizing Object.defineProperty calls

* Add support for prototype assignments, fix nits

* Fix code review comments

* Add test documenting behavior in a few more odd scenarios
2018-10-19 14:31:55 -07:00
Andy
a3c22683ab
findAllRefs: Fix bug when symbol.declarations is undefined (#27977) 2018-10-18 14:27:21 -07:00
Wesley Wigham
7b5ef64e76
Unify JSX And Normal Call Checking Codepaths (#27627)
* Unify JSX Call Checking Codepaths

* Add tests for fixed issues

* Fix lint, move all error checking into the only-run-once resolveSignature call

* Remove unused (unreachable?) code path

* Consolidate a little more duplicated logic into signature checking

* Fix #19775 a bit more

* Cosmetic changes from CR
2018-10-16 20:16:00 -04:00
Sheetal Nandi
cb954cbb0a
Merge pull request #27871 from Microsoft/formatting
Handle when advancing past , of call expression moves past endPos of formatting
2018-10-15 21:10:09 -07:00
Sheetal Nandi
3aa33aa4ed Simplify the test 2018-10-15 15:55:45 -07:00
Nathan Shively-Sanders
c184184713
Add getEffectiveConstructSignatures (#27561)
* Add helpers that understand constructor functions

* getEffectiveConstructSignatures gets construct signatures from type, and
  call signatures from constructor functions if there are no construct
  signatures.
* getEffectiveConstructSignatureReturnType gets the "JS Class type" for
  constructor functions, and the return type of signatures for all other
  declarations.

This is a first step toward making constructor functions have construct
signatures instead of call signatures, which will also contribute to
fixing instantiation of generic constructor functions, which is basically
broken right now.

Note that the baselines *improve* but, because of the previously
mentioned generic problem, are still not correct. Construct signatures
for constructor functions and generic constructor functions turns out to
be an intertwined problem.

* Correct correct originalBaseType

And, for now, return anyType for generic constructor functions used as
base types. Don't give an incorrect error based on the function's return
type, which is usually void.

* Add error examples to tests

* Add construct signatures instead of getEffective* functions

* Fix typo in baseline

* Remove pesky newline

I thought I got rid of it!

* Test of constructor tag on object literal method

It doesn't work, and shouldn't in the future, because it's a runtime
error.
2018-10-15 12:47:57 -07:00
Sheetal Nandi
e3bfec5217 Handle when advancing past , of call expression moves past endPos of formatting
Fixes #26513
2018-10-12 16:06:24 -07:00
Andy
54a5be1860
At '.' in object literal, don't close the object (#27850)
* At '.' in object literal, don't close the object

* Include diagnostics test
2018-10-12 08:49:04 -07:00
Nathan Shively-Sanders
ec0e8cbe2b
noImplicitAny as suggestion (#27693)
* noImplicitAny as suggestion

Note that not all noImplicitAny errors turn into suggestions. In
particular,

1. reportErrorsFromWidening does not, because it doesn't log an error
that infer-from-usage fixes, and fixing it would require
otherwise-unnecessary code.
2. auto types do not have implicit any suggestions, because that would
require running control flow in noImplicitAny mode.

* Rename reportImplicitAny+forbid it for non-checkJS

In JS, you only get implicit any errors/suggestions with checkJS or
ts-check turned on.

* Update baselines

* Use isCheckJsEnabledForFile

* Remove noImplicitAny parameter since it's in scope already
2018-10-11 16:15:38 -07:00
Andy
dd764b318f
importFixes: Skip alias when testing isTypeOnlySymbol (#27674) 2018-10-10 13:45:52 -07:00
Nathan Shively-Sanders
53906f222f
containsTopLevelCommonjs:handle uninitialised vars (#27642)
Previously it assumed that all variable declarations had an initialiser,
which is not correct.
2018-10-09 13:17:54 -07:00
Nathan Shively-Sanders
88d3c6fd5f
inferFromUsage codefix now emits JSDoc in JS files (#27610)
* Now adding @type to variable declarations, at least

Probably everything else, but not as well.

* Improve @param output and add test

It's still bad, but at least it's not wrong.

* Add some js/inferFromUsage tests and fixes

Also, remove redundant is(Set|Get)Accessor functions.

* Fix @typedef refactor

* Emit JSDoc optional parameters

By surrounding the parameter name with brackets. It is super, super ugly
right now.

* Get rest of existing tests working

* Correct location of comments

* Handle @param blocks

1. Format multiple params nicely in a single-multiline block.
2. Generate only params that haven't already been documented. Existing
documentation is not touched.

* Re-add isGet/SetAccessor -- it is part of the API

* Move isSet/GetAccessor back to the original location

* Oh no I missed a newline and a space

* Switch to an object type

* A lot of cleanup

More to come, though. annotate is only called in
annotateVariableDeclaration where we don't know whether we're in JS or
not.

* Move and delegate to annotateJSDocParameters

* Address PR comments

* Lint: newline problems!!!!

* Switch another call to getNonformattedText

* Update baseline missed after merge
2018-10-09 10:38:46 -07:00
Nathan Shively-Sanders
ca94d8efd9
Infer from usage better import types (#27626)
* Use host to improve SymbolTracker implementation

* inferFromUsage: Provide a better moduleResolverHost

This produces better paths on import types.
2018-10-09 07:12:09 -07:00
Andy
f6ca10565d
Fix bug: Ensure JSDoc type range is valid (#27343) 2018-10-08 17:09:48 -07:00
Daniel Rosenwasser
8474949336
Merge pull request #27203 from sbaidon/signatureHelpInAdjacentBlockBody
Fix signature help not showing in block body bug
2018-10-07 23:07:59 -07:00
Andy
0a97663843
Add 'prefixText' and 'suffixText' when renaming shorthand properties (#27356)
* Add 'prefixText' and 'suffixText' when renaming shorthand properties

* Make prefixText and suffixText missing instead of undefined

* Fix test
2018-09-26 16:58:01 -07:00
Andy
4855920314
navigationBar/Tree: Better description for anonymous function (#27063) 2018-09-26 11:22:44 -07:00
Andy
b3dd471584
Support completions after 'async' in object literal (#27250) 2018-09-26 11:22:27 -07:00
Andy
d4d947e488
Fix bug: Allow completions after '@' with no contextToken (#27325) 2018-09-26 11:22:08 -07:00
Ron Buckton
b8cf9d4f94 Fixes the completionForStringLiteralNonrelativeImport13 test 2018-09-24 16:17:40 -07:00
Sergio Baidon
bb58558e64 Fix signature help not showing in block body bug 2018-09-18 17:30:07 -05:00
Andy
c57ff087d6
Add codefix to generate types for untyped module (#26588) 2018-09-18 11:47:29 -07:00
Andy
cfd0a62357
When renaming module, ensure rename span is just the last component of the path (#27151) 2018-09-17 15:26:41 -07:00
Andy
e710645bf9
Never escape string literals from textChanges (#26971)
* Never escape string literals from textChanges

* Use `boolean | undefined`
2018-09-17 11:06:39 -07:00
Andy
95c1570c4b
Fix bug: VariableDeclaration may have SemanticMeaning.All if an @enum in JS (#27085) 2018-09-14 09:20:54 -07:00
Andy
009dc0f1b9
For completion in string literal union, don't include strings already in the union (#26755) 2018-09-14 09:20:11 -07:00
Andy
ee7d0e21da
getEditsForFileRename: Don't resolve to a.js when a.ts is moved (#27081) 2018-09-13 15:49:42 -07:00
Andy
cc7bfc0349
Support testing jsdoc tags of completions (#26962) 2018-09-13 08:47:50 -07:00
Andy
2b888c30f9
Consistently pass indent to 'parseTagComments' (#27055)
* Consistently pass indent to 'parseTagComments'

* Update baselines
2018-09-12 17:44:06 -07:00
Ryan Cavanaugh
5a26747428
Merge pull request #27004 from RyanCavanaugh/noJsNewModuleCompletions
Don't offer module completions in non-module JS files
2018-09-12 08:32:14 -07:00
Andy
24a5bdd1b1
Add 'fileToRename' property to RenameInfo (#24702)
* Add 'fileToRename' property to RenameInfo

* Update tests

* Support directory rename
2018-09-10 11:25:03 -07:00
Ryan Cavanaugh
95ba73e16b Don't offer module completions in non-module JS files 2018-09-10 11:24:51 -07:00
Ron Buckton
af8e44ac85
Merge pull request #26568 from Microsoft/typesVersions
Adds support for "typesVersions" redirects
2018-09-07 15:40:50 -07:00
Ron Buckton
a255d9a163 Merge branch 'master' into typesVersions 2018-09-07 13:52:12 -07:00
Andy
cbde861af6
Improve use of SemanticMeaning in symbol display (#26953) 2018-09-07 12:23:23 -07:00
Andy
b1430e5e2c
Avoid adding duplicate completion from contextual keyword (#26947) 2018-09-07 12:18:03 -07:00
Andy
d31973b905
findAllReferences: Consistently use 'this' parameter as definition site (#26950) 2018-09-06 17:06:50 -07:00
Andy
c401d63c5f
findAllReferences: Fix declarationIsWriteAccess for PropertyAssignment in destructuring (#26949) 2018-09-06 15:24:07 -07:00
Andy
a0ebbfb8f0
Fix JSX completions after boolean property (#26943) 2018-09-06 14:15:12 -07:00
Andy
8c22770ea8
Improve 'isWriteAccess' for findAllReferences (#26889) 2018-09-06 10:44:32 -07:00
Ryan Cavanaugh
4975dc85b1
Merge pull request #25822 from Kingwl/rechabilityImprove
improve enum rechability check
2018-09-05 11:46:07 -07:00
Andy
1eb3082387
Support completions inside JSDoc before EndOfFileToken (#25568) 2018-09-05 11:34:27 -07:00
Andy
06774962ed
Properly handle JS enum symbols (#26893) 2018-09-05 11:19:32 -07:00
Nathan Shively-Sanders
ff05082e45
Bind non-expando property assignments at top-level (#26908)
* Bind non-expando property assignments at toplevel

Previously, only property assignments with expando initialisers were
bound in top-level statements. Now, all property assignments are bound.

This requires a matching change in the checker to make sure that these
assignments remain context sensitive if their valueDeclaration is a
'real' declaration (ie a non assignment-declaration).

* Add baselines for new test
2018-09-05 10:53:43 -07:00
Tim Schaub
262ea5b06e Skip asterisks after newline when parsing JSDoc types (#26528)
* Skip asterisks after newline when parsing JSDoc types

* Single boolean expression

* Test for parsing and printing multiline function signatures with *
2018-09-04 15:41:08 -07:00
Nathan Shively-Sanders
540e8b9eb0
Collect jsdoc tags for type parameters (#26824)
Before the template tag, there was no reason to do this, but now you can
add JSDoc for type parameters in Typescript.
2018-09-04 09:29:19 -07:00
Sheetal Nandi
bf6d265b97 Add test for signaure help with recursive type
Test for #26155
2018-08-30 10:12:04 -07:00
Andy
cea49dfb0d
Completion for tuple index doesn't need to include quotes (#26750) 2018-08-29 16:38:42 -07:00
Andy
f78dc2ad11
importFixes: Only provide a fix using the best module specifier for a given module (#26738) 2018-08-29 16:18:56 -07:00
Andy
7b4f864b49
moduleSpecifiers: Simpler criteria for preferring relative path vs baseUrl (#25803)
* moduleSpecifiers: Simpler criteria for preferring relative path vs baseUrl

* Don't unconditonally use a path mapping
2018-08-29 15:06:26 -07:00