Hi! Could you please suggest how to declare field types in a model class when you extend Model?
I get typings error when I refer to fields as this.myField
.
Property 'myField' does not exist on type 'MyModel'.
For example:
import { Model, DataFieldConfig } from '@bryntum/schedulerpro'
class PlayerModel extends Model {
static $name = 'PlayerModel'
static get fields(): Partial<DataFieldConfig>[] {
// [TypeScript] Property type is missing in DataFieldConfig #5017
// https://github.com/bryntum/support/issues/5017
return [
{ name: 'firstName', type: 'string', dataSource: 'first_name' },
{ name: 'lastName', type: 'string', dataSource: 'last_name' },
]
}
get isPlayerModel(): boolean {
return true
}
get fullName(): string {
// TODO: think how to declare 'firstName' and 'lastName'.
// Property 'firstName' does not exist on type 'PlayerModel'.
// Property 'lastName' does not exist on type 'PlayerModel'.
return `${this.firstName} ${this.lastName}`
}
set fullName(name: string) {
const [firstName, ...otherNames] = name.split(' ')
const lastName = otherNames.join(' ')
this.firstName = firstName
this.lastName = lastName
}
}
export default PlayerModel
Thanks in advance!