Commit Graph

3385 Commits

Author SHA1 Message Date
Andrew Branch 5d04250ea8 Improve “Add missing await” fix-all (#32922)
* Improve codeFixAll for add missing await

* Improve add missing await for initializers and fix-all

* Fix when only one side of a binary expression can have its initializer fixed
2019-08-20 16:53:28 -07:00
Zixiang Li 24201cfe6e Add support for jsdoc properties with hyphen (#32631) 2019-08-20 14:49:40 -07:00
Nathan Shively-Sanders 6ca9d04b60 Constructor functions as classes (#32944)
* Initial implementation

The original test passes but I haven't run any other tests yet, so I
assume the world is now broken.

* Append constructor function construct sigs

Instead of overwriting them

* Grab bag of improvements.

1. Mark @class-tagged functions with Class too.
2. Only gather local type parameters of constructor functions.
3. Remove getJSClassType calls with getDeclaredTypeOfSymbol.
4. Add a couple more failing tests.

getDeclaredTypeOfClassOrInterface now needs to understand prototype
assignment. That's next, I think.

* Prototype assignments work now

1. Binder marks prototype assignments as Class now.
2. Checker merges prototype assignments using the same merge code as for
functions and their declarations. No more intersections.

Many fewer failing tests now.

* Mark prototype-property assignments as Class

Even if there are no this-property assignments in them. (Then why are
you using a class?).

* Simplify getJSClassType, remove calls to its guts

It's probably not needed because now it's just a conditional call to
getDeclaredTypeOfSymbol, and I think most callers already know whether
they have a JS constructor function beforehand.

* isJSDocConstructor doesn't need to check prototype anymore

Because all the properties are merged during getDeclaredTypeOfSymbol.

* outer type parameter lookup follow prototype assignment

* this-type and -expression support in ctor funcs

Pretty cool!

* Fix remaining tests

* Fix minor lint

* Delete now-unused code

* Add class flag to nested class declarations

Also remove old TODOs
2019-08-19 14:12:53 -07:00
Nathan Shively-Sanders 2b8ccf40ae jsdoc template tags might be unmatched (#32936)
* jsdoc template tags might be unmatched

* Update fourslash test
2019-08-16 13:39:57 -07:00
Hoang Pham 46b7972885 Add JSX codefix if available (#32281)
* Add JSX codefix if available

* Update react jsx.

* Update diagnostic code.
2019-08-16 12:46:55 -07:00
Wesley Wigham 1747ee7a55 Perfer the non-module name of a symbol when writing the name of a symbol (#32880) 2019-08-14 17:16:17 -07:00
Andrew Branch 2217f0b859 Fix export=global auto import exclusion (#32898) 2019-08-14 15:50:25 -07:00
Daniel Rosenwasser c8d937ecd3 Merge pull request #32726 from fuafa/completion-after-private
Fix completion disappear after a property declaration with a private modifier
2019-08-13 11:09:32 -07:00
Ron Buckton decc3cd671 Elide /index from auto-import when using rootDirs compiler option (#32828) 2019-08-12 16:05:15 -07:00
Orta 2a2866c3a9 Merge pull request #32563 from orta/fix_31298
Handle namepaths inside JSDoc type expressions a bit better
2019-08-09 16:15:50 -07:00
Ron Buckton 98b6db81d9 Allow accessors in ambient class declarations (#32787)
* Allow accessors in ambient class declarations

* Update src/compiler/transformers/declarations.ts

Co-Authored-By: Wesley Wigham <wewigham@microsoft.com>
2019-08-09 16:11:25 -07:00
Wesley Wigham f2719f95b4 Allow functions and ambient classes to merge (#32584) 2019-08-09 16:10:10 -07:00
Sheetal Nandi b7e49d1d1c Ignore unknown files to search from in document highlights 2019-08-09 15:06:51 -07:00
Andrew Branch 984956afec Only add unnecessary-await suggestion on await expressions (#32754) 2019-08-07 11:27:36 -07:00
Orta Therox 77cdca2971 Adds another test around parsing jsdoc 2019-08-06 15:45:28 -04:00
Orta Therox 487e2ffe2a Merge master 2019-08-06 15:34:06 -04:00
Nathan Shively-Sanders 269c3d3a56 Suggestions now use diagnosticCollection (#32740)
Previously they used multiMaps, unlike all the other diagnostics. This
prevents duplicate suggestions, like other kinds diagnostics.

Fixes #28710
2019-08-06 11:15:06 -07:00
xiaofa e1bca8ff2a Fix class member completion disappear after a property declaration with a private modifier 2019-08-06 08:35:34 +08:00
Andrew Branch c1e0db7953 Escape apparent substitution in synthesized NoSubstitutionTemplateLiterals (#32580)
* Add failing test

* Escape apparent substitution in synthesized NoSubstitutionTemplateLiterals
2019-08-05 09:31:59 -07:00
Andrew Branch e82d0af554 Fix readonly occurrences highlighting (#32583)
* Fix readonly occurrences highlighting

* Rename function

* Rename again

* Apply suggestions from code review

Remove unused function
2019-08-02 18:24:46 -07:00
Andrew Branch 62f65a7884 Make auto-imports more likely to be valid for the file (including JS) & project settings (#32684)
* Add failing tests

* Use default import or namespace import for import fixes when compiler options allow

* Don’t do import * for export=, ever

* Only do import default for export equals if nothing else will work

* Never do import/require in a JavaScript file

* Update tests for changes in master

* Add const/require fix for JS and select based on usage heuristic

* Fix JS UMD import
2019-08-02 15:58:10 -07:00
Andrew Branch 725321f08c Prioritize “property names” over punctuation in smart select (#32687)
* Prioritize “property names” over punctuation in smart select

* Update doc comment
2019-08-02 15:57:44 -07:00
Orta 4a26271b63 Merge pull request #32663 from orta/fix_31195
Ensure that the comma is removed when all named imports are removed via moveToFile
2019-08-02 10:29:51 -04:00
Orta 78e03848a4 Merge pull request #31946 from orta/30246
Don't let the additional property setting on an object show up as a definition to tsserver
2019-08-02 10:29:34 -04:00
Orta Therox c337f046fb Ensure that the comma is removed when all named imports are removed via moveToFile - fixes #31195 2019-08-01 15:01:52 -04:00
Orta Therox 3145656f6a Merge branch 'master' of https://github.com/microsoft/typescript into 30246 2019-07-31 17:08:45 -04:00
Andrew Casey dbe9e3d237 Merge pull request #32565 from amcasey/TripleSlashClassification
Support classification of triple-slash references
2019-07-29 12:27:55 -07:00
Orta Therox 30aad9db8d Support more terminators for parsing jsdoc filepaths 2019-07-29 09:46:42 -04:00
Wesley Wigham 2a4930f4ec Bind a jsdoc enum as SymbolFlags.TypeAlias and not SymbolFlags.Enum (#32520)
* Bind a jsdoc enum as SymbolFlags.TypeAlias and not SymbolFlags.Enum

* Actually include an @enum tag as a declaration

* Add enum tag refs into a couple more syntax kind lists

* accept symbol baseline update
2019-07-26 13:57:22 -07:00
Orta Therox b902a71e5f Handle namepaths inside JSDoc type expressions a bit better - fixes #31298 2019-07-25 19:38:48 -04:00
Andrew Casey 9647506d8c Support classification of triple-slash references
Note: not restricted to the element and attribute names that actually
bind
2019-07-25 15:59:17 -07:00
Andrew Branch aa12ec440c Fix smart select on last blank line of file (#32544)
* Fix SmartSelection on last blank line of file

* Add baseline
2019-07-25 09:47:57 -07:00
Sheetal Nandi b8e779d89a When the exported symbol is merged symbol from declaration use that name to verify quality
Fixes #27880
2019-07-23 16:31:59 -07:00
Nathan Shively-Sanders e543d8bc5a Fix type keyword completions (#32474)
* Fix type keyword completions

1. In functions, type keywords were omitted.
2. In All context, no keywords were omitted.

(1) fixes #28737
(2) removes 17 keywords that should not be suggested, even at the
toplevel of a typescript file:

* private
* protected
* public
* static
* abstract
* as
* constructor
* get
* infer
* is
* namespace
* require
* set
* type
* from
* global
* of

I don't know whether we have a bug tracking this or not.

* Change keyword filter in filterGlobalCompletion

Instead of changing FunctionLikeBodyKeywords

* Add more tests cases

* Make type-only completions after < more common

Because isPossiblyTypeArgumentPosition doesn't give false positives now
that it uses type information.
2019-07-19 15:22:04 -07:00
Andrew Branch 387c917765 Revert "Proposal: If there’s a package.json, only auto-import things in it, more or less (#31893)" (#32448)
This reverts commit 60a1b1dc1a.
2019-07-17 14:02:18 -07:00
Dmitrijs Minajevs 7608dc2306 Merge branch 'master' into fix29666 2019-07-16 10:52:26 +03:00
Dmitrijs Minajevs 9a37ef8667 typeAssertionKeywords tests 2019-07-16 10:04:14 +03:00
Daniel Rosenwasser c7b8b2ae9b Merge pull request #32382 from dragomirtitian/GH-29769-generic-auto-completion-missing-primitives
Fixed auto completion after a < token to return types not values.
2019-07-15 16:41:03 -07:00
Andrew Branch 7cdfbceb43 Improve accuracy of remove unnecessary await fix (#32384) 2019-07-15 15:17:32 -07:00
Sheetal Nandi 0038b0baa3 Merge pull request #31815 from gb714us/bug/31631
create outlining span for JsxFragment
2019-07-15 11:19:24 -07:00
Orta 2c26ac2e43 Merge pull request #32243 from orta/fix-30536
Adds support for class completions after ASI inserted class property definition
2019-07-15 11:54:13 -04:00
Orta 4bb0aaea06 Merge pull request #32359 from orta/fix_14589
Don't add extra indentation for objects inside function parameters
2019-07-15 11:33:48 -04:00
Titian Cernicova-Dragomir ba79b5ffac Fixed auto completion after a < token to return types not values. 2019-07-12 23:14:42 +03:00
Orta Therox 59d5585814 Don't indent properties if an object literal follows directly from another object on the same line 2019-07-12 15:24:07 -04:00
Andrew Branch 89badcc9d5 Add 'Remove unnecessary await' suggestion and fix (#32363)
* Add remove unnecessary await fix

* Add test for removing unnecessary parens after await is gone

* Fix handling of numbers in property access expressions

* Don’t offer suggestion when awaited type is any/unknown

* Fix random other test

* Fix new expression edge cases

* Only remove parens for identifiers and call expressions
2019-07-12 11:03:20 -07:00
Andrew Branch 60a1b1dc1a Proposal: If there’s a package.json, only auto-import things in it, more or less (#31893)
* Move package.json related utils to utilities

* Add failing test

* Make first test pass

* Don’t filter when there’s no package.json, fix scoped package imports

* Use type acquisition as a heuristic for whether a JS project is using node core

* Make same fix in getCompletionDetails

* Fix re-exporting

* Change JS node core module heuristic to same-file utilization

* Remove unused method

* Remove other unused method

* Remove unused triple-slash ref

* Update comment

* Refactor findAlias to forEachAlias to reduce iterations

* Really fix re-exporting

* Use getModuleSpecifier instead of custom hack

* Fix offering auto imports to paths within node modules

* Rename things and make comments better

* Add another reexport test

* Inline `symbolHasBeenSeen`

* Simplify forEachAlias to findAlias

* Add note that symbols is mutated

* Symbol order doesn’t matter here

* Style nits

* Add test with nested package.jsons

* Fix and add tests for export * re-exports
2019-07-12 10:08:55 -07:00
Andrew Branch 71bec5b698 Add quick fix to add missing 'await' (#32356)
* Start prototyping addMissingAwait codefix

* Filter by diagnostics that have missing-await related info

* Start writing tests and checking precedence

* Implement codeFixAll, add test for binary expressions

* Add test for iterables

* Add test for passing argument

* Add test for call/construct signatures

* Add test for awaiting initializer

* Improve assertion error

* Replace specific property access error with general one and add await related info

* Add test for property access

* Require code to be inside a function body to offer await

* Accept suggestion

Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* Add explicit test for code fix being not available unless something is a Promise

* Skip looking for function body if already in AwaitContext flags

* Inline getCodeActions function for symmetry
2019-07-12 10:07:55 -07:00
Dmitrijs Minajevs b2c555a57d Added new keword compeltion filter for assertions 2019-07-12 15:25:00 +03:00
Dmitrijs Minajevs 74805c2e23 Fixed failing test due to changed details 2019-07-12 14:11:23 +03:00
Orta Therox dfc97db323 Don't add extra indentation for objects inside function parameters 2019-07-11 14:26:03 -04:00