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

All typescript breaks when component has uninitialized export #932

Closed
abalmos opened this issue Mar 31, 2021 · 4 comments
Closed

All typescript breaks when component has uninitialized export #932

abalmos opened this issue Mar 31, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@abalmos
Copy link

abalmos commented Mar 31, 2021

Describe the bug
If a component has an uninitialized export (and is not typed as undefined) then all error reporting breaks. It appears from the log (attached before) that svelte-language-server throws in this case. I have tried to track the bug down, but I am not familiar enough with the code base yet.

To Reproduce
Steps to reproduce the behavior:

  1. Open the below code snippet.
  2. Note let name: number = ''; is not flagged
  3. Change export let test: string; -> export let test: string | undefined or export let test = "test";
  4. let name: number = ''; is now flagged

Test.svelte

<script lang="ts">                                                               
   export let test: string;                                                       
                                                                                
  let name: number = '';                                                         
</script>                                                                        
                                                                                   
<div>{test}</div>   

Expected behavior
I except the type checking to continue and for other errors/warnings to be emitted.

Maybe a Variable 'test' is used before being assigned error is appropriate too, although, with the context of Svelte these are required props (?).

Screenshots
If applicable, add screenshots to help explain your problem.

System (please complete the following information):

  • OS: Linux Debian Testing
  • IDE: nvim/coc-nvim
  • Plugin/Package: coc-svelte (which uses svelte-language-server)

Additional context

I believe this is a the relevant error from the CoC log:

  [
    [
      "nvim_call_function",
      [
        "setbufline",
        [
          "output:///svelte",
          "$",
          "Error: Range#create called with invalid arguments[[object Object], [object Object], undefined, undefined]"
        ]
      ]
    ],
    [
      "nvim_call_function",
      [
        "appendbufline",
        [
          "output:///svelte",
          "$",
          [
            "    at Object.create (/home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/vscode-languageserver-protocol/node_modules/vscode-languageserver-types/lib/umd/main.js:71:23)",
            "    at mapRangeToOriginal (/home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/svelte-language-server/dist/src/lib/documents/DocumentMapper.js:141:42)",
            "    at Object.mapObjWithRangeToOriginal (/home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/svelte-language-server/dist/src/lib/documents/DocumentMapper.js:163:38)",
            "    at /home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/svelte-language-server/dist/src/plugins/typescript/features/DiagnosticsProvider.js:45:46",
            "    at Array.map (<anonymous>)",
            "    at DiagnosticsProviderImpl.getDiagnostics (/home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/svelte-language-server/dist/src/plugins/typescript/features/DiagnosticsProvider.js:45:14)",
            "    at async PluginHost.tryExecutePlugin (/home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/svelte-language-server/dist/src/plugins/PluginHost.js:228:20)",
            "    at async Promise.all (index 2)",
            "    at async PluginHost.getDiagnostics (/home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/svelte-language-server/dist/src/plugins/PluginHost.js:34:33)",
            "    at async DiagnosticsManager.update (/home/abalmos/.config/coc/extensions/node_modules/coc-svelte/node_modules/svelte-language-server/dist/src/lib/DiagnosticsManager.js:16:29)",
            ""
          ]
        ]
      ]
    ]
  ]
@abalmos abalmos added the bug Something isn't working label Mar 31, 2021
@jasonlyu123
Copy link
Member

jasonlyu123 commented Apr 1, 2021

Seems like this is an old version of svelte-language-server. We no longer use that Object.create function in the trace. Can you check what version you're using?

@abalmos
Copy link
Author

abalmos commented Apr 1, 2021

@jasonlyu123 Your right. I was using coc-svelte which is quite out of date. Tested using vscode and and the svelte plugin and everything works as expected.

Sorry for the noise

@abalmos abalmos closed this as completed Apr 1, 2021
@jasonlyu123
Copy link
Member

There's a fork of coc-svelte that is more well maintained. Guess you can also try it.

@abalmos
Copy link
Author

abalmos commented Apr 1, 2021

@jasonlyu123 Thanks for the tip. I found coc-svelte-fork but it seems even older. Do you mind sharing which extension your referring to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants