diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts index f0a42de22..cde28c983 100644 --- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts @@ -130,13 +130,37 @@ function enhanceIfNecessary(diagnostic: Diagnostic): Diagnostic { message: 'Type definitions are missing for this Svelte Component. ' + // eslint-disable-next-line max-len - 'It needs a class definition with at least the property \'$$prop_def\' which should contain a map of input property definitions.\n' + + "It needs a class definition with at least the property '$$prop_def' which should contain a map of input property definitions.\n" + 'Example:\n' + - 'class ComponentName { $$prop_def: { propertyName: string; } }\n\n' + + ' class ComponentName { $$prop_def: { propertyName: string; } }\n' + + 'If you are using Svelte 3.31+, use SvelteComponentTyped:\n' + + ' import type { SvelteComponentTyped } from "svelte";\n' + + ' class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}\n\n' + + 'Underlying error:\n' + diagnostic.message }; } + if (diagnostic.code === 2607) { + return { + ...diagnostic, + message: + 'Element does not support attributes because ' + + 'type definitions are missing for this Svelte Component or element cannot be used as such.\n\n' + + 'Underlying error:\n' + + diagnostic.message + }; + } + + if (diagnostic.code === 1184) { + return { + ...diagnostic, + message: + diagnostic.message + + '\nIf this is a declare statement, move it into ' + }; + } + return diagnostic; }