Skip to content

Commit 681392a

Browse files
committed
Add strict types
1 parent 170e655 commit 681392a

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

build.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import fs from 'node:fs'
22
import {emojiEmotion} from 'emoji-emotion'
33
import {emojiToName} from 'gemoji'
44

5+
/** @type {Record<string, number>} */
56
const data = {}
67
let index = -1
78

89
while (++index < emojiEmotion.length) {
9-
data[emojiEmotion[index].emoji] = emojiEmotion[index].polarity
10-
data[':' + emojiToName[emojiEmotion[index].emoji] + ':'] =
11-
emojiEmotion[index].polarity
10+
const info = emojiEmotion[index]
11+
data[info.emoji] = info.polarity
12+
data[':' + emojiToName[info.emoji] + ':'] = info.polarity
1213
}
1314

1415
fs.writeFileSync(

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function inject(values) {
8383
* Get the polarity of a word.
8484
*
8585
* @param {string} value
86-
* @param {Inject} inject
86+
* @param {Inject} [inject]
8787
* @returns {number}
8888
*/
8989
function getPolarity(value, inject) {

test/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ test('algorithm', function (t) {
158158
t.end()
159159
})
160160

161-
// Simple word tokenizer.
161+
/**
162+
* Simple word tokenizer.
163+
*
164+
* @param {string} value
165+
* @returns {Array<string>}
166+
*/
162167
function tokenize(value) {
163-
return value.toLowerCase().match(/\S+/g)
168+
const match = value.toLowerCase().match(/\S+/g)
169+
return match ? [...match] : []
164170
}

tsconfig.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
2-
"include": ["*.js"],
2+
"include": ["**/**.js"],
3+
"exclude": ["coverage", "node_modules"],
34
"compilerOptions": {
4-
"target": "ES2020",
5-
"lib": ["ES2020"],
6-
"module": "ES2020",
7-
"moduleResolution": "node",
8-
"allowJs": true,
95
"checkJs": true,
106
"declaration": true,
117
"emitDeclarationOnly": true,
12-
"allowSyntheticDefaultImports": true,
13-
"skipLibCheck": true
8+
"exactOptionalPropertyTypes": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"lib": ["es2020"],
11+
"module": "node16",
12+
"newLine": "lf",
13+
"skipLibCheck": true,
14+
"strict": true,
15+
"target": "es2020"
1416
}
1517
}

0 commit comments

Comments
 (0)