Skip to content

Commit e79e2eb

Browse files
committed
update
1 parent 397df6e commit e79e2eb

File tree

6 files changed

+26
-44
lines changed

6 files changed

+26
-44
lines changed

packages/package/src/typescript.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,21 @@ export async function emit_dts(input, output, final_output, cwd, alias, files, t
5858
let source = fs.readFileSync(path.join(tmp, normalized), 'utf8');
5959
if (file.endsWith('.d.ts.map')) {
6060
// Because we put the .d.ts files in a temporary directory, the relative path needs to be adjusted
61-
source = source.replace(/("sources":\[")(.+?)("\])/, (_, prefix, source_path, suffix) => {
62-
const new_sourcepath = posixify(
63-
path.join(
64-
path.relative(
65-
path.dirname(path.join(final_output, normalized)),
66-
path.dirname(path.join(input, normalized))
67-
),
68-
path.basename(source_path)
61+
const parsed = JSON.parse(source);
62+
if (parsed.sources) {
63+
parsed.sources = /** @type {string[]} */ (parsed.sources).map((source) =>
64+
posixify(
65+
path.join(
66+
path.relative(
67+
path.dirname(path.join(final_output, normalized)),
68+
path.dirname(path.join(input, normalized))
69+
),
70+
path.basename(source)
71+
)
6972
)
7073
);
71-
return prefix + new_sourcepath + suffix;
72-
});
74+
source = JSON.stringify(parsed);
75+
}
7376
} else {
7477
source = resolve_aliases(input, normalized, source, alias);
7578
}
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<script lang="ts">
2-
import { createEventDispatcher } from 'svelte';
3-
export const astring = 'potato';
4-
const dispatch = createEventDispatcher();
5-
dispatch('event', true);
2+
let { foo } = $props();
63
</script>
74

8-
<slot {astring} />
5+
{foo}
Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
import { SvelteComponentTyped } from 'svelte';
2-
declare const __propDef: {
3-
props: {
4-
astring?: string;
5-
};
6-
events: {
7-
event: CustomEvent<boolean>;
8-
} & {
9-
[evt: string]: CustomEvent<any>;
10-
};
11-
slots: {
12-
default: {
13-
astring: string;
14-
};
15-
};
1+
type $$ComponentProps = {
2+
foo: string;
163
};
17-
export type TestProps = typeof __propDef.props;
18-
export type TestEvents = typeof __propDef.events;
19-
export type TestSlots = typeof __propDef.slots;
20-
export default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {
21-
get astring(): string;
22-
}
23-
export {};
4+
declare const Test: import("svelte").Component<$$ComponentProps, {}, "">;
5+
type Test = ReturnType<typeof Test>;
6+
export default Test
247
//# sourceMappingURL=Test.svelte.d.ts.map

packages/package/test/fixtures/typescript-declaration-map/expected/Test.svelte.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/package/test/fixtures/typescript-declaration-map/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"version": "1.0.0",
55
"description": "standard typescript package with declarationMap:true",
66
"type": "module",
7+
"peerDependencies": {
8+
"svelte": "^5.0.0"
9+
},
710
"exports": {
811
".": {
912
"types": "./dist/index.d.ts",
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<script lang="ts">
2-
import { createEventDispatcher } from 'svelte';
3-
export const astring: string = 'potato';
4-
5-
const dispatch = createEventDispatcher<{ event: boolean }>();
6-
dispatch('event', true);
2+
let { foo }: { foo: string } = $props();
73
</script>
84

9-
<slot {astring} />
5+
{foo}

0 commit comments

Comments
 (0)