Skip to content

fix: correct typecheck issues#1526

Open
gjtorikian wants to merge 2 commits intomainfrom
fix/correct-typecheck
Open

fix: correct typecheck issues#1526
gjtorikian wants to merge 2 commits intomainfrom
fix/correct-typecheck

Conversation

@gjtorikian
Copy link
Contributor

Description

If you npm run typecheck on main, it errors:

> @workos-inc/node@8.9.0 typecheck
> tsc --noEmit

src/roles/serializers/role.serializer.ts:3:75 - error TS2322: Type '{ object: "role"; id: string; name: string; slug: string; description: string | null; permissions: string[]; type: "EnvironmentRole" | "OrganizationRole"; createdAt: string; updatedAt: string; }' is not assignable to type 'Role'.
  Property 'resourceTypeSlug' is missing in type '{ object: "role"; id: string; name: string; slug: string; description: string | null; permissions: string[]; type: "EnvironmentRole" | "OrganizationRole"; createdAt: string; updatedAt: string; }' but required in type 'OrganizationRole'.

  3 export const deserializeRole = (role: OrganizationRoleResponse): Role => ({
                                                                              ~
  4   object: role.object,
    ~~~~~~~~~~~~~~~~~~~~~~
...
 12   updatedAt: role.updated_at,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 13 });
    ~

  src/authorization/interfaces/organization-role.interface.ts:8:3
    8   resourceTypeSlug: string;
        ~~~~~~~~~~~~~~~~
    'resourceTypeSlug' is declared here.


Found 1 error in src/roles/serializers/role.serializer.ts:3

organization-domain.serializer.ts was also missing a serializer.

This PR corrects those errors. It also adds typecheck to CI to prevent this in the future.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@gjtorikian gjtorikian requested a review from nicknisi March 19, 2026 00:20
@gjtorikian gjtorikian requested review from a team as code owners March 19, 2026 00:20
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 19, 2026

Greptile Summary

This PR fixes two TypeScript type errors that caused npm run typecheck to fail on main, and adds a typecheck step to CI to prevent future regressions.

Key changes:

  • src/roles/serializers/role.serializer.ts: Adds the missing resourceTypeSlug: role.resource_type_slug field mapping. Both EnvironmentRole and OrganizationRole require resourceTypeSlug, and the corresponding resource_type_slug field is present on OrganizationRoleResponse, so the fix is correct and complete.
  • src/organization-domains/serializers/organization-domain.serializer.ts: Adds the missing serializeOrganizationDomain function (inverse of the existing deserializeOrganizationDomain). All fields, including the optional verificationToken and verificationPrefix (handled via conditional spread), are correctly mapped to their snake_case counterparts in OrganizationDomainResponse.
  • .github/workflows/ci.yml: Adds npm run typecheck between the lint and build steps, ensuring TypeScript compilation errors are caught in CI on every push and pull request.

Confidence Score: 5/5

  • This PR is safe to merge — all changes are targeted bug fixes with no logic changes or security implications.
  • The role serializer fix is a straightforward one-line addition of a field that already exists in the source interface. The new serializeOrganizationDomain function faithfully mirrors the existing deserializeOrganizationDomain and correctly handles all required and optional fields. The CI change is additive and low risk.
  • No files require special attention.

Important Files Changed

Filename Overview
src/roles/serializers/role.serializer.ts Adds the missing resourceTypeSlug: role.resource_type_slug mapping to fix the TypeScript error; straightforward and correct since resource_type_slug exists in OrganizationRoleResponse and resourceTypeSlug is required in both EnvironmentRole and OrganizationRole.
src/organization-domains/serializers/organization-domain.serializer.ts Adds the missing serializeOrganizationDomain function that correctly maps all fields from OrganizationDomain to OrganizationDomainResponse, including optional spread handling for verificationToken and verificationPrefix.
.github/workflows/ci.yml Adds npm run typecheck step to CI pipeline between lint and build, which will prevent future type regressions from being merged undetected.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[API Response\nsnake_case JSON] -->|deserializeOrganizationDomain| B[OrganizationDomain\ncamelCase object]
    B -->|serializeOrganizationDomain NEW| A

    C[OrganizationRoleResponse\nsnake_case JSON] -->|deserializeRole FIXED| D[Role\nEnvironmentRole or OrganizationRole]

    subgraph role_fix [Role Serializer Fix]
        C
        D
        E[resource_type_slug] -->|maps to| F[resourceTypeSlug]
    end

    subgraph domain_new [New Organization Domain Serializer]
        A
        B
        G[verification_token optional] -->|spread maps to| H[verificationToken optional]
        I[verification_prefix optional] -->|spread maps to| J[verificationPrefix optional]
    end
Loading

Last reviewed commit: "add typechecking to ..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant