File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ function fixupClassBases(nameToCls: Map<string, InterfaceIR>): void {
6565 cls . concrete = true ;
6666 break ;
6767 }
68+ // If the base is a jsobject set the subclass to be a jsobject. This
69+ // probably shouldn't be necessary and indicates an issue somewhere
70+ // else.
71+ if ( s ?. jsobject ) {
72+ cls . jsobject = true ;
73+ }
6874 }
6975 }
7076 if ( ! cls . jsobject && ! cls . concrete ) {
Original file line number Diff line number Diff line change @@ -2004,6 +2004,39 @@ describe("emit", () => {
20042004 ) ;
20052005 } ) ;
20062006 } ) ;
2007+ it ( "inheriting from jsobject is also jsobject" , ( ) => {
2008+ const res = emitFile ( `
2009+ interface C {
2010+ a: string;
2011+ }
2012+ declare var C: {
2013+ prototype: C;
2014+ new(): C;
2015+ };
2016+ declare function f(a: C & {b: string}): void;
2017+ ` ) ;
2018+ // Maybe f__Sig0__a should inherit from C_iface instead? This doesn't happen
2019+ // in many places though so for now I am just trying to make it not broken.
2020+ assert . strictEqual (
2021+ removeTypeIgnores ( res . slice ( 1 ) . join ( "\n\n" ) ) ,
2022+ dedent ( `
2023+ def f(a: f__Sig0__a, /) -> None: ...
2024+
2025+ class C(C_iface, _JsObject):
2026+ @classmethod
2027+ def new(self, /) -> C: ...
2028+
2029+ class C_iface(Protocol):
2030+ a: str = ...
2031+
2032+ class f__Sig0__a__Intersection1(Protocol):
2033+ b: str = ...
2034+
2035+ class f__Sig0__a(f__Sig0__a__Intersection1, C, _JsObject):
2036+ pass
2037+ ` ) . trim ( ) ,
2038+ ) ;
2039+ } ) ;
20072040 describe ( "adjustments" , ( ) => {
20082041 it ( "setTimeout" , ( ) => {
20092042 const res = emitIRNoTypeIgnores ( convertBuiltinFunction ( "setTimeout" ) ) ;
You can’t perform that action at this time.
0 commit comments