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

Property 'get' in type 'ToastInjector' is not assignable to the same property in base type...

Discussão em 'Angular' iniciado por John Mikel, Setembro 26, 2024.

  1. John Mikel

    John Mikel Guest

    error TS2416: Property 'get' in type 'ToastInjector' is not assignable to the same property in base type 'Injector'.

    Type '(token: any, notFoundValue?: T, flags?: InjectFlags) => ToastPackage | T' is not assignable to type '{ (token: ProviderToken, notFoundValue: undefined, options: InjectOptions & { optional?: false; }): T; (token: ProviderToken, notFoundValue: null, options: InjectOptions): T; (token: ProviderToken<...>, notFoundValue?: T, options?: InjectOptions | InjectFlags): T; (token: ProviderToken<...>, notFou...'.

    Types of parameters 'flags' and 'options' are incompatible.
    Type 'InjectOptions & { optional?: false; }' is not assignable to type 'InjectFlags'.


    toast-injector.ts

    import {Injector, InjectFlags} from '@angular/core’;

    import { ToastPackage } from './toast-config';



    export class ToastRef<T> {

    export class ToastInjector implements Injector {

    constructor (

    private _toastPck: ToastPackage,

    private _parntInjtr: Injector

    ) {}


    //eslint-disable-next-line

    get<T> (token: any, notFoundValue?: T, flags?: InjectFlags): T | ToastPackage {

    if (token === ToastPackage) {

    return this. _toastPck;

    }

    return this._parntInjtr.get<T> (token, notFoundValue, flags);

    }

    }


    The issue is coming in angular 16 after upgradation.Actual issue causing at "get". Any suggestion how to handle this get.

    [​IMG]

    Continue reading...

Compartilhe esta Página