Skip to content

Commit 6870589

Browse files
committed
fix: remove non-null assetion to improve type safety
1 parent 1468ee0 commit 6870589

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/plugins/block/src/composable/useBlock.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ const copySchema = (schema: Partial<BlockContent['schema']>, contentList: string
166166
})
167167

168168
emitList.forEach((e) => {
169-
let key = e.match(/'.*?'/g)![0].replace(/'/g, '')
169+
const matches = e.match(/'.*?'/g)
170+
171+
if (!matches || !matches.length) {
172+
return
173+
}
174+
175+
let key = matches[0].replace(/'/g, '')
170176

171177
key = `on${key[0].toLocaleUpperCase() + key.slice(1, key.length)}`
172178
if (schema?.events?.[key]) {

0 commit comments

Comments
 (0)