You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typedef User = {
@:primary @:autoIncrement final id:Id<User>;
@:unique final username:VarChar<255>;
final password:VarChar<64>;
final salt:VarChar<32>;
final displayName:VarChar<255>;
final roles:Int;
}
...
typedef UserVo = {
var id(default, never):Int;
var username(default, never):String;
var displayName(default, never):String;
var isAdmin(default, never):Bool;
var isSuperUser(default, never):Bool;
}
...
public function list():Promise<Array<UserVo>>
return db.User.all()
.next(all -> all.map(parseUser));
static function parseUser(u:User):UserVo
return {
id: u.id,
username: u.username,
displayName: u.displayName,
isAdmin: u.roles & UserRole.ADMIN != 0,
isSuperUser: u.roles & UserRole.SUPERUSER != 0
};
The following doesn't compile using the latest haxe nightly, complaining about:
src/server/api/UsersApi.hx:9: characters 31-34 : error: Cannot unify final and non-final fields
src/server/api/UsersApi.hx:9: characters 31-34 : have: { displayName: Dynamic }
src/server/api/UsersApi.hx:9: characters 31-34 : want: { displayName: Dynamic }
src/server/api/UsersApi.hx:9: characters 31-34 : For function argument 'u'
If I remove the finals, everything works.
If I inline the code from parseUser into the .next(), everything works.
The problem happens when trying to type the result of .all() (or .first()) as db.User. But in theory it should be db.User, why isn't it?
The text was updated successfully, but these errors were encountered:
Also having this problem, and so does @kevinresol as he confirmed on gitter.
Is it really because of the unimplemented default: linked by @back2dos last year? Issue has been fixed though, but I'm putting macro Sisyphus content here in order to try to attract interest on this issue:
The following doesn't compile using the latest haxe nightly, complaining about:
If I remove the finals, everything works.
If I inline the code from
parseUser
into the.next()
, everything works.The problem happens when trying to type the result of
.all()
(or.first()
) asdb.User
. But in theory it should bedb.User
, why isn't it?The text was updated successfully, but these errors were encountered: