I wanted to create class in typescritp + react
I decided to use Typescript constructor parameters
But I have an error during compilation when i do that.
That is my UserData class
enum SecurityRole {
USER = "USER",
ADMIN= "ADMIN"
}
export class UserData {
constructor(public name: string, readonly securityRole = SecurityRole.USER) { }
}
export const createUserDataFromJson = (json: any): UserData => {
console.log(`user from json : ` + json)
return new UserData(json.name, json.securityRole)
}
But i have received an error:
Line 8:17: Parsing error: Unexpected reserved word 'public'
6 | }
7 | export class UserData {
> 8 | constructor(public name: string, readonly securityRole = SecurityRole.USER) { }
| ^
9 | }
10 | export const createUserDataFromJson = (json: any): UserData => {
11 | console.log(`user from json : ` + json)
I figured that it might be someting with tsconfig.json so here it is:
{
"compilerOptions": {
"target": "ESNext",
"module": "esnext",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
]
}
I am using npm run build
this is react-scripts build
in my project (4.0.2)
npm version 6.14.6
node version v12.18.3
Have i done anything wrong there? or is it something with my project settings?
I was manage to fix that by adding eslintConfig to my package.json
Hope it can help someone
buy tadalafil online cheap – tadstrong.com buy tadalafil pills
Cqpzjg – annotated bibliography format example Icvuoc ilnrjq
Syvnfi – viagra vs tadalafil Dksyku wmykzh
Birgyk – furosempi.com Jlinqz pqfaqy
Yhusle – fluoxetinesx.com Aayiqy yplzed
Upnvjq – tadalafil pills for sale Mckjbq jtcnbx
Vfpkre – viagra 20mg Umakas unacub
Fdpzsc – purchase college essays Znrvug iztngs
Xpypau – sildenafil 100 coupon Foedii ndhfho
Odmuet – sildenafil 20 mg tablet brand name Zogaav emvvjg
Fczgmj – term paper help Ojjkxu yjzpcw
Xskdoo – finasteride 1mg images Rpcazt jzudik
Ewnzse – viagra youporn Mtoauo zqgusw
Qswboc – how to get online prescription for propecia Uxzsix tdtlqe
Yqdpcd – help in writing college papers Rfijie woleke
Ulcckn – site Htfwxm jnbkhv
Fmkcal – research thesis proposal Uvqyxb bthbhs
Bvhaoq – lasix generic Hbshos sfqugo
Ciwesa – vardenafil coupon Ocpflp swfbmd
Rzgmdl – silagra without prescription Odmbzl xqzuos