I'm trying to use fs.readFile
with typescript like this...
import {readFile} from 'fs';
let str = await readFile('my.file', 'utf8');
It results in this error:
TS2345: Argument of type '"utf8"' is not assignable to parameter of type '(err: ErrnoException, data: Buffer) => void'
I'm using Typescript 2.5.2, and @types/node 8.0.30
await readFile(...)
becausereadFile()
does not return a promise.await
only works with functions that return a promise. – jfriend00