github sveltejs/language-tools language-server-0.14.0

latest releases: extensions-109.0.1, svelte-check-4.0.2, svelte2tsx-0.7.19...
3 years ago
  • (chore) bump typescript to 4.3 and support semantic tokens on js (#1032)
  • (fix) more robust mapping for Svelte diagnostics (#1035)
  • (breaking) be more strict with required props (#1030)

Breaking Change

Previously, properties that had no initializer were only required if the user was using both TypeScript and activated strict mode. This is changed now: People using TypeScript, and those using checkJs also in JavaScript files, will always see this behavior now.

The fix is to provide a default value for properties that are optional. That's either the specific value kind or undefined.
Example TS:
export let optional: string;
Becomes
export let optional: string = ''; (or just export let optional = '')
Example JS:
export let optional;
Becomes
export let optional = undefined;

If you don't have control over the code because it's from a library, ask the author of that library to adjust their code. In the meantime you can create a d.ts file where you specify the types yourself.
Example:

<script>
  import { Foo } from 'package';
  import Bar from 'package/File.svelte';
</script>

Create a .d.ts file:

declare module 'package' {
  import { SvelteComponentTyped } from 'svelte';
  export class Foo extends SvelteComponentTyped<{..props definition here..}> {}
}
declare module 'package/File.svelte' {
  import { SvelteComponentTyped } from 'svelte';
  export default class Bar extends SvelteComponentTyped<{..props definition here..}> {}
}

Don't miss a new language-tools release

NewReleases is sending notifications on new releases.