TypeScript and IDE
Types in the component
svelte
<script lang="ts">
import type { MyNodeProps } from './types';
let { node }: { node: MyNodeProps } = $props();
</script>$props, $state, $derived, $effect and $bindable are typed by dxp, the same way as RED. Add dxp to the types of your tsconfig.json (as for any dxp package):
json
{ "compilerOptions": { "types": ["node-red", "@keload/node-red-dxp"] } }Typing the exports
Type the module exports with SvelteNodeConfig:
ts
import type { SvelteNodeConfig } from '@keload/node-red-dxp/editor/svelte';
export const defaults: SvelteNodeConfig<MyNodeProps>['defaults'] = { name: { value: '' } };What is checked
tsconly checks.tsfiles: the content of a.sveltefile is not type-checked bypnpm typecheck.- Put logic in a
.tsfile and import it when you want it checked. - The components of
@keload/node-red-dxp/uiare published with their.svelte.d.tstypes.
Known limitations
svelte-check(the CLI that checks.sveltefiles) refuses TypeScript 7 unless TypeScript 6 is installed next to it.- Prop autocompletion of the
uicomponents can be missing in WebStorm (tracked, not fixed yet). The props are listed in Components.