Prerequisites
Fastify version
4.24.0
Plugin version
5.8.0
Node.js version
18.18.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Sonoma 14.0
Description
Using fastify-cli to generate TypeScript boilerplate does not appear to be working.
The npm run build:ts command flags 286 errors in 4 files - included here without colorization:
node_modules/typescript/bin/tsc --pretty false > build-errors.txt 2>&1
This looks like it may have to do with version of typescript that fastify-cli sets when generating boilerplate code:
If I replace this with a more recent version, I'm able to build without issue:
npm run build:ts
> sample@1.0.0 build:ts
> tsc
npm run start
> sample@1.0.0 start
> npm run build:ts && fastify start -l info dist/app.js
> sample@1.0.0 build:ts
> tsc
{"level":30,"time":1697062116174,"pid":19537,"hostname":"tmd.lan","msg":"Server listening at http://[::1]:3000"}
{"level":30,"time":1697062116175,"pid":19537,"hostname":"tmd.lan","msg":"Server listening at http://127.0.0.1:3000"}
npm run test
> sample@1.0.0 test
> npm run build:ts && tsc -p test/tsconfig.json && tap --ts "test/**/*.test.ts"
> sample@1.0.0 build:ts
> tsc
PASS test/plugins/support.test.ts 1 OK 11.494ms
PASS test/routes/example.test.ts 1 OK 624.56ms
PASS test/routes/root.test.ts 1 OK 628.892ms
🌈 SUMMARY RESULTS 🌈
Suites: 3 passed, 3 of 3 completed
Asserts: 3 passed, of 3
Time: 1s
--------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
src | 100 | 100 | 100 | 100 |
app.ts | 100 | 100 | 100 | 100 |
src/plugins | 100 | 100 | 100 | 100 |
sensible.ts | 100 | 100 | 100 | 100 |
support.ts | 100 | 100 | 100 | 100 |
src/routes | 100 | 100 | 100 | 100 |
root.ts | 100 | 100 | 100 | 100 |
src/routes/example | 100 | 100 | 100 | 100 |
index.ts | 100 | 100 | 100 | 100 |
--------------------|---------|----------|---------|---------|-------------------
Steps to Reproduce
fastify generate sample --lang=typescript
generated README.md
generated .gitignore
generated .taprc
generated tsconfig.json
generated test/helper.ts
generated test/tsconfig.json
generated src/app.ts
generated test/plugins/support.test.ts
generated test/routes/example.test.ts
generated src/plugins/README.md
generated src/routes/README.md
generated test/routes/root.test.ts
generated src/plugins/sensible.ts
generated src/plugins/support.ts
generated src/routes/root.ts
generated src/routes/example/index.ts
--> reading package.json in sample
edited package.json, saving
saved package.json
--> project sample generated successfully
run 'npm install' to install the dependencies
run 'npm start' to start the application
run 'npm build:ts' to compile the typescript application
run 'npm run dev' to start the application with pino-colada pretty logging (not suitable for production)
run 'npm test' to execute the unit tests
cd sample && npm install
added 367 packages, and audited 532 packages in 10s
47 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm run build:ts
Found 286 errors in 4 files.
Errors Files
259 node_modules/fastify/types/instance.d.ts:202
21 node_modules/fastify/types/route.d.ts:124
3 src/routes/example/index.ts:4
3 src/routes/root.ts:4
Expected Behavior
The fastify generate --lang=typescript command should produce functional code, which may mean simply updating the bundled version of typescript.
Prerequisites
Fastify version
4.24.0
Plugin version
5.8.0
Node.js version
18.18.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Sonoma 14.0
Description
Using
fastify-clito generate TypeScript boilerplate does not appear to be working.The
npm run build:tscommand flags286 errors in 4 files- included here without colorization:node_modules/typescript/bin/tsc --pretty false > build-errors.txt 2>&1This looks like it may have to do with version of
typescriptthatfastify-clisets when generating boilerplate code:If I replace this with a more recent version, I'm able to build without issue:
npm run build:tsnpm run startnpm run testSteps to Reproduce
fastify generate sample --lang=typescriptcd sample && npm installnpm run build:tsExpected Behavior
The
fastify generate --lang=typescriptcommand should produce functional code, which may mean simply updating the bundled version oftypescript.