@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import { extractRequestError , LogService , MatrixClient , UserID } from "matrix-bot-sdk" ;
17+ import { extractRequestError , LogService , MatrixClient , RoomCreateOptions , UserID } from "matrix-bot-sdk" ;
1818import { EventEmitter } from "events" ;
1919import { ALL_RULE_TYPES , EntityType , ListRule , Recommendation , ROOM_RULE_TYPES , RULE_ROOM , RULE_SERVER , RULE_USER , SERVER_RULE_TYPES , USER_RULE_TYPES } from "./ListRule" ;
2020
@@ -121,7 +121,7 @@ class PolicyList extends EventEmitter {
121121 client : MatrixClient ,
122122 shortcode : string ,
123123 invite : string [ ] ,
124- createRoomOptions = { }
124+ createRoomOptions : RoomCreateOptions = { }
125125 ) : Promise < string /* room id */ > {
126126 const powerLevels : { [ key : string ] : any } = {
127127 "ban" : 50 ,
@@ -143,7 +143,7 @@ class PolicyList extends EventEmitter {
143143 } ,
144144 "users_default" : 0 ,
145145 } ;
146- const finalRoomCreateOptions = {
146+ const finalRoomCreateOptions : RoomCreateOptions = {
147147 // Support for MSC3784.
148148 creation_content : {
149149 type : PolicyList . ROOM_TYPE
@@ -161,7 +161,8 @@ class PolicyList extends EventEmitter {
161161 ...createRoomOptions
162162 } ;
163163 // Guard room type in case someone overwrites it when declaring custom creation_content in future code.
164- if ( ! PolicyList . ROOM_TYPE_VARIANTS . includes ( finalRoomCreateOptions . creation_content . type ) ) {
164+ const roomType = finalRoomCreateOptions . creation_content ?. type ;
165+ if ( typeof roomType === 'string' && ! PolicyList . ROOM_TYPE_VARIANTS . includes ( roomType ) ) {
165166 throw new TypeError ( `Creating a policy room with a type other than the policy room type is not supported, you probably don't want to do this.` ) ;
166167 }
167168 const listRoomId = await client . createRoom ( finalRoomCreateOptions ) ;
0 commit comments