Skip to content

Latest commit

 

History

History
55 lines (48 loc) · 1.37 KB

File metadata and controls

55 lines (48 loc) · 1.37 KB

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.

Functions
// 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) {};
Generators
// 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>() {};