samchon / typia

Super-fast/easy runtime validators and serializers via transformation
https://typia.io/
MIT License
4.62k stars 159 forks source link

Error: no transform has been configured #785

Closed LBF38 closed 1 year ago

LBF38 commented 1 year ago

Question on setup

Hi, I just found about typia and I'm trying to make it work inside my project.

However, I always have the following error when setting up and trying to use it. Am I missing something ?

 Error: Error on typia.validateParse(): no transform has been configured. Read and follow https://typia.io/docs/setup please.

Here is the code I'm using from typia :

// utils.ts
export function parse<T>(input: string) {
return validateParse<T>(input);
}

// Then, I use my utils method 
const data: unknown = "{ version: '1.3.5' }"
const result = parse<{version: string}>(data);
if(!result.success) throw result.errors;
console.log(result.data.version); // should have the given type, i.e. `{ version: string }`

Therefore, am I doing something wrong or missing something ? Btw, I have followed the instructions on https://typia.io/docs/setup. But I didn't understand the part on transform.

Thanks for your help !

samchon commented 1 year ago

https://typia.io/playground/?script=JYWwDg9gTgLgBAbzgNwIYBtgBNUwKYAKqUAznnAL5wBmUEIcARDIwFCt4AeksNArgDsAxjGAQBcMMTIAeACoA+ABTABYPjABccEjCiqA5gEpErOObhQ8MPlAlpMOfEVJ55y1ephGA3KwrsAPSBcHIAFngCADRwAJJwfGRwIACeCaLoJMnWYRBYcKxC4rpwTqjaggDWAhAA7hIAvExIyHikYgLaAOQAjAB0AMx9AKxdlGxFAiVWJHzo8E1SrjIIre3i2rr6AgYUymW+rMDUSgCEM3MwfbNCQngkJCYwYXS1lveXfW10pH6TJBB0Hg+ugIAYlBd5n0yn01iQOr4gA

Well, the error message is Error on typia.validatParse(): non-specified generic argument..

As you can see from the message, typia does not support universal generic function.

LBF38 commented 1 year ago

Thank you for the answer. So, we should directly use the validateParse<T>() function in our code.

Moreover, if I want to use it with esbuild or other compilers (as said in the doc), I will need to generate code before building the whole project ? I haven't correctly understood this part. For example, with this code snippet, I would have to write my code, types, etc... Then, I would do the Typia generation code step, and finally, I would make the project build using esbuild config. Is this correct ?

samchon commented 1 year ago

Yes, correct. In my case, I build typed related features as SDK, and import it through npm private module of Github. Especially like below case. I know it is inconvenient in frontend project unless using ts-loader, but no way until stc being released.

https://nestia.io/docs/sdk/simulator/

LBF38 commented 1 year ago

I understand it better. Thank you for your help. I close the issue then.