Issue 1:
Hi. Please see the question I have made here for a description of the problem.

http://stackoverflow.com/questions/34546446/flattening-typescript-typings-or-interfaces

Here's the post:

As a TypeScript developer, I have become too used to "Duplicate identifier" issues when working with .d.ts files.

Most recently, this occurred because I needed both the typings (.d.ts files) of Angular 2, and Parse.

Angular 2 doesn't distribute their .d.ts files through DefinitelyTyped, so I had to fetch Angular 2 through NPM which includes the source files as well.

Now, Parse's .d.ts come from DefinitelyTyped. Fine - so far, so good.

The issue then arises because both of these libraries depend on Node JS typings. The Node JS typings of Parse are located in the typings folder, whereas the Node JS typings of Angular 2 are located in a subfolder under node_modules/angular2.

This gives me a huge amount of duplicate identifier issues when compiling.

So, the big question(s)

- Can I flatten `.d.ts` files so that it doesn't have duplicates somehow?
- Can I somehow make the TypeScript compiler ignore duplicate interface definitions?

Issue 2:
TypeScript Version:

1.8.7

Code

Transpiling _apply.js of lodash-es@4.6.1 with the command

tsc --allowJs _apply.js --out apply.js -m amd

breaks the code. Apparently, the (arguably invalid) @param {...*} args JSDoc comment causes the TypeScript compiler to generate code as if the parameter declaration was apply(func, thisArg, ...args), although it is not.

/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {...*} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
var length = args.length;
switch (length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}

export default apply;

Expected behavior:

define("_apply", ["require", "exports"], function (require, exports) {
"use strict";
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {...*} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
var length = args.length;
switch (length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
exports.__esModule = true;
exports["default"] = apply;
});

Actual behavior:

define("_apply", ["require", "exports"], function (require, exports) {
"use strict";
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {...*} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
var length = args.length;
switch (length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
exports.__esModule = true;
exports["default"] = apply;
});

I've not been able to reproduce this in the TypeScript playground (currently running 1.8.2), which suggests a regression somewhere between 1.8.2 and 1.8.7.