typescript: error TS2693: 'Promise' only refers to a type, but is being used as a value here












112















I am trying to use Typescript for my AWS Lambda and i am getting the following errors where ever I use promises.




error TS2693: 'Promise' only refers to a type, but is being used as a value here.


I tried using the following variations in the code



Using the Promise constructor



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


using Promise.reject



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


Versions



Following are the versions in my dev dependencies:



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


Contents of 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"
]
}


I am using grunt-ts with the following configuration for running ts task.



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


I tried with the solution mentioned in I get: [ts] 'Promise' only refers to a type, but is being used as a value here but no luck.










share|improve this question




















  • 1





    No return value is needed for the callback function passed in to the Promise constructor. Just get rid of return.

    – Pointy
    Mar 30 '17 at 13:23











  • Do you mean like this? responsePromise = new Promise((resolve, reject) => { reject(new Error("missing is needed data"))}) I tried it. But it did not hep with the problem.

    – kalyanvgopal
    Mar 30 '17 at 13:29













  • Yes. JavaScript doesn't care whether you return a value or not, but it won't pay attention to it. TypeScript, however, does care.

    – Pointy
    Mar 30 '17 at 13:30











  • Got it. But why does tsc fails to compile any flavour of Promose.resolve or Promise.reject?

    – kalyanvgopal
    Mar 30 '17 at 13:33











  • That, I don't know. How exactly is responsePromise declared?

    – Pointy
    Mar 30 '17 at 13:35


















112















I am trying to use Typescript for my AWS Lambda and i am getting the following errors where ever I use promises.




error TS2693: 'Promise' only refers to a type, but is being used as a value here.


I tried using the following variations in the code



Using the Promise constructor



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


using Promise.reject



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


Versions



Following are the versions in my dev dependencies:



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


Contents of 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"
]
}


I am using grunt-ts with the following configuration for running ts task.



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


I tried with the solution mentioned in I get: [ts] 'Promise' only refers to a type, but is being used as a value here but no luck.










share|improve this question




















  • 1





    No return value is needed for the callback function passed in to the Promise constructor. Just get rid of return.

    – Pointy
    Mar 30 '17 at 13:23











  • Do you mean like this? responsePromise = new Promise((resolve, reject) => { reject(new Error("missing is needed data"))}) I tried it. But it did not hep with the problem.

    – kalyanvgopal
    Mar 30 '17 at 13:29













  • Yes. JavaScript doesn't care whether you return a value or not, but it won't pay attention to it. TypeScript, however, does care.

    – Pointy
    Mar 30 '17 at 13:30











  • Got it. But why does tsc fails to compile any flavour of Promose.resolve or Promise.reject?

    – kalyanvgopal
    Mar 30 '17 at 13:33











  • That, I don't know. How exactly is responsePromise declared?

    – Pointy
    Mar 30 '17 at 13:35
















112












112








112


21






I am trying to use Typescript for my AWS Lambda and i am getting the following errors where ever I use promises.




error TS2693: 'Promise' only refers to a type, but is being used as a value here.


I tried using the following variations in the code



Using the Promise constructor



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


using Promise.reject



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


Versions



Following are the versions in my dev dependencies:



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


Contents of 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"
]
}


I am using grunt-ts with the following configuration for running ts task.



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


I tried with the solution mentioned in I get: [ts] 'Promise' only refers to a type, but is being used as a value here but no luck.










share|improve this question
















I am trying to use Typescript for my AWS Lambda and i am getting the following errors where ever I use promises.




error TS2693: 'Promise' only refers to a type, but is being used as a value here.


I tried using the following variations in the code



Using the Promise constructor



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


using Promise.reject



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


Versions



Following are the versions in my dev dependencies:



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


Contents of 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"
]
}


I am using grunt-ts with the following configuration for running ts task.



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


I tried with the solution mentioned in I get: [ts] 'Promise' only refers to a type, but is being used as a value here but no luck.







javascript typescript promise






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 24 '18 at 18:32









Community

11




11










asked Mar 30 '17 at 13:22









kalyanvgopalkalyanvgopal

7162712




7162712








  • 1





    No return value is needed for the callback function passed in to the Promise constructor. Just get rid of return.

    – Pointy
    Mar 30 '17 at 13:23











  • Do you mean like this? responsePromise = new Promise((resolve, reject) => { reject(new Error("missing is needed data"))}) I tried it. But it did not hep with the problem.

    – kalyanvgopal
    Mar 30 '17 at 13:29













  • Yes. JavaScript doesn't care whether you return a value or not, but it won't pay attention to it. TypeScript, however, does care.

    – Pointy
    Mar 30 '17 at 13:30











  • Got it. But why does tsc fails to compile any flavour of Promose.resolve or Promise.reject?

    – kalyanvgopal
    Mar 30 '17 at 13:33











  • That, I don't know. How exactly is responsePromise declared?

    – Pointy
    Mar 30 '17 at 13:35
















  • 1





    No return value is needed for the callback function passed in to the Promise constructor. Just get rid of return.

    – Pointy
    Mar 30 '17 at 13:23











  • Do you mean like this? responsePromise = new Promise((resolve, reject) => { reject(new Error("missing is needed data"))}) I tried it. But it did not hep with the problem.

    – kalyanvgopal
    Mar 30 '17 at 13:29













  • Yes. JavaScript doesn't care whether you return a value or not, but it won't pay attention to it. TypeScript, however, does care.

    – Pointy
    Mar 30 '17 at 13:30











  • Got it. But why does tsc fails to compile any flavour of Promose.resolve or Promise.reject?

    – kalyanvgopal
    Mar 30 '17 at 13:33











  • That, I don't know. How exactly is responsePromise declared?

    – Pointy
    Mar 30 '17 at 13:35










1




1





No return value is needed for the callback function passed in to the Promise constructor. Just get rid of return.

– Pointy
Mar 30 '17 at 13:23





No return value is needed for the callback function passed in to the Promise constructor. Just get rid of return.

– Pointy
Mar 30 '17 at 13:23













Do you mean like this? responsePromise = new Promise((resolve, reject) => { reject(new Error("missing is needed data"))}) I tried it. But it did not hep with the problem.

– kalyanvgopal
Mar 30 '17 at 13:29







Do you mean like this? responsePromise = new Promise((resolve, reject) => { reject(new Error("missing is needed data"))}) I tried it. But it did not hep with the problem.

– kalyanvgopal
Mar 30 '17 at 13:29















Yes. JavaScript doesn't care whether you return a value or not, but it won't pay attention to it. TypeScript, however, does care.

– Pointy
Mar 30 '17 at 13:30





Yes. JavaScript doesn't care whether you return a value or not, but it won't pay attention to it. TypeScript, however, does care.

– Pointy
Mar 30 '17 at 13:30













Got it. But why does tsc fails to compile any flavour of Promose.resolve or Promise.reject?

– kalyanvgopal
Mar 30 '17 at 13:33





Got it. But why does tsc fails to compile any flavour of Promose.resolve or Promise.reject?

– kalyanvgopal
Mar 30 '17 at 13:33













That, I don't know. How exactly is responsePromise declared?

– Pointy
Mar 30 '17 at 13:35







That, I don't know. How exactly is responsePromise declared?

– Pointy
Mar 30 '17 at 13:35














19 Answers
19






active

oldest

votes


















105














I had the same issue with the aws-sdk and I solved it by using "target": "es2015". This is my tsconfig.json file.



{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": false,
"noImplicitAny": false,
"module": "commonjs",
"target": "es2015"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}





