Last active
February 17, 2020 05:09
-
-
Save LayZeeDK/2cd1ff1fc605af6f578a39311b3aba99 to your computer and use it in GitHub Desktop.
Angular Ivy detection logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Type, | |
ɵNG_COMP_DEF, | |
ɵNG_DIR_DEF, | |
ɵNG_MOD_DEF, | |
ɵNG_PIPE_DEF, | |
} from '@angular/core'; | |
function isIvy(): boolean { | |
const ng: any = ((self || global || window) as any).ng; | |
return ng === undefined | |
|| ng.getComponent !== undefined | |
|| ng.applyChanges !== undefined; | |
} | |
function isIvyComponent(componentType: Type<any>): boolean { | |
return (componentType as any)[ɵNG_COMP_DEF] !== undefined; | |
} | |
function isIvyDirective(directiveType: Type<any>): boolean { | |
return (directiveType as any)[ɵNG_DIR_DEF] !== undefined; | |
} | |
function isIvyModule(moduleType: Type<any>): boolean { | |
return (moduleType as any)[ɵNG_MOD_DEF] !== undefined; | |
} | |
function isIvyPipe(pipeType: Type<any>): boolean { | |
return (pipeType as any)[ɵNG_PIPE_DEF] !== undefined; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See, it was too late. haha.
Thanks! Updated it.