patricknelson/svelte-retag

Add `.d.ts` files for improved TypeScript support

Closed this issue · 3 comments

Describe the problem

It would be awesome if the project supports types.d file ( or maybe rewrite in typescript? )

Otherwise it's not possible to use this project in typescript based project ( well it's possible to use @ts-ignore, but you get the idea )
`

Describe the proposed solution

The way i see it, there's 2 options

  1. Rewrite in typescript ( since project already uses jsdoc, it should be easier )
  2. Add types files ( this is the approach that requires the least amount of work )

Alternatives considered

Ignoring types in typescript file

Importance

would make my life easier

Already supports TypeScript, the lib just isn't written in it. That said: I do not plan on ever converting this library to TypeScript, at least not for now. My reasoning is aligned with that of the Svelte framework itself, which does the same thing (see here for a good article on that topic).

And for option 2 can you be more specific on what you're proposing? It may be because I'm relatively new to TypeScript, but I can say that I'm using svelte-retag inside of a TypeScript project already and the Intellisense and linting (in IDE at least) are working well. See below.

Also, please feel free to submit a PR as well!

image

Already supports TypeScript, the lib just isn't written in it. That said: I do not plan on ever converting this library to TypeScript, at least not for now. My reasoning is aligned with that of the Svelte framework itself, which does the same thing (see here for a good article on that topic).

Fair enough, then something along the line of type file would be awesome.

I'm using svelte-retag inside of a TypeScript project already and the Intellisense and linting (in IDE at least) are working well. See below.

This is awkward, vscode doesn't pick up any type definition for svelte-retag
Screenshot 2023-12-02 104922

with following tsconfig.json:

{
    "include": ["./**/*.ts", "./**/*.tsx", "django_core/static_src/components/index.ts"],
    "exclude": ["node_modules", "postcss.config.cjs", "django_core/static"],
    "compilerOptions": {
        "lib": ["esnext", "DOM", "DOM.Iterable"],
        "allowJs": true,
        "checkJs": true,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "resolveJsonModule": true,
        "moduleResolution": "Bundler",
        "module": "esnext",
        "target": "esnext",
        "ignoreDeprecations": "5.0",
        "skipLibCheck": false,
        "sourceMap": true,
        "strict": true,
        "paths": {
            "$functions": ["./django_core/static_src/functions/"],
            "$functions/*": ["./django_core/static_src/functions/*"],
            "$icons": ["./django_core/static_src/components/icons/"],
            "$icons/*": ["./django_core/static_src/components/icons/*"],
            "$components": ["./django_core/static_src/components/"],
            "$components/*": ["./django_core/static_src/components/*"]
        }
    }
}

So my proposal is to add a definition file. ( example from marked-emoji )

See #33 (WIP)