admin管理员组

文章数量:1387285

I'm trying to compile the code below and I get the error: error TS1110: Type expected

import { LayoutBase } from '../layout-base';
import { Style } from '../../styling/style';
import { CssProperty } from '../../core/properties';
import { View } from '../../core/view';
import { CoreTypes } from '../../enums';

export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
export type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
export type FlexFlow = `${FlexDirection} ${FlexWrap}`;

What is wrong with the last line of code.

Error image

I expect the code to run without error

I'm trying to compile the code below and I get the error: error TS1110: Type expected

import { LayoutBase } from '../layout-base';
import { Style } from '../../styling/style';
import { CssProperty } from '../../core/properties';
import { View } from '../../core/view';
import { CoreTypes } from '../../enums';

export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
export type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
export type FlexFlow = `${FlexDirection} ${FlexWrap}`;

What is wrong with the last line of code.

Error image

I expect the code to run without error

Share Improve this question edited Mar 17 at 14:58 Krzysztof Guć asked Mar 17 at 14:53 Krzysztof GućKrzysztof Guć 234 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

You are using older version of TypeScript (below 4.0.5), type interpolation was introduced from version 4.1.5 onwards.

https://www.typescriptlang./play/?ts=4.1.5#code/KYDwDg9gTgLgBDAnmYcBiAbUARAllYAYxlwgDs4BeOAciggHca4AfW+hgWgIDdgoAzsGZsahCBgCuAWzIja4qbO7A+g4QG4AUKEiwEyVJlAB1KAEMwVWmUYWw8mg3uPnllWqE1tu6PCQo6FggmIzWAAYAJADexiB4BMSkZAC+cDFxZpYp4dpAA

You can change version on the left to 4.0.5 to see the same error.

For the best results, you can add typescript as a dev dependency in your project or install new version of typescript globally on your machine.

try to update your typescript may solve your problem because it seems like your using the older version of Typscript

本文标签: Typescriptwhat39s wrongerror TS1110 Type expectedStack Overflow