# \[Resolved\] Before hook type error

**URL:** https://forum.heroiclabs.com/t/resolved-before-hook-type-error/4186
**Category:** Runtime Framework
**Tags:** server-framework
**Created:** [August 3, 2023, 12:45am UTC](https://forum.heroiclabs.com/t/resolved-before-hook-type-error/4186 "2023-08-03T00:45:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![justin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/justin/32/1702_2.png) [@justin](https://forum.heroiclabs.com/u/justin)
#### Post date: [August 3, 2023, 12:45am UTC](https://forum.heroiclabs.com/t/resolved-before-hook-type-error/4186/1 "2023-08-03T00:45:24Z")

</div>

reference: [Heroic Labs Documentation | Matchmaker](https://heroiclabs.com/docs/nakama/concepts/multiplayer/matchmaker/#properties)

in the example code from the docs:

```auto
function InitModule(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, initializer: nkruntime.Initializer) {
  initializer.registerRtBefore("MatchmakerAdd", beforeMatchmakerAdd)
}

const beforeMatchmakerAdd : nkruntime.RtBeforeHookFunction<nkruntime.EnvelopeMatchmakerAdd> = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, envelope: nkruntime.EnvelopeMatchmakerAdd) : nkruntime.EnvelopeMatchmakerAdd | void {
  const region = envelope.matchmakerAdd.stringProperties["region"];

  // If the string properties contain a region value of "europe", modify it to "europe-west"
  if (region && region == "europe") {
    envelope.matchmakerAdd.stringProperties["region"] = "europe-west";
  }

  return envelope;
}

```

initializing `beforeMatchmakerAdd` gives me a type error:

```auto
Argument of type 'RtBeforeHookFunction<EnvelopeMatchmakerAdd>' is not assignable to parameter of type 'RtBeforeHookFunction<Envelope>'. Type 'Envelope' is not assignable to type 'EnvelopeMatchmakerAdd'

```

am I missing something?

---

<div class="post-metadata">

### Author: ![justin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/justin/32/1702_2.png) [@justin](https://forum.heroiclabs.com/u/justin)
#### Post date: [August 3, 2023, 1:03pm UTC](https://forum.heroiclabs.com/t/resolved-before-hook-type-error/4186/2 "2023-08-03T13:03:09Z")

</div>

fixed this by making the type to be just `Envelope` and just added this inside the function `const e = envelope as nkruntime.EnvelopeMatchmakerAdd ` that way I can now access `matchmakerAdd`
