Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Jan 10, 2025
1 parent 397df6e commit e79e2eb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 44 deletions.
23 changes: 13 additions & 10 deletions packages/package/src/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ export async function emit_dts(input, output, final_output, cwd, alias, files, t
let source = fs.readFileSync(path.join(tmp, normalized), 'utf8');
if (file.endsWith('.d.ts.map')) {
// Because we put the .d.ts files in a temporary directory, the relative path needs to be adjusted
source = source.replace(/("sources":\[")(.+?)("\])/, (_, prefix, source_path, suffix) => {
const new_sourcepath = posixify(
path.join(
path.relative(
path.dirname(path.join(final_output, normalized)),
path.dirname(path.join(input, normalized))
),
path.basename(source_path)
const parsed = JSON.parse(source);
if (parsed.sources) {
parsed.sources = /** @type {string[]} */ (parsed.sources).map((source) =>
posixify(
path.join(
path.relative(
path.dirname(path.join(final_output, normalized)),
path.dirname(path.join(input, normalized))
),
path.basename(source)
)
)
);
return prefix + new_sourcepath + suffix;
});
source = JSON.stringify(parsed);
}
} else {
source = resolve_aliases(input, normalized, source, alias);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
export const astring = 'potato';
const dispatch = createEventDispatcher();
dispatch('event', true);
let { foo } = $props();
</script>

<slot {astring} />
{foo}
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
import { SvelteComponentTyped } from 'svelte';
declare const __propDef: {
props: {
astring?: string;
};
events: {
event: CustomEvent<boolean>;
} & {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {
astring: string;
};
};
type $$ComponentProps = {
foo: string;
};
export type TestProps = typeof __propDef.props;
export type TestEvents = typeof __propDef.events;
export type TestSlots = typeof __propDef.slots;
export default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {
get astring(): string;
}
export {};
declare const Test: import("svelte").Component<$$ComponentProps, {}, "">;
type Test = ReturnType<typeof Test>;
export default Test
//# sourceMappingURL=Test.svelte.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"version": "1.0.0",
"description": "standard typescript package with declarationMap:true",
"type": "module",
"peerDependencies": {
"svelte": "^5.0.0"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
export const astring: string = 'potato';
const dispatch = createEventDispatcher<{ event: boolean }>();
dispatch('event', true);
let { foo }: { foo: string } = $props();
</script>

<slot {astring} />
{foo}

0 comments on commit e79e2eb

Please sign in to comment.