Skip to content

Commit

Permalink
(feat) make it possible to pass additional file paths to emitDts
Browse files Browse the repository at this point in the history
Needed when someone uses the svelte.JSX typings.
Closes sveltejs#1405
  • Loading branch information
Simon committed Mar 14, 2022
1 parent 9c92206 commit 10147c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/svelte2tsx/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export interface EmitDtsConfig {
* Example: `require.resolve('svelte2tsx/svelte-shims.d.ts')`
*/
svelteShimsPath: string;
/**
* Additional file paths that need to be present when doing the dts emit.
* Example: `[require.resolve('svelte2tsx/svelte-jsx.d.ts')]` for the Svelte HTML ambient type definitions
*/
additionalPaths?: string[];
/**
* If you want to emit types only for part of your project,
* then set this to the folder for which the types should be emitted.
Expand Down
2 changes: 2 additions & 0 deletions packages/svelte2tsx/src/emitDts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { svelte2tsx } from './svelte2tsx';
export interface EmitDtsConfig {
declarationDir: string;
svelteShimsPath: string;
additionalPaths?: string[];
libRoot?: string;
}

Expand Down Expand Up @@ -72,6 +73,7 @@ function loadTsconfig(config: EmitDtsConfig, svelteMap: SvelteMap) {
// Add ambient functions so TS knows how to resolve its invocations in the
// code output of svelte2tsx.
filenames.push(config.svelteShimsPath);
filenames.push(...(config.additionalPaths || []));

return {
options: {
Expand Down

0 comments on commit 10147c3

Please sign in to comment.