victory icon indicating copy to clipboard operation
victory copied to clipboard

Ts build fail TS1110: Type expected.

Open 98DE9E1F opened this issue 1 year ago • 3 comments

Describe the bug A clear and concise description of what the bug is.

/Users/bafan/tuya/doberman-front/node_modules/victory-core/lib/victory-util/events.d.ts(9,42) TS1110: Type expected.

the code is

export declare type ComponentEventName = `on${Capitalize<string>}`;

Victory version Which npm version are you using? 6.14.7 typescript 3.8.3

98DE9E1F avatar Aug 05 '22 06:08 98DE9E1F

TypeScript 4.1 introduced these Template Literal Types ... so this issue appears to be due to the older TypeScript version being used.

That being said, I'll investigate how often we use this syntax, and see if we could drop it, to increase TS compatibility.

scottrippey avatar Aug 09 '22 22:08 scottrippey

@gksander We currently use "Template Literal Types" syntax in 2 places: [ComponentEventName] and [SafeAttribute]. Neither is too critical, and only provides a tiny-bit of type safety, so what do you think about replacing these types with string, in order to improve TS compatibility with <4.1?

scottrippey avatar Aug 09 '22 22:08 scottrippey

That sounds reasonable to me. I wonder if there's any way to fork a type based on TS version it's being used on 🤔 I'm not aware of any mechanism, but it certainly would be nice to use template literals and then TS just fallback to strings on TS <4.1.

gksander avatar Aug 09 '22 23:08 gksander

Fixed in 36.6.1 👍

scottrippey avatar Aug 16 '22 21:08 scottrippey