Return type of Trie.replace

Hi,

I’m trying to write a helper function and i am running into an issue with the return type of Trie.replace.

i’ve got this code

public func addUser(users: Trie.Trie<Principal, User>, newUser: AddUser, key: Principal): (Trie.Trie<Principal, User>, ?User) {
		let newTrie = Trie.replace(users, createKey(key), compareKeys, ?newUser);
		newTrie;
	};

but it gives me the following error

(Trie<Principal,
         {email : Text; friends : [Text]; image : Text; username : Text}>,
   ?{email : Text; friends : [Text]; image : Text; username : Text})
cannot produce expected type
  (Trie<Principal, User/1>, ?User/1)

Documentation for reference:

Thanks in advance

I cant edit the post (get a 403)

But i missed this

i declared this both in the controller and helper file

type User = Model.User;
type AddUser = Model.AddUser;

Ahh i was passing in the the AddUser directly into the function without mapping it to a User

fixed it like so

Helper:

type User = Model.User;
type AddUser = Model.AddUser;

public func addOrReplaceUser(users: Trie.Trie<Principal, User>, newUser: User, key: Principal): (Trie.Trie<Principal, User>, ?User) {
		let newTrie = Trie.replace(users, createKey(key), compareKeys, ?newUser);
		newTrie;
	};

Controller:

type User = Model.User;
type AddUser = Model.AddUser;

private stable var users: Trie.Trie<Principal, User> = Trie.empty();

public shared({caller}) func addUser(user: AddUser): async (Text) {

// logic 

    var newUser = UserHelper.mapAddUserToUser(user, id);
    users := UserHelper.addOrReplaceUser(users, newUser, caller).0;

// logic

}