Incorrect TS2345 error reported in template string


Webstorm is incorrectly reporting a TS2345 error (Argument of type 'TemplateStringsArray' is not assignable to parameter of type 'string | RegExp' . . . )

in this code:

return `${myString.split` `[0]}`;

Maybe it's complaining about the nested template, but this is completely valid syntax, and executes correctly.

评论操作 固定链接

Perhaps my code isn't truly valid TS after all.  myString might need to be a TemplateStringsArray instead of a string. 


Investigating . . .