Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #7

Closed
Alexnortung opened this issue Feb 22, 2023 · 4 comments
Closed

Typescript support #7

Alexnortung opened this issue Feb 22, 2023 · 4 comments

Comments

@Alexnortung
Copy link

Currently, when adding the config object to the router, the key roles is not part of the type HandlerConfig

// api/page/routes/page.ts
/**
 * page router
 */

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::page.page', {
  config: {
    find: {
      roles: ['public'],
    },
    findOne: {
      // @ts-ignore - this is specified in strapi-plugin-route-permissions
      roles: ['public'],
    },
  }
});

Diagnostics:

1. Type '{ roles: string[]; }' is not assignable to type 'HandlerConfig'.
     Object literal may only specify known properties, and 'roles' does not exist in type 'HandlerConfig'.

Solution:

A solution would be to provide type definitions that would extend on the strapi HandlerConfig type.

@PaulRichez
Copy link
Owner

I just notice, i will investigate

@BayBreezy
Copy link

Any headway on this?

@PaulRichez
Copy link
Owner

@BayBreezy i didnt fond a solution actually, you Can juste add ts-ignore for this lane

@BayBreezy
Copy link

OK cool cool. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants