diff --git a/CHANGELOG.md b/CHANGELOG.md index 896a550c3f..d4daf1fc0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased * Support `` ([#2079](https://github.com/sveltejs/svelte/issues/2079)) +* Add types to `get` function in `svelte/store` ([#5269](https://github.com/sveltejs/svelte/pull/5269)) * Add `EventSource` to known globals ([#5463](https://github.com/sveltejs/svelte/issues/5463)) * Fix compiler exception with `~`/`+` combinators and `{...spread}` attributes ([#5465](https://github.com/sveltejs/svelte/issues/5465)) diff --git a/src/compiler/compile/index.ts b/src/compiler/compile/index.ts index 9d56dfae02..c29cbc1dbf 100644 --- a/src/compiler/compile/index.ts +++ b/src/compiler/compile/index.ts @@ -1,4 +1,3 @@ -import { assign } from '../../runtime/internal/utils'; import Stats from '../Stats'; import parse from '../parse/index'; import render_dom from './render_dom/index'; @@ -68,7 +67,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) { } export default function compile(source: string, options: CompileOptions = {}) { - options = assign({ generate: 'dom', dev: false }, options); + options = Object.assign({ generate: 'dom', dev: false }, options); const stats = new Stats(); const warnings = []; diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index 633b6f054c..828cb97c27 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -1,3 +1,5 @@ +import { Readable } from "svelte/store"; + export function noop() {} export const identity = x => x; @@ -60,7 +62,7 @@ export function subscribe(store, ...callbacks) { return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; } -export function get_store_value(store) { +export function get_store_value>(store: S): T { let value; subscribe(store, _ => value = _)(); return value; @@ -158,4 +160,4 @@ export const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, export function action_destroyer(action_result) { return action_result && is_function(action_result.destroy) ? action_result.destroy : noop; -} \ No newline at end of file +}