Skip to content
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

throw new Error("Error on typia.json.".concat(name, "(): no transform has been configured. #1014

Open
tungrix opened this issue Mar 27, 2024 · 6 comments

Comments

@tungrix
Copy link

tungrix commented Mar 27, 2024

I am following the example code from document.
Document:

If you repeat to call typia.json.stringify() function on the same type, size of JavaScript files would be larger because of duplicated AOT compilation. To prevent it, you can generate reusable function through typia.json.createStringify() function.

import typia, { tags } from "typia";
 
export const assertDepartment = typia.json.createAssertStringify<IDepartment>();

My code, using "typia": "^5.5.7":

import typia from "typia";

const stringifyOutputMessage = typia.json.createStringify<OutputMessage>();

const stringifiedMessage = stringifyOutputMessage(outputEvent)

Error:

 /usr/src/app/node_modules/typia/lib/json.js:160
     throw new Error("Error on typia.json.".concat(name, "(): no transform has been configured. Read and follow https://typia.io/docs/setup please."));
           ^
 
 Error: Error on typia.json.createStringify(): no transform has been configured. Read and follow https://typia.io/docs/setup please.
     at halt (/usr/src/app/node_modules/typia/lib/json.js:160:11)
     at Object.createStringify (/usr/src/app/node_modules/typia/lib/json.js:128:5)
     at file:///usr/src/app/dist/index.js:16:50
     at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
     at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
     at async loadESM (node:internal/process/esm_loader:28:7)
     at async handleMainPromise (node:internal/modules/run_main:120:12)
@DenisKut
Copy link

I have the same problem. I used clear React + TS + Webpack project, then used documentation, wrote this files
tsconfig.json
package.json

then added webpack dir with files that were created according to the layout from this article, then edited in common.config.js this block:

....
// Modules resolved
  resolve: {
    extensions: [".tsx", ".ts", ".js"],
    // alias: {
    //   typia: path.resolve(__dirname, '../node_modules/typia')
    // }
  },
  module: {
    strictExportPresence: true, // Strict mod to avoid of importing non-existent objects
    rules: [
      {
        test: /\.[tj]sx?$/,
        exclude: /node_modules/,
        loader: "ts-loader",
      },
      // // --- JS | TS USING BABEL
      // {
      //   test: /\.[jt]sx?$/,
      //   exclude: /node_modules/,
      //   use: {
      //     loader: "babel-loader",
      //     options: {
      //       cacheDirectory: true, // Using a cache to avoid of recompilation
      //     },
      //   },
      // },
      // --- HTML
      { test: /\.(html)$/, use: ["html-loader"] },
      // --- S/A/C/SS
      {
        test: /\.(s[ac]|c)ss$/i,
        use: [
          MiniCssExtractPlugin.loader,
          {
            loader: "css-loader", // translates css into CommonJS
            options: {
              esModule: true,
              // css modules
              modules: {
                localIdentName: "[name]__[local]__[hash:base64:5]", // format of output
                namedExport: true, // named exports instead of default
              },
            },
          },
          {
            // autoprefixer
            loader: "postcss-loader",
            options: {
              postcssOptions: {
                plugins: [
                  [
                    "postcss-preset-env",
                    {
                      // Options
                    },
                  ],
                ],
              },
            },
          },
        ],
      },
      
      ....

But when i use start-dev script, i take this error in browser console:

Uncaught Error: Error on typia.json.createAssertParse(): no transform has been configured. Read and follow https://typia.io/docs/setup please.
    halt json.js:160
    createAssertParse json.js:112
    ts ITypedTRPR.ts:1065
    Webpack 9
json.js:160

I've been fighting this for 3 days now...
Unsuccessfully ((( ...

@DenisKut
Copy link

In code i use custom interfaces, which were created according to documentation and export them:

export interface E2TRPR {
  sdtrpr: SDTRPR;
  trpr: (TStrobe & tags.MaxItems<16>)[];
}

export const assertE2TRPR = typia.createAssertGuardEquals<E2TRPR>();
export const assertParseE2TRPR = typia.json.createAssertParse<E2TRPR>();
export const assertStringifyE2TRPR = typia.json.createAssertStringify<E2TRPR>();

in App.tsx taking imports:

import { assertParseE2TRPR } from '../../interfaces/ITypedTRPR';
import * as styles from './styles.module.scss';

import React, { useEffect } from 'react';

// const loadJson = async (file: string) => {
const loadJson = async () => {
  const path = '../../DevInfo/trpr.json';

  const response = await fetch(path);
  const data = await response.text();

  const parsedData = assertParseE2TRPR(data);
  return parsedData;
};

function App() {
  useEffect(() => {}, []);

  return (
    <div className={styles.app}>
      <button onClick={loadJson}>Взять данные из trpr.json</button>
    </div>
  );
}

export default App;

And i haven't errors, when i compiling it, just this error in browser console....

@tungrix
Copy link
Author

tungrix commented Mar 28, 2024

I simply using typia.json.createStringify<OutputMessage>() in my node-js application, after reading the document, still got no idea on no transform has been configured.

@DenisKut
Copy link

DenisKut commented Mar 28, 2024

@tungrix, i still waiting for support(((
Because there is no idea of configure more than i did before(((

@DenisKut
Copy link

@samchon

@DenisKut
Copy link

DenisKut commented Apr 1, 2024

I simply using typia.json.createStringify<OutputMessage>() in my node-js application, after reading the document, still got no idea on no transform has been configured.

@tungrix, I think thad i found the problem... In my realization, there were mistakes with constructions Uint8Array, When i changed that into Arrau<[custom uint8]> in my interfaces, then transform mistake dissapeares

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants