0

I have JSON files in my TwinCAT HMI project which I would like to use in my HMI scripts. The project is typescript based, but it's little relevant I think. What I've tried is to place temperature-namings.json file next to .ts file and call this in the script:

import test = require("temperature-namings.json");
// or (also with ./ path prefix)
import test from "temperature-namings.json";

Build:Cannot find module 'temperature-namings.json' or its corresponding type declarations.

I've tried to use path specifiers such as .. but intellisense doesn't show this file. I have an impression that it's filtering types, since json files are part of script function ecosystem. So I've placed my json into Imports, but still can't import it.

I also tried to put the following into tsconfig file:

"resolveJsonModule": true,
"esModuleInterop": true,

But then another error pops up:

Build:Option '--resolveJsonModule' cannot be specified without 'node' module resolution

How can I place JSON file inside TwinCAT HMI project and read the content from my custom .ts functions?

Pablo
  • 28,133
  • 34
  • 125
  • 215

0 Answers0