0

I have the following issue:

The TypeScript declarations for the Pixi library exist but seem to be broken. Firstly, they start with

declare module PIXI

instead of

declare module "PIXI"

I'm not sure if this is wrong but all the other delcarations (for node, socket.io, etc.) seem to use strings for names. When I change it to a string it works but encounters an error later. Outside of that PIXI module there this:

declare function requestAnimFrame( animate: PIXI.IBasicCallback );

Now because I changed PIXI to a string (I assume), it says that the variable PIXI doesn't contain a type named IBasicCallback. The module does export that type, but it's just not available outside of it. Outside of the declaration file, in my code, I can use PIXI.IBasicCallback just fine, but inside the same file it's not recognized.

What can I do to fix this?

1
  • I should note that if I don't change PIXI to "PIXI", my require code can't find the module: import PIXI = require("PIXI"); Commented Sep 11, 2013 at 16:35

2 Answers 2

4

There is a difference between internal and external modules (CommonJS/NodeJS,AMD/RequireJS). "SomeThing" is used for external modules. Whereas a internal modules are declared without a string.

// Declare a external module 
declare module "Foo"{
    var foo:number; 
    export = foo;
}
// Use 
import a = require("Foo");


// Declare an internal module 
declare module Boo{
    export var boo:string;
}
// usage
var  b = Boo.boo; 

I also did a video on the subject : http://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1

Sign up to request clarification or add additional context in comments.

Comments

0

It appears that some modules require you to do stuff like

declare module "pixi" {
    exports = PIXI;
}

manually. Adding that to be bottom of the delcaration (and not changing the original declaration to a string) works.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.