Import JSON file in TypeScript - Open4Tech (2024)

In this example, I will show you a simple way to import JSON files in TypeScript code. It requires just two simple steps. The first is to change the tsconfig.json file by adding the line:

, "resolveJsonModule":true

in “compilerOptions” section.

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

After that, you have to import the file into your ts-file.

import * as config from './config.json';

Now we are ready. We can use it the following way:

import * as config from './config.json';interface AppConfig{ prop: string;}class App{ ... public configuration: AppConfig; private constructor(){ this.configuration = config as AppConfig; //just for example } ...}

Was this article helpful?

If you have any suggestions or questions, please leave a comment below.

2022-09-13T21:14:21+03:00By Gandalf The White|Categories: How To|0 Comments

Related Posts

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Import JSON file in TypeScript - Open4Tech (2024)
Top Articles
How Does Sarwa Work? Diversified, Long-Term Investing - Sarwa
20 Biggest Stock Markets In The World
Room Background For Zepeto
Canary im Test: Ein All-in-One Überwachungssystem? - HouseControllers
Katmoie
From Algeria to Uzbekistan-These Are the Top Baby Names Around the World
Mr Tire Prince Frederick Md 20678
Google Jobs Denver
Fnv Turbo
Nm Remote Access
Mawal Gameroom Download
Minn Kota Paws
Buckaroo Blog
Voyeuragency
C Spire Express Pay
finaint.com
Craigslist Edmond Oklahoma
Teenleaks Discord
Are They Not Beautiful Wowhead
What Happened To Anna Citron Lansky
Craigslist In Flagstaff
Grayling Purnell Net Worth
Www Craigslist Milwaukee Wi
Gina Wilson All Things Algebra Unit 2 Homework 8
Glover Park Community Garden
Rubber Ducks Akron Score
How do you get noble pursuit?
Lilpeachbutt69 Stephanie Chavez
Delta Math Login With Google
Guinness World Record For Longest Imessage
Craigslistodessa
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Kokomo Mugshots Busted
Kazwire
Qlima© Petroleumofen Elektronischer Laserofen SRE 9046 TC mit 4,7 KW CO2 Wächter • EUR 425,95
Craigslist Freeport Illinois
Aita For Announcing My Pregnancy At My Sil Wedding
O'reilly's El Dorado Kansas
If You're Getting Your Nails Done, You Absolutely Need to Tip—Here's How Much
Post A Bid Monticello Mn
Santa Clara County prepares for possible ‘tripledemic,’ with mask mandates for health care settings next month
Luciane Buchanan Bio, Wiki, Age, Husband, Net Worth, Actress
What to Do at The 2024 Charlotte International Arts Festival | Queen City Nerve
Martha's Vineyard – Travel guide at Wikivoyage
Unblocked Games - Gun Mayhem
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
Boyfriends Extra Chapter 6
Unbiased Thrive Cat Food Review In 2024 - Cats.com
Cool Math Games Bucketball
Escape From Tarkov Supply Plans Therapist Quest Guide
All Obituaries | Roberts Funeral Home | Logan OH funeral home and cremation
Latest Posts
Article information

Author: Trent Wehner

Last Updated:

Views: 6061

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.