Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added explicit any type to generic promise #3

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

awwong1
Copy link
Contributor

@awwong1 awwong1 commented Mar 22, 2018

promise error from ts #1

@mrbar42
Copy link
Owner

mrbar42 commented Mar 23, 2018

Thanks for this!

@awwong1 can you share a code example that reproduces that error so i can add it to the TypeScript tests?

@mrbar42 mrbar42 merged commit 950692e into mrbar42:master Mar 23, 2018
@awwong1
Copy link
Contributor Author

awwong1 commented Mar 23, 2018

Sure! I am using this library in a typescript express web app.

This is my typescript configuration:

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "sourceMap": true,
    "outDir": "dist",
    "strict": true,
    "strictPropertyInitialization": false,
    "esModuleInterop": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

Here's my index.ts file:

import { createServer } from "http";
import Graceful from "node-graceful";
import { createConnection } from "typeorm";
import app from "./app";
import { NODE_ENV, PORT } from "./constants";
import logger from "./util/logger";

/**
 * Start the server. Initialize the Database Client and tables.
 */
const start = async () => {
  const connection = await createConnection();
  logger.info(
    `Connected to ${connection.options.database} ${connection.options.type}: ${
      connection.isConnected
    }`
  );
  app.set("dbConnection", connection);
  const server = createServer(app);

  server.listen(PORT, async () => {
    logger.info(`UDIA ${NODE_ENV} server running on port ${PORT}`);
  });

  Graceful.on("exit", (done, event, signal) => {
    logger.warn(`3)\tSignal ${signal} received.`);
    server.close(() => {
      logger.warn(`2)\tHTTP server closed.`);
      connection.close().then(() => {
        logger.warn(`1)\tDatabase connections closed.`);
        done();
      });
    });
  });
  return server;
};

if (require.main === module) {
  start();
}

export default start;

Running tsc shows the following warning in console output:

➜  udia git:(master) ✗ tsc
node_modules/node-graceful/index.d.ts(1,86): error TS2314: Generic type 'Promise<T>' requires 1 type argument(s).

@awwong1
Copy link
Contributor Author

awwong1 commented Mar 23, 2018

Also, in VSCode with the typescript extensions, I see this error:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants