question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is Excalibur typescript 2.0 compatible?

See original GitHub issue

Sorry if this is wrong place to ask questions, but forum seems deserted.

My problem is that I want to use Excalibur with TypeScript and webpack. I was able to setup webpack and ts compiler so everything works, including loading 3rd-party libs installed with npm (e.g. lodash). It looks like this: https://github.com/hogart/excalibur-test. But at the moment I add import {ex} from 'excalibur'; I get an error TS2306: File '<path-to-project>/node_modules/excalibur/dist/excalibur.d.ts' is not a module..

I looked at how lodash .d.ts is written and manually added following to dist/excalibur.d.ts:

export = ex;
export as namespace ex;

This did the trick, ex.Engine was properly imported and initialized, but this can’t be called a solution.

Since I’m pretty new to TS, I’m bit lost. Am I missing something in my tsconfig.json? Can this issue be fixed with some custom .d.ts. which re-exports ex namespace? Should I downgrade to TypeScript 1.8, since this version used for developing Excalibur?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
hogartcommented, Nov 3, 2016

Ok, I’ll watch that issue for news. Thanks for support and great lib:)

Funny thing that at first I tried Phaser and was disappointed that it requires monkey-patching .d.ts in order to work with typescript. Anyway, Excalibur is better because it doesn’t require ugly crutches to work with webpack and provided typings obviously superior.

0reactions
kamranayubcommented, Nov 3, 2016

Appreciate it, we still have some work to do. Maybe tonight I will write up a guide on using Ex with module loaders and add it to the docs. @eonarheim did a similar monkey patch for https://github.com/eonarheim/TypeState/pull/13 to support module loading with TS, we could do it the same way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installation Guide - Excalibur.js
We recommend using TypeScript for the best experience using Excalibur, but it will work just as well using plain JavaScript. No Bundler or...
Read more >
Excalibur v0.25.0 Released! - Erik Onarheim
Excalibur started as a tech demo in a presentation to show how powerful TypeScript can be. The engine has come so far since...
Read more >
excalibur.js (@excaliburjs) / Twitter
Build amazing 2D games for the web using Excalibur. For Free. ... GitHub - excaliburjs/template-ts-vite: Excalibur Template with TypeScript for Vite.
Read more >
Microsoft/TypeScript - Gitter
404 Not found : @types/excalibur ... I'm using 2.0.3 and TS seems to not recognize @types in .ts files ... I'm new to...
Read more >
excalibur - npm
Excalibur is a free game engine written in TypeScript for making 2D games in HTML5 canvas. Our goal is to make it easier...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found