In a basic typescript project:
server.ts:
import * as Fastify from 'fastify'
import * as fastifyJwt from 'fastify-jwt'
const fastify = Fastify()
fastify.register(fastifyJwt, {
secret: 'supersecret'
})
fastify.post('/signup', (req, reply) => {
// some code
const token = fastify.jwt.sign({ "foo":"bar" })
reply.send({ token })
})
fastify.listen(3000, err => {
if (err) throw err
})
tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noEmit": true,
"strict": true,
"noImplicitAny": true
},
"include": [
"server.ts"
],
"exclude": [
"node_modules"
]
}
Running this basic build command results in the following error:
👻 tsc-fastify-playground▷ npm run build
> [email protected] build /Users/ethanarrowood/Documents/GitHub/Fastify/tsc-fastify-playground
> tsc --project tsconfig.json
node_modules/fastify-jwt/index.d.ts:3:83 - error TS7016: Could not find a declaration file for module 'jsonwebtoken'. '/Users/ethanarrowood/Documents/GitHub/Fastify/tsc-fastify-playground/node_modules/jsonwebtoken/index.js' implicitly has an 'any' type.
Try `npm install @types/jsonwebtoken` if it exists or add a new declaration (.d.ts) file containing `declare module 'jsonwebtoken';`
3 import { DecodeOptions, Secret, SignOptions, VerifyCallback, VerifyOptions } from "jsonwebtoken";
~~~~~~~~~~~~~~
Found 1 error.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `tsc --project tsconfig.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ethanarrowood/.npm/_logs/2019-03-28T17_13_55_699Z-debug.log
Not sure whats up -- going to work on it and figure it out though
In a basic typescript project:
server.ts:
tsconfig.json:
{ "compilerOptions": { "module": "commonjs", "target": "es6", "noEmit": true, "strict": true, "noImplicitAny": true }, "include": [ "server.ts" ], "exclude": [ "node_modules" ] }Running this basic build command results in the following error:
Not sure whats up -- going to work on it and figure it out though