f2.ts(2,5): error TS2564: Property 'n' has no initializer and is not definitely assigned in the constructor.
f3.ts(4,1): error TS2322: Type '() => undefined' is not assignable to type '() => B'.
  Type 'undefined' is not assignable to type 'B'.
f4.ts(5,9): error TS2454: Variable 'a' is used before being assigned.


==== f1.ts (0 errors) ====
    export class A {}
    
==== f2.ts (1 errors) ====
    export class B {
        n: number;
        ~
!!! error TS2564: Property 'n' has no initializer and is not definitely assigned in the constructor.
    }
    
==== f3.ts (1 errors) ====
    import {A} from "./f1";
    import {B} from "./f2";
    
    A.prototype.foo = function () { return undefined; }
    ~~~~~~~~~~~~~~~
!!! error TS2322: Type '() => undefined' is not assignable to type '() => B'.
!!! error TS2322:   Type 'undefined' is not assignable to type 'B'.
    declare module "./f1" {
        interface A {
            foo(): B;
        }
    }
    
==== f4.ts (1 errors) ====
    import {A} from "./f1";
    import "./f3";
    
    let a: A;
    let b = a.foo().n;
            ~
!!! error TS2454: Variable 'a' is used before being assigned.