Skip to content

Commit

Permalink
improve snippet functions in code emit
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Jun 11, 2024
1 parent d7c4e87 commit 5f4f46b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions examples/Button.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script context="module" lang="ts">
import { defineMeta } from '@storybook/addon-svelte-csf';
import { defineMeta, setTemplate } from '@storybook/addon-svelte-csf';
import Button from './components/Button.svelte';
import { setTemplate } from '#index';
/**
* These are the stories for the `Button` component.
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/emit-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ const getFunctionName = (fn: Function & { getMockName?: () => string }) => {
* convert a value to a stringified version
*/
const valueToString = (value: any): string => {
if (value[Symbol.for('svelte.snippet')]) {

Check failure on line 103 in src/runtime/emit-code.ts

View workflow job for this annotation

GitHub Actions / Test

src/runtime/emit-code.test.ts > Emit Code > should replace individually referenced args

TypeError: Cannot read properties of undefined (reading 'Symbol(svelte.snippet)') ❯ valueToString src/runtime/emit-code.ts:103:7 ❯ src/runtime/emit-code.ts:85:14 ❯ Module.generateCodeToEmit src/runtime/emit-code.ts:82:6 ❯ src/runtime/emit-code.test.ts:95:7
return 'snippet';
}

if (typeof value === 'function') {
return getFunctionName(value);
}
Expand Down

0 comments on commit 5f4f46b

Please sign in to comment.