You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classJSExampleEmptyextendsEmptyObjectOverloads{/** @param {*} a */constructor(a){// hover over super: constructor EmptyObjectOverloads<any>(a: any, b?: any): EmptyObjectOverloads<any> (+1 overload)super(a);// deprecation warning '(a: any, b?: any): EmptyObjectOverloads<any>' is deprecated ts(6385)}}classJSExampleRecordextendsRecordOverloads{/** @param {*} a */constructor(a){// hover over super: constructor RecordOverloads<Record<string, any>>(a: Readonly<Record<string, any>>): RecordOverloads<Record<string, any>> (+1 overload)super(a);}}
Expected behavior:
Both TSExampleEmpty and JSExampleEmpty pick same overload similar to TSExampleRecord and JSExampleRecord.
Actual behavior: TSExampleEmpty uses default generic value {} and picks first overload.
For JSExampleEmpty generic value to is any and second (deprecated) overload picked, while JSExampleRecord works as expected.
In real world examples this behavior marks all super(props); in React class components in JS files as deprecated.
Of course it's impossible to report TS issue without mentioning React 😆 related constructor declaration
TypeScript Version: 4.0.0-dev.20200703, 3.9.2 (playground)
Search Terms: js ts overload difference, javascript different overload, javascript wrong overload, javascript overload generic empty object
Code
definition.d.ts
ts-example.ts
js-example.js
Expected behavior:
Both
TSExampleEmpty
andJSExampleEmpty
pick same overload similar toTSExampleRecord
andJSExampleRecord
.Actual behavior:
TSExampleEmpty
uses default generic value{}
and picks first overload.For
JSExampleEmpty
generic value to isany
and second (deprecated) overload picked, whileJSExampleRecord
works as expected.In real world examples this behavior marks all
super(props);
in React class components in JS files as deprecated.Of course it's impossible to report TS issue without mentioning React 😆 related constructor declaration
Playground Link:
Example TS Example JS
Related Issues: Haven't found any
The text was updated successfully, but these errors were encountered: