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.
f4.ts(6,9): error TS2454: Variable 'a' is used before being assigned.
f4.ts(7,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'.
    
    export namespace N {
        export interface Ifc { a: number; }
        export interface Cls { b: number; }
    }
    import I = N.Ifc;
    import C = N.Cls;
    
    declare module "./f1" {
        interface A {
            foo(): B;
            bar(): I;
            baz(): C;
        }
    }
    
==== f4.ts (3 errors) ====
    import {A} from "./f1";
    import "./f3";
    
    let a: A;
    let b = a.foo().n;
            ~
!!! error TS2454: Variable 'a' is used before being assigned.
    let c = a.bar().a;
            ~
!!! error TS2454: Variable 'a' is used before being assigned.
    let d = a.baz().b;
            ~
!!! error TS2454: Variable 'a' is used before being assigned.