Skip to content

Commit cb7145c

Browse files
committed
fix
1 parent f5c3a50 commit cb7145c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

apps/svelte.dev/content/docs/svelte/03-runes/01-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ In the examples above, `$state` and `$derived` only appear at the top level of c
172172

173173
```ts
174174
/// file: counter.svelte.ts
175-
export function createCounter(initial) {
175+
export function createCounter(initial: number) {
176176
let count = $state(initial);
177177
let double = $derived(count * 2);
178178
return {

apps/svelte.dev/content/docs/svelte/04-runtime/02-context.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,16 @@ You can also retrieve the whole context map that belongs to the closest parent c
116116
The above methods are very unopionated about how to use them. When your app grows in scale, it's worthwhile to encapsulate setting and getting the context into functions and properly type them.
117117

118118
```ts
119-
let userKey = new Symbol('user');
119+
// @errors: 2304
120+
import { getContext, setContext } from 'svelte';
121+
122+
let userKey = Symbol('user');
120123

121124
export function setUserContext(user: User) {
122125
setContext(userKey, user);
123126
}
124127

125-
export function setUserContext(): User {
128+
export function getUserContext(): User {
126129
return getContext(userKey) as User;
127130
}
128131
```

0 commit comments

Comments
 (0)