share|improve this answer



















  • 2





    Thanks Sandro. Tried same but did not help in my case.

    – kalyanvgopal
    Mar 30 '17 at 16:22











  • Maybe the @types/aws-lambda are out of date. Amazon ships Typescript types with the official SDK. There is no need for DefinitelyTyped.

    – Sandro Keil
    Mar 31 '17 at 8:54











  • That solved the exact error defined in the question for me and I was just importing rxjs, not even using Promis. Thanks so much!

    – muzurBurcu
    May 26 '17 at 2:22






  • 2





    This is probably the best answer for those who were targeting es5 to begin with. Switching from es5 to es2015 also fixed this for me as well. Be warned however, you likely will still see the error until you shut down and restart your IDE/editor. Something about the TSC (or it's watch mode) was making it appear that this wasn't fixing it when it really was, but required a restart of vscode.

    – user2080225
    Oct 9 '17 at 23:30






  • 7





    update/addendum: if you want to still target es5 (for better browser support, and is important) that does still work as long as you supply this in your compiler options: "lib" : ["es2015", "dom", "ScriptHost"], The trick for me was realizing i had to restart VSCode editor, before it would begin working after making that change.

    – user2080225
    Oct 10 '17 at 1:39



















69














Encounter the same error today and solved it with:



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


Update:



add:



import {Promise} from 'es6-promise'





share|improve this answer





















  • 2





    + and restarting VS Code helps too, after installation of the types

    – Legends
    Feb 6 '18 at 23:31











  • Tried it, not working

    – Loic Coenen
    Apr 2 '18 at 13:49






  • 3





    Erratum: It works using this line import {Promise} from 'es6-promise';

    – Loic Coenen
    Apr 2 '18 at 13:52













  • where to add "import {Promise} from 'es6-promise'" ?

    – bArraxas
    Jul 24 '18 at 7:54



















29














I solved this by adding below code to tsconfig.json file.



"lib": [
"ES5",
"ES2015",
"DOM",
"ScriptHost"]





share|improve this answer





















  • 2





    this worked for me, but note that the "lib" array needs to be inside of the "compilerOptions" object in the tsconfig.json file.

    – BillyRayCyrus
    Jun 29 '17 at 14:46






  • 2





    Using TypeScript 2.4.1 I had to change all of the characters in the string array to be lowercase. Then it worked. Many thanks.

    – JDTLH9
    Jul 18 '17 at 10:57





















17














Solved by changing the target in compilerOptions.



{
"compilerOptions": {
"module": "es2015",
"target": "es2015",
"lib": [
"es2016",
"dom"
],
"moduleResolution": "node",
"noImplicitAny": false,
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "./public/js/app"
},
"exclude": [
"node_modules",
"public/js",
"assets/app/polyfills.ts"
],
"angularCompilerOptions": {
"skipMetadataEmit": true
}
}





share|improve this answer































    9














    Here is my tip. Tested with vscode 1.21.1 (on MAC)



    Put below config to tsconfig.json



    "lib": [
    "es2016",
    "dom"
    ]


    into
    compilerOptions



    Restart IDE (this action is required :D )






    share|improve this answer





















    • 3





      This is listed in multiple of the answers here and it important for sure: "Restart IDE (this action is required)"

      – atconway
      Sep 19 '18 at 19:07





















    8














    Add below line to file where error is being thrown.This should fix the issue



    declare var Promise: any;





    share|improve this answer



















    • 14





      This is just removing the type check for 'Promise,' rather than fixing it so Typescript finds the correct type.

      – edibleEnergy
      Dec 11 '17 at 1:05






    • 1





      This workaround does not work with Internet Explorer 11 for example. I throws an 'undefined' error when trying to use Promise. Anyway with Chrome the workaround does his job.

      – adSad
      Jun 21 '18 at 7:59





















    3














    Finally tsc started working without any errors. But multiple changes. Thanks to Sandro Keil, Pointy & unional




    • Removed dt~aws-lambda

    • Removed options like noEmit,declaration

    • Modified Gruntfile and removed ignoreSettings


    tsconfig.json



    {
    "compileOnSave": true,
    "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny": false,
    "strictNullChecks": true,
    "alwaysStrict": true,
    "preserveConstEnums": true,
    "sourceMap": false,
    "moduleResolution": "Node",
    "lib": [
    "dom",
    "es2015",
    "es5",
    "es6"
    ]
    },
    "include": [
    "*",
    "src/**/*"
    ],
    "exclude": [
    "./node_modules"
    ]
    }


    Gruntfile.js



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





    share|improve this answer

































      3














      None of the up-voted answers here work for me. Here is a guaranteed and reasonable solution. Put this near the top of any code file that uses Promise...



      declare const Promise: any;





      share|improve this answer































        2














        Had the same issue with typescript and the aws-sdk. The solve was to change the target to es6.



        My complete tsconfig.json file:



        {
        compilerOptions: {
        outDir: ./dist/,
        sourceMap: true,
        noImplicitAny: true,
        module: commonjs,
        target: es6,
        jsx: react,
        allowJs: true
        },
        include: [
        ./src/**/*
        ]
        }





        share|improve this answer



















        • 3





          Yes tartgeting es6 should fix it, but then you have less browser compatibility. Most apps are still today targeting es5, because many browsers still aren't on es6 yet (as of 2017)

          – user2080225
          Oct 9 '17 at 22:59











        • @user2080225 although that is true, it doesn't make my answer less correct since the original question didn't state anything about browser compatibility. Therefore this solution could still help others like it helped me.

          – Fanus du Toit
          Apr 9 '18 at 19:26



















        1














        I had the same problem and this saved me from the problem in second:



        write in console this:



        npm i --save bluebird
        npm i --save-dev @types/bluebird @types/core-js@0.9.36


        in the file where the problem is copy paste this:



        import * as Promise from 'bluebird';





        share|improve this answer

































          1














          I am using the "promise-polyfill" library, which may be the cause of my issue.



          I added this import to the top of my file:



          import {Promise} from 'es6-promise';





          share|improve this answer































            1














            I had the same issue until I added the following lib array in typeScript 3.0.1



            tsconfig.json



            {
            "compilerOptions": {
            "outDir": "lib",
            "module": "commonjs",
            "allowJs": false,
            "declaration": true,
            "target": "es5",
            "lib": ["dom", "es2015", "es5", "es6"],
            "rootDir": "src"
            },
            "include": ["./**/*"],
            "exclude": ["node_modules", "**/*.spec.ts"]
            }





            share|improve this answer

































              1














              I had this error but I resolved it by using this command, my ts file name is promises-fs.ts:



              tsc promises-fs.ts --target es6 && node promises-fs.js


              and the error is gone






              share|improve this answer































                0














                Core-js did not work for me as it caused other issues, however, simply installing the latest version of npm i @types/es6-promise --save-dev got rid of the issues. The issues for me stemmed from compiling an sdk that was using rxjs. Here is the error I was getting:



                `node_modules/rxjs/Observable.d.ts(59,60): error TS2693: Promise only refers to a type, but is being used as a value here.`





                share|improve this answer































                  0














                  Just change the target to "ES2017" in tsconfig.json file.



                  this is my tsconfig.json file



                  {
                  "compilerOptions": {
                  /* Basic Options */
                  "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
                  "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
                  "declaration": true, /* Generates corresponding '.d.ts' file. */
                  "sourceMap": true, /* Generates corresponding '.map' file. */
                  "outDir": "./dist", /* Redirect output structure to the directory. */
                  "strict": true /* Enable all strict type-checking options. */
                  },
                  "include": [
                  "src/**/*"
                  ],
                  "exclude": [
                  "node_modules"
                  ]
                  }





                  share|improve this answer































                    0














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



                    after up command, you'd better check tsconfig.json make sure the "target" must great than "es6". maybe tsc not support es5 yet.






                    share|improve this answer































                      0














                      Having spent lot of time trying to fix this. I had no luck with any solution provide here or elsewhere.



                      But then later realised it wasn't so much as just solving the issue. But you also need to RESTART the VSCODE for it to take affect.






                      share|improve this answer































                        0














                        If you're using the DefinitelyTyped repository in your project you might be experiencing this recent issue.



                        A decent workaround you might use (other than waiting for an updated build of the definitions file or refactoring your TS code) is to specify an explicit version+build for the core-js typings rather than let Visual Studio pick the latest/most recent one. I found one that seems to be unaffected by this problem (in my case at least), you can use it replacing the following line from your package.json file:



                          "scripts": {
                        "postinstall": "typings install dt~core-js --global"
                        }


                        With the following one:



                          "scripts": {
                        "postinstall": "typings install dt~core-js@0.9.7+20161130133742 --global"
                        }


                        This fixed my issue for good. However, is highly recommended to remove the explicit version+build reference as soon as the issue will be released.



                        For further info regarding this issue, you can also read this blog post that I wrote on the topic.






                        share|improve this answer

































                          0














                          Well, this might be counter-intuitive but I solved this adding esnext to my lib.



                          {
                          "compilerOptions": {
                          "lib": [
                          "esnext"
                          ],
                          "target": "es5",
                          }
                          }


                          The FIX, as suggested by the compiler is to




                          Try changing the lib compiler option to es2015 or later.







                          share|improve this answer























                            Your Answer






                            StackExchange.ifUsing("editor", function () {
                            StackExchange.using("externalEditor", function () {
                            StackExchange.using("snippets", function () {
                            StackExchange.snippets.init();
                            });
                            });
                            }, "code-snippets");

                            StackExchange.ready(function() {
                            var channelOptions = {
                            tags: "".split(" "),
                            id: "1"
                            };
                            initTagRenderer("".split(" "), "".split(" "), channelOptions);

                            StackExchange.using("externalEditor", function() {
                            // Have to fire editor after snippets, if snippets enabled
                            if (StackExchange.settings.snippets.snippetsEnabled) {
                            StackExchange.using("snippets", function() {
                            createEditor();
                            });
                            }
                            else {
                            createEditor();
                            }
                            });

                            function createEditor() {
                            StackExchange.prepareEditor({
                            heartbeatType: 'answer',
                            autoActivateHeartbeat: false,
                            convertImagesToLinks: true,
                            noModals: true,
                            showLowRepImageUploadWarning: true,
                            reputationToPostImages: 10,
                            bindNavPrevention: true,
                            postfix: "",
                            imageUploader: {
                            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                            allowUrls: true
                            },
                            onDemand: true,
                            discardSelector: ".discard-answer"
                            ,immediatelyShowMarkdownHelp:true
                            });


                            }
                            });














                            draft saved

                            draft discarded


















                            StackExchange.ready(
                            function () {
                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43119163%2ftypescript-error-ts2693-promise-only-refers-to-a-type-but-is-being-used-as%23new-answer', 'question_page');
                            }
                            );

                            Post as a guest















                            Required, but never shown

























                            19 Answers
                            19






                            active

                            oldest

                            votes








                            19 Answers
                            19






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes









                            105














                            I had the same issue with the aws-sdk and I solved it by using "target": "es2015". This is my tsconfig.json file.



                            {
                            "compilerOptions": {
                            "outDir": "./dist/",
                            "sourceMap": false,
                            "noImplicitAny": false,
                            "module": "commonjs",
                            "target": "es2015"
                            },
                            "include": [
                            "src/**/*"
                            ],
                            "exclude": [
                            "node_modules",
                            "**/*.spec.ts"
                            ]
                            }





                            share|improve this answer



















                            • 2





                              Thanks Sandro. Tried same but did not help in my case.

                              – kalyanvgopal
                              Mar 30 '17 at 16:22











                            • Maybe the @types/aws-lambda are out of date. Amazon ships Typescript types with the official SDK. There is no need for DefinitelyTyped.

                              – Sandro Keil
                              Mar 31 '17 at 8:54











                            • That solved the exact error defined in the question for me and I was just importing rxjs, not even using Promis. Thanks so much!

                              – muzurBurcu
                              May 26 '17 at 2:22






                            • 2





                              This is probably the best answer for those who were targeting es5 to begin with. Switching from es5 to es2015 also fixed this for me as well. Be warned however, you likely will still see the error until you shut down and restart your IDE/editor. Something about the TSC (or it's watch mode) was making it appear that this wasn't fixing it when it really was, but required a restart of vscode.

                              – user2080225
                              Oct 9 '17 at 23:30






                            • 7





                              update/addendum: if you want to still target es5 (for better browser support, and is important) that does still work as long as you supply this in your compiler options: "lib" : ["es2015", "dom", "ScriptHost"], The trick for me was realizing i had to restart VSCode editor, before it would begin working after making that change.

                              – user2080225
                              Oct 10 '17 at 1:39
















                            105














                            I had the same issue with the aws-sdk and I solved it by using "target": "es2015". This is my tsconfig.json file.



                            {
                            "compilerOptions": {
                            "outDir": "./dist/",
                            "sourceMap": false,
                            "noImplicitAny": false,
                            "module": "commonjs",
                            "target": "es2015"
                            },
                            "include": [
                            "src/**/*"
                            ],
                            "exclude": [
                            "node_modules",
                            "**/*.spec.ts"
                            ]
                            }





                            share|improve this answer



















                            • 2





                              Thanks Sandro. Tried same but did not help in my case.

                              – kalyanvgopal
                              Mar 30 '17 at 16:22











                            • Maybe the @types/aws-lambda are out of date. Amazon ships Typescript types with the official SDK. There is no need for DefinitelyTyped.

                              – Sandro Keil
                              Mar 31 '17 at 8:54











                            • That solved the exact error defined in the question for me and I was just importing rxjs, not even using Promis. Thanks so much!

                              – muzurBurcu
                              May 26 '17 at 2:22






                            • 2





                              This is probably the best answer for those who were targeting es5 to begin with. Switching from es5 to es2015 also fixed this for me as well. Be warned however, you likely will still see the error until you shut down and restart your IDE/editor. Something about the TSC (or it's watch mode) was making it appear that this wasn't fixing it when it really was, but required a restart of vscode.

                              – user2080225
                              Oct 9 '17 at 23:30






                            • 7





                              update/addendum: if you want to still target es5 (for better browser support, and is important) that does still work as long as you supply this in your compiler options: "lib" : ["es2015", "dom", "ScriptHost"], The trick for me was realizing i had to restart VSCode editor, before it would begin working after making that change.

                              – user2080225
                              Oct 10 '17 at 1:39














                            105












                            105








                            105







                            I had the same issue with the aws-sdk and I solved it by using "target": "es2015". This is my tsconfig.json file.



                            {
                            "compilerOptions": {
                            "outDir": "./dist/",
                            "sourceMap": false,
                            "noImplicitAny": false,
                            "module": "commonjs",
                            "target": "es2015"
                            },
                            "include": [
                            "src/**/*"
                            ],
                            "exclude": [
                            "node_modules",
                            "**/*.spec.ts"
                            ]
                            }





                            share|improve this answer













                            I had the same issue with the aws-sdk and I solved it by using "target": "es2015". This is my tsconfig.json file.



                            {
                            "compilerOptions": {
                            "outDir": "./dist/",
                            "sourceMap": false,
                            "noImplicitAny": false,
                            "module": "commonjs",
                            "target": "es2015"
                            },
                            "include": [
                            "src/**/*"
                            ],
                            "exclude": [
                            "node_modules",
                            "**/*.spec.ts"
                            ]
                            }






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 30 '17 at 15:41









                            Sandro KeilSandro Keil

                            1,067164




                            1,067164








                            • 2





                              Thanks Sandro. Tried same but did not help in my case.

                              – kalyanvgopal
                              Mar 30 '17 at 16:22











                            • Maybe the @types/aws-lambda are out of date. Amazon ships Typescript types with the official SDK. There is no need for DefinitelyTyped.

                              – Sandro Keil
                              Mar 31 '17 at 8:54











                            • That solved the exact error defined in the question for me and I was just importing rxjs, not even using Promis. Thanks so much!

                              – muzurBurcu
                              May 26 '17 at 2:22






                            • 2





                              This is probably the best answer for those who were targeting es5 to begin with. Switching from es5 to es2015 also fixed this for me as well. Be warned however, you likely will still see the error until you shut down and restart your IDE/editor. Something about the TSC (or it's watch mode) was making it appear that this wasn't fixing it when it really was, but required a restart of vscode.

                              – user2080225
                              Oct 9 '17 at 23:30






                            • 7





                              update/addendum: if you want to still target es5 (for better browser support, and is important) that does still work as long as you supply this in your compiler options: "lib" : ["es2015", "dom", "ScriptHost"], The trick for me was realizing i had to restart VSCode editor, before it would begin working after making that change.

                              – user2080225
                              Oct 10 '17 at 1:39














                            • 2





                              Thanks Sandro. Tried same but did not help in my case.

                              – kalyanvgopal
                              Mar 30 '17 at 16:22











                            • Maybe the @types/aws-lambda are out of date. Amazon ships Typescript types with the official SDK. There is no need for DefinitelyTyped.

                              – Sandro Keil
                              Mar 31 '17 at 8:54











                            • That solved the exact error defined in the question for me and I was just importing rxjs, not even using Promis. Thanks so much!

                              – muzurBurcu
                              May 26 '17 at 2:22






                            • 2





                              This is probably the best answer for those who were targeting es5 to begin with. Switching from es5 to es2015 also fixed this for me as well. Be warned however, you likely will still see the error until you shut down and restart your IDE/editor. Something about the TSC (or it's watch mode) was making it appear that this wasn't fixing it when it really was, but required a restart of vscode.

                              – user2080225
                              Oct 9 '17 at 23:30






                            • 7





                              update/addendum: if you want to still target es5 (for better browser support, and is important) that does still work as long as you supply this in your compiler options: "lib" : ["es2015", "dom", "ScriptHost"], The trick for me was realizing i had to restart VSCode editor, before it would begin working after making that change.

                              – user2080225
                              Oct 10 '17 at 1:39








                            2




                            2





                            Thanks Sandro. Tried same but did not help in my case.

                            – kalyanvgopal
                            Mar 30 '17 at 16:22





                            Thanks Sandro. Tried same but did not help in my case.

                            – kalyanvgopal
                            Mar 30 '17 at 16:22













                            Maybe the @types/aws-lambda are out of date. Amazon ships Typescript types with the official SDK. There is no need for DefinitelyTyped.

                            – Sandro Keil
                            Mar 31 '17 at 8:54





                            Maybe the @types/aws-lambda are out of date. Amazon ships Typescript types with the official SDK. There is no need for DefinitelyTyped.

                            – Sandro Keil
                            Mar 31 '17 at 8:54













                            That solved the exact error defined in the question for me and I was just importing rxjs, not even using Promis. Thanks so much!

                            – muzurBurcu
                            May 26 '17 at 2:22





                            That solved the exact error defined in the question for me and I was just importing rxjs, not even using Promis. Thanks so much!

                            – muzurBurcu
                            May 26 '17 at 2:22




                            2




                            2





                            This is probably the best answer for those who were targeting es5 to begin with. Switching from es5 to es2015 also fixed this for me as well. Be warned however, you likely will still see the error until you shut down and restart your IDE/editor. Something about the TSC (or it's watch mode) was making it appear that this wasn't fixing it when it really was, but required a restart of vscode.

                            – user2080225
                            Oct 9 '17 at 23:30





                            This is probably the best answer for those who were targeting es5 to begin with. Switching from es5 to es2015 also fixed this for me as well. Be warned however, you likely will still see the error until you shut down and restart your IDE/editor. Something about the TSC (or it's watch mode) was making it appear that this wasn't fixing it when it really was, but required a restart of vscode.

                            – user2080225
                            Oct 9 '17 at 23:30




                            7




                            7





                            update/addendum: if you want to still target es5 (for better browser support, and is important) that does still work as long as you supply this in your compiler options: "lib" : ["es2015", "dom", "ScriptHost"], The trick for me was realizing i had to restart VSCode editor, before it would begin working after making that change.

                            – user2080225
                            Oct 10 '17 at 1:39





                            update/addendum: if you want to still target es5 (for better browser support, and is important) that does still work as long as you supply this in your compiler options: "lib" : ["es2015", "dom", "ScriptHost"], The trick for me was realizing i had to restart VSCode editor, before it would begin working after making that change.

                            – user2080225
                            Oct 10 '17 at 1:39













                            69














                            Encounter the same error today and solved it with:



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


                            Update:



                            add:



                            import {Promise} from 'es6-promise'





                            share|improve this answer





















                            • 2





                              + and restarting VS Code helps too, after installation of the types

                              – Legends
                              Feb 6 '18 at 23:31











                            • Tried it, not working

                              – Loic Coenen
                              Apr 2 '18 at 13:49






                            • 3





                              Erratum: It works using this line import {Promise} from 'es6-promise';

                              – Loic Coenen
                              Apr 2 '18 at 13:52













                            • where to add "import {Promise} from 'es6-promise'" ?

                              – bArraxas
                              Jul 24 '18 at 7:54
















                            69














                            Encounter the same error today and solved it with:



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


                            Update:



                            add:



                            import {Promise} from 'es6-promise'





                            share|improve this answer





















                            • 2





                              + and restarting VS Code helps too, after installation of the types

                              – Legends
                              Feb 6 '18 at 23:31











                            • Tried it, not working

                              – Loic Coenen
                              Apr 2 '18 at 13:49






                            • 3





                              Erratum: It works using this line import {Promise} from 'es6-promise';

                              – Loic Coenen
                              Apr 2 '18 at 13:52













                            • where to add "import {Promise} from 'es6-promise'" ?

                              – bArraxas
                              Jul 24 '18 at 7:54














                            69












                            69








                            69







                            Encounter the same error today and solved it with:



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


                            Update:



                            add:



                            import {Promise} from 'es6-promise'





                            share|improve this answer















                            Encounter the same error today and solved it with:



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


                            Update:



                            add:



                            import {Promise} from 'es6-promise'






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jun 21 '18 at 11:09









                            TlmaK0

                            1,86711738




                            1,86711738










                            answered Sep 10 '17 at 0:45









                            KenshinKenshin

                            82244




                            82244








                            • 2





                              + and restarting VS Code helps too, after installation of the types

                              – Legends
                              Feb 6 '18 at 23:31











                            • Tried it, not working

                              – Loic Coenen
                              Apr 2 '18 at 13:49






                            • 3





                              Erratum: It works using this line import {Promise} from 'es6-promise';

                              – Loic Coenen
                              Apr 2 '18 at 13:52













                            • where to add "import {Promise} from 'es6-promise'" ?

                              – bArraxas
                              Jul 24 '18 at 7:54














                            • 2





                              + and restarting VS Code helps too, after installation of the types

                              – Legends
                              Feb 6 '18 at 23:31











                            • Tried it, not working

                              – Loic Coenen
                              Apr 2 '18 at 13:49






                            • 3





                              Erratum: It works using this line import {Promise} from 'es6-promise';

                              – Loic Coenen
                              Apr 2 '18 at 13:52













                            • where to add "import {Promise} from 'es6-promise'" ?

                              – bArraxas
                              Jul 24 '18 at 7:54








                            2




                            2





                            + and restarting VS Code helps too, after installation of the types

                            – Legends
                            Feb 6 '18 at 23:31





                            + and restarting VS Code helps too, after installation of the types

                            – Legends
                            Feb 6 '18 at 23:31













                            Tried it, not working

                            – Loic Coenen
                            Apr 2 '18 at 13:49





                            Tried it, not working

                            – Loic Coenen
                            Apr 2 '18 at 13:49




                            3




                            3





                            Erratum: It works using this line import {Promise} from 'es6-promise';

                            – Loic Coenen
                            Apr 2 '18 at 13:52







                            Erratum: It works using this line import {Promise} from 'es6-promise';

                            – Loic Coenen
                            Apr 2 '18 at 13:52















                            where to add "import {Promise} from 'es6-promise'" ?

                            – bArraxas
                            Jul 24 '18 at 7:54





                            where to add "import {Promise} from 'es6-promise'" ?

                            – bArraxas
                            Jul 24 '18 at 7:54











                            29














                            I solved this by adding below code to tsconfig.json file.



                            "lib": [
                            "ES5",
                            "ES2015",
                            "DOM",
                            "ScriptHost"]





                            share|improve this answer





















                            • 2





                              this worked for me, but note that the "lib" array needs to be inside of the "compilerOptions" object in the tsconfig.json file.

                              – BillyRayCyrus
                              Jun 29 '17 at 14:46






                            • 2





                              Using TypeScript 2.4.1 I had to change all of the characters in the string array to be lowercase. Then it worked. Many thanks.

                              – JDTLH9
                              Jul 18 '17 at 10:57


















                            29














                            I solved this by adding below code to tsconfig.json file.



                            "lib": [
                            "ES5",
                            "ES2015",
                            "DOM",
                            "ScriptHost"]





                            share|improve this answer





















                            • 2





                              this worked for me, but note that the "lib" array needs to be inside of the "compilerOptions" object in the tsconfig.json file.

                              – BillyRayCyrus
                              Jun 29 '17 at 14:46






                            • 2





                              Using TypeScript 2.4.1 I had to change all of the characters in the string array to be lowercase. Then it worked. Many thanks.

                              – JDTLH9
                              Jul 18 '17 at 10:57
















                            29












                            29








                            29







                            I solved this by adding below code to tsconfig.json file.



                            "lib": [
                            "ES5",
                            "ES2015",
                            "DOM",
                            "ScriptHost"]





                            share|improve this answer















                            I solved this by adding below code to tsconfig.json file.



                            "lib": [
                            "ES5",
                            "ES2015",
                            "DOM",
                            "ScriptHost"]






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited May 18 '17 at 20:54









                            csano

                            10.7k12241




                            10.7k12241










                            answered May 14 '17 at 8:59









                            NileshNilesh

                            29922




                            29922








                            • 2





                              this worked for me, but note that the "lib" array needs to be inside of the "compilerOptions" object in the tsconfig.json file.

                              – BillyRayCyrus
                              Jun 29 '17 at 14:46






                            • 2





                              Using TypeScript 2.4.1 I had to change all of the characters in the string array to be lowercase. Then it worked. Many thanks.

                              – JDTLH9
                              Jul 18 '17 at 10:57
















                            • 2





                              this worked for me, but note that the "lib" array needs to be inside of the "compilerOptions" object in the tsconfig.json file.

                              – BillyRayCyrus
                              Jun 29 '17 at 14:46






                            • 2





                              Using TypeScript 2.4.1 I had to change all of the characters in the string array to be lowercase. Then it worked. Many thanks.

                              – JDTLH9
                              Jul 18 '17 at 10:57










                            2




                            2





                            this worked for me, but note that the "lib" array needs to be inside of the "compilerOptions" object in the tsconfig.json file.

                            – BillyRayCyrus
                            Jun 29 '17 at 14:46





                            this worked for me, but note that the "lib" array needs to be inside of the "compilerOptions" object in the tsconfig.json file.

                            – BillyRayCyrus
                            Jun 29 '17 at 14:46




                            2




                            2





                            Using TypeScript 2.4.1 I had to change all of the characters in the string array to be lowercase. Then it worked. Many thanks.

                            – JDTLH9
                            Jul 18 '17 at 10:57







                            Using TypeScript 2.4.1 I had to change all of the characters in the string array to be lowercase. Then it worked. Many thanks.

                            – JDTLH9
                            Jul 18 '17 at 10:57













                            17














                            Solved by changing the target in compilerOptions.



                            {
                            "compilerOptions": {
                            "module": "es2015",
                            "target": "es2015",
                            "lib": [
                            "es2016",
                            "dom"
                            ],
                            "moduleResolution": "node",
                            "noImplicitAny": false,
                            "sourceMap": false,
                            "emitDecoratorMetadata": true,
                            "experimentalDecorators": true,
                            "outDir": "./public/js/app"
                            },
                            "exclude": [
                            "node_modules",
                            "public/js",
                            "assets/app/polyfills.ts"
                            ],
                            "angularCompilerOptions": {
                            "skipMetadataEmit": true
                            }
                            }





                            share|improve this answer




























                              17














                              Solved by changing the target in compilerOptions.



                              {
                              "compilerOptions": {
                              "module": "es2015",
                              "target": "es2015",
                              "lib": [
                              "es2016",
                              "dom"
                              ],
                              "moduleResolution": "node",
                              "noImplicitAny": false,
                              "sourceMap": false,
                              "emitDecoratorMetadata": true,
                              "experimentalDecorators": true,
                              "outDir": "./public/js/app"
                              },
                              "exclude": [
                              "node_modules",
                              "public/js",
                              "assets/app/polyfills.ts"
                              ],
                              "angularCompilerOptions": {
                              "skipMetadataEmit": true
                              }
                              }





                              share|improve this answer


























                                17












                                17








                                17







                                Solved by changing the target in compilerOptions.



                                {
                                "compilerOptions": {
                                "module": "es2015",
                                "target": "es2015",
                                "lib": [
                                "es2016",
                                "dom"
                                ],
                                "moduleResolution": "node",
                                "noImplicitAny": false,
                                "sourceMap": false,
                                "emitDecoratorMetadata": true,
                                "experimentalDecorators": true,
                                "outDir": "./public/js/app"
                                },
                                "exclude": [
                                "node_modules",
                                "public/js",
                                "assets/app/polyfills.ts"
                                ],
                                "angularCompilerOptions": {
                                "skipMetadataEmit": true
                                }
                                }





                                share|improve this answer













                                Solved by changing the target in compilerOptions.



                                {
                                "compilerOptions": {
                                "module": "es2015",
                                "target": "es2015",
                                "lib": [
                                "es2016",
                                "dom"
                                ],
                                "moduleResolution": "node",
                                "noImplicitAny": false,
                                "sourceMap": false,
                                "emitDecoratorMetadata": true,
                                "experimentalDecorators": true,
                                "outDir": "./public/js/app"
                                },
                                "exclude": [
                                "node_modules",
                                "public/js",
                                "assets/app/polyfills.ts"
                                ],
                                "angularCompilerOptions": {
                                "skipMetadataEmit": true
                                }
                                }






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered May 31 '17 at 20:02









                                Mani SMani S

                                1,103512




                                1,103512























                                    9














                                    Here is my tip. Tested with vscode 1.21.1 (on MAC)



                                    Put below config to tsconfig.json



                                    "lib": [
                                    "es2016",
                                    "dom"
                                    ]


                                    into
                                    compilerOptions



                                    Restart IDE (this action is required :D )






                                    share|improve this answer





















                                    • 3





                                      This is listed in multiple of the answers here and it important for sure: "Restart IDE (this action is required)"

                                      – atconway
                                      Sep 19 '18 at 19:07


















                                    9














                                    Here is my tip. Tested with vscode 1.21.1 (on MAC)



                                    Put below config to tsconfig.json



                                    "lib": [
                                    "es2016",
                                    "dom"
                                    ]


                                    into
                                    compilerOptions



                                    Restart IDE (this action is required :D )






                                    share|improve this answer





















                                    • 3





                                      This is listed in multiple of the answers here and it important for sure: "Restart IDE (this action is required)"

                                      – atconway
                                      Sep 19 '18 at 19:07
















                                    9












                                    9








                                    9







                                    Here is my tip. Tested with vscode 1.21.1 (on MAC)



                                    Put below config to tsconfig.json



                                    "lib": [
                                    "es2016",
                                    "dom"
                                    ]


                                    into
                                    compilerOptions



                                    Restart IDE (this action is required :D )






                                    share|improve this answer















                                    Here is my tip. Tested with vscode 1.21.1 (on MAC)



                                    Put below config to tsconfig.json



                                    "lib": [
                                    "es2016",
                                    "dom"
                                    ]


                                    into
                                    compilerOptions



                                    Restart IDE (this action is required :D )







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited May 9 '18 at 11:07

























                                    answered Mar 25 '18 at 15:10









                                    Nhan CaoNhan Cao

                                    1,430910




                                    1,430910








                                    • 3





                                      This is listed in multiple of the answers here and it important for sure: "Restart IDE (this action is required)"

                                      – atconway
                                      Sep 19 '18 at 19:07
















                                    • 3





                                      This is listed in multiple of the answers here and it important for sure: "Restart IDE (this action is required)"

                                      – atconway
                                      Sep 19 '18 at 19:07










                                    3




                                    3





                                    This is listed in multiple of the answers here and it important for sure: "Restart IDE (this action is required)"

                                    – atconway
                                    Sep 19 '18 at 19:07







                                    This is listed in multiple of the answers here and it important for sure: "Restart IDE (this action is required)"

                                    – atconway
                                    Sep 19 '18 at 19:07













                                    8














                                    Add below line to file where error is being thrown.This should fix the issue



                                    declare var Promise: any;





                                    share|improve this answer



















                                    • 14





                                      This is just removing the type check for 'Promise,' rather than fixing it so Typescript finds the correct type.

                                      – edibleEnergy
                                      Dec 11 '17 at 1:05






                                    • 1





                                      This workaround does not work with Internet Explorer 11 for example. I throws an 'undefined' error when trying to use Promise. Anyway with Chrome the workaround does his job.

                                      – adSad
                                      Jun 21 '18 at 7:59


















                                    8














                                    Add below line to file where error is being thrown.This should fix the issue



                                    declare var Promise: any;





                                    share|improve this answer



















                                    • 14





                                      This is just removing the type check for 'Promise,' rather than fixing it so Typescript finds the correct type.

                                      – edibleEnergy
                                      Dec 11 '17 at 1:05






                                    • 1





                                      This workaround does not work with Internet Explorer 11 for example. I throws an 'undefined' error when trying to use Promise. Anyway with Chrome the workaround does his job.

                                      – adSad
                                      Jun 21 '18 at 7:59
















                                    8












                                    8








                                    8







                                    Add below line to file where error is being thrown.This should fix the issue



                                    declare var Promise: any;





                                    share|improve this answer













                                    Add below line to file where error is being thrown.This should fix the issue



                                    declare var Promise: any;






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jun 9 '17 at 9:11









                                    Imamudin NaseemImamudin Naseem

                                    976916




                                    976916








                                    • 14





                                      This is just removing the type check for 'Promise,' rather than fixing it so Typescript finds the correct type.

                                      – edibleEnergy
                                      Dec 11 '17 at 1:05






                                    • 1





                                      This workaround does not work with Internet Explorer 11 for example. I throws an 'undefined' error when trying to use Promise. Anyway with Chrome the workaround does his job.

                                      – adSad
                                      Jun 21 '18 at 7:59
















                                    • 14





                                      This is just removing the type check for 'Promise,' rather than fixing it so Typescript finds the correct type.

                                      – edibleEnergy
                                      Dec 11 '17 at 1:05






                                    • 1





                                      This workaround does not work with Internet Explorer 11 for example. I throws an 'undefined' error when trying to use Promise. Anyway with Chrome the workaround does his job.

                                      – adSad
                                      Jun 21 '18 at 7:59










                                    14




                                    14





                                    This is just removing the type check for 'Promise,' rather than fixing it so Typescript finds the correct type.

                                    – edibleEnergy
                                    Dec 11 '17 at 1:05





                                    This is just removing the type check for 'Promise,' rather than fixing it so Typescript finds the correct type.

                                    – edibleEnergy
                                    Dec 11 '17 at 1:05




                                    1




                                    1





                                    This workaround does not work with Internet Explorer 11 for example. I throws an 'undefined' error when trying to use Promise. Anyway with Chrome the workaround does his job.

                                    – adSad
                                    Jun 21 '18 at 7:59







                                    This workaround does not work with Internet Explorer 11 for example. I throws an 'undefined' error when trying to use Promise. Anyway with Chrome the workaround does his job.

                                    – adSad
                                    Jun 21 '18 at 7:59













                                    3














                                    Finally tsc started working without any errors. But multiple changes. Thanks to Sandro Keil, Pointy & unional




                                    • Removed dt~aws-lambda

                                    • Removed options like noEmit,declaration

                                    • Modified Gruntfile and removed ignoreSettings


                                    tsconfig.json



                                    {
                                    "compileOnSave": true,
                                    "compilerOptions": {
                                    "module": "commonjs",
                                    "target": "es5",
                                    "noImplicitAny": false,
                                    "strictNullChecks": true,
                                    "alwaysStrict": true,
                                    "preserveConstEnums": true,
                                    "sourceMap": false,
                                    "moduleResolution": "Node",
                                    "lib": [
                                    "dom",
                                    "es2015",
                                    "es5",
                                    "es6"
                                    ]
                                    },
                                    "include": [
                                    "*",
                                    "src/**/*"
                                    ],
                                    "exclude": [
                                    "./node_modules"
                                    ]
                                    }


                                    Gruntfile.js



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





                                    share|improve this answer






























                                      3














                                      Finally tsc started working without any errors. But multiple changes. Thanks to Sandro Keil, Pointy & unional




                                      • Removed dt~aws-lambda

                                      • Removed options like noEmit,declaration

                                      • Modified Gruntfile and removed ignoreSettings


                                      tsconfig.json



                                      {
                                      "compileOnSave": true,
                                      "compilerOptions": {
                                      "module": "commonjs",
                                      "target": "es5",
                                      "noImplicitAny": false,
                                      "strictNullChecks": true,
                                      "alwaysStrict": true,
                                      "preserveConstEnums": true,
                                      "sourceMap": false,
                                      "moduleResolution": "Node",
                                      "lib": [
                                      "dom",
                                      "es2015",
                                      "es5",
                                      "es6"
                                      ]
                                      },
                                      "include": [
                                      "*",
                                      "src/**/*"
                                      ],
                                      "exclude": [
                                      "./node_modules"
                                      ]
                                      }


                                      Gruntfile.js



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





                                      share|improve this answer




























                                        3












                                        3








                                        3







                                        Finally tsc started working without any errors. But multiple changes. Thanks to Sandro Keil, Pointy & unional




                                        • Removed dt~aws-lambda

                                        • Removed options like noEmit,declaration

                                        • Modified Gruntfile and removed ignoreSettings


                                        tsconfig.json



                                        {
                                        "compileOnSave": true,
                                        "compilerOptions": {
                                        "module": "commonjs",
                                        "target": "es5",
                                        "noImplicitAny": false,
                                        "strictNullChecks": true,
                                        "alwaysStrict": true,
                                        "preserveConstEnums": true,
                                        "sourceMap": false,
                                        "moduleResolution": "Node",
                                        "lib": [
                                        "dom",
                                        "es2015",
                                        "es5",
                                        "es6"
                                        ]
                                        },
                                        "include": [
                                        "*",
                                        "src/**/*"
                                        ],
                                        "exclude": [
                                        "./node_modules"
                                        ]
                                        }


                                        Gruntfile.js



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





                                        share|improve this answer















                                        Finally tsc started working without any errors. But multiple changes. Thanks to Sandro Keil, Pointy & unional




                                        • Removed dt~aws-lambda

                                        • Removed options like noEmit,declaration

                                        • Modified Gruntfile and removed ignoreSettings


                                        tsconfig.json



                                        {
                                        "compileOnSave": true,
                                        "compilerOptions": {
                                        "module": "commonjs",
                                        "target": "es5",
                                        "noImplicitAny": false,
                                        "strictNullChecks": true,
                                        "alwaysStrict": true,
                                        "preserveConstEnums": true,
                                        "sourceMap": false,
                                        "moduleResolution": "Node",
                                        "lib": [
                                        "dom",
                                        "es2015",
                                        "es5",
                                        "es6"
                                        ]
                                        },
                                        "include": [
                                        "*",
                                        "src/**/*"
                                        ],
                                        "exclude": [
                                        "./node_modules"
                                        ]
                                        }


                                        Gruntfile.js



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






                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited May 23 '17 at 12:10









                                        Community

                                        11




                                        11










                                        answered Apr 3 '17 at 18:41









                                        kalyanvgopalkalyanvgopal

                                        7162712




                                        7162712























                                            3














                                            None of the up-voted answers here work for me. Here is a guaranteed and reasonable solution. Put this near the top of any code file that uses Promise...



                                            declare const Promise: any;





                                            share|improve this answer




























                                              3














                                              None of the up-voted answers here work for me. Here is a guaranteed and reasonable solution. Put this near the top of any code file that uses Promise...



                                              declare const Promise: any;





                                              share|improve this answer


























                                                3












                                                3








                                                3







                                                None of the up-voted answers here work for me. Here is a guaranteed and reasonable solution. Put this near the top of any code file that uses Promise...



                                                declare const Promise: any;





                                                share|improve this answer













                                                None of the up-voted answers here work for me. Here is a guaranteed and reasonable solution. Put this near the top of any code file that uses Promise...



                                                declare const Promise: any;






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Apr 6 '18 at 16:56









                                                user1618323user1618323

                                                23246




                                                23246























                                                    2














                                                    Had the same issue with typescript and the aws-sdk. The solve was to change the target to es6.



                                                    My complete tsconfig.json file:



                                                    {
                                                    compilerOptions: {
                                                    outDir: ./dist/,
                                                    sourceMap: true,
                                                    noImplicitAny: true,
                                                    module: commonjs,
                                                    target: es6,
                                                    jsx: react,
                                                    allowJs: true
                                                    },
                                                    include: [
                                                    ./src/**/*
                                                    ]
                                                    }





                                                    share|improve this answer



















                                                    • 3





                                                      Yes tartgeting es6 should fix it, but then you have less browser compatibility. Most apps are still today targeting es5, because many browsers still aren't on es6 yet (as of 2017)

                                                      – user2080225
                                                      Oct 9 '17 at 22:59











                                                    • @user2080225 although that is true, it doesn't make my answer less correct since the original question didn't state anything about browser compatibility. Therefore this solution could still help others like it helped me.

                                                      – Fanus du Toit
                                                      Apr 9 '18 at 19:26
















                                                    2














                                                    Had the same issue with typescript and the aws-sdk. The solve was to change the target to es6.



                                                    My complete tsconfig.json file:



                                                    {
                                                    compilerOptions: {
                                                    outDir: ./dist/,
                                                    sourceMap: true,
                                                    noImplicitAny: true,
                                                    module: commonjs,
                                                    target: es6,
                                                    jsx: react,
                                                    allowJs: true
                                                    },
                                                    include: [
                                                    ./src/**/*
                                                    ]
                                                    }





                                                    share|improve this answer



















                                                    • 3





                                                      Yes tartgeting es6 should fix it, but then you have less browser compatibility. Most apps are still today targeting es5, because many browsers still aren't on es6 yet (as of 2017)

                                                      – user2080225
                                                      Oct 9 '17 at 22:59











                                                    • @user2080225 although that is true, it doesn't make my answer less correct since the original question didn't state anything about browser compatibility. Therefore this solution could still help others like it helped me.

                                                      – Fanus du Toit
                                                      Apr 9 '18 at 19:26














                                                    2












                                                    2








                                                    2







                                                    Had the same issue with typescript and the aws-sdk. The solve was to change the target to es6.



                                                    My complete tsconfig.json file:



                                                    {
                                                    compilerOptions: {
                                                    outDir: ./dist/,
                                                    sourceMap: true,
                                                    noImplicitAny: true,
                                                    module: commonjs,
                                                    target: es6,
                                                    jsx: react,
                                                    allowJs: true
                                                    },
                                                    include: [
                                                    ./src/**/*
                                                    ]
                                                    }





                                                    share|improve this answer













                                                    Had the same issue with typescript and the aws-sdk. The solve was to change the target to es6.



                                                    My complete tsconfig.json file:



                                                    {
                                                    compilerOptions: {
                                                    outDir: ./dist/,
                                                    sourceMap: true,
                                                    noImplicitAny: true,
                                                    module: commonjs,
                                                    target: es6,
                                                    jsx: react,
                                                    allowJs: true
                                                    },
                                                    include: [
                                                    ./src/**/*
                                                    ]
                                                    }






                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Aug 11 '17 at 9:35









                                                    Fanus du ToitFanus du Toit

                                                    436513




                                                    436513








                                                    • 3





                                                      Yes tartgeting es6 should fix it, but then you have less browser compatibility. Most apps are still today targeting es5, because many browsers still aren't on es6 yet (as of 2017)

                                                      – user2080225
                                                      Oct 9 '17 at 22:59











                                                    • @user2080225 although that is true, it doesn't make my answer less correct since the original question didn't state anything about browser compatibility. Therefore this solution could still help others like it helped me.

                                                      – Fanus du Toit
                                                      Apr 9 '18 at 19:26














                                                    • 3





                                                      Yes tartgeting es6 should fix it, but then you have less browser compatibility. Most apps are still today targeting es5, because many browsers still aren't on es6 yet (as of 2017)

                                                      – user2080225
                                                      Oct 9 '17 at 22:59











                                                    • @user2080225 although that is true, it doesn't make my answer less correct since the original question didn't state anything about browser compatibility. Therefore this solution could still help others like it helped me.

                                                      – Fanus du Toit
                                                      Apr 9 '18 at 19:26








                                                    3




                                                    3





                                                    Yes tartgeting es6 should fix it, but then you have less browser compatibility. Most apps are still today targeting es5, because many browsers still aren't on es6 yet (as of 2017)

                                                    – user2080225
                                                    Oct 9 '17 at 22:59





                                                    Yes tartgeting es6 should fix it, but then you have less browser compatibility. Most apps are still today targeting es5, because many browsers still aren't on es6 yet (as of 2017)

                                                    – user2080225
                                                    Oct 9 '17 at 22:59













                                                    @user2080225 although that is true, it doesn't make my answer less correct since the original question didn't state anything about browser compatibility. Therefore this solution could still help others like it helped me.

                                                    – Fanus du Toit
                                                    Apr 9 '18 at 19:26





                                                    @user2080225 although that is true, it doesn't make my answer less correct since the original question didn't state anything about browser compatibility. Therefore this solution could still help others like it helped me.

                                                    – Fanus du Toit
                                                    Apr 9 '18 at 19:26











                                                    1














                                                    I had the same problem and this saved me from the problem in second:



                                                    write in console this:



                                                    npm i --save bluebird
                                                    npm i --save-dev @types/bluebird @types/core-js@0.9.36


                                                    in the file where the problem is copy paste this:



                                                    import * as Promise from 'bluebird';





                                                    share|improve this answer






























                                                      1














                                                      I had the same problem and this saved me from the problem in second:



                                                      write in console this:



                                                      npm i --save bluebird
                                                      npm i --save-dev @types/bluebird @types/core-js@0.9.36


                                                      in the file where the problem is copy paste this:



                                                      import * as Promise from 'bluebird';





                                                      share|improve this answer




























                                                        1












                                                        1








                                                        1







                                                        I had the same problem and this saved me from the problem in second:



                                                        write in console this:



                                                        npm i --save bluebird
                                                        npm i --save-dev @types/bluebird @types/core-js@0.9.36


                                                        in the file where the problem is copy paste this:



                                                        import * as Promise from 'bluebird';





                                                        share|improve this answer















                                                        I had the same problem and this saved me from the problem in second:



                                                        write in console this:



                                                        npm i --save bluebird
                                                        npm i --save-dev @types/bluebird @types/core-js@0.9.36


                                                        in the file where the problem is copy paste this:



                                                        import * as Promise from 'bluebird';






                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Aug 8 '17 at 14:13

























                                                        answered Aug 7 '17 at 9:21









                                                        Zack ZilicZack Zilic

                                                        378217




                                                        378217























                                                            1














                                                            I am using the "promise-polyfill" library, which may be the cause of my issue.



                                                            I added this import to the top of my file:



                                                            import {Promise} from 'es6-promise';





                                                            share|improve this answer




























                                                              1














                                                              I am using the "promise-polyfill" library, which may be the cause of my issue.



                                                              I added this import to the top of my file:



                                                              import {Promise} from 'es6-promise';





                                                              share|improve this answer


























                                                                1












                                                                1








                                                                1







                                                                I am using the "promise-polyfill" library, which may be the cause of my issue.



                                                                I added this import to the top of my file:



                                                                import {Promise} from 'es6-promise';





                                                                share|improve this answer













                                                                I am using the "promise-polyfill" library, which may be the cause of my issue.



                                                                I added this import to the top of my file:



                                                                import {Promise} from 'es6-promise';






                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered Mar 30 '18 at 23:37









                                                                Matthias DaileyMatthias Dailey

                                                                4,15742337




                                                                4,15742337























                                                                    1














                                                                    I had the same issue until I added the following lib array in typeScript 3.0.1



                                                                    tsconfig.json



                                                                    {
                                                                    "compilerOptions": {
                                                                    "outDir": "lib",
                                                                    "module": "commonjs",
                                                                    "allowJs": false,
                                                                    "declaration": true,
                                                                    "target": "es5",
                                                                    "lib": ["dom", "es2015", "es5", "es6"],
                                                                    "rootDir": "src"
                                                                    },
                                                                    "include": ["./**/*"],
                                                                    "exclude": ["node_modules", "**/*.spec.ts"]
                                                                    }





                                                                    share|improve this answer






























                                                                      1














                                                                      I had the same issue until I added the following lib array in typeScript 3.0.1



                                                                      tsconfig.json



                                                                      {
                                                                      "compilerOptions": {
                                                                      "outDir": "lib",
                                                                      "module": "commonjs",
                                                                      "allowJs": false,
                                                                      "declaration": true,
                                                                      "target": "es5",
                                                                      "lib": ["dom", "es2015", "es5", "es6"],
                                                                      "rootDir": "src"
                                                                      },
                                                                      "include": ["./**/*"],
                                                                      "exclude": ["node_modules", "**/*.spec.ts"]
                                                                      }





                                                                      share|improve this answer




























                                                                        1












                                                                        1








                                                                        1







                                                                        I had the same issue until I added the following lib array in typeScript 3.0.1



                                                                        tsconfig.json



                                                                        {
                                                                        "compilerOptions": {
                                                                        "outDir": "lib",
                                                                        "module": "commonjs",
                                                                        "allowJs": false,
                                                                        "declaration": true,
                                                                        "target": "es5",
                                                                        "lib": ["dom", "es2015", "es5", "es6"],
                                                                        "rootDir": "src"
                                                                        },
                                                                        "include": ["./**/*"],
                                                                        "exclude": ["node_modules", "**/*.spec.ts"]
                                                                        }





                                                                        share|improve this answer















                                                                        I had the same issue until I added the following lib array in typeScript 3.0.1



                                                                        tsconfig.json



                                                                        {
                                                                        "compilerOptions": {
                                                                        "outDir": "lib",
                                                                        "module": "commonjs",
                                                                        "allowJs": false,
                                                                        "declaration": true,
                                                                        "target": "es5",
                                                                        "lib": ["dom", "es2015", "es5", "es6"],
                                                                        "rootDir": "src"
                                                                        },
                                                                        "include": ["./**/*"],
                                                                        "exclude": ["node_modules", "**/*.spec.ts"]
                                                                        }






                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited Aug 18 '18 at 16:39

























                                                                        answered Aug 18 '18 at 16:15









                                                                        Jon GearJon Gear

                                                                        566515




                                                                        566515























                                                                            1














                                                                            I had this error but I resolved it by using this command, my ts file name is promises-fs.ts:



                                                                            tsc promises-fs.ts --target es6 && node promises-fs.js


                                                                            and the error is gone






                                                                            share|improve this answer




























                                                                              1














                                                                              I had this error but I resolved it by using this command, my ts file name is promises-fs.ts:



                                                                              tsc promises-fs.ts --target es6 && node promises-fs.js


                                                                              and the error is gone






                                                                              share|improve this answer


























                                                                                1












                                                                                1








                                                                                1







                                                                                I had this error but I resolved it by using this command, my ts file name is promises-fs.ts:



                                                                                tsc promises-fs.ts --target es6 && node promises-fs.js


                                                                                and the error is gone






                                                                                share|improve this answer













                                                                                I had this error but I resolved it by using this command, my ts file name is promises-fs.ts:



                                                                                tsc promises-fs.ts --target es6 && node promises-fs.js


                                                                                and the error is gone







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Sep 20 '18 at 12:45









                                                                                Hazem HASANHazem HASAN

                                                                                4842720




                                                                                4842720























                                                                                    0














                                                                                    Core-js did not work for me as it caused other issues, however, simply installing the latest version of npm i @types/es6-promise --save-dev got rid of the issues. The issues for me stemmed from compiling an sdk that was using rxjs. Here is the error I was getting:



                                                                                    `node_modules/rxjs/Observable.d.ts(59,60): error TS2693: Promise only refers to a type, but is being used as a value here.`





                                                                                    share|improve this answer




























                                                                                      0














                                                                                      Core-js did not work for me as it caused other issues, however, simply installing the latest version of npm i @types/es6-promise --save-dev got rid of the issues. The issues for me stemmed from compiling an sdk that was using rxjs. Here is the error I was getting:



                                                                                      `node_modules/rxjs/Observable.d.ts(59,60): error TS2693: Promise only refers to a type, but is being used as a value here.`





                                                                                      share|improve this answer


























                                                                                        0












                                                                                        0








                                                                                        0







                                                                                        Core-js did not work for me as it caused other issues, however, simply installing the latest version of npm i @types/es6-promise --save-dev got rid of the issues. The issues for me stemmed from compiling an sdk that was using rxjs. Here is the error I was getting:



                                                                                        `node_modules/rxjs/Observable.d.ts(59,60): error TS2693: Promise only refers to a type, but is being used as a value here.`





                                                                                        share|improve this answer













                                                                                        Core-js did not work for me as it caused other issues, however, simply installing the latest version of npm i @types/es6-promise --save-dev got rid of the issues. The issues for me stemmed from compiling an sdk that was using rxjs. Here is the error I was getting:



                                                                                        `node_modules/rxjs/Observable.d.ts(59,60): error TS2693: Promise only refers to a type, but is being used as a value here.`






                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Nov 14 '17 at 17:56









                                                                                        Danny FenstermakerDanny Fenstermaker

                                                                                        576510




                                                                                        576510























                                                                                            0














                                                                                            Just change the target to "ES2017" in tsconfig.json file.



                                                                                            this is my tsconfig.json file



                                                                                            {
                                                                                            "compilerOptions": {
                                                                                            /* Basic Options */
                                                                                            "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
                                                                                            "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
                                                                                            "declaration": true, /* Generates corresponding '.d.ts' file. */
                                                                                            "sourceMap": true, /* Generates corresponding '.map' file. */
                                                                                            "outDir": "./dist", /* Redirect output structure to the directory. */
                                                                                            "strict": true /* Enable all strict type-checking options. */
                                                                                            },
                                                                                            "include": [
                                                                                            "src/**/*"
                                                                                            ],
                                                                                            "exclude": [
                                                                                            "node_modules"
                                                                                            ]
                                                                                            }





                                                                                            share|improve this answer




























                                                                                              0














                                                                                              Just change the target to "ES2017" in tsconfig.json file.



                                                                                              this is my tsconfig.json file



                                                                                              {
                                                                                              "compilerOptions": {
                                                                                              /* Basic Options */
                                                                                              "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
                                                                                              "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
                                                                                              "declaration": true, /* Generates corresponding '.d.ts' file. */
                                                                                              "sourceMap": true, /* Generates corresponding '.map' file. */
                                                                                              "outDir": "./dist", /* Redirect output structure to the directory. */
                                                                                              "strict": true /* Enable all strict type-checking options. */
                                                                                              },
                                                                                              "include": [
                                                                                              "src/**/*"
                                                                                              ],
                                                                                              "exclude": [
                                                                                              "node_modules"
                                                                                              ]
                                                                                              }





                                                                                              share|improve this answer


























                                                                                                0












                                                                                                0








                                                                                                0







                                                                                                Just change the target to "ES2017" in tsconfig.json file.



                                                                                                this is my tsconfig.json file



                                                                                                {
                                                                                                "compilerOptions": {
                                                                                                /* Basic Options */
                                                                                                "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
                                                                                                "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
                                                                                                "declaration": true, /* Generates corresponding '.d.ts' file. */
                                                                                                "sourceMap": true, /* Generates corresponding '.map' file. */
                                                                                                "outDir": "./dist", /* Redirect output structure to the directory. */
                                                                                                "strict": true /* Enable all strict type-checking options. */
                                                                                                },
                                                                                                "include": [
                                                                                                "src/**/*"
                                                                                                ],
                                                                                                "exclude": [
                                                                                                "node_modules"
                                                                                                ]
                                                                                                }





                                                                                                share|improve this answer













                                                                                                Just change the target to "ES2017" in tsconfig.json file.



                                                                                                this is my tsconfig.json file



                                                                                                {
                                                                                                "compilerOptions": {
                                                                                                /* Basic Options */
                                                                                                "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
                                                                                                "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
                                                                                                "declaration": true, /* Generates corresponding '.d.ts' file. */
                                                                                                "sourceMap": true, /* Generates corresponding '.map' file. */
                                                                                                "outDir": "./dist", /* Redirect output structure to the directory. */
                                                                                                "strict": true /* Enable all strict type-checking options. */
                                                                                                },
                                                                                                "include": [
                                                                                                "src/**/*"
                                                                                                ],
                                                                                                "exclude": [
                                                                                                "node_modules"
                                                                                                ]
                                                                                                }






                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered Feb 8 '18 at 4:47









                                                                                                Camilo SotoCamilo Soto

                                                                                                11610




                                                                                                11610























                                                                                                    0














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



                                                                                                    after up command, you'd better check tsconfig.json make sure the "target" must great than "es6". maybe tsc not support es5 yet.






                                                                                                    share|improve this answer




























                                                                                                      0














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



                                                                                                      after up command, you'd better check tsconfig.json make sure the "target" must great than "es6". maybe tsc not support es5 yet.






                                                                                                      share|improve this answer


























                                                                                                        0












                                                                                                        0








                                                                                                        0







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



                                                                                                        after up command, you'd better check tsconfig.json make sure the "target" must great than "es6". maybe tsc not support es5 yet.






                                                                                                        share|improve this answer













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



                                                                                                        after up command, you'd better check tsconfig.json make sure the "target" must great than "es6". maybe tsc not support es5 yet.







                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered Mar 4 '18 at 15:54









                                                                                                        MostoneMostone

                                                                                                        91




                                                                                                        91























                                                                                                            0














                                                                                                            Having spent lot of time trying to fix this. I had no luck with any solution provide here or elsewhere.



                                                                                                            But then later realised it wasn't so much as just solving the issue. But you also need to RESTART the VSCODE for it to take affect.






                                                                                                            share|improve this answer




























                                                                                                              0














                                                                                                              Having spent lot of time trying to fix this. I had no luck with any solution provide here or elsewhere.



                                                                                                              But then later realised it wasn't so much as just solving the issue. But you also need to RESTART the VSCODE for it to take affect.






                                                                                                              share|improve this answer


























                                                                                                                0












                                                                                                                0








                                                                                                                0







                                                                                                                Having spent lot of time trying to fix this. I had no luck with any solution provide here or elsewhere.



                                                                                                                But then later realised it wasn't so much as just solving the issue. But you also need to RESTART the VSCODE for it to take affect.






                                                                                                                share|improve this answer













                                                                                                                Having spent lot of time trying to fix this. I had no luck with any solution provide here or elsewhere.



                                                                                                                But then later realised it wasn't so much as just solving the issue. But you also need to RESTART the VSCODE for it to take affect.







                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered Apr 8 '18 at 15:42









                                                                                                                ravish.hackerravish.hacker

                                                                                                                618917




                                                                                                                618917























                                                                                                                    0














                                                                                                                    If you're using the DefinitelyTyped repository in your project you might be experiencing this recent issue.



                                                                                                                    A decent workaround you might use (other than waiting for an updated build of the definitions file or refactoring your TS code) is to specify an explicit version+build for the core-js typings rather than let Visual Studio pick the latest/most recent one. I found one that seems to be unaffected by this problem (in my case at least), you can use it replacing the following line from your package.json file:



                                                                                                                      "scripts": {
                                                                                                                    "postinstall": "typings install dt~core-js --global"
                                                                                                                    }


                                                                                                                    With the following one:



                                                                                                                      "scripts": {
                                                                                                                    "postinstall": "typings install dt~core-js@0.9.7+20161130133742 --global"
                                                                                                                    }


                                                                                                                    This fixed my issue for good. However, is highly recommended to remove the explicit version+build reference as soon as the issue will be released.



                                                                                                                    For further info regarding this issue, you can also read this blog post that I wrote on the topic.






                                                                                                                    share|improve this answer






























                                                                                                                      0














                                                                                                                      If you're using the DefinitelyTyped repository in your project you might be experiencing this recent issue.



                                                                                                                      A decent workaround you might use (other than waiting for an updated build of the definitions file or refactoring your TS code) is to specify an explicit version+build for the core-js typings rather than let Visual Studio pick the latest/most recent one. I found one that seems to be unaffected by this problem (in my case at least), you can use it replacing the following line from your package.json file:



                                                                                                                        "scripts": {
                                                                                                                      "postinstall": "typings install dt~core-js --global"
                                                                                                                      }


                                                                                                                      With the following one:



                                                                                                                        "scripts": {
                                                                                                                      "postinstall": "typings install dt~core-js@0.9.7+20161130133742 --global"
                                                                                                                      }


                                                                                                                      This fixed my issue for good. However, is highly recommended to remove the explicit version+build reference as soon as the issue will be released.



                                                                                                                      For further info regarding this issue, you can also read this blog post that I wrote on the topic.






                                                                                                                      share|improve this answer




























                                                                                                                        0












                                                                                                                        0








                                                                                                                        0







                                                                                                                        If you're using the DefinitelyTyped repository in your project you might be experiencing this recent issue.



                                                                                                                        A decent workaround you might use (other than waiting for an updated build of the definitions file or refactoring your TS code) is to specify an explicit version+build for the core-js typings rather than let Visual Studio pick the latest/most recent one. I found one that seems to be unaffected by this problem (in my case at least), you can use it replacing the following line from your package.json file:



                                                                                                                          "scripts": {
                                                                                                                        "postinstall": "typings install dt~core-js --global"
                                                                                                                        }


                                                                                                                        With the following one:



                                                                                                                          "scripts": {
                                                                                                                        "postinstall": "typings install dt~core-js@0.9.7+20161130133742 --global"
                                                                                                                        }


                                                                                                                        This fixed my issue for good. However, is highly recommended to remove the explicit version+build reference as soon as the issue will be released.



                                                                                                                        For further info regarding this issue, you can also read this blog post that I wrote on the topic.






                                                                                                                        share|improve this answer















                                                                                                                        If you're using the DefinitelyTyped repository in your project you might be experiencing this recent issue.



                                                                                                                        A decent workaround you might use (other than waiting for an updated build of the definitions file or refactoring your TS code) is to specify an explicit version+build for the core-js typings rather than let Visual Studio pick the latest/most recent one. I found one that seems to be unaffected by this problem (in my case at least), you can use it replacing the following line from your package.json file:



                                                                                                                          "scripts": {
                                                                                                                        "postinstall": "typings install dt~core-js --global"
                                                                                                                        }


                                                                                                                        With the following one:



                                                                                                                          "scripts": {
                                                                                                                        "postinstall": "typings install dt~core-js@0.9.7+20161130133742 --global"
                                                                                                                        }


                                                                                                                        This fixed my issue for good. However, is highly recommended to remove the explicit version+build reference as soon as the issue will be released.



                                                                                                                        For further info regarding this issue, you can also read this blog post that I wrote on the topic.







                                                                                                                        share|improve this answer














                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer








                                                                                                                        edited Oct 18 '18 at 14:56

























                                                                                                                        answered Apr 21 '17 at 15:05









                                                                                                                        DarksealDarkseal

                                                                                                                        5,51514070




                                                                                                                        5,51514070























                                                                                                                            0














                                                                                                                            Well, this might be counter-intuitive but I solved this adding esnext to my lib.



                                                                                                                            {
                                                                                                                            "compilerOptions": {
                                                                                                                            "lib": [
                                                                                                                            "esnext"
                                                                                                                            ],
                                                                                                                            "target": "es5",
                                                                                                                            }
                                                                                                                            }


                                                                                                                            The FIX, as suggested by the compiler is to




                                                                                                                            Try changing the lib compiler option to es2015 or later.







                                                                                                                            share|improve this answer




























                                                                                                                              0














                                                                                                                              Well, this might be counter-intuitive but I solved this adding esnext to my lib.



                                                                                                                              {
                                                                                                                              "compilerOptions": {
                                                                                                                              "lib": [
                                                                                                                              "esnext"
                                                                                                                              ],
                                                                                                                              "target": "es5",
                                                                                                                              }
                                                                                                                              }


                                                                                                                              The FIX, as suggested by the compiler is to




                                                                                                                              Try changing the lib compiler option to es2015 or later.







                                                                                                                              share|improve this answer


























                                                                                                                                0












                                                                                                                                0








                                                                                                                                0







                                                                                                                                Well, this might be counter-intuitive but I solved this adding esnext to my lib.



                                                                                                                                {
                                                                                                                                "compilerOptions": {
                                                                                                                                "lib": [
                                                                                                                                "esnext"
                                                                                                                                ],
                                                                                                                                "target": "es5",
                                                                                                                                }
                                                                                                                                }


                                                                                                                                The FIX, as suggested by the compiler is to




                                                                                                                                Try changing the lib compiler option to es2015 or later.







                                                                                                                                share|improve this answer













                                                                                                                                Well, this might be counter-intuitive but I solved this adding esnext to my lib.



                                                                                                                                {
                                                                                                                                "compilerOptions": {
                                                                                                                                "lib": [
                                                                                                                                "esnext"
                                                                                                                                ],
                                                                                                                                "target": "es5",
                                                                                                                                }
                                                                                                                                }


                                                                                                                                The FIX, as suggested by the compiler is to




                                                                                                                                Try changing the lib compiler option to es2015 or later.








                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered Dec 29 '18 at 8:43









                                                                                                                                Salathiel GenèseSalathiel Genèse

                                                                                                                                787616




                                                                                                                                787616






























                                                                                                                                    draft saved

                                                                                                                                    draft discarded




















































                                                                                                                                    Thanks for contributing an answer to Stack Overflow!


                                                                                                                                    • Please be sure to answer the question. Provide details and share your research!

                                                                                                                                    But avoid



                                                                                                                                    • Asking for help, clarification, or responding to other answers.

                                                                                                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                                    To learn more, see our tips on writing great answers.




                                                                                                                                    draft saved


                                                                                                                                    draft discarded














                                                                                                                                    StackExchange.ready(
                                                                                                                                    function () {
                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43119163%2ftypescript-error-ts2693-promise-only-refers-to-a-type-but-is-being-used-as%23new-answer', 'question_page');
                                                                                                                                    }
                                                                                                                                    );

                                                                                                                                    Post as a guest















                                                                                                                                    Required, but never shown





















































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown

































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown







                                                                                                                                    Popular posts from this blog

                                                                                                                                    Monofisismo

                                                                                                                                    Angular Downloading a file using contenturl with Basic Authentication

                                                                                                                                    Olmecas