diff --git a/packages/lit-analyzer/src/lib/rules/util/type/is-assignable-binding-under-security-system.ts b/packages/lit-analyzer/src/lib/rules/util/type/is-assignable-binding-under-security-system.ts index b81d439d..8ba92a7b 100644 --- a/packages/lit-analyzer/src/lib/rules/util/type/is-assignable-binding-under-security-system.ts +++ b/packages/lit-analyzer/src/lib/rules/util/type/is-assignable-binding-under-security-system.ts @@ -112,7 +112,7 @@ function matchesAtLeastOneNominalType(typeNames: string[], typeB: SimpleType): b return true; } const normalized = normalizeTypeName(typeBName); - if (normalized !== undefined && typeNames.includes(typeBName)) { + if (normalized !== undefined && typeNames.includes(normalized)) { return true; } } diff --git a/packages/lit-analyzer/src/test/rules/security-system.ts b/packages/lit-analyzer/src/test/rules/security-system.ts index d126b80a..0f42adde 100644 --- a/packages/lit-analyzer/src/test/rules/security-system.ts +++ b/packages/lit-analyzer/src/test/rules/security-system.ts @@ -169,3 +169,29 @@ tsTest(testName, t => { const { diagnostics } = getDiagnostics(preface + "html`
`", { securitySystem: "ClosureSafeTypes" }); hasNoDiagnostics(t, diagnostics); }); + +testName = "Types renamed by Clutz are properly matched against allowed types."; +tsTest(testName, t => { + const { diagnostics } = getDiagnostics( + [ + { + fileName: "main.ts", + text: ` + // A type name known to have been output by Clutz. + class module$contents$goog$html$SafeUrl_SafeUrl {} + + html\`This is a link.\`; + + // A type name of the same format. + class module$some$clutz$name_TrustedResourceUrl {} + + html\`\`; + ` + } + ], + { + securitySystem: "ClosureSafeTypes" + } + ); + hasNoDiagnostics(t, diagnostics); +});