Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
Can't get Express @types working

I'm trying to get the Express @types working but without any success. I'm using Visual Studio Code and I'd really love to have the autocompletition working. So far I've seen that installing the @types it gives the autocompletition too.

Things that I've done:
Installed express with npm: npm i -g express
Installed express-generator with npm: npm i -g express-generator
Generated the project with express-generator
cd into the project
Ran npm i
Installed types with npm: npm i --save-dev @types/express

// Top of the file: var express = require('express');

app.use(function (req, res: Express.Response, next) {
    var err: any = new Error('Not Found');

    //if I try to use res.end() it gets underlined in red
    res.end('some text');
});

As you can see the Express.Response was suggested by vscode, so this kinda confuses me. How can you find the Express.Response type but not it's methods?

The 'funny' fact is that in plain js everything works. Am I missing something or doing something wrong?

Here's my tsconfig.json file if it can help:

{
    "compileOnSave": false,
    "compilerOptions": {
        "outDir": "./dist/out-tsc",
        "baseUrl": "src",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "lib": [
            "es2016",
            "dom"
        ]
    }
}

Any help will be really appreciated!

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Solved by myself

For some reason now import * as express from 'express' now gives me the correct completition and type checking. However trying this before didn't worked. That's odd, however closing it as solved.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda