-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples on TypeScript #13
Comments
Hi @UnknownHero, Have you got a code snippet showing the problem you are having? |
I get your basic example - https://github.com/yortus/asyncawait#basic-example //references to node and asyncawait .d.ts
import Promise = require('bluebird');
import fs = require('fs');
import path = require('path');
import async = require('asyncawait/async');
import await = require('asyncawait/await');
var fsPromise = Promise.promisifyAll(fs);
// Return the number of files in the given directory
var countFiles = async (function(dir) {
var files = await (fsPromise.readdirSync(dir));
return 1;
});
countFiles(__dirname)
.then (function (num) { console.log('There are ' + num + ' files in ' + __dirname); })
.catch(function (err) { console.log('Something went wrong: ' + err); }); pachage.json {
"name": "",
"version": "0.0.1",
"dependencies": {
"asyncawait" : "0.7.4",
"bluebird" : "*",
}
} Compile command: tsc src/app.ts --sourceMap --outDir build/ --module commonjs Compiler version: 1.4.1.0
|
The problem is with this line: var fsPromise = Promise.promisifyAll(fs); The You can override the typing easily though, just replace the line with: var fsPromise: any = Promise.promisifyAll(fs); and you should be good to go. |
Thank you.
to:
and my code compile . Can write something like that ? :
or
I want autocomplete for Intellij Idea or Visual Studio. |
I suspect you mean to use the That's why I suggested typing Alternatively, you can promisify just the functions you want, like so: var readdirAsync = Promise.promisify(fs.readdir); in which case In general, the 'shape' of the return values of functions like |
Thank you so much ! |
Hello!
Can you provide examples written on TypeScript ?
I try do it, but get "types" errors when compile code.
Thanks
The text was updated successfully, but these errors were encountered: