-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript Module Augmentation #10
Comments
Yes, we solved that problem for pixi-spine, and its time to move it to pixi-display. Use modified ".d.ts", its ok. |
Hi guys, can you detail a bit on how do we make it work with typescript? Im interested too :) |
You have to modify "bin/pixi-display.js" or "bin/pixi-layers.js" file. remove "typeof" thing and change all modules to "PIXI.tilemap" Or you can just use "pixi_display.DisplayGroup" instead of "PIXI.tilemap" when you define a field with specific type |
Thanks ivan for the infos, but can we rollback a little? I initially wanted to use the pixi-layers plugin who seem to be encapsuled inside the pixi-display plugins right? I'm asking this because you were talking about the pixi-tilemap. ps: Im not even clear on how I am supposed to install a plugin in PIXI, is there a npm package for PIXI-display or Im forced to install it manually? |
Sorry, my mistake :) How to install pixi-layers:
You can see pixi-layers plugin, but there's one problem: let layer = new PIXI.display.Layer(); //that will work
let x : PIXI.display.Layer = layer; // that wont :(
let x : pixi_display.Layer = layer; //that will work Solution to that problem was applied to pixi-spine, but not pixi-display |
Thanks ! It's clear for me 👍 Im gonna try it soon and I'll come back if it's needed :) |
I just modified the core pixi.js.d.ts file and included the pixi_display classes/changes It's a hack I know but I'd rather adjust one or two .d.ts files than all my code. This way |
ok, that works too :) |
Hey guys I still have an issue : In Typescript I used PIXI this way : What is my mistake? |
will that work? You'll have display as separate module that way
|
I was able to import PIXI from pixi_display but it dropped all the definitions from the core I couldn't figure it out... |
You have to import PIXI from pixi and pixi_display from pixi-display, "pixi_display.Layer" must work |
Yes, this works when I reference something like: but this throws an error
|
what about that?
I'm sorry about your problems, we are going to port "pixi-spine" solution in this repo. It supports vanilla and browserify and webpack. You can use modified ".d.ts" for now :) |
No worries, that's what I figured, I kept getting weird errors so it was actually faster to just merge your |
Would love to see Layers working out of box with TypeScript, NPM, Webpack and ES6 module imports. |
@jlost it should be pretty straightforward now.
import "pixi-display"; // import for side effects, need to be done once in `src/index.ts`
import * as PIXI from 'pixi.js';
const greenGroup = new PIXI.display.DisplayGroup(0, false); |
does that really work? |
Or in case of
import "pixi-layers"; // import for side effects, need to be done once in `src/index.ts`
import * as PIXI from 'pixi.js';
const greenGroup = new PIXI.display.Group(0, false); |
oh, nice :) I'll add that to README! You really solved it! |
I saw in #5 you were referring to what's happening with the core library but in the meantime I can't for the life of me get my project to let your Augments work... I can pull in
pixi_display
but it won't merge up with the core PIXI namespace.For the moment I'm manually adjusting a .d.ts file but I didn't know if you had a trick to get it to work
The text was updated successfully, but these errors were encountered: