Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/svelte2tsx/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function svelte2tsx(
}
): SvelteCompiledToTsx

export interface EmitDtsConig {
export interface EmitDtsConfig {
/**
* Where to output the declaration files
*/
Expand All @@ -74,10 +74,14 @@ export interface EmitDtsConig {
libRoot?: string;
}

// to make typo fix non-breaking, continue to export the old name but mark it as deprecated
/**@deprecated*/
export interface EmitDtsConig extends EmitDtsConfig {} /* eslint-disable-line @typescript-eslint/no-empty-interface */

/**
* Searches for a jsconfig or tsconfig starting at `root` and emits d.ts files
* into `declarationDir` using the ambient file from `svelteShimsPath`.
* Note: Handwritten `d.ts` files are not copied over; TypeScript does not
* touch these files.
*/
export function emitDts(config: EmitDtsConig): Promise<void>;
export function emitDts(config: EmitDtsConfig): Promise<void>;
6 changes: 3 additions & 3 deletions packages/svelte2tsx/src/emitDts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import * as path from 'path';
import ts from 'typescript';
import { svelte2tsx } from './svelte2tsx';

export interface EmitDtsConig {
export interface EmitDtsConfig {
declarationDir: string;
svelteShimsPath: string;
libRoot?: string;
}

export async function emitDts(config: EmitDtsConig) {
export async function emitDts(config: EmitDtsConfig) {
const svelteMap = await createSvelteMap(config);
const { options, filenames } = loadTsconfig(config, svelteMap);
const host = await createTsCompilerHost(options, svelteMap);
const program = ts.createProgram(filenames, options, host);
program.emit();
}

function loadTsconfig(config: EmitDtsConig, svelteMap: SvelteMap) {
function loadTsconfig(config: EmitDtsConfig, svelteMap: SvelteMap) {
const libRoot = config.libRoot || process.cwd();

const jsconfigFile = ts.findConfigFile(libRoot, ts.sys.fileExists, 'jsconfig.json');
Expand Down