Typia aka JSON goodness #578
dirk-bester
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
https://github.com/samchon/typia now works with sveltekit via ts-patch which allows it to get its preprocessing done. Recipe below. (needs some duplicate steps removed)
It does this kind of thing:
`
// STRICT VALIDATORS
export function equals(input: unknown | T): input is T;
export function assertEquals(input: unknown | T): T;
export function validateEquals(input: unknown | T): IValidation;
// JSON
export function assertParse(input: string): T; // type safe parser
export function assertStringify(input: T): string; // safe and faster
`
etc. by simply using your Typescript efforts and precompiling the hard parts. To me that makes it a great match for svelte.
So question: is there a way to automate this and package it together so it is seamless for svelte users? I am happy to do the hacking if someone can point me in the right direction.
RECIPE
npm create svelte@latest
npm install sveltestrap
npm install --save-dev eslint-config-prettier eslint-plugin-prettier
git init
npx typia setup
--compiler (ts-patch)
--manager (npm|pnpm|yarn)
--project {tsconfig.json file path}
npm install --save-dev typescript
npm install --save-dev ts-node
npm install --save-dev ts-patch
npx ts-patch install
npm install --save typescript@latest
npm install --save-dev @rollup/plugin-typescript
vite.config.ts
import typescript from '@rollup/plugin-typescript';
plugins: [sveltekit(), typescript()],
package.json
"scripts": {
"prepare": "ts-patch install”,
tsconfig.json
"compilerOptions": {
"strict": true,
"plugins": [
{
"transform": "typia/lib/transform",
// "functional": true, // validate function type
// "numeric": true, // check
isNaN()
andisFinite()
}
],
npm run prepare
npm run dev -- --open
Beta Was this translation helpful? Give feedback.
All reactions