From 2228d026a477aa008d35356be426a1e09438b137 Mon Sep 17 00:00:00 2001 From: Ronen Amiel Date: Fri, 17 Jan 2025 15:47:40 +0200 Subject: [PATCH 1/2] adjust tests to verify no-unnecessary-type-assertion doesn't throw on template expressions with expressions --- .../tests/rules/no-unnecessary-type-assertion.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts b/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts index db8309164efb..c1556d8eed30 100644 --- a/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts @@ -294,12 +294,12 @@ function bar(items: string[]) { }, // https://github.com/typescript-eslint/typescript-eslint/issues/8737 ` -let myString = 'foo'; +const myString = 'foo'; const templateLiteral = \`\${myString}-somethingElse\` as const; `, // https://github.com/typescript-eslint/typescript-eslint/issues/8737 ` -let myString = 'foo'; +const myString = 'foo'; const templateLiteral = \`\${myString}-somethingElse\`; `, 'let a = `a` as const;', From 27ba6f72a352d59f06f658ab7f6b05d8b9642dc2 Mon Sep 17 00:00:00 2001 From: Ronen Amiel Date: Sun, 19 Jan 2025 22:21:16 +0200 Subject: [PATCH 2/2] adjust tests to use declare cosnt instead --- .../tests/rules/no-unnecessary-type-assertion.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts b/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts index c1556d8eed30..d792a6494dc3 100644 --- a/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts @@ -294,13 +294,17 @@ function bar(items: string[]) { }, // https://github.com/typescript-eslint/typescript-eslint/issues/8737 ` -const myString = 'foo'; +declare const myString: 'foo'; const templateLiteral = \`\${myString}-somethingElse\` as const; `, // https://github.com/typescript-eslint/typescript-eslint/issues/8737 ` -const myString = 'foo'; +declare const myString: 'foo'; const templateLiteral = \`\${myString}-somethingElse\`; + `, + ` +const myString = 'foo'; +const templateLiteral = \`\${myString}-somethingElse\` as const; `, 'let a = `a` as const;', {