Skip to content

Support @ts-ignore for suppressing errors in template literals #51600

Open
@rishipal

Description

@rishipal

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:

function bar(x: string) { console.log(x);}
function foo(x: string) {  console.log(x); }

// @ts-ignore
bar`error in the line below  
${foo(true)} 
is not suppressed`

This does not work either (attempt2):

bar`error in the line below  
// @ts-ignore 
${foo(true)} 
is not suppressed`

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions