From 71cbfeded447b7d6b7da29d03a701dc26660d070 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 9 Jan 2019 14:46:52 +0100 Subject: [PATCH] trusted-types: Prevent structural typing --- types/trusted-types/index.d.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/types/trusted-types/index.d.ts b/types/trusted-types/index.d.ts index 64ed96b713..2d2db62999 100644 --- a/types/trusted-types/index.d.ts +++ b/types/trusted-types/index.d.ts @@ -3,10 +3,21 @@ // Definitions by: Jakub Vrana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare class TrustedHTML {} -declare class TrustedScript {} -declare class TrustedScriptURL {} -declare class TrustedURL {} +declare class TrustedHTML { + private readonly _TrustedHTMLBrand: true; // To prevent structural typing. +} + +declare class TrustedScript { + private readonly _TrustedScriptBrand: true; // To prevent structural typing. +} + +declare class TrustedScriptURL { + private readonly _TrustedScriptURLBrand: true; // To prevent structural typing. +} + +declare class TrustedURL { + private readonly _TrustedURL: trueBrand; // To prevent structural typing. +} declare class TrustedTypePolicy { createHTML(s: string): TrustedHTML;