Always add a space after the function
keyword (#3903 by @j-f1, @josephfrazier, @sosukesuzuki, @thorn0)
Previously, a space would be added after the function
keyword in function declarations, but not in function expressions. Now, for consistency, a space is always added after the function
keyword, including in generators. Also, a space is now added between yield
and *
, which can help with catching bugs.
// Prettier stable
const identity = function(value) {
return value;
};
function identity(value) {
return value;
}
const f = function<T>(value: T) {};
// Prettier master
const identity = function (value) {
return value;
};
function identity(value) {
return value;
}
const f = function <T>(value: T) {};
// Prettier stable
function* foo<T>() {}
class Bar {
static *foo<T>() {
yield* foo<T>();
}
}
baz = {
async *foo<T>() {}
};
f = function*<T>() {};
// Prettier master
function *foo<T>() {}
class Bar {
static *foo<T>() {
yield *foo<T>();
}
}
baz = {
async *foo<T>() {}
};
f = function *<T>() {};