Typescript Constructor Parameters. Parsing error: Unexpected reserved word 'public'

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",
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": [
    "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": [

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?

206 thoughts on “Typescript Constructor Parameters. Parsing error: Unexpected reserved word 'public'”

  1. What’s Taking place i’m new to this, I stumbled upon this I
    have found It positively helpful and it has helped me
    out loads. I am hoping to contribute & help other users like its helped me.
    Good job.

  2. Hello there, just became alert to your blog through
    Google, and found that it’s truly informative. I am
    going to watch out for brussels. I will be grateful if you continue this
    in future. Numerous people will be benefited from
    your writing. Cheers!

  3. Having read this I believed it was really enlightening.
    I appreciate you taking the time and energy to put this content together.
    I once again find myself personally spending way too much time both reading and posting comments.
    But so what, it was still worthwhile!

  4. Hey! This is kind of off topic but I need some help
    from an established blog. Is it very hard to set up your own blog?

    I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about setting up my own but I’m not
    sure where to start. Do you have any points or suggestions?
    Thank you

  5. Good day! I know this is kinda off topic but I was wondering which blog platform are you using for this website?
    I’m getting tired of WordPress because I’ve had issues with hackers and I’m looking at
    alternatives for another platform. I would be great if you could point me in the direction of a good
    platform. quest bars http://bit.ly/3C2tkMR quest bars

  6. Pingback: sildenafil online
  7. Pingback: buy sildenafil
  8. Pingback: cialis rx
  9. Pingback: cialis 10 mg
  10. Pingback: cialis by mail
  11. Pingback: cialis 20
  12. Pingback: cialis france
  13. Pingback: viagra
  14. Pingback: viagra samples
  15. Pingback: sildenafil 20mg
  16. Pingback: 20mg cialis daily
  17. Pingback: tadalafil bnf
  18. Pingback: buy viagra china
  19. Pingback: sildenafil moa
  20. Pingback: sildenafil 50mg
  21. 270658 121445Hi. Cool write-up. Theres an problem together with your site in firefox, and you may want to check this The browser will be the market chief and a very good section of men and women will pass more than your fantastic writing because of this issue. 944875

  22. Pingback: female viagra
  23. Pingback: doctor x viagra
  24. Pingback: viagra pornhub
  25. Pingback: viagra women
  26. Pingback: viagra homme
  27. Pingback: viagra walmart
  28. Pingback: snorting viagra
  29. Pingback: viagra alternative
  30. Pingback: walmart viagra
  31. Pingback: viagra or cialis
  32. Pingback: viagra online
  33. Pingback: sildenafil teva
  34. When someone writes an post he/she keeps the idea of a user in his/her brain that
    how a user can be aware of it. Thus that’s why this paragraph is amazing.