最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Typescript - what's wrong - error TS1110: Type expected - Stack Overflow

programmeradmin4浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论