typescript

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


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


Solution

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

    https://www.typescriptlang.org/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.