Skip to content

TypeScript error when importing TextMorph from torph/svelte #46

@notnotjake

Description

@notnotjake

import { TextMorph } from 'torph/svelte' gives typescript error: "Module '"torph/svelte"' has no exported member 'TextMorph'." and using TextMorph you don't get any prop types in Svelte. It works just fine at runtime.

Looking into it, the generated declaration files only export TextMorphProps and do not export the TextMorph component so Typescript sees it as missing.

A potential fix is to edit src/svelte/types.ts to include and export the component:

// packages/torph/src/svelte/types.ts
+ import type { Component } from "svelte";
import type { TextMorphOptions } from "../lib/text-morph/types";

export interface TextMorphProps extends Omit<TextMorphOptions, "element"> {
  text: string;
  class?: string;
  style?: string;
  as?: string;
}

+ export declare const TextMorph: Component<TextMorphProps>;

I did this in a fork and it fixes the issue in my usage: notnotjake@b692c96. Can open PR if that is acceptable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions