Skip to content

Commit 7945b1a

Browse files
committed
add tests
1 parent 6174840 commit 7945b1a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
"ssb"
1414
],
1515
"scripts": {
16-
"prepublish": "tsc"
16+
"prepublish": "tsc",
17+
"test": "tsc --noEmit test.ts"
1718
},
1819
"devDependencies": {
20+
"tsd":"~0.15.1",
1921
"ts-node": "^9.1.1",
2022
"typescript": "~4.2.2"
2123
}

test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {expectType} from 'tsd';
2+
import {Content} from './readme';
3+
4+
const content: Content = null as any;
5+
if (content.type === 'post') {
6+
expectType<'post'>(content.type);
7+
expectType<string>(content.text);
8+
} else if (content.type === 'about') {
9+
expectType<string>(content.about);
10+
} else if (content.type === 'contact') {
11+
expectType<string>(content.contact);
12+
} else if (content.type === 'blog') {
13+
expectType<string>(content.title);
14+
expectType<string>(content.summary);
15+
expectType<string>(content.blog);
16+
} else if (content.type === 'vote') {
17+
expectType<{value: number; expression: string; link: string}>(content.vote);
18+
}

0 commit comments

Comments
 (0)