Merge branch 'master' into pr/5936

pull/5936/head
Conduitry 6 years ago
commit 6021bee705

@ -1,5 +1,10 @@
# Svelte changelog # Svelte changelog
## Unreleased
* Throw a parser error for `class:` directives with an empty class name ([#5858](https://github.com/sveltejs/svelte/issues/5858))
* Fix type inference for derived stores ([#5935](https://github.com/sveltejs/svelte/pull/5935))
## 3.32.0 ## 3.32.0
* Allow multiple instances of the same action on an element ([#5516](https://github.com/sveltejs/svelte/issues/5516)) * Allow multiple instances of the same action on an element ([#5516](https://github.com/sveltejs/svelte/issues/5516))

@ -387,6 +387,13 @@ function read_attribute(parser: Parser, unique_names: Set<string>) {
}, start); }, start);
} }
if (type === 'Class' && directive_name === '') {
parser.error({
code: 'invalid-class-directive',
message: 'Class binding name cannot be empty'
}, start + colon_index + 1);
}
if (value[0]) { if (value[0]) {
if ((value as any[]).length > 1 || value[0].type === 'Text') { if ((value as any[]).length > 1 || value[0].type === 'Text') {
parser.error({ parser.error({

@ -125,10 +125,12 @@ type StoresValues<T> = T extends Readable<infer U> ? U :
* *
* @param stores - input stores * @param stores - input stores
* @param fn - function callback that aggregates the values * @param fn - function callback that aggregates the values
* @param initial_value - when used asynchronously
*/ */
export function derived<S extends Stores, T>( export function derived<S extends Stores, T>(
stores: S, stores: S,
fn: (values: StoresValues<S>) => T fn: (values: StoresValues<S>, set: (value: T) => void) => Unsubscriber | void,
initial_value?: T
): Readable<T>; ): Readable<T>;
/** /**
@ -137,12 +139,10 @@ export function derived<S extends Stores, T>(
* *
* @param stores - input stores * @param stores - input stores
* @param fn - function callback that aggregates the values * @param fn - function callback that aggregates the values
* @param initial_value - when used asynchronously
*/ */
export function derived<S extends Stores, T>( export function derived<S extends Stores, T>(
stores: S, stores: S,
fn: (values: StoresValues<S>, set: (value: T) => void) => Unsubscriber | void, fn: (values: StoresValues<S>) => T
initial_value?: T
): Readable<T>; ): Readable<T>;
export function derived<T>(stores: Stores, fn: Function, initial_value?: T): Readable<T> { export function derived<T>(stores: Stores, fn: Function, initial_value?: T): Readable<T> {

@ -0,0 +1,10 @@
{
"code": "invalid-class-directive",
"message": "Class binding name cannot be empty",
"start": {
"line": 1,
"column": 10,
"character": 10
},
"pos": 10
}
Loading…
Cancel
Save