Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class constructor Base cannot be invoked without 'new' #45

Open
gduggirala opened this issue Mar 4, 2019 · 1 comment
Open

Class constructor Base cannot be invoked without 'new' #45

gduggirala opened this issue Mar 4, 2019 · 1 comment

Comments

@gduggirala
Copy link

Created a new model called Recipient

import {RegistrationStatus} from "./RegistrationStatus"
import * as Pring from "pring"

const property = Pring.property;
const File = Pring.File;

export class Recipient extends Pring.Base{

    @property _id?: string
    @property fullName: string = ""
    @property email: string = ""
    @property country: string = ""
    @property gender: string = ""
    @property dateOfBirth: Date = new Date()
    @property _status: RegistrationStatus = RegistrationStatus.NotRegistered

    set gaurdianName(gaurdianName: string){
        this.gaurdianName = gaurdianName
    }

    set gaurdianPhone(gaurdianPhone: string){
        this.gaurdianPhone = gaurdianPhone
    }
    
    set state(state:string){
        this.state = state
    }

    set recipientNumber(recipientNumber:string){
        this.recipientNumber = recipientNumber
    }

    set addressLine1(addLine1:string){
        this.addressLine1 = addLine1
    }

    set addressLine2(addLine2:string){
        this.addressLine2 = addLine2
    }

    set city(city:string){
        this.city = city
    }

    set search(search:Array<string>){
        this.search = search
    }

}

And iam trying to use this in the component as follows.

@Component
export default class HelloWorld extends Vue {
  @Prop() private msg!: string;
  @Emit()
  async onClick(): Promise<void>{
    console.log("I am inside click event...")
    let recp = new Recipient();
    recp.fullName = "My full name"
    recp.recipientNumber = "+1 888 999 0000"
    recp.email = "myemail@emaildomain.com"
    recp.city = "City name"
    let temp = await recp.save().catch(e=>{
      console.log("Error while saving ", e)
    })
    console.log("Temp received after storing is ", temp)
  }
}

I used https://github.com/1amageek/vue-pring-sample project and just added above code.
After adding the above code I am getting the following error.

Uncaught (in promise) TypeError: Class constructor Base cannot be invoked without 'new'
    at new Recipient (Recipient.ts?8a02:18)
    at _callee$ (VM3962 HelloWorld.vue:45)
    at tryCatch (runtime.js?96cf:62)
    at Generator.invoke [as _invoke] (runtime.js?96cf:288)
    at Generator.prototype.(:8080/anonymous function) [as next] (webpack-internal:///./node_modules/regenerator-runtime/runtime.js:114:21)
    at eval (tslib.es6.js?9ab4:71)
    at new Promise (<anonymous>)
    at Module.__awaiter (tslib.es6.js?9ab4:67)
    at VueComponent.onClick (VM3962 HelloWorld.vue:36)
    at VueComponent.emitter (vue-property-decorator.js?60a3:112)

I am new to typescript and dont know how to interpret the errors, any help is appreciated.

Thank you,

@praveenrejeti
Copy link

praveenrejeti commented Mar 5, 2019

Initially me also faced the same issue but after research and debug came to know that we have to configure tsconfig properly 💯

It's working by adding the repo dependency instead of installing from npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants