I'm try to integrate JWT authentication into my loopback 4 application. Right now I've been following the documentation here and the shopping tutorial, but I'm getting a strange build error when I'm registering my authentication strategy.
Here's my application.ts:
export class Application extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
) {
constructor(options?: ApplicationConfig) {
super(options);
this.setUpBindings();
this.component(AuthenticationComponent);
registerAuthenticationStrategy(this, JWTAuthenticationStrategy);
this.sequence(MySequence);
// Set up default home page
this.static('/', path.join(__dirname, '../public'));
this.component(RestExplorerComponent);
this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
controllers: {
// Customize ControllerBooter Conventions here
dirs: ['controllers'],
extensions: ['.controller.js'],
nested: true,
},
};
}
setUpBindings(): void {
// my bindings
}
}
The build script in my package.json (using @loopback/build)
"build": "lb-tsc -p tsconfig.build.json --target es2017 --outDir dist"
Here's the error I'm getting:
npm run build =>
src/application.ts:71:33 - error TS2345: Argument of type 'this' is not assignable to parameter of type 'Context'.
Type 'Application' is not assignable to type 'Context'.
Property 'registry' is protected but type 'Context' is not a class derived from 'Context'.
registerAuthenticationStrategy(this, JWTAuthenticationStrategy);
I am on Windows 10 using powershell.