#response.locals [TS]

13 messages · Page 1 of 1 (latest)

tough charm
#

no matter Typescript is still a important part of nest
-# why isn't there a typescript tag?

and i'm having some issues with it trying to set a value in the response.locals but typescript doesn't see this valid property i hve been trying to define it but had some trouble with it
so i need some help with it i got a src/types/express.d.ts where i usually define these kinds of things but struggled to get this defined for some reason so i need some help

subtle hill
#
export declare global {
  namespace Express {
    interface Locals {
      user?: string;
    }
  }
}
tough charm
subtle hill
tough charm
subtle hill
#

Within the files specified in the include section of tsconfig.json, it is applied globally.

It can also be used for defining common types.

export declare global {
  type Nullable<T> = T | null;
  type Optional<T> = T | undefined;
  //...something...
}
subtle hill
tough charm
#

yeah that makes sense

tough charm
tough charm
#

managed to move them outside the src again

tough charm