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

fix(sdk): Allow passing readonly arrays #3308

Merged
merged 3 commits into from
May 30, 2024

Conversation

Alexnortung
Copy link
Contributor

@Alexnortung Alexnortung commented May 30, 2024

Description

It should be possible to assign readonly types to Component and other @builder.io/sdk types, since no mutations are(/should) happening.

This is needed to make type inference working in the @oak-digital/builder-helpers package.

See the following example:

import Counter from './counter';

const registerCounter = {
    name: 'Counter',
    inputs: [
        {
            name: 'text',
            type: 'string',
        },
    ];
} as const;

Builder.registerComponent(Counter, registerCounter);

This example would result in a type error while registering the component to builder. This is not really desired, so this PR makes it possible to ALSO assign readonly types.

This PR fixes #3293

@Alexnortung Alexnortung requested a review from a team as a code owner May 30, 2024 13:10
@Alexnortung Alexnortung requested review from samijaber and removed request for a team May 30, 2024 13:10
Copy link

changeset-bot bot commented May 30, 2024

🦋 Changeset detected

Latest commit: 88d9882

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@builder.io/sdk Patch
@builder.io/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented May 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextjs-app-router-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 2:13pm
nextjs-pages-router-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 2:13pm
remix-gen2-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 2:13pm
svelte-vite-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 2:13pm

Copy link
Contributor

@samijaber samijaber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this fix!

@samijaber
Copy link
Contributor

I don't have write permissions to this PR, but we need to add a Changesets file so that we can publish your changes properly. Mind merging this PR or providing write permissions so I can make the change? https://github.com/Oak-Digital/builder/pull/1/files#diff-e1ba98944d0ca436baa0fdf8fb51f74d56e420ea215c44ae93a16aac0392cf97

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

Successfully merging this pull request may close these issues.

TypeScript readonly error
2 participants