"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "website/blog/2019-06-06-1.18.0.md" between
prettier-1.18.1.tar.gz and prettier-1.18.2.tar.gz

About: Prettier is an opinionated code formatter for JS, JSON, Flow, CSS, Markdown, YAML and more.

2019-06-06-1.18.0.md  (prettier-1.18.1):2019-06-06-1.18.0.md  (prettier-1.18.2)
skipping to change at line 75 skipping to change at line 75
return <div></div>; return <div></div>;
} }
``` ```
## Other changes ## Other changes
### JavaScript ### JavaScript
#### Fix closure compiler typecasts ([#5947] by [@jridgewell]) #### Fix closure compiler typecasts ([#5947] by [@jridgewell])
If a closing parenthesis follows after a typecast in an inner expression, the ty pecast would wrap everything to the that following parenthesis. If a closing parenthesis follows after a typecast in an inner expression, the ty pecast would wrap everything to that following parenthesis.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```js ```js
// Input // Input
test(/** @type {!Array} */ (arrOrString.length)); test(/** @type {!Array} */(arrOrString).length);
test(/** @type {!Array} */ (arrOrString.length + 1)); test(/** @type {!Array} */((arrOrString)).length + 1);
// Output (Prettier stable) // Output (Prettier stable)
test(/** @type {!Array} */ (arrOrString.length)); test(/** @type {!Array} */ (arrOrString.length));
test(/** @type {!Array} */ (arrOrString.length + 1)); test(/** @type {!Array} */ (arrOrString.length + 1));
// Output (Prettier master) // Output (Prettier master)
test(/** @type {!Array} */ (arrOrString.length)); test(/** @type {!Array} */ (arrOrString).length);
test(/** @type {!Array} */ (arrOrString.length + 1)); test(/** @type {!Array} */ (arrOrString).length + 1);
``` ```
#### Fix closure typecasts without spaces ([#6116] by [@jridgewell]) #### Fix closure typecasts without spaces ([#6116] by [@jridgewell])
Previously, a space was required between the `@type` and opening `{` of a closur e typecast, or else the enclosing parenthesis would be removed. Closure itself d oes not require a space. Previously, a space was required between the `@type` and opening `{` of a closur e typecast, or else the enclosing parenthesis would be removed. Closure itself d oes not require a space.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```tsx ```tsx
// Input // Input
const v = /** @type{string} */(value); const v = /** @type{string} */(value);
skipping to change at line 246 skipping to change at line 246
// Output (Prettier stable) // Output (Prettier stable)
export default function log() {}.toString(); export default function log() {}.toString();
export default function log() {} as typeof console.log; // syntax error export default function log() {} as typeof console.log; // syntax error
// Output (Prettier master) // Output (Prettier master)
export default (function log() {}).toString(); export default (function log() {}).toString();
export default (function log() {} as typeof console.log); export default (function log() {} as typeof console.log);
``` ```
#### Address parentheses bugs for edge cases with call and new. ([#6148] by [@ba kkot]) #### Address parentheses bugs for edge cases with call and `new` ([#6148] by [@b akkot])
Adding all and only the necessary parentheses when mixing `new` with function ca lls is tricky. This change fixes two issues where necessary parentheses were omi tted and one when redundant parentheses were added. Adding all and only the necessary parentheses when mixing `new` with function ca lls is tricky. This change fixes two issues where necessary parentheses were omi tted and one when redundant parentheses were added.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```ts ```ts
// Input // Input
new (x()``.y)(); new (x()``.y)();
new (x()!.y)(); new (x()!.y)();
new e[f().x].y() new e[f().x].y()
skipping to change at line 288 skipping to change at line 288
// SyntaxError: Expecting Unicode escape sequence \uXXXX (1:8) // SyntaxError: Expecting Unicode escape sequence \uXXXX (1:8)
// Output (Prettier master) // Output (Prettier master)
const html = /* HTML */ ` const html = /* HTML */ `
<script> <script>
var a = \`\`; var a = \`\`;
</script> </script>
`; `;
``` ```
#### Keep necessary parentheses around the bind expression passed to "new" expre ssion.([#6152] by [@sosukesuzuki]) #### Keep necessary parentheses around bind expressions passed to `new` expressi ons ([#6152] by [@sosukesuzuki])
Previously, Prettier has removed necessary parentheses around the bind expressio n if the result is passed to "new" expression. Previously, Prettier removed necessary parentheses around a bind expression if i t was passed to a `new` expression.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```js ```js
// Input // Input
new (a::b)(); new (a::b)();
// Output (Prettier stable) // Output (Prettier stable)
new a::b(); new a::b();
// Output (Prettier master) // Output (Prettier master)
skipping to change at line 322 skipping to change at line 322
f[(a::b)]; f[(a::b)];
// Output (Prettier master); // Output (Prettier master);
f[a::b]; f[a::b];
``` ```
### TypeScript ### TypeScript
#### Keep trailing comma in TSX type parameters ([#6115] by [@sosukesuzuki]) #### Keep trailing comma in TSX type parameters ([#6115] by [@sosukesuzuki])
Previously, a trailing comma after single type parameter in arrow function was c leaned up. The formatted result is valid as TSX, but is invalid as TSX. This is now fixed in 1.19. Previously, a trailing comma after single type parameter in arrow function was c leaned up. The formatted result is valid as TS, but is invalid as TSX. This is n ow fixed in 1.19.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```tsx ```tsx
// Input // Input
type G<T> = any; type G<T> = any;
const myFunc = <T,>(arg1: G<T>) => false; const myFunc = <T,>(arg1: G<T>) => false;
// Output (Prettier stable) // Output (Prettier stable)
type G<T> = any; type G<T> = any;
const myFunc = <T>(arg1: G<T>) => false; const myFunc = <T>(arg1: G<T>) => false;
// Output (prettier master) // Output (prettier master)
type G<T> = any; type G<T> = any;
const myFunc = <T,>(arg1: G<T>) => false; const myFunc = <T,>(arg1: G<T>) => false;
``` ```
#### Don’t breakup call expressions when the last argument is an arrow function with a simple return type ([#6106] by [@brainkim]) #### Don’t breakup call expressions when the last argument is an arrow function with a simple return type ([#6106] by [@brainkim])
Fixes [an edge case][#6099] where we were splitting up call expressions containi
ng arrow functions with simple return types.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```js ```js
Fixes [an edge-case](#6099) where we were splitting up call expressions containi ng arrow functions with simple return types.
app.get("/", (req, res): void => { app.get("/", (req, res): void => {
res.send("Hello World!"); res.send("Hello World!");
}); });
// Output (Prettier stable) // Output (Prettier stable)
app.get( app.get(
"/", "/",
(req, res): void => { (req, res): void => {
res.send("Hello World!"); res.send("Hello World!");
}, },
); );
// Output (Prettier master) // Output (Prettier master)
app.get("/", (req, res): void => { app.get("/", (req, res): void => {
res.send("Hello World!"); res.send("Hello World!");
}); });
``` ```
#### Keep a pair of parentheses when there are extra pairs. ([#6131] by [@sosuke suzuki]) #### Keep a pair of parentheses when there are extra pairs ([#6131] by [@sosukes uzuki])
Previously, Prettier removes the necessary parentheses when trying to remove unn ecessary parentheses, in TypeScript. Previously, Prettier removed necessary parentheses when trying to remove unneces sary parentheses, in TypeScript.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```ts ```ts
// Input // Input
type G = ((keyof T))[]; type G = ((keyof T))[];
// Output (Prettier stable) // Output (Prettier stable)
type G = keyof T[]; type G = keyof T[];
// Output (prettier master) // Output (prettier master)
type G = (keyof T)[]; type G = (keyof T)[];
``` ```
#### Keep necessary parentheses around non-null assertions. ([#6136] by [@sosuke suzuki], [#6140] by [@thorn0], [#6148] by [@bakkot]) #### Keep necessary parentheses around non-null assertions ([#6136] by [@sosukes uzuki], [#6140] by [@thorn0], [#6148] by [@bakkot])
Previously, Prettier removed necessary parentheses around non-null assertions if the result of the assertion expression was called as a constructor. Previously, Prettier removed necessary parentheses around non-null assertions if the result of the assertion expression was called as a constructor.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```ts ```ts
// Input // Input
const b = new (c()!)(); const b = new (c()!)();
// Output (Prettier stable) // Output (Prettier stable)
const b = new c()!(); const b = new c()!();
skipping to change at line 414 skipping to change at line 415
// Output (Prettier stable) // Output (Prettier stable)
type A<T> = { readonly [P in keyof T]: T[P] }; type A<T> = { readonly [P in keyof T]: T[P] };
// Output (Prettier master) // Output (Prettier master)
type A<T> = { type A<T> = {
readonly [P in keyof T]: T[P]; readonly [P in keyof T]: T[P];
}; };
``` ```
#### Add trailing comma on tuple types with `--trailing-commma=all` ([#6172] by [@sosukesuzuki]) #### Add trailing comma on tuple types with `--trailing-comma=all` ([#6172] by [ @sosukesuzuki])
TypeScript supports a trailing comma on tuple types since version 3.3. TypeScript supports a trailing comma on tuple types since version 3.3.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```ts ```ts
// Input // Input
export type Foo = [ export type Foo = [
number, number,
number, // comment number, // comment
]; ];
skipping to change at line 504 skipping to change at line 505
/> />
</div> </div>
``` ```
### API ### API
#### Prettier now works in Atom again ([#6129] by [@duailibe]) #### Prettier now works in Atom again ([#6129] by [@duailibe])
Atom has a security feature where code containing `eval` is not allowed to be ru n. One of Prettier's dependencies uses `eval` to prevent bundlers from including debug code. We've now made sure that this `eval` does not end up in the code we ship to npm, making Prettier play nice with Atom again. Atom has a security feature where code containing `eval` is not allowed to be ru n. One of Prettier's dependencies uses `eval` to prevent bundlers from including debug code. We've now made sure that this `eval` does not end up in the code we ship to npm, making Prettier play nice with Atom again.
[#5947]: https://github.com/prettier/prettier/pull/5947
[#5979]: https://github.com/prettier/prettier/pull/5979 [#5979]: https://github.com/prettier/prettier/pull/5979
[#6038]: https://github.com/prettier/prettier/pull/6038 [#6038]: https://github.com/prettier/prettier/pull/6038
[#6086]: https://github.com/prettier/prettier/pull/6086 [#6086]: https://github.com/prettier/prettier/pull/6086
[#6088]: https://github.com/prettier/prettier/pull/6088 [#6088]: https://github.com/prettier/prettier/pull/6088
[#6089]: https://github.com/prettier/prettier/pull/6089 [#6089]: https://github.com/prettier/prettier/pull/6089
[#6099]: https://github.com/prettier/prettier/pull/6099
[#6106]: https://github.com/prettier/prettier/pull/6106 [#6106]: https://github.com/prettier/prettier/pull/6106
[#6110]: https://github.com/prettier/prettier/pull/6110 [#6110]: https://github.com/prettier/prettier/pull/6110
[#6115]: https://github.com/prettier/prettier/pull/6115 [#6115]: https://github.com/prettier/prettier/pull/6115
[#6116]: https://github.com/prettier/prettier/pull/6116 [#6116]: https://github.com/prettier/prettier/pull/6116
[#6119]: https://github.com/prettier/prettier/pull/6119 [#6119]: https://github.com/prettier/prettier/pull/6119
[#6127]: https://github.com/prettier/prettier/pull/6127 [#6127]: https://github.com/prettier/prettier/pull/6127
[#6129]: https://github.com/prettier/prettier/pull/6129 [#6129]: https://github.com/prettier/prettier/pull/6129
[#6130]: https://github.com/prettier/prettier/pull/6130 [#6130]: https://github.com/prettier/prettier/pull/6130
[#6131]: https://github.com/prettier/prettier/pull/6131 [#6131]: https://github.com/prettier/prettier/pull/6131
[#6133]: https://github.com/prettier/prettier/pull/6133 [#6133]: https://github.com/prettier/prettier/pull/6133
 End of changes. 15 change blocks. 
14 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)