-
-
Notifications
You must be signed in to change notification settings - Fork 24
Support Svelte's $$Generic type #306
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
Comments
Thank you for posting issue. The RFC about -- Related to sveltejs/eslint-plugin-svelte#390 |
I see, so it is on the radar somehow but needs some deeper digging. Thanks a bunch. For anyone stumbling across this: for now I simply workaround by defining ...
env: {
...
},
globals: {
$$Generic: 'readonly'
},
... |
@ota-meshi I'm exploring an alternative syntax for this currently, which would look like this: <script lang="ts" generics="T, X extends string">
export let items: T[];
export let key: X;
</script> From an implementation-perspective, how hard would it be for (I'm not saying it's decided that we switch to this syntax yet, but I want to have as much feedback as possible before making the decision) |
Thank you for letting me know. The current idea is to insert virtual code like this: type T = unknown;
type X = string; In TypeScript, this might generate the wrong type like the following example code, but I anticipate no problem within the scope of the checks used in typescript-eslint. <script lang="ts" generics="T extends string | number">
let val: T = 42 // It's a type error in TypeScript.
</script> ↓ Virtual code type T = string | number
let val: T = 42 // It's not an error. Also, `val` is inferred to be of type number. If it works, I think svelte-eslint-parser can handle it the same way. |
It would be nice to keep the $$Generic in inside the script. If you have a lot of generics you can't just write them on one line. And can you keep the types interactive and highlighted as a generics property? |
Why is this not supported? |
It's not supported yet because it's still experimental, which is a valid choice. |
Would love to update to Svelte 4, but the deprecated |
@probablykasper Switch to |
@theodorejb I would love to, but it sounds like |
Would you be open to a PR to add support for the feature, even if it's still just an RFC? If you are focused on other tasks, which I of course understand, I'd try to look into what I can do to help the feature along. We're using generics in multiple production apps and having this break with the upgrade to svelte-4 is a step back for our project setup... |
I think we can add support for |
It's pretty bad dev experience when the official docs say to use these features but then linting fails out of the box when using these features... |
Yes... I'm looking into writing a PR to add support for it, but I haven't gotten around to it yet since I'm not yet familiar with developing eslint-plugin related things^^ |
Yeah also ran into this issue. I thought I was doing something wrong but apparently not |
Temporary workaround for those people who's <script generics="T" lang="ts">
// TODO: REMOVE WHEN https://github.com/sveltejs/svelte-eslint-parser/issues/306 IS FIXED
// eslint-disable-next-line no-undef, @typescript-eslint/no-explicit-any
type X = T | any
export let options = X[] This will get the errors to disappear |
* Created new sveltekit project * Added VS Code launch support for svelte. * Added tailwind and dasiyui * Added helpful resources * Added models generated from swagger. * WIP Added login page * Updated login * Fixed launch config and updated login styles * WIP - login page validation work. * Added api client. * Added problem details * Fixed tests * Fixed tests * WIP Problem details. * Login page refactor * Some cleanup and get events list page * Minor * Store token in localstorage, redirect back to page after login * Logout page * Added api launch config * Fixed formatting. * Change default proxy port to match API. Some work on OAuth login. * Login page fixes * Fixed login page * Swagger fixes * Google login working * Adding other oauth providers * State is google specific * Added shared layout for auth pages. * Few minor oauth updates * Fixed merge build errors * Fixed build errors * Update deps * Applied linting * Regenerated models after Nullable reference types * Added default templates npx swagger-typescript-api generate-templates -o api-templates * Updates to client side model generation * Added ability to pull in fluent validation rules into swagger. * Updated generation * more generation improvements * Improved code gen * More code gen fixes * Updated signup model validation * code gen improvements * Removed constructor * Some cleanup of problem details / validation * Updated swagger config * WIP: MiniValidation with automatic problem details DamianEdwards/MiniValidation#51 * Login and logout flow + dashboard with auth detection. * Reverted some model state changes * Reworked how api client redirects * Added websockets and layout auth redirection * Added samples for both paging and infinity paging * Updated to tanstack query (other one was deprecated) * More example resources * Updated deps * Added paging helpers to json response * Updated server response types and base summary model * Added Events Table component which supports column selection, default summaries (WIP) * Pushed summary updates * FetchClient changes to add middleware and make it more generic * Add global default options to FetchClient, setup global model validator, and global middleware to redirect on 401. * Some small fixes. * some fetch updates * Fixed build warnings * Early WIP - Taillog component * Greatly improved summaries * some query client work * WIP event tail log * Always return search tokens * Updated deps * Added default public env file * Conditionally turn off account creation * Moved oauth to use env * Added exceptionless client * Fixed client warnings and errors by adding trace logging. * changed file type of hook * Fixed app login * Fixed summary formatters * More efficient events tail log. * Added temporary drawer * Added live mode, start of pager. * Moving app base to /next, more FetchClient updates, fix unmount code for eventstail component. * Some styling * More style * Conditionally render summaries * Added new websocket message component to streamline how we listen to events * Working on getting both client apps to run together * Remove lint from build * Handle fallback for /next client app * Fixed logo * Change URL to /next for SPA startup * Change launchUrl to match SPA url * Some paging updates * Added paging summary * Fixed paging * Fixed paging * Fixed the pager on mobile. * Created generic table component (WIP) * forward events https://learn.svelte.dev/tutorial/event-forwarding * Ensure json doesn't get new line inserted * Fixed summary tests * Fixed validation tests * Fixed all tests * Fixed bad auto git merge * Fixed redirect * Added pagination helper. * WIP: Added column sorting * Added column picker * Added ability to navigate to the first page * Fixed binding issue * Fixed callback * Fixed drawer * Use store for drawer and for live view * WIP search and filtering * Added empty table message. * Workaround for $$Generic sveltejs/svelte-eslint-parser#306 * Fixed linting errors, updated deps * Use global fetch / loading * Updated deps * Work arounds for slot forwarding, couldn't reuse let:variable syntax and had to use writables for page. sveltejs/svelte#7021 * use persisted storage for events column options * WIP events drawer * Updated deps * Rearranged models a bit and pulled in some models from the exceptionless client * Added components for time formatting * WIP: Events drawer and overview. * Fix issue with code formatter changing line endings and causing git issues. Turn daisyui banner off. * Parallelize build * Events Sidebar * Ran formatting * Try building just exceptionless all in one image during docker build step * Don't run client tests yet * Try only building app docker image * Set artifact retention * Tweak how we start docker services * Don't wait for docker compose * Debug * Try different approach * Checkout on deploy * Try different docker build * Another parallel approach * Break out deploy * More build tweaks * Add code coverage * Use run-all to run multiple tasks * Revert some CSP policy changes * Comment out unused code to pass lint rules * Allow http gravatar * Add missing logo back * increased sidebar width * WIP - Error and Simple error stack traces * Fixed http file * Updated deps * Reworked how stack traces are rendered * removed extra whitespace. * Whitespace formatting * More styling fixes * make stack trace look nicer * Updated deps * WIP: Clickable filters with ability to enter custom keyword filters. * rearranged loading rendering order in component due to global loader. * Renamed functions * Added more search + log level component * Fixed warning --------- Co-authored-by: Blake Niemyjski <[email protected]>
@Rich-Harris will this be fixed in Svelte 5 because of the new props system? |
|
I see. Is there any issues that need resolving that perhaps I could help work on? |
I'll defer to @ota-meshi and @baseballyama for this question |
I think if someone works on this implementation, it can be added as an experimental feature. |
I'm not sure if this is a bug or a feature but I think
svelte-eslint-parser
doesn't support Svelte's$$Generic
type to type component properties.Relevant information is probably this: sveltejs/eslint-plugin-svelte3#127
The text was updated successfully, but these errors were encountered: