1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Trusted types in Angular

Discussão em 'Angular' iniciado por Wave, Outubro 8, 2024.

  1. Wave

    Wave Guest

    I am trying to enable trusted types in Angular. Adding the CSP header is not a problem but once I try to add a custom policy I get the following error.

    If I look at MDN they say the property does exist but is not supported in all browsers.


    ✘ [ERROR] TS2339: Property 'trustedTypes' does not exist on type 'Window & typeof globalThis'. [plugin angular-compiler]

    src/main.ts:13:29:
    13 │ let sanatizer = window.trustedTypes.createPolicy('my-policy', {



    You can reproduce it with opening Angular playground and adding the test method to the component.

    import {Component} from '@angular/core';
    import {bootstrapApplication} from '@angular/platform-browser';

    @Component({
    selector: 'app-root',
    standalone: true,
    template: `
    Hello world!
    `,
    })
    export class PlaygroundComponent {
    public test() : void {
    let sanatizer = window.trustedTypes.createPolicy('my-policy', {

    ));
    }
    }

    bootstrapApplication(PlaygroundComponent);


    What am I missing?

    Continue reading...

Compartilhe esta Página