Skip to content

Commit

Permalink
More TypeScript (#103)
Browse files Browse the repository at this point in the history
This does some minimal TS conversions. The goal is to turn off
`allowJs`.
  • Loading branch information
oyamauchi authored Aug 2, 2023
1 parent 599b1ef commit 0b55311
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/@types/geocodio-library-node.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Trivial module declaration to satisfy tsc
declare module 'geocodio-library-node';
2 changes: 2 additions & 0 deletions src/@types/sqlite.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Trivial module declaration to satisfy tsc
declare module 'fastify-sqlite';
1 change: 1 addition & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default async function (
// through your application
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
forceESM: true,
options: Object.assign({}, opts),
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/plugins/swagger.js → src/plugins/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default fp(async function (fastify) {
},
refResolver: {
buildLocalReference(json, baseUri, fragment, i) {
return json.$id || `my-fragment-${i}`;
return (json.$id as string) || `my-fragment-${i}`;
},
},
});
Expand Down
4 changes: 3 additions & 1 deletion src/routes/openapi.js → src/routes/openapi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default async function (fastify) {
import { FastifyInstance } from 'fastify';

export default async function (fastify: FastifyInstance) {
fastify.get('/spec.json', { schema: { hide: true } }, (_, reply) => {
const spec = fastify.swagger();
reply.status(200).type('application/json').send(spec);
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"extends": "fastify-tsconfig",
"include": ["src/**/*.ts", "src/**/*.js"],
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
Expand All @@ -11,5 +10,8 @@
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true
},
"ts-node": {
"files": true
}
}

0 comments on commit 0b55311

Please sign in to comment.