Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
619 views
in Technique[技术] by (71.8m points)

angular - Property 'finally' does not exist on type 'Promise<void>'

I am trying to use the finally method on a promise but I keep getting this error.

Property 'finally' does not exist on type 'Promise<void>'.

I have looked up similar questions to this which have suggested adding "es2018.promise" to the "lib" array in tsconfig.js. This then produces the following error:

typescript error
        Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom',
        'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator',
        'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol',
        'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string',
        'es2017.intl', 'esnext.asynciterable'.

Any help resolving this is greatly appreciated!

question from:https://stackoverflow.com/questions/52079031/property-finally-does-not-exist-on-type-promisevoid

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For TypeScript 3.3.3, just add es2018.promise to your tsconfig.json - compilerOptions.lib config like this:

"lib": ["es2015", "es2016", "dom", "es2018.promise"]

If you use vscode, maybe you should reload window after adding this option to your tsconfig.json file


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...