mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Add trusted-types
This commit is contained in:
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// Type definitions for trusted-types 1.0
|
||||
// Project: https://github.com/WICG/trusted-types
|
||||
// Definitions by: Jakub Vrana <https://github.com/vrana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare class TrustedHTML {}
|
||||
declare class TrustedScript {}
|
||||
declare class TrustedScriptURL {}
|
||||
declare class TrustedURL {}
|
||||
|
||||
declare class TrustedTypePolicy {
|
||||
createHTML(s: string): TrustedHTML;
|
||||
createScript(s: string): TrustedScript;
|
||||
createScriptURL(s: string): TrustedScriptURL;
|
||||
createURL(s: string): TrustedURL;
|
||||
}
|
||||
|
||||
interface TrustedTypeInnerPolicy {
|
||||
createHTML(s: string): string;
|
||||
createScript(s: string): string;
|
||||
createScriptURL(s: string): string;
|
||||
createURL(s: string): string;
|
||||
}
|
||||
|
||||
declare class TrustedTypePolicyFactory {
|
||||
createPolicy(name: string, policy: TrustedTypeInnerPolicy, expose?: boolean): TrustedTypePolicy;
|
||||
getExposedPolicy(name: string): TrustedTypePolicy;
|
||||
getPolicyNames(): string[];
|
||||
}
|
||||
|
||||
declare const TrustedTypes: TrustedTypePolicyFactory;
|
||||
@@ -0,0 +1,17 @@
|
||||
const policy = {
|
||||
createHTML: (s: string) => s,
|
||||
createScript: (s: string) => s,
|
||||
createScriptURL: (s: string) => s,
|
||||
createURL: (s: string) => s,
|
||||
};
|
||||
|
||||
TrustedTypes.getPolicyNames();
|
||||
TrustedTypes.createPolicy('default', policy, true);
|
||||
TrustedTypes.getExposedPolicy('default');
|
||||
|
||||
const trustedTypes = TrustedTypes.createPolicy('test', policy);
|
||||
|
||||
trustedTypes.createHTML('') instanceof TrustedHTML;
|
||||
trustedTypes.createScript('') instanceof TrustedScript;
|
||||
trustedTypes.createScriptURL('') instanceof TrustedScriptURL;
|
||||
trustedTypes.createURL('') instanceof TrustedURL;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"trusted-types-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user