Strange wrapping with typescript and rest operator

 

I am not sure what are these grey arrows mean, but I've got this strange wrapping with TypeScript and React in WebStorm.

 

Can I fix this?

0
7 comments

what wrapping are you talking about? Is it about code folding, or? Please share a code snippet the issue can be reproduced with

0
Avatar
Permanently deleted user

It is about folding, and wrapping to the next line. It happens using Typescript and React Native. So this happens on `.tsx`  files

 

Here is an example of code:

import React, { FC } from 'react';
import { View } from 'react-native';
import { MarkerProps } from 'react-native-maps';

export interface ITeddyMarkerDraggable extends MarkerProps {
}

const TeddyMarkerDraggable: FC<ITeddyMarkerDraggable> = ({
props,
...rest,
}) => <View />;

export default TeddyMarkerDraggable;


And an image to illustrate the issue:

As you can see the spread argument `...rest` is folded in 3 lines. Also not visible on the screenshot, there is a comma on the right of the Type annotation hint

0

can't reproduce

from your screenshot it seems that the code is not parsed properly. What errors are reported? what IDE version is it?

0
Avatar
Permanently deleted user

I am using WebStorm 2019.3.4

 

Here is code sample without linting errors:

import React, { FC } from 'react';
import { Text, TextProps } from 'react-native';

export interface ITeddyMarkerDraggable extends TextProps {
description: string;
}

const TeddyMarkerDraggable: FC<ITeddyMarkerDraggable> = ({
description,
...rest
}) => {
return <Text {...rest}>{description}</Text>;
};

export default TeddyMarkerDraggable;



I have just realised that it happens only if the window is not large enough:
working version:

problematic version:


Also, I just noticed this only happens with Editor > General > Soft Wraps > Soft-wrap files: * enabled

0
Avatar
Permanently deleted user

It seems this issue might be related:
https://youtrack.jetbrains.com/issue/WEB-43954

0
Avatar
Permanently deleted user

Thank you very much!

0

Please sign in to leave a comment.