phaserjs / phaser-ce

Phaser CE is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.

Home Page:http://phaser.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visual Studio Code cannot scan for type definition

imben1109 opened this issue · comments

commented

I am using visual studio for TypeScript Application Development. Recently, I try to study Phaser.

I just install the phaser by yarn.

yarn add phaser-ce

I can find the folder phaser-ce in the folder of node_modules and the typescript folder in phaser-ce. However, I found that Visual Studio Code cannot scan the Type Definition. It throw errors when I tried to write a small Phaser Application.

How does it looks with Atom ?

commented

The same

commented

You might have to add a tsconfig file to your project.

commented

Added . The below is my tsconfig

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "outDir": "target",
        "jsx": "react",
        "moduleResolution": "node",
        "allowJs": true
    },
    "include": [
        "src/**/*"
    ]
}
commented

@samme. Thanks. But it still throws the below exception

[ts] Module '"phaser-ce"' has no exported member 'Phaser'.

import { Phaser } from 'phaser-ce';

export default class Test{
    test: Phaser.Game;
}

Changed tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "outDir": "target",
        "jsx": "react",
        "moduleResolution": "node",
        "allowJs": true
    },
    "files": [
        "./node_modules/phaser-ce/typescript/phaser.d.ts"        
    ],
    "include": [
        "src/**/*"
    ]
}

commented

Try removing

import { Phaser } from 'phaser-ce';

Or import Phaser from 'phaser-ce';