Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagnostic display and autocomplete for javascript are abnormal #3625

Closed
12 tasks done
yangxyo opened this issue Mar 17, 2020 · 21 comments
Closed
12 tasks done

Diagnostic display and autocomplete for javascript are abnormal #3625

yangxyo opened this issue Mar 17, 2020 · 21 comments

Comments

@yangxyo
Copy link

yangxyo commented Mar 17, 2020

Issue Prelude

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

  • I have read and understood YCM's [CONTRIBUTING][cont] document.
  • I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
  • I have read and understood YCM's [README][readme], especially the
    [Frequently Asked Questions][faq] section.
  • 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])
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • 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.
  • If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • 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.
  • 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
    }
}

I've done :

cd YouCompleteMe/third_party/ycmd
git checkout master
git pull
git submodule update --init --recursive
./build.py --skip-build --no-regex --ts-completer
  • What did you expect to happen?
    I hope the ==Diagnostic display== and ==autocomplete== for javascript can Running correctly.

Include description of the expected behaviour.

  • What actually happened?
    image
    image
    image

Diagnostic data

Output of vim --version

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

Output of YcmDebugInfo

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

Output of YcmDiags

 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)

@puremourning
Copy link
Member

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’t do this.

@puremourning
Copy link
Member

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

@yangxyo
Copy link
Author

yangxyo commented Mar 17, 2020

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

@puremourning
Copy link
Member

Ok thanks. Can you update YCM first then?

It’s here https://github.com/ycm-core/YouCompleteMe/blob/master/vimrc_ycm_minimal

@yangxyo
Copy link
Author

yangxyo commented Mar 17, 2020

I reinstall YCM yesterday.

@yangxyo
Copy link
Author

yangxyo commented Mar 17, 2020

image
... wait, I reinstall again.

@bstaletic
Copy link
Collaborator

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.

@yangxyo
Copy link
Author

yangxyo commented Mar 17, 2020

OO..Thanks.

@bstaletic
Copy link
Collaborator

More specifically, this works.

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

person.age = 29;

@yangxyo
Copy link
Author

yangxyo commented Mar 17, 2020

Thanks, you know a lot about this.

@yangxyo yangxyo closed this as completed Mar 17, 2020
@puremourning
Copy link
Member

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 };

@puremourning
Copy link
Member

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

@bstaletic
Copy link
Collaborator

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.

@puremourning
Copy link
Member

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

@bstaletic
Copy link
Collaborator

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

@puremourning
Copy link
Member

i see test.js in the screenshots?

@bstaletic
Copy link
Collaborator

bstaletic commented Mar 17, 2020

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.

@yangxyo
Copy link
Author

yangxyo commented Mar 18, 2020

Does it work if you do

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

@yangxyo
Copy link
Author

yangxyo commented Mar 18, 2020

image
image

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

@yangxyo yangxyo reopened this Mar 18, 2020
@puremourning
Copy link
Member

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

@yangxyo
Copy link
Author

yangxyo commented Mar 18, 2020

Okk, THX.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants