TS2416: Property 'canActivate' in type 'MyGuard' is not assignable to the same property in base type 'CanActivate'

ts2416 typescript
property 'render' is missing in type
property state is not assignable

I have written an angular 4.3.0 typescript library. While building my library I saw below error in *.d.ts file.

ERROR in [at-loader] ..\myLibrary\lib-commonjs\my-guard.service.d.ts:13:5 TS2416: Property 'canActivate' in type 'MyGuard' is not assignable to the same property in base type 'CanActivate'. Type '(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) => boolean | Promise | Observ...' is not assignable to type '(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => boolean | Observable | Pr...'. Type 'boolean | Promise | Observable' is not assignable to type 'boolean | Observable | Promise'. Type 'Observable' is not assignable to type 'boolean | Observable | Promise'. Type 'Observable' is not assignable to type 'Promise'. Property '[Symbol.toStringTag]' is missing in type 'Observable'.

This is how my guard looks like

  @Injectable()
    export class MyGuard implements CanActivate {
         canActivate( next: ActivatedRouteSnapshot ,state: RouterStateSnapshot):  Observable<boolean> | Promise<boolean> | boolean  {
return true;
        }
    }

The error goes away after I removed the return type (Observable | Promise | boolean ) from canActivate. I want to understand why I need to remove it to make it work.

 canActivate( next: ActivatedRouteSnapshot ,state: RouterStateSnapshot)  {
    }

Error


The error you are facing is because you copied the code that is for a different version of Angular than what you are using.

The error went away when you removed the return value because you made the function compatible with the version you have on your machine.

You can check the function signature at your current version by navigating to CanActivate on your machine. If you are using Visual Studio Code, you can press Ctrl and click on it to navigate to its file.

generic type extends has TS2416 error · Issue #22198 · microsoft , d.ts(29,5): error TS2416: Property 'inputs' in type 'WorkflowStep<T>' is not assignable to the same property in base  RxJS version: "^5.5.6", Code to reproduce: Expected behavior: Actual behavior: Additional information:


@user911 - I recently started learning angular and fortunately came up with the same issue.

The reason for the error would probably be that your IDE accidentally imported Promise from 'q' import {Promise} from 'q'; remove this and you can even declare the return type of the canActivate method which is Observable< boolean> | Promise< boolean> | boolean.

The import is the only reason for which your app works fine when you remove the return type of the canActivate method.

Try this for better understanding:

  1. Make sure you define the return type of the canActivate method and while defining the type let IDE automatically import the Promise from q or import it manually.

  2. As we expect there will be error and now remove Promise< boolean> from the return type and the error should go away unless you are returning a promise with your canActivate method.

TS2416: Property 'canActivate' in type 'MyGuard' is not assignable to , The error you are facing is because you copied the code that is for a different version of Angular than what you are using. The error went away  The TS-2000 can be found in hotels, restaurants, retail stores, shopping centers, property management and more. This radio is the complete package for your business needs. The Maxon TS-2000 package comes complete with the radio and also the antenna, battery, charger, belt clip, and user manual.


The problem is in the returned types. This works for me:

canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | 
boolean | UrlTree {

}

TypeScript issue with class properties : typescript, src/app/layout/Main.tsx:11:3 - error TS2416: Property 'state' in type 'App' is not assignable to the same property in base type 'Component<Props, State>'. Right, because having a callback taking a T makes the class contravariant in T. As for fixing your situation, is the base class even needed? You could just move the contents of WorkflowStepBase into WorkflowStep, replacing StepBody with T.


Change this (: Observable<boolean> | Promise<boolean> | boolean ) to :any would definitely work for you

I've got a TS bug and I think it's because I'm stupid : typescript, d.ts(23,5): error TS2416: Property 'level' in type 'LocalLogger' is not assignable to the same property in base type 'LoggerInterface  Type '<T2, P extends keyof T2>(obj: T2, property: P) => void' is not assignable to type '<T2, P extends keyof T2>(obj: T2, property: P) => void'. Two different types with this name exist, but they are unrelated. Types of parameters 'property' and 'property' are incompatible. Type 'P' is not assignable to type 'keyof T2'.


For me, I put in the return type Observable< Boolean> | Promise< Boolean> | Boolean isntead of Observable< boolean> | Promise< boolean> | boolean. When I replace it works.

The 5.1.1 update to kendo-angular-buttons is breaking the grid , error TS2416: Property 'click' in type 'AddCommandDirective' is not assignable to the same property in base type 'ButtonDirective'. Type '(e:  The property pane allows end users to configure the web part with several properties. The article Build your first web part describes how the property pane is defined in the HelloWorldWebPart class. The property pane properties are defined in propertyPaneSettings. A property pane has three key


T752037, node_modules/devexpress-reporting/dx-reportdesigner.d.ts:14794:17 - error TS2416: Property 'initialize' in type 'ReportWizard' is not  The type variable K, which gets bound to each property in turn. The string literal union Keys, which contains the names of properties to iterate over. The resulting type of the property. In this simple example, Keys is a hard-coded list of property names and the property type is always boolean, so this mapped type is equivalent to writing:


visual studio 2017 type script error TS2416 - angularjs - html, getting the following error in visual studio 17 when i run the program Error TS2416 Property 'lift' in type 'Subject' is not assignable to the same property in base  This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. Read more about our automatic conversation locking policy.


Error TS6200: Definitions of some identifiers conflict, ts(37,9): error TS2416: Property 'render' in type 'SimpleDayGrid' is not assignable to the same property in base type 'DateComponent<  I changed my code from commented line to the one below and it started working. I believe the latest 7.1.1 has changed code or fixed it. Am less than a week into angular/web technologies, I appreciate if someone can explain if this is right way to fix it or is there a better way to do it?