Skip to content

fix: init admin typings and scaffold regressions#107

Open
Link2Twenty wants to merge 6 commits intostrapi:mainfrom
Link2Twenty:register-types
Open

fix: init admin typings and scaffold regressions#107
Link2Twenty wants to merge 6 commits intostrapi:mainfrom
Link2Twenty:register-types

Conversation

@Link2Twenty
Copy link
Copy Markdown
Contributor

@Link2Twenty Link2Twenty commented Jan 29, 2026

What does it do?

Remove the any from register and update the function so it matches the existing type.
One of the changes is to make App a default export, this is simply to make the linter happy and changing the type might be the correct way to go.

Why is it needed?

Types are good

How to test it?

Load the types in and see the linter is happy.

Related issue(s)/PR(s)

N/A


Edit:
I noticed there was already a type the describes this whole export so I've set it up to use that instead.
While I was in there I realised the mapping of translation keys wasn't happening so I've added that in.
Let me know if yo need that to be a send PR.

Signed-off-by: Andrew Bone <AndrewB05@gmail.com>
addMenuLink['Component'] expects 

```tsx
() => Promise<{
  default: React.ComponentType;
}>;
```

Meaning the component must be the default export

Signed-off-by: Andrew Bone <AndrewB05@gmail.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 29, 2026

⚠️ No Changeset found

Latest commit: 6735b09

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@dosubot
Copy link
Copy Markdown

dosubot Bot commented Jan 29, 2026

Related Documentation

Checked 2 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

- Use the `StrapiAppPlugin` type rather than remaking it
- fix registerTrads so it actually transforms languages. 

Signed-off-by: Andrew Bone <AndrewB05@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
54.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@innerdvations
Copy link
Copy Markdown
Collaborator

Thanks for this! I pushed a change that:

  • adds regression tests around generated admin templates
  • fixes a TS template formatting issue that was producing malformed generated output
  • keeps the JS/TS registerTrads behavior aligned
  • reverts the App default export change for now to stay consistent with current Strapi docs/examples -- I agree it's probably slightly better but I don't want to add unneccessary friction

If this looks good to you still, I’m happy to merge!

@innerdvations innerdvations changed the title Fix types in Register Improve init admin typings and scaffold regressions Apr 23, 2026
@innerdvations innerdvations changed the title Improve init admin typings and scaffold regressions fix: init admin typings and scaffold regressions Apr 23, 2026
@Link2Twenty
Copy link
Copy Markdown
Contributor Author

The reason I changed the export to default was because the addMenuLink type expects it to be a default export. As it stands now it will throw and type error.

addMenuLink: (link: Omit<MenuItem, 'Component'> & {
  Component: () => Promise<{
    default: React.ComponentType;
  }>;
}) => void;

We could fake the import in admin/src/index.ts by wrapping it in an object but it feels a little hoop jumpy

Component: async () => {
  const { App } = await import('./pages/App');

  return {default: App};
},

But other than that everything looks great.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants