How do I use ES6 syntax
Opened this issue · 0 comments
benlieb commented
I'm confused because the docs have Typescript and ES5 syntax, but I generally write ES6.
I can't figure out how to instantiate my models with ES6. I'd really rather not write TS.
This works:
const ApplicationRecord = SpraypaintBase.extend(
{
static: {
baseUrl: window.location.origin,
apiNamespace: "/api"
}
}
)
const Tag = ApplicationRecord.extend(
{
static: {
jsonapiType: "tags"
},
attrs: {
name: attr(),
},
methods: {
sayHi: function() {
return `Hi I'm a ${this.name} tag`
}
}
}
)
But I'd prefer to write something like this, thought I'm not sure how to define attributes etc... Please help...
export default class ApplicationRecord extends SpraypaintBase {
static baseUrl = window.location.origin
static apiNamespace = "/api"
}
export default class Tag extends ApplicationRecord {
static jsonapiType = "tags"
//attributes ... etc
sayHi() {
return `Hi I'm a ${this.name} tag`
}
}