-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
TypeScript Version: 2.4.1 (but likely anything since 2.2)
When utilising code targeted at ES5 mixed with code targeted at ES6 causes a runtime error when using mixin classes. The real world use case was using a library that was targeted at ES5 for distribution compatibility reasons while downstream code is being targeted at ES2017 because of running in a known limited environment.
Code
Tagged.ts
// @target: es5
export interface Constructor<T> {
new(...args: any[]): T;
prototype: T;
}
export default function Tagged<T extends Constructor<{}>>(Base: T) {
return class extends Base {
_tag = '';
}
}TaggedExample.ts
// @target: es2015
import Tagged from './Tagged';
class Example {
log() {
console.log('Hello World!');
}
}
const TaggedExample = Tagged(Example);
const taggedExample = new TaggedExample(); // Uncaught TypeError: Class constructor Example cannot be invoked without 'new'Expected behavior:
No run-time errors.
Actual behavior:
A runtime error of Uncaught TypeError: Class constructor Example cannot be invoked without 'new'.
bradleyayers, fabiospampinato, trotyl, elado, tzachbon and 1 more
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript