@jest-com/types 1.260826.3 → 1.260827.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +22 -12
  2. package/index.d.ts +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -13,16 +13,31 @@ describes the global `JestSDK` object that script creates.
13
13
  npm install --save-dev @jest-com/types
14
14
  ```
15
15
 
16
- ## Usage
16
+ ## Setup
17
17
 
18
- Import any type from the package, anywhere in your project:
18
+ TypeScript auto-loads types only from `node_modules/@types/*`, so name this
19
+ package in your `tsconfig.json`:
20
+
21
+ ```json
22
+ {
23
+ "compilerOptions": {
24
+ "types": ["vite/client", "@jest-com/types"]
25
+ }
26
+ }
27
+ ```
28
+
29
+ List every type package you rely on. A `types` array replaces TypeScript's
30
+ automatic inclusion, so anything left out of it stops being picked up.
31
+
32
+ To avoid managing that list, add a `.d.ts` under your source root instead. Vite
33
+ projects already have `src/vite-env.d.ts` for this:
19
34
 
20
35
  ```typescript
21
- import type { Jest, PlayerProfile, PurchaseData } from "@jest-com/types";
36
+ /// <reference types="vite/client" />
37
+ /// <reference types="@jest-com/types" />
22
38
  ```
23
39
 
24
- That is the whole setup. `JestSDK` and `window.JestSDK` are typed globals in
25
- every file, not just the one that imports:
40
+ Either way, `JestSDK` and `window.JestSDK` are typed globals in every file:
26
41
 
27
42
  ```typescript
28
43
  await JestSDK.init();
@@ -30,15 +45,10 @@ await JestSDK.init();
30
45
  const player = JestSDK.getPlayer();
31
46
  ```
32
47
 
33
- If your game only touches the global and never annotates a named type, there is
34
- nothing for it to import. Add a `.d.ts` file instead, for example
35
- `src/jestsdk.d.ts`:
48
+ Named types are exported for your own signatures:
36
49
 
37
50
  ```typescript
38
- /// <reference types="@jest-com/types" />
51
+ import type { Jest, PlayerProfile, SubscriptionData } from "@jest-com/types";
39
52
  ```
40
53
 
41
- TypeScript auto-loads types only from `node_modules/@types/*`, so one or the
42
- other is needed.
43
-
44
54
  Full docs: https://docs.jest.com/sdk/html5
package/index.d.ts CHANGED
@@ -1240,7 +1240,7 @@ export interface JestSDK {
1240
1240
  declare global {
1241
1241
  const JestSDK: Jest;
1242
1242
  interface Window {
1243
- JestSDK: Jest;
1243
+ JestSDK?: Jest;
1244
1244
  }
1245
1245
  }
1246
1246
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jest-com/types",
3
- "version": "1.260826.3",
3
+ "version": "1.260827.14",
4
4
  "description": "TypeScript types for the Jest HTML5 game SDK global (window.JestSDK).",
5
5
  "keywords": [
6
6
  "jest",