Skip to content

Commit 96959ad

Browse files
feat: support specifying tsconfig for emitDts (#2454)
part of #2355
1 parent f6ad24d commit 96959ad

File tree

7 files changed

+41
-1
lines changed

7 files changed

+41
-1
lines changed

packages/svelte2tsx/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ export interface EmitDtsConfig {
108108
* set to `src/lib` by default.
109109
*/
110110
libRoot?: string;
111+
/**
112+
* Name of your tsconfig file, if it's not the standard `tsconfig.json` or `jsconfig.json`
113+
*/
114+
tsconfig?: string;
111115
}
112116

113117
// to make typo fix non-breaking, continue to export the old name but mark it as deprecated

packages/svelte2tsx/src/emitDts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface EmitDtsConfig {
66
declarationDir: string;
77
svelteShimsPath: string;
88
libRoot?: string;
9+
tsconfig?: string;
910
}
1011

1112
export async function emitDts(config: EmitDtsConfig) {
@@ -47,7 +48,7 @@ function loadTsconfig(config: EmitDtsConfig, svelteMap: SvelteMap) {
4748
const libRoot = config.libRoot || process.cwd();
4849

4950
const jsconfigFile = ts.findConfigFile(libRoot, ts.sys.fileExists, 'jsconfig.json');
50-
let tsconfigFile = ts.findConfigFile(libRoot, ts.sys.fileExists);
51+
let tsconfigFile = ts.findConfigFile(libRoot, ts.sys.fileExists, config.tsconfig);
5152

5253
if (!tsconfigFile && !jsconfigFile) {
5354
throw new Error('Failed to locate tsconfig or jsconfig');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"tsconfig": "tsconfig.build.json"
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** Calculate how much someone earns in a week */
2+
export declare function weeklySalary(dayRate: number): number;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Days available in a week
3+
* @internal
4+
*/
5+
export const daysInAWeek = 7;
6+
7+
/** Calculate how much someone earns in a week */
8+
export function weeklySalary(dayRate: number) {
9+
return daysInAWeek * dayRate;
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"stripInternal": true
5+
}
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "node",
4+
"module": "es2020",
5+
"lib": ["es2020", "DOM"],
6+
"target": "es2019",
7+
"isolatedModules": true,
8+
"resolveJsonModule": true,
9+
"esModuleInterop": true,
10+
"allowJs": true,
11+
"checkJs": true
12+
},
13+
"include": ["./src/**/*.d.ts", "./src/**/*.js", "./src/**/*.ts", "./src/**/*.svelte"]
14+
}

0 commit comments

Comments
 (0)