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 issues #77

Open
Akkuma opened this issue Apr 8, 2024 · 0 comments
Open

TypeScript issues #77

Akkuma opened this issue Apr 8, 2024 · 0 comments

Comments

@Akkuma
Copy link

Akkuma commented Apr 8, 2024

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

According to https://arethetypeswrong.github.io/?p=permitio%402.4.1 there appears to be TS issues.

While developing it also comes across as problematic. Using permit.api.roles.create is the one I came across so far, if I Go to Definition in VS Code I get:

    /**
     * Creates a new role.
     *
     * @param roleData The data for the new role.
     * @returns A promise that resolves to the created role.
     * @throws {@link PermitApiError} If the API returns an error HTTP status code.
     * @throws {@link PermitContextError} If the configured {@link ApiContext} does not match the required endpoint context.
     */
    async create(roleData) {
        await this.ensureAccessLevel(context_1.ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY);
        await this.ensureContext(context_1.ApiContextLevel.ENVIRONMENT);
        try {
            return (await this.roles.createRole(Object.assign(Object.assign({}, this.config.apiContext.environmentContext), { roleCreate: roleData }))).data;
        }
        catch (err) {
            this.handleApiError(err);
        }
    }

Unfortunately, that has no type information available for me to inspect roleData or the return type.

If I instead do Go to Type Definition, I get only the return type RoleRead pulled up, which doesn't take me to the type of create nor show RoleCreate. The only way to navigate there is to instead use Go to Implementations, which I've never had to do before

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Ideally one could navigate to the type definition as expected.

EDIT: The tsconfig.json is targeting a much lower version than expected, so generally out of date https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping. Ideally this should be targeting ES2022 as node 16 is EOL.

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

1 participant