question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Documentation] Express Typing

See original GitHub issue

It’s really good to see a web framework that deals with TypeScript as a first class citizen! I’m really excited about this project because of this.

However, when turning the option: noImplicitAny in the tsconfig.json the compiler will produce warnings about a lot of the examples in the documentation.

I highly recommend adding Express TypeScript declarations to the examples like so:


import {Request,Response,NextFunction} from "@types/express";


@Controller({})
export class UsersController {
	getAllUsers(req:Request, res:Response, next:NextFunction) {
		// will have auto completion, type safety ...etc
	}
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
marcus-sacommented, Dec 27, 2018

Then the server package would still need to have both Fastify and Nest platform installed for it to work, and Nest still supports JS, so that’s not an option either, plus it’s more a downgrade than an actual bug fix imo. My advice? Stop being lazy.

2reactions
KerryRittercommented, May 5, 2017

@ThomRick He’s asking that the examples on https://kamilmysliwiec.gitbooks.io/nest/content/ add the Express types. Right now they just say:

@Get('/:id')
public async getUser(@Response() res, @Param('id') id) {

as opposed to

@Get('/:id')
public async getUser(@Response() res: Response, @Param('id') id) {
Read more comments on GitHub >

github_iconTop Results From Across the Web

5.x API - Express.js
Returns middleware that only parses JSON and only looks at requests where the Content-Type header matches the type option. This parser accepts any...
Read more >
@types/express - npm
This package contains type definitions for Express (http://expressjs.com). Details. Files were exported from https://github.com/DefinitelyTyped/ ...
Read more >
Documenting your Express API with Swagger - LogRocket Blog
This tutorial shows you how to maintain thorough API documentation by using Swagger with an Express API in Node.
Read more >
Express/Node introduction - Learn web development | MDN
Go back to the terminal and type the following command: ... The following example (from the Express documentation) shows a handler that will ......
Read more >
Typed express with generated swagger docs
Typed Express swagger-docs TLDR: I was missing some simple and minimalist... Tagged with typescript, backend, express, swagger.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found