Dara Shel
Dara Shel

Reputation: 37

Node.js argument type string is not assignable to parameter type function(T)

I learn Node.js. I started to create my first app with API.

enter image description here

What means the error on the tooltip? (see the image) I have seen it for the first time.

My code:

const express = require('express'),
      app = express(),
      bodyParser = require('body-parser'),
      mongoose = require('mongoose'),
      morgan = require('morgan'),
      consign = require('consign'),
      cors = require('cors'),
      passport = require('passport'),
      passportConfig = require('./passport')(passport),
      jtw = require('jsonwebtoken'),
      config = require('./index.js'),
      database = require('./database')(mongoose, config);


      app.use(express.static('.'));
      app.use(bodyParser.urlencoded({ extended: true }));
      app.use(bodyParser.json());
      app.use(morgan('dev'));
      app.use(cors());
      app.use(passport.initialize());

      app.set('medsecret', config.secret);
      consign({ cwd: './services' })
          .include('../API/app/setup')
          .then('../API/app/api')
          .then('API/app/routes')
          .into(app);


module.exports = app;

Upvotes: 0

Views: 963

Answers (1)

nerdier.js
nerdier.js

Reputation: 601

You may ignore this tooltip, if then is an innate feature of consign module. Essentially, for the editor you're using, then chain is being interpreted by it as set of promises, and since you cannot merely pass strings as an argument to promises in the fashion like this, it displays false error.

Rest assured, if it doesn't lead to a loss of functionality, it is acceptable. You may ignore this tooltip for now.

Alternatively, you may try to install the ts defintions of the same, and then see if the erroneous tooltip vanishes.

Upvotes: 1

Related Questions