Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
export JSON file from index file in typescript

in my typescript project, i am able to re-export my default exports in index.ts of a folder.

for eg:

export { default as BaseError } from "./errorResponse";

but i am unable to export JSON files like this.

export * as configFiles from "./config";

how to bundle and export JSON files such that i can use it in paths of tsconfig

{
  "compilerOptions": {
    "paths": {
      "@errorClass": ["src/helpers/errorClasses"],
      "@config": ["src/config"],
      "@routes": ["src/routes"]
    },
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Add the following options inside your tsconfig.json file:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "resolveJsonModule": true
  }
}

After updating tsconfig file export configFile like below:

export { default as configFiles } from "./config.json";

Now to import the configFiles inside your code use below:

import { configFiles } from "./file-path-to-configFiles-variable";

console.log(configFiles);
about 4 years ago · Juan Pablo Isaza Report

0

example tsconfig.json

"compilerOptions": {
        "baseUrl": "src",
        ...
        "paths": {
            "@config":["src/config/*"],
         ...
        },`
import { xConfig } from '@config/index';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!