Youcompleteme: Diagnostic display and autocomplete for javascript are abnormal

Created on 17 Mar 2020  路  21Comments  路  Source: ycm-core/YouCompleteMe

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [x] I have read and understood YCM's [CONTRIBUTING][cont] document.
  • [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
  • [x] I have read and understood YCM's [README][readme], especially the
    [Frequently Asked Questions][faq] section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. ([Example Google
    search.][search])
  • [x] If filing a bug report, I have included the output of vim --version.
  • [x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [x] If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • [x] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [x] If filing a bug report, I have included a minimal test case that reproduces
    my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I
    expected to happen and what actually happened.
  • [x] If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • [x] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key
questions:

  • What did you do?
function! BuildYCM(info)
  " - name: YouCompleteMe
  " - status: 'installed'
  if a:info.status == 'installed' || a:info.force
    !python3 ./install.py --clangd-completer --go-completer --ts-completer
    !python3 .ycm_extra_conf.py ~/.vim/plugged/YouCompleteMe/third_party/ycmd
  endif
endfunction

Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM'), 'for': ['go', 'javascript']}
// jsconfig.json
{
    "compilerOptions": {
        "checkJs": true
    }
}



md5-cdc1d9d711bdf69fee2b4f6a10fef7bb



cd YouCompleteMe/third_party/ycmd
git checkout master
git pull
git submodule update --init --recursive
./build.py --skip-build --no-regex --ts-completer



md5-ebd10739e6cfb014f90f5a781fd0ce74



VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar  4 2020 22:41:50)
macOS version



md5-2e256ddd309da97238eba837da042c2c



Printing YouCompleteMe debug information...
-- Client logfile: /var/folders/9n/5k9ghmws7kd6zswgsvlcdcsh0000gn/T/ycm_oewx6d0r.log
-- Server Python interpreter: /usr/local/opt/python/bin/python3.7
-- Server Python version: 3.7.7
-- Server has Clang support compiled in: False
-- Clang version: None
-- Extra configuration file found and loaded
-- Extra configuration path: /Users/sweeney/.vim/plugged/YouCompleteMe/third_party/ycm
d/.ycm_extra_conf.py
-- TypeScript completer debug information:
--   TSServer running
--   TSServer process ID: 91992
--   TSServer executable: /Users/sweeney/.vim/plugged/YouCompleteMe/third_party/ycmd/t
hird_party/tsserver/bin/tsserver
--   TSServer logfiles:
--     /var/folders/9n/5k9ghmws7kd6zswgsvlcdcsh0000gn/T/tsserver_4yg2v56h.log
--   TSServer version: 3.7.2
-- Server running at: http://127.0.0.1:53613
-- Server process ID: 91983
-- Server logfiles:
--   /var/folders/9n/5k9ghmws7kd6zswgsvlcdcsh0000gn/T/ycmd_53613_stdout_cslslm51.log
--   /var/folders/9n/5k9ghmws7kd6zswgsvlcdcsh0000gn/T/ycmd_53613_stderr_zavq4o61.log



md5-2e1a0d864c094b294bbb751b2ecf85e2



 1 test.js|2 col 8 error| Property 'name' does not exist on type 'Object'. (FixIt ava  2 test.js|3 col 8 error| Property 'age' does not exist on type 'Object'. (FixIt avai
  3 test.js|4 col 8 error| Property 'job' does not exist on type 'Object'. (FixIt avai  4 test.js|6 col 8 error| Property 'sayName' does not exist on type 'Object'. (FixIt
  5 test.js|7 col 20 error| Property 'name' does not exist on type 'Object'. (FixIt av  6 test.js|11 col 8 error| Property 'sayName' does not exist on type 'Object'. (FixIt
  7 test.js|13 col 8 error| Identifier expected.

OS version, distribution, etc.

macos 10.15.3 (19D76)

Most helpful comment

This is nothing to do with YCM, this is entirely the expected behaviour of tsserver. See my link to Tern as an alternative.

All 21 comments

Please reproduce using the minimal vimrc and provide steps to reproduce.

If filing a bug report, I have included a minimal test case that reproduces
my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I
expected to happen and what actually happened

You didn鈥檛 do this.

FWIW I鈥檓 fairly certain that this is just how typescript works. Tern might work better for you, but afaict YCM is working correctly

I check, I don't have vimrc_ycm_minimal in /path/to/YouCompleteMe.

Ok thanks. Can you update YCM first then?

It鈥檚 here https://github.com/ycm-core/YouCompleteMe/blob/master/vimrc_ycm_minimal

I reinstall YCM yesterday.

image
... wait, I reinstall again.

The "problem" is that TSServer is expecting static interfaces - no dynamic properties allowed. So if you declare a Person interface and instantiate a new Person(), it will owrk.

OO..Thanks.

More specifically, this works.

class Person {
    age: number;
}
var person = new Person();

person.age = 29;

Thanks, you know a lot about this.

as i said, if you want a more javascript-like setup with type inferences like this, try tern

TBH i'm surprised that tsserver isn't doing a better job of this. Does it work if you do:

var person = { 'name': "Joe", 'age': 100 };

btw; check your vim-plug setup IIRC it has some dodgy cacheing thing which breaks YCM updates.

TBH i'm surprised that tsserver isn't doing a better job of this. Does it work if you do:

Yes, it works with object literals. I'd call this behaviour fine, since the entire point of typescript is having types.

I would agree, except the file is quite clearly javascript, not typescript.

But the file's extension was .ts and therefore typescript.

i see test.js in the screenshots?

Hmm... I can repro the above behaviour if I name the file test.ts. There's no spurious diagnostics and complaining if I name the file test.js.

EDIT: No I can't. It reports the same error even for javascript.

Does it work if you do

image
I'm sorry to reply to you for so long. It works.

image
image

It seems this error of diagnostic display is only for Object().
But autocompletion is not supported, either.

This is nothing to do with YCM, this is entirely the expected behaviour of tsserver. See my link to Tern as an alternative.

Okk, THX.

Was this page helpful?
0 / 5 - 0 ratings