Skip to content

Commit 2c5f1c4

Browse files
add typings to get_store_value (#5269)
Co-authored-by: Julian Laubstein <contact@julianlaubstein.de>
1 parent 8056829 commit 2c5f1c4

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
* Support `<slot slot="...">` ([#2079](https://github.com/sveltejs/svelte/issues/2079))
6+
* Add types to `get` function in `svelte/store` ([#5269](https://github.com/sveltejs/svelte/pull/5269))
67
* Add `EventSource` to known globals ([#5463](https://github.com/sveltejs/svelte/issues/5463))
78
* Fix compiler exception with `~`/`+` combinators and `{...spread}` attributes ([#5465](https://github.com/sveltejs/svelte/issues/5465))
89

src/compiler/compile/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { assign } from '../../runtime/internal/utils';
21
import Stats from '../Stats';
32
import parse from '../parse/index';
43
import render_dom from './render_dom/index';
@@ -68,7 +67,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
6867
}
6968

7069
export default function compile(source: string, options: CompileOptions = {}) {
71-
options = assign({ generate: 'dom', dev: false }, options);
70+
options = Object.assign({ generate: 'dom', dev: false }, options);
7271

7372
const stats = new Stats();
7473
const warnings = [];

src/runtime/internal/utils.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Readable } from "svelte/store";
2+
13
export function noop() {}
24

35
export const identity = x => x;
@@ -60,7 +62,7 @@ export function subscribe(store, ...callbacks) {
6062
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
6163
}
6264

63-
export function get_store_value(store) {
65+
export function get_store_value<T, S extends Readable<T>>(store: S): T {
6466
let value;
6567
subscribe(store, _ => value = _)();
6668
return value;
@@ -158,4 +160,4 @@ export const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj,
158160

159161
export function action_destroyer(action_result) {
160162
return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;
161-
}
163+
}

0 commit comments

Comments
 (0)