Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

express and cookie typings are not available automatically #492

Open
O4epegb opened this issue Sep 24, 2021 · 5 comments · May be fixed by #555
Open

express and cookie typings are not available automatically #492

O4epegb opened this issue Sep 24, 2021 · 5 comments · May be fixed by #555

Comments

@O4epegb
Copy link

O4epegb commented Sep 24, 2021

nookies functions depends on typings from other libraries, for example:

import * as cookie from 'cookie';
import * as express from 'express';
import * as next from 'next';

export declare function setCookie(ctx: Pick<next.NextPageContext, 'res'> | {
    res: next.NextApiResponse;
} | {
    res: express.Response;
} | null | undefined, name: string, value: string, options?: cookie.CookieSerializeOptions): {};

But it seems like they are not installed automatically because they are in devDependencies:

  "devDependencies": {
    "@types/cookie": "0.4.1",
    "@types/express": "4.17.13",
    // ...
  },

Maybe they should be moved to the regular dependencies instead? What is the best practice here?

@mecaota
Copy link

mecaota commented Oct 14, 2021

I also encountered the same symptom. In my case, the type inference in the setCookie option did not work, so I solved the problem by adding manually to the project I was using.

yarn add -D @types/cookie @types/express

However, I think it can be fixed by adding include node_modules to tsconfig at nookies.

"include": ["src"]

"include": ["src", "node_modules"] 

@O4epegb
Copy link
Author

O4epegb commented Oct 14, 2021

How would that help?

I don't think it will because this packages are not even installed when you install nookies, so it does not matter what you include, you would still need to install them manually.

In my understanding this is not Typescript related, more like NPM related thing

@mecaota
Copy link

mecaota commented Oct 14, 2021

I don't think it will because this packages are not even installed when you install nookies, so it does not matter what you include, you would still need to install them manually.

In my understanding this is not Typescript related, more like NPM related thing

You were right. I was wrong.

So, I think the solution is to move the some definition package in devDependencies. If so, I'm thinking of issuing a PR.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
@O4epegb
Copy link
Author

O4epegb commented Apr 17, 2022

I think it's still actual

@stale stale bot removed the stale label Apr 17, 2022
@boredland boredland linked a pull request Jun 20, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants