This repository has been archived by the owner on Dec 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
How to generate .d.ts for ES6 Modules ? #42
Comments
Any resolution on this? |
when es6 suppose will be available? thank you |
|
dts-gen is pretty much useless |
This was referenced Dec 13, 2017
Is this going to be supported? |
Doesn't seem to be working on ES6 modules at all. :( This would be very useful for initial transition from js to ts. |
add below to // @ts-ignore
require("babel-polyfill");
// @ts-ignore
require('babel-register')({
cache: false,
}); and for expressions import { transform, TransformOptions } from 'babel-core';
const babelOpt: TransformOptions = {
extends: `${process.cwd()}/.babelrc`,
}
/** ... **/
} else if (args.expression) {
name = args.name || 'dts_gen_expr';
result = guess.generateIdentifierDeclarationFile(name, eval(transform(args.expression, babelOpt).code || ''));
} else if (args['expression-file']) {
if (args.name) throw new ArgsError('Cannot use -name with -expression-file');
const filename = args['expression-file'];
name = path.basename(filename, path.extname(filename)).replace(/[^A-Za-z0-9]/g, '_');
(module as any).paths.unshift(process.cwd() + '/node_modules');
const fileContent = fs.readFileSync(filename, "utf-8");
result = guess.generateIdentifierDeclarationFile(name, eval(transform(fileContent, babelOpt).code || '')); at least it works for me 🎉 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have a third party library written in ES6, how could I generate typings for this ?
The text was updated successfully, but these errors were encountered: