Skip to content

Commit 668cacb

Browse files
committed
Activate narrow type inline handlers
1 parent 3b18282 commit 668cacb

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/components/NotificationItem.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import dayjs from 'dayjs'
3-
import { MinimalRepository, Thread } from '../api/notifications'
3+
import type { MinimalRepository, Thread } from '../api/notifications'
44
import type { NotificationList } from '../types'
55
import { formatReason, isRepository, notificationSubjectIcon } from '../utils/notification'
66
import Separator from './Separator.vue'
@@ -33,15 +33,15 @@ function handleRepoClick(repo: MinimalRepository) {
3333
>
3434
<button
3535
class="notification-title"
36-
@click="handleRepoClick(value as MinimalRepository)"
36+
@click="handleRepoClick(value)"
3737
>
3838
<img
3939
class="notification-title-icon"
40-
:src="(value as MinimalRepository).owner.avatar_url"
40+
:src="value.owner.avatar_url"
4141
alt="repo logo"
4242
>
4343
<span class="notification-title-text">
44-
{{ (value as MinimalRepository).full_name }}
44+
{{ value.full_name }}
4545
</span>
4646
</button>
4747

@@ -51,23 +51,23 @@ function handleRepoClick(repo: MinimalRepository) {
5151
<button
5252
v-else
5353
class="notification-item"
54-
:class="{ 'notification-item-read': !(value as Thread).unread }"
55-
@click="handleThreadClick(value as Thread)"
54+
:class="{ 'notification-item-read': !value.unread }"
55+
@click="handleThreadClick(value)"
5656
>
5757
<Component
58-
:is="notificationSubjectIcon((value as Thread).subject.type)"
58+
:is="notificationSubjectIcon(value.subject.type)"
5959
class="notification-item-icon"
6060
/>
6161

6262
<div class="notification-item-content">
6363
<div class="notification-item-content-title">
64-
{{ (value as Thread).subject.title }}
64+
{{ value.subject.title }}
6565
</div>
6666

6767
<div class="notification-item-content-subtitle">
68-
{{ formatReason((value as Thread).reason) }}
68+
{{ formatReason(value.reason) }}
6969
-
70-
{{ dayjs((value as Thread).updated_at).fromNow() }}
70+
{{ dayjs(value.updated_at).fromNow() }}
7171
</div>
7272
</div>
7373
</button>

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
"skipLibCheck": true
1515
},
1616
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", ".github/**/*.ts"],
17-
"references": [{ "path": "./tsconfig.node.json" }]
17+
"references": [{ "path": "./tsconfig.node.json" }],
18+
"vueCompilerOptions": {
19+
"narrowingTypesInInlineHandlers": true
20+
}
1821
}

0 commit comments

Comments
 (0)