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

Javascript completion for react components does not display certain completion proposals #6720

Open
yyoncho opened this issue Dec 8, 2019 · 7 comments · Fixed by typescript-language-server/typescript-language-server#131
Labels
bug bugs found in the application typescript issues related to the typescript language

Comments

@yyoncho
Copy link

yyoncho commented Dec 8, 2019

Description

The completion does not work for React component.

Reproduction Steps

Setup:

npm install -g create-react-app
create-react-app react-demo 
cd react-demo 
docker run -it --init -p 3000:3000 -v "$(pwd):/home/project:cached" theiaide/theia:next

Then the completion under React does not work unless you comment the import statement: here it is a gif demonstrating the behaviour.

theia

OS and Theia version:
0.14.0-next (or at least all components in about box are that version).

@akosyakov
Copy link
Member

Have you tried with VS Code built-in typescript extensions?

@akosyakov akosyakov added bug bugs found in the application typescript issues related to the typescript language labels Dec 9, 2019
@yyoncho
Copy link
Author

yyoncho commented Dec 9, 2019

It works in vscode. We found the issue in the typescript language server and @danielmartin will provide a PR.

@akosyakov
Copy link
Member

@yyoncho You can use VS Code extension for TypeScript with Theia. It gives you a better to support. It's a bit cumbersome to get for now. @marcdumais-work Do you think it is already possible to get proper vsix file from your PR: eclipse-theia/vscode-builtin-extensions#15

We are going to drop support of Theia TypeScript extension soon.

@marcdumais-work
Copy link
Contributor

I just tried the React scenario above using the built-ins and it's not working well yet. I'll use this as a base to troubleshoot and report-back when I have made progress.

@danielmartin
Copy link

danielmartin commented Dec 9, 2019

We are going to drop support of Theia TypeScript extension soon.

That'd be bad, because I think this is the best LSP extension for TypeScript right now. Not everyone uses VSCode. This extension uses tsserver directly (in contrast to https://github.com/sourcegraph/javascript-typescript-langserver), so its behavior is the most similar to what VSCode offers.

I just tried the React scenario above using the built-ins and it's not working well yet. I'll use this as a base to troubleshoot and report-back when I have made progress.

I've debugged this problem already. What I saw is that the language server is missing a call to compilerOptionsForInferredProjects. This is needed for this kind of "inferred" projects because otherwise the TypeScript compiler doesn't know how to compile the code.

If you place a tsconfig.json file like this one in the root of the React project, compilation will work as expected:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2016",
    "jsx": "preserve",
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "allowNonTsExtensions": true
  }
}

Here's the JSON payload, as shown by VSCode when TS logging is enabled and the server is initializing:

    {"seq":1,"type":"request","command":"compilerOptionsForInferredProjects","arguments":{"options":{"module":"commonjs","target":"es2016","jsx":"preserve","allowJs":true,"allowSyntheticDefaultImports":true,"allowNonTsExtensions":true}}}

@akosyakov
Copy link
Member

That'd be bad, because I think this is the best LSP extension for TypeScript right now.

It is still out there. We can make you a maintainer for this project or someone can fork it.

I've debugged this problem already.

It is fixable, but someone has to test/review/land it and then upgrade Theia with the same process. You will need to find someone. cc @eclipse-theia/ecd-theia-committers

@marcdumais-work
Copy link
Contributor

@akosyakov

I can now get Typescript to work nicely from the built-ins, but some manual intervention is required. Please see: eclipse-theia/vscode-builtin-extensions#15 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application typescript issues related to the typescript language
Projects
None yet
4 participants