
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
svelte-ts-preprocess
Advanced tools
!!! THIS PREPROCESSOR IS VERY EXPERIMENTAL !!!
Typescript type-checking preprocessor for Svelte 3.
Install with npm or yarn:
npm install --save-dev svelte-ts-preprocess
Then import the plugin to your bundler config. Rollup example below.
import svelte from 'rollup-plugin-svelte';
import ts from 'svelte-ts-preprocess';
...
export default {
...
plugins: [
svelte({
...
preprocess: [
ts()
]
}),
...
]
};
Or use it with svelte-preprocess:
import svelte from 'rollup-plugin-svelte';
import ts from 'svelte-ts-preprocess';
import preprocess from 'svelte-preprocess';
...
export default {
...
plugins: [
svelte({
...
preprocess: preprocess({
transformers: {
ts: ts().script
},
aliases: [
['ts', 'typescript']
]
})
}),
...
]
};
By default Typescript options will be retrieved from tsconfig.json but you also can pass config object directly to the preprocessor function. You should choose one of this variants to get it work.
After preprocessor is setted up you'll be able to write Typescript code inside of component's script.
<script lang="ts">
interface HTMLInputTarget {
"target": HTMLInputElement;
}
export let num: number = 0;
function handleChange(e: HTMLInputTarget) {
num = e.target.value;
}
</script>
<input on:change={handleChange} placeholper="Enter a number">
And will get type-checking warnings upon building process.
./src/App.svelte (9,2): Type 'string' is not assignable to type 'number'.
MIT
FAQs
Typescript preprocessor for Svelte 3
The npm package svelte-ts-preprocess receives a total of 2 weekly downloads. As such, svelte-ts-preprocess popularity was classified as not popular.
We found that svelte-ts-preprocess demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.