# GroupChannelOrder type definition

**URL:** https://community.sendbird.com/t/groupchannelorder-type-definition/3486
**Category:** JavaScript
**Tags:** group-channel, chatsdk
**Created:** [December 6, 2021, 9:40am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486 "2021-12-06T09:40:01Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![hewong](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/hewong/32/1817_2.png) [@hewong](https://community.sendbird.com/u/hewong)
#### Post date: [December 6, 2021, 9:40am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/1 "2021-12-06T09:40:01Z")

</div>

I’m trying to use create a `GroupChannelCollection` following the documentation like this:

```auto
sb.GroupChannel.createGroupChannelCollection()
	.setOrder(sb.GroupChannelCollection.GroupChannelOrder.LATEST_LAST_MESSAGE)
	.setFilter(groupChannelFilter)
	.build();

```

but I got a TypeScript error complaining that `string` is not assignable to `GroupChannelOrder`

Seems like there’s some problem in the type definition file:

```auto
type GroupChannelOrder = {
    LATEST_LAST_MESSAGE: 'latest_last_message',
    CHRONOLOGICAL: 'chronological',
    CHANNEL_NAME_ALPHABETICAL: 'channel_name_alphabetical',
};

```

This type expects me to pass in this exact object:

```auto
.setOrder({ LATEST_LAST_MESSAGE: 'latest_last_message', CHRONOLOGICAL: 'chronological', CHANNEL_NAME_ALPHABETICAL: 'channel_name_alphabetical' })

```

Also, I believe it doesn’t happen to just `GroupChannelOrder`…

---

<div class="post-metadata">

### Author: ![Brian\_Sang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/brian_sang/32/1228_2.png) [@Brian\_Sang](https://community.sendbird.com/u/Brian_Sang)
#### Post date: [December 7, 2021, 7:51am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/2 "2021-12-07T07:51:21Z")

</div>

Hi hewong,

There should be no error when following the documentation below.

> **[Group channel collection | Chat JavaScript SDK | Sendbird Docs](https://sendbird.com/docs/chat/v3/javascript/guides/group-channel-collection#2-create-a-collection)**
>
> Learn how to use GroupChannelCollection for Local caching.

What is the type definition file you mentioned? Where did you find them?

---

<div class="post-metadata">

### Author: ![hewong](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/hewong/32/1817_2.png) [@hewong](https://community.sendbird.com/u/hewong)
#### Post date: [December 7, 2021, 8:16am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/3 "2021-12-07T08:16:44Z")

</div>

Yes, that’s the documentation that I followed.

This is the type definition file that I mentioned: [SendBird.d.ts](https://github.com/sendbird/SendBird-SDK-JavaScript/blob/master/SendBird.d.ts) (line 85)

Here’s a screenshot of the error when I followed exactly the documentation:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/0/032e05ed2e27f60fa8450d9d50cb429f4c9e02f9.png)  
And if I put in a string:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/9/9d9a2308c71d667efce4110d1dc05e3e7d3d0e03.png)

The current `GroupChannelOrder` requires all properties to be present, which is an object.  
What should be expected by `.setOrder` is a string, and to solve this issue, the type declaration should be something like this:

```auto
type GroupChannelOrder = 'latest_last_message' | 'chronological' | 'channel_name_alphabetical';

```

---

<div class="post-metadata">

### Author: ![Brian\_Sang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/brian_sang/32/1228_2.png) [@Brian\_Sang](https://community.sendbird.com/u/Brian_Sang)
#### Post date: [December 7, 2021, 8:41am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/4 "2021-12-07T08:41:55Z")

</div>

Could you try to use it like this?

```auto
.setOrder(sb.GroupChannelCollection.GroupChannelOrder.ORDER_LATEST_LAST_MESSAGE) 

```

---

<div class="post-metadata">

### Author: ![hewong](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/hewong/32/1817_2.png) [@hewong](https://community.sendbird.com/u/hewong)
#### Post date: [December 7, 2021, 8:53am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/5 "2021-12-07T08:53:45Z")

</div>

Isn’t that what I did as mentioned in my topic and reply? That is also exactly what is documented.

If you’re thinking about the `this` keyword that’s because I’m using a class component.  
It’s still the same even if I don’t put it in a class component.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/5/5d954e1779f78425297aa4ce62bcd97514883c7c.png)

I really hope you did read what I said, please take a look at the type definition file, any TypeScript programmer should know what I mean…

Thank you

---

<div class="post-metadata">

### Author: ![Brian\_Sang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/brian_sang/32/1228_2.png) [@Brian\_Sang](https://community.sendbird.com/u/Brian_Sang)
#### Post date: [December 7, 2021, 9:39am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/6 "2021-12-07T09:39:14Z")

</div>

Really sorry. Let me check with JS engineer.

---

<div class="post-metadata">

### Author: ![Brian\_Sang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/brian_sang/32/1228_2.png) [@Brian\_Sang](https://community.sendbird.com/u/Brian_Sang)
#### Post date: [December 7, 2021, 10:08am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/7 "2021-12-07T10:08:42Z")

</div>

My teammate suggested a workaround as below including a comment.

> It’s like if you in typescript declare the variable as `const sort :any = ...` If you pass the string, it’s not the same as `any`

```auto
const order = sb.GroupChannelCollection.GroupChannelOrder.LATEST_LAST_MESSAGE;

var groupChannelCollection = sb.GroupChannel.createGroupChannelCollection()
        .setOrder(order)
        .setFilter(groupChannelFilter)
        .build();

```

Once getting the technical details, I will share with you.

---

<div class="post-metadata">

### Author: ![hewong](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/hewong/32/1817_2.png) [@hewong](https://community.sendbird.com/u/hewong)
#### Post date: [December 7, 2021, 10:21am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/8 "2021-12-07T10:21:35Z")

</div>

Thanks, would give it a try

---

<div class="post-metadata">

### Author: ![Brian\_Sang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/brian_sang/32/1228_2.png) [@Brian\_Sang](https://community.sendbird.com/u/Brian_Sang)
#### Post date: [December 7, 2021, 10:33am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/9 "2021-12-07T10:33:01Z")

</div>

This issue will be fixed soon. Sorry to make you confusing.

---

<div class="post-metadata">

### Author: ![hewong](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/hewong/32/1817_2.png) [@hewong](https://community.sendbird.com/u/hewong)
#### Post date: [December 7, 2021, 1:14pm UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/10 "2021-12-07T13:14:52Z")

</div>

No worries, thanks for the reply!

---

<div class="post-metadata">

### Author: ![Charis\_Theodoulou](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/charis_theodoulou/32/1401_2.png) [@Charis\_Theodoulou](https://community.sendbird.com/u/Charis_Theodoulou)
#### Post date: [December 16, 2021, 10:16am UTC](https://community.sendbird.com/t/groupchannelorder-type-definition/3486/11 "2021-12-16T10:16:42Z")

</div>

Hi @hewong this has been fixed in [3.1.4 version](https://github.com/sendbird/SendBird-SDK-JavaScript/releases/tag/v3.1.4) of the Sendbird SDK.

Update to resolve this by running:

```auto
npm i sendbird@3.1.4

```
