microsoft / TypeScript-Node-Starter

A reference example for TypeScript and Node with a detailed README describing how to use the two together.
MIT License
11.29k stars 2.76k forks source link

feat(Root): Development mode using nodemon with custom type loading #354

Open DerianCordobaPerez opened 2 years ago

DerianCordobaPerez commented 2 years ago

Implementation to run in development mode using nodemon loading custom types in order to prevent errors when running the server in development mode.

The error that is being prevented by loading the express-session-types type is the following:

Property 'returnTo' does not exist on type 'Session & Partial<SessionData>'.
req.session.returnTo = req.path;

Which is avoided by importing the following line into the app.ts file:

import * as sessionTypes from "./types/express-session-types";

With this we achieve the execution in development mode with the command npm run dev.

ghost commented 2 years ago

CLA assistant check
All CLA requirements met.

peterblazejewicz commented 2 years ago

Hey, thanks for pr, but it won't work as part of the example, as the direct TS workflow does not work in current setup for non-TS (non-javasript) assets, like images and styles. So the page starts, allow development, but there is no support for other assets. This is why existing nodemon usage support is based on serving content from dist directory