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

Language Service Locks when you have a svelte file which doesn't start with a char in TS #613

Closed
orta opened this issue Oct 16, 2020 · 1 comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@orta
Copy link
Contributor

orta commented Oct 16, 2020

Describe the bug

To Reproduce
Steps to reproduce the behavior:

Using the npx degit sveltejs/template numbers, then making a file 1_File.svelte and editing the main.svelte to:

<script lang="ts">
	import File from "1_File.svelte"
	export let name: string;
</script>

<main>
	<h1>Hello {name}!</h1>
	<File></File>
	<p>Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte apps.</p>
</main>

Works fine in JS mode, but after running node scripts/setupTypeScript.ts then the reference to File gets an error with:

Type definitions are missing for this Svelte Component. It needs a class definition with at least the property '$$prop_def' which should contain a map of input property definitions.
Example:
class ComponentName { $$prop_def: { propertyName: string; } }

'File' cannot be used as a JSX component.
  Its instance type 'SvelteComponentDev' is not a valid JSX element.
    Property '$$prop_def' is missing in type 'SvelteComponentDev' but required in type 'ElementClass'.ts(2786)

It's very likely that somewhere there's probably an assumption that the filename can be a legal JS identifier. This can cause locks in the LSP (my guess is in file renames) which means things like formatting fail to happen.

Expected behavior

I can use any filename (I was writing a wizard and wanted my components in the order folks see them)

Screenshots
N/A

( Other than this, everything has been smooth sailing so far )

@orta orta added the bug Something isn't working label Oct 16, 2020
@dummdidumm
Copy link
Member

Your assumption is correct. We assume the filename is a valid class name which the produces invalid code. We need to strip out leading invalid characters.

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Oct 16, 2020
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants