Skip to content

Commit fc34aa6

Browse files
committed
test: added ts-standard
1 parent 7c29bf0 commit fc34aa6

File tree

5 files changed

+50
-19
lines changed

5 files changed

+50
-19
lines changed

.taprc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ esm: false
22
ts: false
33
jsx: false
44
coverage: true
5-
flow: true

index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { FastifyPlugin } from 'fastify';
2-
import { ServerOptions } from 'socket.io';
1+
import { FastifyPlugin } from 'fastify'
2+
import { ServerOptions } from 'socket.io'
33

44
declare module 'fastify' {
55
export interface FastifyInstance {
6-
io: SocketIO.Server;
6+
io: SocketIO.Server
77
}
88
}
99

10-
declare const socketioServer: FastifyPlugin<ServerOptions>;
11-
export default socketioServer;
10+
declare const socketioServer: FastifyPlugin<ServerOptions>
11+
export default socketioServer

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"types": "index.d.ts",
77
"scripts": {
88
"lint": "standard && npm run lint:typescript",
9-
"lint:typescript": "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin test/types/*.ts",
9+
"lint:typescript": "ts-standard",
1010
"test": "npm run lint && npm run unit && npm run typescript",
1111
"typescript": "tsd",
1212
"unit": "tap --100 test/*.test.js"
@@ -29,6 +29,7 @@
2929
"fastify": "^3.2.1",
3030
"standard": "^14.3.4",
3131
"tap": "^14.10.8",
32+
"ts-standard": "^9.0.0",
3233
"tsd": "^0.13.1",
3334
"typescript": "^3.9.7"
3435
},
@@ -41,5 +42,10 @@
4142
},
4243
"files": [
4344
"index.d.ts"
44-
]
45+
],
46+
"ts-standard": {
47+
"ignore": [
48+
"examples"
49+
]
50+
}
4551
}

test/index.test-d.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ import socketioServer from '..'
33
import { expectType, expectAssignable } from 'tsd'
44
import { ServerOptions } from 'socket.io'
55

6-
const app = fastify()
6+
try {
7+
const app = fastify()
78

8-
app.register(socketioServer)
9+
await app.ready()
910

10-
app.io.emit('test')
11+
await app.register(socketioServer)
1112

12-
expectType<SocketIO.Server>(app.io)
13+
app.io.emit('test')
1314

14-
expectAssignable<ServerOptions>({
15-
path: '/test',
16-
serveClient: false,
17-
pingInterval: 10000,
18-
pingTimeout: 5000,
19-
cookie: false
20-
})
15+
expectType<SocketIO.Server>(app.io)
16+
17+
expectAssignable<ServerOptions>({
18+
path: '/test',
19+
serveClient: false,
20+
pingInterval: 10000,
21+
pingTimeout: 5000,
22+
cookie: false
23+
})
24+
} catch (err) {
25+
console.error(err)
26+
}

tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"esModuleInterop": true,
5+
"allowSyntheticDefaultImports": true,
6+
"target": "es6",
7+
"moduleResolution": "node",
8+
"sourceMap": true,
9+
"outDir": "dist",
10+
"baseUrl": ".",
11+
"paths": {
12+
"*": [
13+
"node_modules/*"
14+
]
15+
}
16+
},
17+
"include": [
18+
"**/*.ts"
19+
]
20+
}

0 commit comments

Comments
 (0)