Search code examples
visual-studioreferencegruntjstypescriptgrunt-ts

Unable to find symbol 'Components'


I've got 3 modules in 3 separate folders, each (test-wise) with one file:

  • components/pagedList.ts
  • directives/testDirective.ts
  • entity1/entity1.ts

Which approx. look like this

// pagedList.ts
module App.Components {
    export interface IPagedList<T> {
        ...
    }
}

// testDirective.ts
module App.Directives {
    export class TestDirective {
        ...
    }
}

// entity1.ts
module App.Entity1 {
    export interface IEntity1 {
        ...
    }
}

When I try to reference them as dependencies, it works for all except module App.Components. Both Intellisense (Visual Studio) as well as my typescript grunt task are unable to find symbol 'App.Components'. Is this a reserved keyword or something? Edit: Tried renaming and relocating, still not working though.

var dependencies = [
    "ui.router", 
    "ui.bootstrap",
    Components, // Unable to find symbol 'Components'
    Directives,
    Entity1,
];

Solution

  • This happens because App.Components is what's called an uninstantiated module. Because there is only an interface in it, the compiler only creates a symbol in the type namespace, and doesn't create any value at runtime.

    Once Components has a class, var, or instantiated module in it, you'll see that error go away. You can put in a dummy non-exported var in here if needed in the meantime.