Skip to content
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

Update TypeScript docs #292

Closed
samme opened this issue Jul 23, 2017 · 5 comments
Closed

Update TypeScript docs #292

samme opened this issue Jul 23, 2017 · 5 comments
Assignees
Milestone

Comments

@samme
Copy link
Collaborator

samme commented Jul 23, 2017

Suggestions?

@Majirefy
Copy link

Majirefy commented Jul 28, 2017

I use TypeScript in Visual Studio Code.

I do nothing but npm install, then npm init, then tsc --init then tslint --init. Everything works fine in VS Code. I don't think there is need to modify TypeScript for using types.

Or we can just publish phaser.comment.d.ts to types. Then we can manually add by using npm install @types/phaserjs like this.

It seems MS prefers use npm install @types/phaserjs instead of typings install.

@Dreaded-Gnu
Copy link
Contributor

For the ionic template project I've just installed phaser-ce as additional dependency without using typings. Code completion within visual studio code worked out of the box. So when it works generally without typings, we could remove the typescript readme and add a simple typescript project template.

I think that it worked out of the box was because of the behaviour of typescript compiler to scan node_modules dependencies, when trying to import some module. You need typings or the @types package only for that reason, that a project has generally no typescript definition file ( plain javascript project ) or when the typescript definition files hasn't been added to package.json correctly, as it was previously. For example sequelizejs is a plain nodejs javascript orm with a extra repository containing typescript definition files ( installed via typings ).

I'll try to migrate a personal typescript game project currently using legacy phaser as dependency to phaser-ce without using typings. I'll post the result of that try here.

@samme
Copy link
Collaborator Author

samme commented Sep 7, 2017

If you use files or include in tsconfig.json, must those also include Phaser's definition files?

@samme
Copy link
Collaborator Author

samme commented Sep 13, 2017

Upshot:

  • Since v2.8.2 NPM-installed Phaser CE's definitions should be found automatically.
  • For Phaser CE before 2.8.2 or installed without NPM, you can
    • Link to Phaser's definitions in tsconfig.json; or
    • Use typings (??)
  • Selecting Phaser's definition files in your editor is probably unnecessary.

@omenking
Copy link

omenking commented Dec 28, 2017

Having lots of pain getting types to show up in VSCode.

I'm uncertain about typings and see more of @types do we simply need it add our types to definitelytyped?

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "lib": ["es2015","es6","es7"],
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "main/*"       : ["src/main/*"],
      "components/*" : ["src/renderer/components/*"],
      "core/*"       : ["src/renderer/core/*"],
      "states/*"     : ["src/renderer/states/*"],
      "ui/*"         : ["src/renderer/ui/*"],
      "common/*"     : ["src/common/*"],
      "devtools_components/*" : ["src/devtools/components/*"],
      "devtools_common/*" : ["src/devtools/common/*"]
    }
  },
  "include": [
    "./src/*",
    "./node_modules/phaser-ce/typescript/pixi.comments.d.ts" ,
    "./node_modules/phaser-ce/typescript/p2.d.ts",
    "./node_modules/phaser-ce/typescript/phaser.comments.d.ts" 
  ],
  "exclude": [
    "dist",
    "app"
  ]
}

screen shot 2017-12-28 at 9 46 35 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants