Skip to content

Problems with calling methods from class under namespace #127

Closed
@MaxGraey

Description

@MaxGraey

Just synthetic minimal example:

import "allocator/arena";

export namespace safe {
  export class U64 {
    constructor(
      public lo: u32,
      public hi: u32 = 0
    ) {}

    static addLo(a: U64, b: U64): U64 {
      return new U64(a.lo + b.lo);
    }
  }
}

var a = new safe.U64(1);
var b = new safe.U64(2);
var c = safe.U64.addLo(a, b);

Output errors:

ERROR TS2304: Cannot find name 'U64'.

     static addLo(a: U64, b: U64): U64 {
                     ~~~
 in main.ts(10,20)

ERROR TS2304: Cannot find name 'U64'.

     static addLo(a: U64, b: U64): U64 {
                     ~~~
 in main.ts(10,20)

ERROR TS2322: Type 'void' is not assignable to type '<auto>'.

 var c = safe.U64.addLo(a, b);
                  ~~~~~~~~~~~
 in main.ts(18,17)
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions