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

chore: add type checking to build script #31

Closed
wants to merge 4 commits into from

Conversation

matthiasweiss
Copy link
Contributor

Since my editor showed my a type error in the ResetPassword component, I tried to add type checking to the build script. There are currently multiple type errors within the starter kit, a full list can be found down below.

Has type checking been omitted on purpose? If not, I'd be glad to add it & fix up the errors that are currently in there.


The full list of type errors is the following:

~/Code/laravel-react-starter-kit npm run build

> build
> tsc && vite build

resources/js/pages/auth/login.tsx:25:72 - error TS2344: Type 'LoginForm' does not satisfy the constraint 'FormDataType'.
  Index signature for type 'string' is missing in type 'LoginForm'.

25     const { data, setData, post, processing, errors, reset } = useForm<LoginForm>({
                                                                          ~~~~~~~~~

resources/js/pages/auth/register.tsx:20:72 - error TS2344: Type 'RegisterForm' does not satisfy the constraint 'FormDataType'.
  Index signature for type 'string' is missing in type 'RegisterForm'.

20     const { data, setData, post, processing, errors, reset } = useForm<RegisterForm>({
                                                                          ~~~~~~~~~~~~

resources/js/pages/auth/reset-password.tsx:24:72 - error TS2344: Type 'ResetPasswordForm' does not satisfy the constraint 'FormDataType'.
  Index signature for type 'string' is missing in type 'ResetPasswordForm'.

24     const { data, setData, post, processing, errors, reset } = useForm<ResetPasswordForm>({
                                                                          ~~~~~~~~~~~~~~~~~

resources/js/pages/welcome.tsx:221:46 - error TS2322: Type '"plus-darker"' is not assignable to type 'MixBlendMode | undefined'.

221                                     style={{ mixBlendMode: 'plus-darker' }}
                                                 ~~~~~~~~~~~~


Found 4 errors in 4 files.

Errors  Files
     1  resources/js/pages/auth/login.tsx:25
     1  resources/js/pages/auth/register.tsx:20
     1  resources/js/pages/auth/reset-password.tsx:24
     1  resources/js/pages/welcome.tsx:221

@GiannisGialamas
Copy link
Contributor

+1 also have these errors.

@matthiasweiss
Copy link
Contributor Author

The error in welcome.tsx seems to be due to an issue in the csstype package.

Their union type for MixBlendMode does not include plus-darker, so we can only assert it.

@matthiasweiss
Copy link
Contributor Author

The other errors seem to be caused by the inertia package, see the discussion on inertiajs/inertia#2060.

While the errors are not caused by the starter kit, I still think, that adding type checking is highly valuable.

@matthiasweiss
Copy link
Contributor Author

I've added a PR to the inertia repository that should fix this issue, see inertiajs/inertia#2246 for more information.

@christophstockinger
Copy link

I have created two PRs, which also fixes this problem here. @matthiasweiss @taylorotwell
#36 #37

@matthiasweiss
Copy link
Contributor Author

matthiasweiss commented Feb 25, 2025

Since switching from interface to type solves the type errors, I'd highly suggest to do so.

I've already created a PR (#47), which changes all type definitions from interface to type.

Let me know what you think @tnylea @taylorotwell

@taylorotwell
Copy link
Member

#37

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.

4 participants