Commit Graph

2998 Commits

Author SHA1 Message Date
Andy
0a59da1a2c In pickLongestCandidateSignature, instantiate using inferred type arguments (#26646) 2018-08-27 10:30:25 -07:00
Andy
e411381266 Fix bug: Don't let empty signature documentation override other documentation (#26638) 2018-08-27 09:38:52 -07:00
Wenlu Wang
8ba501926a try get add missing member return type from context (#26250)
* try get add missing member return type from context

* support contextual type
2018-08-23 21:31:53 -07:00
Andy
f3ceebe552 Fix duplicate completions bugs (#26648)
* Fix duplicate completions bugs

* Remove old TODO
2018-08-23 18:22:07 -07:00
Nathan Shively-Sanders
6ea2278c7a Get symbol at location for class expressions/keywords (#26636)
* getSymbolAtLocation understands class expressions

Previously it did not.

* Update baselines
2018-08-23 11:27:03 -07:00
Andy
194ffb3449 fourslash: Allow to verify textChanges without changing file content (#26607) 2018-08-22 15:20:33 -07:00
Ryan Cavanaugh
7a658256a2 Merge pull request #26431 from mattmccutchen/issue-26430
Mapped types like Pick<T, K> should adopt property documentation from T.
2018-08-16 13:35:55 -07:00
Nathan Shively-Sanders
cc67ce1141 Property assignments in Typescript (#26368)
* Allow special property assignments in TS

But only for functions and constant variable declarations initialised with
functions.

This specifically excludes class declarations and class expressions,
which differs from Javascript. That's because Typescript supports
`static` properties, which are equivalent to property assignments to a
class.

* Improve contextual typing predicate

Don't think it's right yet, but probably closer?

* More fixes.

The code is still fantastically ugly, but everything works the way it
should.

Also update baselines, even where it is ill-advised.

* Cleanup

* Remove extra whitespace

* Some kind of fix to isAnyDeclarationName

It's not done yet.

Specifically, in TS:
Special property assignments are supposed to be declaration sites (but not all
top-level assignments), and I think I
got them to be. (But not sure).

In JS:
Special property assignments are supposed to be declaration sites (but not all
top-level assignments), and I'm pretty sure ALL top-level assignments
have been declaration sites for some time. This is incorrect, and
probably means the predicate needs to be the same for both dialects.

* Add fourslash and improve isAnyDeclarationName

Now JS behaves the same as TS.

* Cleanup from PR comments
2018-08-15 15:25:25 -07:00
Matt McCutchen
d7b802577c Mapped types like Pick<T, K> should adopt property documentation from T.
Fixes #26430.
2018-08-13 19:56:20 -04:00
Sheetal Nandi
2b83b67aa3 Merge pull request #26140 from Kingwl/completionUnionType
improve completions for union type in type arguments
2018-08-13 10:36:19 -07:00
Andy
4bb740218d getDefaultExportInfo: Use getImmediateAliasedSymbol instead of getAliasedSymbol (#26364) 2018-08-10 14:35:18 -07:00
Andy
a73161e9d5 Don't store @template constraint in a TypeParameterDeclaration node (#26283)
* Don't store @template constraint in a TypeParameterDeclaration node

* Code review

* Update API
2018-08-09 17:39:15 -07:00
Andy
5efd1cb4a7 fixAddMissingMember: Support interface and don't crash on type parameter (#25995)
* fixAddMissingMember: Support interface and don't crash on type parameter

* Remove InfoBase
2018-08-09 17:32:28 -07:00
Anders Hejlsberg
20ebe1eb2b Merge pull request #26244 from Microsoft/fixThisAndContextualTypes
Revise logic that computes the contextual type for a parameter
2018-08-09 06:07:11 -07:00
王文璐
23601a10b8 improve completions for union type in type arguments 2018-08-09 17:26:34 +08:00
Andy
1a05f13aef moveToNewFile: Don't remove empty named imports (#26265) 2018-08-07 12:54:46 -07:00
Andy
794f3a5e76 goToTypeDefinition: Go to function return type (#25952)
* goToTypeDefinition: Go to function return type

* Add more tests

* If a function returns 'void' or some other type with no definition, just return the function definition.
2018-08-07 12:54:19 -07:00
Andy
937afab4b0 Support signature help for contextual parameter type (#26022) 2018-08-06 16:46:30 -07:00
Anders Hejlsberg
9d71023b5c Add fourslash tests 2018-08-06 16:33:21 -07:00
Andy
d0ed21cad1 completions: 'true' and 'false' are type keywords (#26237) 2018-08-06 12:42:56 -07:00
Alexander T
37b9a6bca4 25840 - Add a more meaningful error message to the case when calling a public static method on an instance (#25922)
* add a more meaningful error message to the case when calling a public static method on an instance

* Fix tests
2018-08-06 10:24:48 -07:00
Wesley Wigham
fefc47fae3 Flag JS Literals and ignore assignments/accesses to invalid props, instead of adding an index (#25996)
* Remove index signatures from js literals, use an object flag to indicate errors should be ignored instead

* Add focused test on the keyof problem

* Fix fourslash test

* Reenable errors with noImplicitAny flag

* Also disable excess property checks outside of noImplicitAny mode for js literals

* Edit and move comments
2018-08-02 13:40:44 -07:00
Andy
9c9f3e3cf9 importFixes: When one file redirects to another, consider both for global import specifiers (#25834)
* importFixes: When one file redirects to another, consider both for global import specifiers

* Add test for #26044

* Avoid a symlinked package globally importing itself (fixes another case of #26044)

* Compare to node_modules with getCanonicalFileName
2018-07-31 17:28:56 -07:00
Andy
f326b4b7cb Make import fix for default import mention that it's a default import (#26105) 2018-07-31 17:28:35 -07:00
Andy
1599ee2805 Always return a defined result from getTypeFromTypeNode (#26108) 2018-07-31 17:28:15 -07:00
Andy
0d1a49c865 Ignore trailing comma when resolving signature for quick info (#25841)
* Ignore trailing comma when resolving signature for quick info

* Add test for signature help
2018-07-31 11:39:39 -07:00
Tim Schaub
960800d1fe Remove trailing whitespace from JSDoc comments 2018-07-28 10:36:10 -06:00
Andy
5e1872f0c0 getDocCommentTemplateAtPosition: Return result if in empty comment (#26026) 2018-07-27 17:34:16 -07:00
Andy
d40d54984e Support deleting all unused type parameters in a list, and deleting @template tag (#25748)
* Support deleting all unused type parameters in a list, and deleting @template tag

* Support type parameter in 'infer'
2018-07-27 11:55:31 -07:00
Andy
3bfe91cdd8 navigationBar: Fix bug for shorthand ambient module (#25992) 2018-07-26 17:27:12 -07:00
Andy
af3f737451 Fix bug for isValidTrigger when contextToken is undefined (#25993) 2018-07-26 17:26:58 -07:00
Andy
0e5af11625 Fix bugs for go-to-definition on mapped type method (#25991) 2018-07-26 17:26:41 -07:00
Andy
0227997fa5 Use import().T for import completions/fixes of pure types in JS files (#25852)
* Use `import().T` for import completions/fixes of pure types in JS files

* Don't call tryUseExistingNamespaceImport if position undefined
2018-07-26 16:16:57 -07:00
Mohamed Hegazy
3057be3a0b Merge pull request #25966 from ajafff/shorthandPropertyAssignment-initializer-symbol
correctly resolve Symbol of destructuring shorthand intializer
2018-07-26 09:32:39 -07:00
Klaus Meinhardt
d282c75e73 add quickinfo test 2018-07-26 18:09:51 +02:00
Andy
5e94cf626b Expand span of @typedef with properties to include the @typedef tag (#25950) 2018-07-26 08:56:24 -07:00
Andy
bd600cfd50 Fix duplicate "this" completion (#25900) 2018-07-25 12:29:28 -07:00
Andy
d60f4988a6 In getPropertySymbolsFromContextualType, use union discriminant to filter types (#25914) 2018-07-25 11:53:20 -07:00
Nathan Shively-Sanders
9658b476c2 Fix inferFromUsage on index signatures (#25934)
* Fix inferFromUsage on index signatures

1. Check the argumentExpression to determine the index signature type.
Previously, the code mistakenly checked the type of the element access
itself, which never returned a good type.
2. If inference for the index signature type fails, substitute anyType.
Previously, the code would create a bad index signature with an
undefined type.
3. Add tests. Previously, there were no tests.

* Fixing (1) means that number index signatures are now created.
Previously, only string index signatures would be created.
* Fixing (2) means that index signatures will be inferred from single
usage like `return a[0]`. Previously, the refactoring would fail,
perhaps because of a check when stringifying the index signature (I
haven't tracked down why.)

* Update fourslash test with improved inference
2018-07-25 10:51:11 -07:00
Andy
e4d4b0ae4b Handle PropertyAssignment in getCommentOwnerInfo (#25911) 2018-07-24 17:43:46 -07:00
Wesley Wigham
23eb591e01 Lookup files by resolved Path and not by fileName in sourcemapDecoder when querying program (#25908)
* Check if the file returned by the program actually refers to the same file as we intend

* Simplify
2018-07-24 15:44:22 -07:00
Wesley Wigham
797d8bd07b Call toPath on sourceRoot to ensure it is always absolute (#25838)
* Call toPath on sourceRoot to ensure it is always absolute

* Leave canonicalization to avoid a Path/string union
2018-07-24 14:14:41 -07:00
Wesley Wigham
59854bbd55 Inspect all possible module paths when looking for the best one to create a specifier with (#25850)
* Inspect all possible specifier paths when looking for the best one

* Add missing secondary option from test
2018-07-24 13:56:21 -07:00
Andy
30c41492d9 moduleSpecifiers: Allow "*" as a path mapping (#25881) 2018-07-23 17:11:30 -07:00
Andy
3d672d9550 Ensure fixSpelling and importFixes still trigger on "Did you mean the instance/static member ..." (#25847) 2018-07-20 16:51:35 -07:00
Andy
e103692f32 Don't report quickInfo inside a comment in a PropertyAccessExpression (#25813) 2018-07-20 11:49:21 -07:00
Andy
bcd565287c Remove bad import completions tests (#25816) 2018-07-20 11:11:03 -07:00
Wenlu Wang
fedcd3a1b4 improve completions keyword for function like body (#25824) 2018-07-20 08:25:16 -07:00
Andy
46827f4a76 Handle completions at name of namespace declaration (#25661)
* Handle completions at name of namespace declaration

* Handle namespace merging
2018-07-19 10:26:18 -07:00
Andy
d92c26db69 Add test that getEditsForFileRename respects UserPreferences (#25745)
* Add test that getEditsForFileRename respects UserPreferences

* Test quotePreference
2018-07-17 17:05:35 -07:00