Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated package.json files should include "types" field #1628

Closed
Rich-Harris opened this issue Jun 2, 2021 · 0 comments · Fixed by #1646
Closed

Generated package.json files should include "types" field #1628

Rich-Harris opened this issue Jun 2, 2021 · 0 comments · Fixed by #1646

Comments

@Rich-Harris
Copy link
Member

Is your feature request related to a problem? Please describe.
When importing a library generated with svelte-kit package, types declared manually via .d.ts files aren't available idiomatically:

<script>
  import Circle from 'my-library/Circle.svelte';

  /** @type {import('my-library').Point} */
  const point = { x: 1, y: 2 };
</script>

<Circle center={point} radius={5}/>

Instead, you have to know where the types are defined inside the package — e.g. assuming you had a src/lib/types/index.d.ts file you would do this:

- /** @type {import('my-library').Point} */
+ /** @type {import('my-library/types/index.d.ts').Point} */
  const point = { x: 1, y: 2 };

This works because .d.ts files, like other files, get an entry in the generated "exports" map. But it's a bit ugly.

Describe the solution you'd like

  • add a config.kit.package.types option, defaulting to "types" (or "."?), that gets included in the generated package.json
  • when we get round to generating declaration files from components (and converting .ts files) in src/lib, we use this value as the output directory
  • don't include .d.ts files in "exports"

Describe alternatives you've considered
Continuing to rely on "exports"

How important is this feature to you?
Important for authors and users of libraries created with svelte-kit package, but probably not urgent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant