Package URL: https://www.npmjs.com/package/dts-bundle-generator
- Using 'fs' module (or other node.js core packages) in TypeScript
- TypeScript compilation is success
- DTS bundle generator build valid declaration file
- TS Lint check is success
When my code import fs
package, DTS bundle generator generate invalid declaration file.
My original code.
Importing fs
package as usual normal way
import * as fs from 'fs'
Using Stats
object via namespace fs.Stats
Declaration file import only {Stats}
and throw error Cannot find namespace 'fs'.
I think that this is right usage and this one should work
Using two imports from one package works fine, but it is not valid according TS lint
import * as fs from 'fs'
import {Stats} from 'fs'
Working solution that we import only Stats
and fs
package is required.
It's working solution, but really ugly.
import {Stats} from 'fs';
const fs = require('fs');