-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- global types for sveltify & react, these values are imported or generated when used but not defined. - Compatible with `<react:*` notation, but a deprecation warning - PreProcessor injects react dependencies as second argument to sveltify. - Added migration docs Fixes #1 & #32
- Loading branch information
Showing
32 changed files
with
326 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Migration to 2.0 | ||
|
||
Change `<react:MyComponent>` into `<react.MyComponent>` (`:` to `.`). | ||
|
||
When using Typescript, add: | ||
|
||
```ts | ||
const react = sveltify({ MyComponent }); | ||
``` | ||
|
||
in the `<script lang="ts">` section for type safety. | ||
|
||
When getting ESLint no-undef errors: | ||
|
||
in `eslint.config.js` add `sveltify: true` to your globals or add a `import { sveltify } from 'svelte-preprocess-react'`. | ||
|
||
Also add `react: true` if you don't want | ||
|
||
## Why the change? | ||
|
||
In Svelte 5 the compiler gives a warning when using `<react:MyComponent />` syntax: | ||
|
||
> Self-closing HTML tags for non-void elements are ambiguous — use `<react:MyComponent ...></react:MyComponent>` rather than `<react:MyComponent ... />`(element_invalid_self_closing_tag) | ||
Easily solved, but it a less elegant syntax. | ||
|
||
Secondly, the new syntax allows for IDE support. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Component } from "svelte"; | ||
import type { Sveltified } from "./internal/types"; | ||
|
||
declare global { | ||
function sveltify< | ||
T extends { | ||
[key: string]: | ||
| keyof JSX.IntrinsicElements | ||
| React.JSXElementConstructor<any>; | ||
}, | ||
>( | ||
components: T, | ||
): { | ||
[K in keyof T]: K extends keyof JSX.IntrinsicElements | ||
? Sveltified[K] | ||
: Sveltified<T[K]>; | ||
}; | ||
|
||
const react: { | ||
[component: string]: Component; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.