Skip to content

Commit 1d367d0

Browse files
authored
fix: ignore noEmitOnError and isolatedDeclarations in emitDts (#3129)
With noEmitOnError: true in the tsconfig, emitDts silently writes no declarations, because the svelte2tsx output for element markup references svelteHTML, which the program never loads. isolatedDeclarations: true drops component declarations too, because the generated code can't satisfy it. Fixes #3131
1 parent 565abf9 commit 1d367d0

5 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte2tsx': patch
3+
---
4+
5+
fix: ignore `noEmitOnError` and `isolatedDeclarations` in `emitDts`

‎packages/svelte2tsx/src/emitDts.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ function loadTsconfig(config: EmitDtsConfig, svelteMap: SvelteMap) {
126126
options: {
127127
...options,
128128
noEmit: false, // Set to true in case of jsconfig, force false, else nothing is emitted
129+
noEmitOnError: false, // Type errors are svelte-check's job, force false, else nothing is emitted
130+
isolatedDeclarations: false, // Same, and generated component code can't satisfy it
129131
moduleResolution:
130132
options.moduleResolution &&
131133
options.moduleResolution !== ts.ModuleResolutionKind.Classic
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { SvelteComponentTyped } from "svelte";
2+
declare const __propDef: {
3+
props: {
4+
label?: string;
5+
};
6+
events: {
7+
[evt: string]: CustomEvent<any>;
8+
};
9+
slots: {};
10+
};
11+
export type ProbeProps = typeof __propDef.props;
12+
export type ProbeEvents = typeof __propDef.events;
13+
export type ProbeSlots = typeof __propDef.slots;
14+
export default class Probe extends SvelteComponentTyped<ProbeProps, ProbeEvents, ProbeSlots> {
15+
}
16+
export {};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
export let label = '';
3+
</script>
4+
5+
<button>{label}</button>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "bundler",
4+
"module": "es2020",
5+
"lib": ["es2020", "DOM"],
6+
"target": "es2019",
7+
"skipLibCheck": true,
8+
"noEmitOnError": true,
9+
"isolatedDeclarations": true
10+
},
11+
"include": ["./src/**/*.ts", "./src/**/*.svelte"]
12+
}

0 commit comments

Comments
 (0)