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
[1.x] Add opt-in TypeScript support #267
Conversation
75f9848
to
efcc5db
Compare
Yes yes yes!! I've wanted to dive into TypeScript for a while but never knew where to begin. This will be a fantastic base (and learning curve). |
Great addition! Love that strict mode is enabled by default 👌 Thank you!! |
Amazing 😍 Curious enough I was planning to work on something similar so I guess I need to find something else to be my first contribution here. |
It will be a great impactful addition ❤️. |
Wiii make life easy! Thanks man |
How did you get the dropdown in ur picture? my statusbar of vscode at the bottom does not show me the typescript version i need to click on as per the vscode docs https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript |
From the Command Palette (Ctrl+Shift+P) just type |
Thanks. This indeed fixed those errors for me. @jessarcher a possible solution could be defining useImperativeHandle like this: However when doing this and accessing the input element like |
Yay! Thank you Laravel team! <3 |
Great works, Thanks! |
i cannot get the command for creating a new project with typescript support. like this: laravel new app --breeze dosen't show the typescript options thanks. |
Hi @abderrahim-kharit these are different repos, one is your usual Laravel installation, the other is for the Breeze package. Take a look at Laravel Breeze Installation, when issuing the A step by step would be: composer create-project laravel/laravel example-app
cd example-app
composer require laravel/breeze --dev
php artisan breeze:install --typescript |
Hi @jessarcher I'm sorry for mention vue : 3.4.19 I install fresh using latest breeze - Here my global.d.ts from breeze import { PageProps as InertiaPageProps } from '@inertiajs/core';
import { AxiosInstance } from 'axios';
import { route as ziggyRoute } from 'ziggy-js';
import { PageProps as AppPageProps } from './';
declare global {
interface Window {
axios: AxiosInstance;
}
const route: typeof ziggyRoute;
}
declare module 'vue' {
interface ComponentCustomProperties {
route: typeof ziggyRoute;
}
}
declare module '@inertiajs/core' {
interface PageProps extends InertiaPageProps, AppPageProps {}
} Here my index.d.ts from breeze import { Config } from 'ziggy-js';
export interface User {
id: number;
name: string;
email: string;
email_verified_at: string;
}
export type PageProps<T extends Record<string, unknown> = Record<string, unknown>> = T & {
auth: {
user: User;
};
ziggy: Config & { location: string };
}; I think this is just my IDE problem, but here my type check Or I have some error/missmatch config ? |
I think this issue will solve on inertia inertiajs/inertia#1794 |
This PR introduces opt-in TypeScript support for the Vue and React stacks.
It can be installed by passing the
--typescript
flag to the installer. When no arguments are given to the installer, the user will be prompted if they select the Vue or React stack.Some details on the implementation
I wanted to set a strong base standard for the community, so strict mode is enabled by default and the
any
type is not used in the scaffolded code. Of course, developers are free to relax this based on their needs. The rest of the TypeScript configuration is based on information from https://vitejs.dev/guide/features.html#typescript.It's important to note that Vite only transpiles the TypeScript, but does not handle type checking. For that reason,
tsc
/vue-tsc
is run as part of the build script.The type noise in the components is pleasantly minimal while offering type safety and vastly improved IDE support.
The Vue components follow the conventions documented at https://vuejs.org/guide/typescript/composition-api.html.
The React components rely on existing React types so that components like
<PrimaryButton>
inherit the prop types for everything on the underlying<button>
.I have included the
--typescript
option in GitHub actions which runs the build script and validates the types, so future PRs cannot inadvertently ship type errors.My only concern with this PR is that it introduces two new sets of stubs to maintain, which will be tedious when adding new features or redesigning. Ultimately I think it's worth it, though.