Property 'setCookie' does not exist on type 'FastifyReply<ServerResponse>'.
See original GitHub issueInstalled fastify-cookie with npm install fastify-cookie.
Using VSCode.
fastify v.2.0.1
fastify-cookie v.3.0.2
error:
{
"code": "2339",
"message": "Property 'setCookie' does not exist on type 'FastifyReply<ServerResponse>'.",
"source": "ts",
}
Code:
const fastifyCookie = require("fastify-cookie");
export const renderMiddleware = (fastify: FastifyInstance) => {
fastify.register(fastifyCookie);
fastify.post("/create-session-cookie", async (req, res) => {
try {
const sessionCookie = await thriftClient.createSession(
"blabla",
tokenExpDate,
lastIp,
tokenData,
null
);
res.setCookie("sessionId", sessionCookie.sessionId, {}) < Throws error
.status(200)
.send(sessionCookie);
} catch (e) {
req.log.info(JSON.stringify(e));
res.status(500).send(e);
return;
}
});
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Property 'cookies' does not exist on type 'undefined'
Solution. Look at the code: Cypress.on('window:before:load', (win) => { // because this is called before any scripts // have loaded - the ga ......
Read more >fastify-cookie - npm
Install · Repository · Homepage · Weekly Downloads · Version · License · Unpacked Size · Total Files.
Read more >Cookies | NestJS - A progressive Node.js framework
These properties are name value pairs of the cookie name to cookie value. When secret is provided, this module will unsign and validate...
Read more >Document.cookie - Web APIs | MDN
The Document property cookie lets you read and write cookies associated with the document. It serves as a getter and setter for the...
Read more >setcookie - Manual - PHP
If output exists prior to calling this function, setcookie() will fail and return false . ... This does not indicate whether the user...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@colinmcparland I got more time to look into this and see the real issue.
Change:
to this:
Import will make TS import the typings.
I have the same problem. Was this fixed?
TS2339: Property 'setCookie' does not exist on type 'FastifyReply<Server, IncomingMessage, ServerResponse, RouteGenericInterface, unknown>'.The package manager used does not affect the problem. I tried both
npmandpnpm.EDIT: Nevermind, I was using the wrong package because I was following NestJS docs where it states to use
fastify-cookie. Needed to use@fastify/cookie