Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

595
Views
mecanografiado: error TS2693: 'Promesa' solo se refiere a un tipo, pero se usa como un valor aquí

Estoy tratando de usar Typescript para mi AWS Lambda y obtengo los siguientes errores donde sea que use promesas.

error TS2693: 'Promise' solo se refiere a un tipo, pero aquí se usa como un valor.

Intenté usar las siguientes variaciones en el código.

Usando el constructor Promise

 responsePromise = new Promise((resolve, reject) => { return reject(new Error(`missing is needed data`)) })

usando Promise.reject

 responsePromise = Promise.reject(new Error(`Unsupported method "${request.httpMethod}"`));

Versiones

Las siguientes son las versiones en mis dependencias de desarrollo:

 "typescript": "^2.2.2" "@types/aws-lambda": "0.0.9", "@types/core-js": "^0.9.40", "@types/node": "^7.0.12",

Contenido de tsconfig.json

 { "compileOnSave": true, "compilerOptions": { "module": "commonjs", // "typeRoots" : ["./typings", "./node_modules/@types"], "target": "es5", // "types" : [ "core-js" ], "noImplicitAny": true, "strictNullChecks": true, "allowJs": true, "noEmit": true, "alwaysStrict": true, "preserveConstEnums": true, "sourceMap": true, "outDir": "dist", "moduleResolution": "Node", "declaration": true, "lib": [ "es6" ] }, "include": [ "index.ts", "lib/**/*.ts" ], "exclude": [ "node_modules", "**/*.spec.ts" ] }

Estoy usando grunt-ts con la siguiente configuración para ejecutar la tarea ts.

 ts: { app: { tsconfig: { tsconfig: "./tsconfig.json", ignoreSettings: true } }, ...

Probé con la solución mencionada en I get: [ts] 'Promise' solo se refiere a un tipo, pero se usa como un valor aquí, pero no tuve suerte.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Tuve el mismo problema con aws-sdk y lo resolví usando "target": "es2015" . Este es mi archivo tsconfig.json .

 { "compilerOptions": { "outDir": "./dist/", "sourceMap": false, "noImplicitAny": false, "module": "commonjs", "target": "es2015" }, "include": [ "src/**/*" ], "exclude": [ "node_modules", "**/*.spec.ts" ] }
over 4 years ago · Santiago Trujillo Report

0

Encuentra el mismo error hoy y lo resolvió con:

 npm i --save-dev @types/es6-promise

Actualizar:

agregar:

 import {Promise} from 'es6-promise'
over 4 years ago · Santiago Trujillo Report

0

Resolví esto agregando el siguiente código al archivo tsconfig.json.

 "lib": [ "ES5", "ES2015", "DOM", "ScriptHost"]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!