typescript class import csv file code example

Example: typescript class import csv file

// # csv file
import csvData from './latlong.csv';
//# text import
import textData from '../common/text/info.txt';
//# json import
import jsonData from '../common/json/jsondata.json';


export const TextResource = textData; // not-work
export const JsonResource = <IJsondata> jsonData; // work
export const CsvResource = <ILatLong[]> csvData; // not-work

export interface IJsondata {
    email: string;
    password: string;
}

export interface ILatLong {
    name: string;
    lat: any;
    long: any;
}

declare module "*.txt" {
    const content: string;
    export default content;
}

declare module '*.csv' {
    const value: any;
    export default value;
}