Commit graph

12 commits

Author SHA1 Message Date
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
Sheetal Nandi 00cea41b65 Add sortText depending scope of symbols
Fixes #15024
2019-05-20 15:53:51 -07:00
Nathan Shively-Sanders be2db9db12
Add globalThis (#29332)
* Restore original code from bind-toplevel-this

With one or two additional comments

* Working in JS, but the symbol is not right.

Still need to

1. Make it work in Typescript.
2. Add test (and make them work) for the other uses of GlobalThis:
window, globalThis, etc.

* Check in TS also; update some tests

Lots of tests still fail, but all but 1 change so far has been correct.

* Update baselines

A couple of tests still fail and need to be fixed.

* Handle type references to globalThis

The type reference must be `typeof globalThis`. Just `globalThis` will
be treated as a value reference in type position -- an error.

* Restore former behaviour of implicitThis errors

I left the noImplicitThis rule for captured use of global this in an
arrow function, even though technically it isn't `any` any more --
it's typeof globalThis.  However, you should still use some other method
to access globals inside an arrow, because captured-global-this is super
confusing there.

* Test values with type globalThis

I ran into a problem with intersecting `Window & typeof globalThis`:

1. This adds a new index signature to Window, which is probably not
desired. In fact, with noImplicitAny, it's not desired on globalThis
either I think.
2. Adding this type requires editing TSJS-lib-generator, not this repo.

So I added the test cases and will probably update them later, when
those two problems are fixed.

* Add esnext declaration for globalThis

* Switch to symbol-based approach

I decided I didn't like the import-type-based approach.

Update baselines to reflect the difference.

* Do not suggest globals for completions at toplevel

* Add tests of element and property access

* Look up globalThis using normal resolution

globalThis is no longer constructed lazily. Its synthetic Identifier
node is also now more realistic.

* Update fourslash tests

* Add missed fourslash test update

* Remove esnext.globalthis.d.ts too

* Add chained globalThis self-lookup test

* Attempt at making globalThis readonly

In progress, had to interrupt for other work.

* Add/update tests

* Addres PR comments:

1. Add parameter to tryGetThisTypeAt to exclude globalThis.
2. Use combined Module flag instead combining them in-place.
3. SymbolDisplay doesn't print 'module globalThis' for this expressions
anymore.
2019-02-27 14:14:34 -08:00
Andy c97fc64972
Always use verify.completions when testing completions (#28137) 2018-10-29 10:03:25 -07:00
Andrew Casey dc3b4166b2 Update test baseline 2017-11-22 15:11:38 -08:00
Ryan Cavanaugh c7f665faa1 Extract Method (squash) 2017-08-04 16:10:33 -07:00
Sheetal Nandi b3d793608d Completion list for a class extending another class should contain members from base class
Handles #7158
2017-05-05 11:30:32 -07:00
Jason Ramsay dba03377b8 Adding JSXExpression check for isGlobalCompletion and associated tests 2016-10-18 14:04:21 -07:00
Jason Ramsay a69fc67986 Restrict IsGlobalCompletion to:
- SourceFile
- Template Expression
- Statements
2016-10-14 16:04:51 -07:00
Ryan Cavanaugh 5b8ecafdf7 Don't show globals (e.g. snippets) in JSX positions 2016-10-05 13:32:12 -07:00
Jason Ramsay 62fddba88e Changes from CR feedback 2016-10-04 12:48:44 -07:00
Jason Ramsay d186c83119 Add isGlobalCompletion to CompletionInfo for snippet injection 2016-10-03 17:45:11 -07:00