Steps to reproduce
// dep.js
export class BaseClass {
constructor() {
this.map = [];
this.map.push(function(){});
}
}
// main.ts
import { BaseClass } from "./dep.js";
declare const key: any;
class Item extends BaseClass {
constructor() {
super();
this.map[key] = {};
// ~~~~~~~~~~~~~
// Type '{}' is not assignable to type '{}'. Two different types with this name exist, but they are unrelated.
}
}
Behavior with typescript@5.9
No error is raised.
Behavior with tsgo
The line this.map[key] = {} raises error 2719; or if any other value is used (e.g., this.map[key] = 7) error 2322. I have noticed other cases where tsgo seems not quite do quite such aggressive type inference on arrays defined in JS files but in this case it does seemingly still identify map as having type {}[].