import css to typescript code example
Example 1: typescript css modules in react
npm install typescript-plugin-css-modules --save-dev
Or if you’re using Yarn, run:
yarn add -D typescript-plugin-css-modules
// For CSS
declare module "*.module.less" {
const classes: { [key: string]: string };
export default classes;
}
// For LESS
declare module "*.module.less" {
const classes: { [key: string]: string };
export default classes;
}
// For SCSS
declare module "*.module.scss" {
const classes: { [key: string]: string };
export default classes;
}
Example 2: typescript class import csv file
//
import csvData from './latlong.csv';
//
import textData from '../common/text/info.txt';
//
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;
}