Enforce template literal expressions to be of string type.
// code-linter.json5
{
"rules": {
"@typescript-eslint/restrict-template-expressions": "error"
}
} const arg: string | undefined = 'foo';
export const msg1 = `arg = ${arg}`;
export const msg2 = `arg = ${arg || 'default'}`; const arg1 = ['1', '2'];
export const msg1 = `arg1 = ${arg1}`;
interface GeneratedObjectLiteralInterface {
name: string;
}
const arg2: GeneratedObjectLiteralInterface = { name: 'Foo' };
export const msg2 = `arg2 = ${arg2 || null}`; plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter.