Open rishipal opened 1 year ago
As a workaround you can place the ts-ignore within the placeholder, but before your expression. That works.
Your suggestion would likely mean that ALL errors in the string are suppressed, something probably unwanted as well.
That's an acceptable workaround.
bar`error in the call below get suppressed
${// @ts-ignore
foo(true)}
`
Would it be possible to introduce a new type of annotation, called ts-ignore-block
(not too attached to the name).
It could work as the initial suggeston in @rishipal 's suggestion:
// @ts-ignore-block
now` all errors in these lines including
${foo(true)}
are all suppressed`
What do you think @MartinJohns @RyanCavanaugh
At Google, we use
@ts-ignore
to suppress build errors when rolling out new TypeScript releases. However, we don't have a mechanism that we can apply in an automated way to suppress errors inside tagged template literals. This comes from the limitation that@ts-ignore
only suppresses errors on the immediate next line, and for errors within a multi-line template the// @ts-ignore
comments get consumed by the literal string itself.Illustrative example with multi-line tagged template literals:
This does not work either (attempt2):
Playground link with relevant code
Actual behavior
The error is not suppressed, and the
// @ts-ignore
comment is consumed in the template literal in attempt2.Expected behavior
Ideally, the error gets suppressed in attempt1.
Search Terms
ts-ignore, tagged-template-literals