Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //commonjs-export-function.js
- module.exports = function() {
- return 'func';
- };
- //commonjs-export-function.d.ts
- declare function func(): string;
- export = func;
- //main.ts
- import { func } from './commonjs-function';
- console.log(func());
- tsc main.ts && node main.js
- main.ts(1,22): error TS2497: Module '"/Users/aleksandar/projects/typescript-playground/commonjs-function"' resolves to a non-module entity and cannot be imported using this construct.
- *~ Note that ES6 modules cannot directly export callable functions.
- *~ This file should be imported using the CommonJS-style:
- *~ import x = require('someLibrary');
- ...
- export = MyFunction;
- declare function MyFunction(): string;
- //commonjs-export-function.d.ts
- declare function func(): string;
- export = func;
- //main.ts
- import func = require('./commonjs-export-function');
- declare module 'promise-map-limit' {
- type IIteratee<T, R> = (value: T) => Promise<R> | R;
- function mapLimit<T, R>(
- iterable: Iterable<T>,
- concurrency: number,
- iteratee: IIteratee<T, R>
- ): Promise<R[]>;
- export = mapLimit;
- }
Add Comment
Please, Sign In to add comment