hazzard993 / love-typescript-definitions

Write LÖVE 2D projects with TypeScript
MIT License
116 stars 11 forks source link

Develop #37

Closed hazzard993 closed 5 years ago

hazzard993 commented 5 years ago

There are two ways to call LÖVE's functions. This PR makes these two methods possible.

love.graphics.newImage("image.png");
import { newImage } from "love.graphics";

newImage("image.png");

These modules contain all of LÖVE's functions, types and enums.

Advantages:

Also good for users who prefer to avoid global variables.

Here are the type paths to use for choosing one of these two methods:

Type Path Description
love-typescript-definitions All types, structs, modules and the love namespace will be globally available.
/expose-modules-only Only LÖVE's modules will be globally available. (love.graphics, etc)
/expose-love-global-callbacks Exposes the love namespace purely for overriding callbacks.

VS Code can automatically create import paths to members within these declarations.

If you want to use LÖVE in this modular way, configure your types in your tsconfig.json like so:

{
  "types": [
    "love-typescript-definitions/expose-modules-only",
    "love-typescript-definitions/expose-love-global-callbacks"
  ]
}