fivetran / typescript-closure-tools

62 stars 11 forks source link

Illegal referencing own base expression #7

Closed trodi closed 9 years ago

trodi commented 9 years ago

In running the tool on https://github.com/google/blockly/, the follow idiom was generated often, which doesn't compile.

declare module MyModule {
  class Foo extends Foo.__Class {}
  module Foo {
    class __Class {
      constructor(x: number, y: number);
    }
  }
}

This change in typescript is documented here along with an alternative acceptable declaration: https://github.com/Microsoft/TypeScript/issues/3602

declare module MyModule {
    class Foo { }
    module Foo {
        class __Class extends Foo {
            constructor(x: number, y: number);
        }
    }
}

In playing with this approach, I got "Property x does not exist on type" errors. One fix was to remove the inner module as below. This worked for my use cases, however I'm new to Typescript and may be missing something important. Would editing the tool to output this be an acceptable fix for the original issue?

declare module MyModule {
    class Foo { 
            constructor(x: number, y: number);
    }
}
trodi commented 9 years ago

Maybe this is actually closer to correct.

declare module MyModule {
     class Foo__Class {
          constructor(x: number, y: number);
      }
     class Foo extends Foo__Class { }
     module Foo {
     }
}
georgewfraser commented 9 years ago

Fixed by https://github.com/fivetran/typescript-closure-tools/pull/8 (and a few more tweaks)

allisonshaw commented 9 years ago

Can the NPM package be updated with these changes, please?

trodi commented 9 years ago

@georgewfraser , agreed to updating npm package.