pixelygroup / keycloak-koa-connect

koa2 keycloack connect
Apache License 2.0
10 stars 5 forks source link

Typescript build fail #11

Open LoiKos opened 4 years ago

LoiKos commented 4 years ago

Hi there, i tried to use your package with typescript and when i tried build my project using tsc i get a whole bunch of errors coming from your lib:

$ tsc --build tsconfig.build.json
node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant.ts:23:10 - error TS2564: Property 'accessToken' has no initializer and is not definitely assigned in the constructor.

23   public accessToken: Token;
            ~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant.ts:24:10 - error TS2564: Property 'refreshToken' has no initializer and is not definitely assigned in the constructor.

24   public refreshToken: Token;
            ~~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant.ts:25:10 - error TS2564: Property 'idToken' has no initializer and is not definitely assigned in the constructor.

25   public idToken: Token;
            ~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant-manager.ts:66:5 - error TS2532: Object is possibly 'undefined'.

66     options.headers['Content-Length'] = data.length;
       ~~~~~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant-manager.ts:301:38 - error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[token: any, callback: any]'.

301     return this.userInfo.apply(this, arguments);
                                         ~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant-manager.ts:363:21 - error TS2345: Argument of type 'Promise<unknown>' is not assignable to parameter of type 'never'.

363       promises.push(validateGrantToken(grant, 'accessToken'));
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant-manager.ts:366:25 - error TS2345: Argument of type 'Promise<unknown>' is not assignable to parameter of type 'never'.

366           promises.push(validateGrantToken(grant, 'refreshToken'));
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/middleware/auth-utils/grant-manager.ts:369:25 - error TS2345: Argument of type 'Promise<unknown>' is not assignable to parameter of type 'never'.

369           promises.push(validateGrantToken(grant, 'idToken'));
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/uuid.ts:8:5 - error TS2322: Type 'string' is not assignable to type 'never'.

8     s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      ~~~~

node_modules/@pixelygroup/keycloak-koa-connect/uuid.ts:10:3 - error TS2322: Type 'string' is not assignable to type 'never'.

10   s[14] = '4';
     ~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/uuid.ts:11:3 - error TS2322: Type 'string' is not assignable to type 'never'.

11   s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
     ~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/uuid.ts:12:3 - error TS2322: Type 'string' is not assignable to type 'never'.

12   s[8] = s[13] = s[18] = s[23] = '-';
     ~~~~

node_modules/@pixelygroup/keycloak-koa-connect/uuid.ts:12:10 - error TS2322: Type 'string' is not assignable to type 'never'.

12   s[8] = s[13] = s[18] = s[23] = '-';
            ~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/uuid.ts:12:18 - error TS2322: Type 'string' is not assignable to type 'never'.

12   s[8] = s[13] = s[18] = s[23] = '-';
                    ~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/uuid.ts:12:26 - error TS2322: Type 'string' is not assignable to type 'never'.

12   s[8] = s[13] = s[18] = s[23] = '-';
                            ~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/index.ts:113:22 - error TS2345: Argument of type '(ctx: any, next: any) => Promise<void>' is not assignable to parameter of type 'never'.

113     middlewares.push(Setup);
                         ~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/index.ts:115:22 - error TS2345: Argument of type '(ctx: any, next: any) => Promise<any>' is not assignable to parameter of type 'never'.

115     middlewares.push(Admin(this, option.admin));
                         ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/index.ts:116:22 - error TS2345: Argument of type '(ctx: any, next: any) => Promise<void>' is not assignable to parameter of type 'never'.

116     middlewares.push(GrantAttacher(this));
                         ~~~~~~~~~~~~~~~~~~~

node_modules/@pixelygroup/keycloak-koa-connect/index.ts:117:22 - error TS2345: Argument of type '(ctx: any, next: any) => Promise<any>' is not assignable to parameter of type 'never'.

117     middlewares.push(Logout(this, option.logout));

I am currently using typescript 4.0.

configuration is the following

// tsconfig.json
{
  "extends": "@tsconfig/node12/tsconfig.json",

  "compilerOptions": {
    "preserveConstEnums": true,
    "outDir": "dist",
    "resolveJsonModule": true,
  }
}

// tsconfig.build.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "noImplicitAny": false,
  },

  "include": ["app/**/*", "extension.d.ts"],
  "exclude": ["node_modules", "**/*.spec.ts"]
}

and the failing command is : tsc --build tsconfig.build.json

Do you have any ideas how i can fixed that ?

aorlowskiddm commented 9 months ago

Same issue here.