Prettier 1.11.1
Playground link
Input:
function y() {
const finalConfiguration =
<Immutable.Map<string, any>>someExistingConfigMap.mergeDeep(fallbackOpts);
if(true) {
const finalConfiguration =
<Immutable.Map<string, any>>someExistingConfigMap.mergeDeep(fallbackOptions);
}
}
Output:
function y() {
const finalConfiguration = <Immutable.Map<
string,
any
>>someExistingConfigMap.mergeDeep(fallbackOpts);
if (true) {
const finalConfiguration = <Immutable.Map<
string,
any
>>someExistingConfigMap.mergeDeep(fallbackOptions);
}
}
Expected behavior:
First assignment would be left as is. The second assignment, which can't fit on one line even with a break after the equals sign, would be rewritten to something like:
if(true) {
const finalConfiguration = <Immutable.Map<string, any>>(
someExistingConfigMap.mergeDeep(fallbackOptions)
);
}
(Adding the parentheses around the expression that's subject to the type assertion is clearer, imo, than:
if(true) {
const finalConfiguration = <Immutable.Map<string, any>>
someExistingConfigMap.mergeDeep(fallbackOptions);
where the type assertion might be read as applying to someExistingConfigMap and not the result of mergeDeep).
Prettier 1.11.1
Playground link
Input:
Output:
Expected behavior:
First assignment would be left as is. The second assignment, which can't fit on one line even with a break after the equals sign, would be rewritten to something like:
(Adding the parentheses around the expression that's subject to the type assertion is clearer, imo, than:
where the type assertion might be read as applying to
someExistingConfigMapand not the result ofmergeDeep).