@interstellar-tools/types 0.5.0 → 0.7.0

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.
@@ -32,14 +32,14 @@ export interface AsteroidBeltInterface {
32
32
  * @typedef {AsteroidBeltInterface[]} AsteroidBeltsType
33
33
  * @example
34
34
  * ```ts
35
- * const asteroidBelt: AsteroidBeltInterface = {
35
+ * const asteroidBelt: AsteroidBeltInterface = [{
36
36
  * name: 'Main Belt',
37
37
  * innerRadius: 2.1,
38
38
  * outerRadius: 3.3,
39
39
  * color: '#888888',
40
40
  * opacity: 0.5,
41
41
  * density: 100,
42
- * };
42
+ * }];
43
43
  * ```
44
44
  * @group Celestial Bodies
45
45
  */
@@ -70,7 +70,7 @@ export interface CometInterface {
70
70
  * @typedef {CometInterface[]} CometsType
71
71
  * @example
72
72
  * ```ts
73
- * const halley: CometInterface = {
73
+ * const halley: CometInterface = [{
74
74
  * name: 'Halley',
75
75
  * type: 'periodic comet',
76
76
  * category: 'halley-type comet',
@@ -86,7 +86,7 @@ export interface CometInterface {
86
86
  * radius: { value: 11, unit: 'km' },
87
87
  * color: '#ffffff',
88
88
  * size: 1.2
89
- * };
89
+ * }];
90
90
  * ```
91
91
  * @group Celestial Bodies
92
92
  */
package/dist/numeric.d.ts CHANGED
@@ -17,15 +17,85 @@ export interface ValueInterface {
17
17
  value: number;
18
18
  }
19
19
  /**
20
- * Type alias representing an angle in **radians**.
20
+ * **Angle in radians** (branded nominal type).
21
21
  *
22
- * @typedef {number} Radians
22
+ * **Relations**
23
+ *
24
+ * $$
25
+ * \pi\ \mathrm{rad}=180^\circ,\qquad
26
+ * 1\ \mathrm{rad}=\frac{\text{arc length}}{\text{radius}}
27
+ * $$
28
+ *
29
+ * **Why branded?**
30
+ * This type brands a `number` to prevent accidentally mixing **degrees** and **radians**
31
+ * at compile time. You must construct it explicitly (e.g., via a small factory or cast).
32
+ *
33
+ * **Units**
34
+ * - Stored as a JavaScript `number` whose unit is **radians** (dimensionless).
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * // Construct with an explicit cast or small factory
39
+ * const halfTurn: Radians = Math.PI as Radians;
40
+ *
41
+ * // Function expecting radians
42
+ * function usesRadians(nu: Radians) { …}
43
+ * usesRadians(halfTurn);
44
+ * // usesRadians(180 as number); // avoid passing degrees as a plain number
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * // Optional helper factory (recommended pattern)
50
+ * const rad = (x: number): Radians => x as Radians;
51
+ * const quarter: Radians = rad(Math.PI / 2);
52
+ * ```
53
+ *
54
+ * @see flightPathAngleFromTrueAnomaly - accepts `nu: Radians`
55
+ * @group Numeric
56
+ */
57
+ export type Radians = number & {
58
+ readonly __unit: 'radians';
59
+ };
60
+ /**
61
+ * **Angle in degrees** (branded nominal type).
62
+ *
63
+ * **Relations**
64
+ *
65
+ * $$
66
+ * 180^\circ=\pi\ \mathrm{rad},\qquad
67
+ * \text{deg}\to\text{rad}:~\theta_\mathrm{rad}=\theta_\mathrm{deg}\,\frac{\pi}{180},\qquad
68
+ * \text{rad}\to\text{deg}:~\theta_\mathrm{deg}=\theta_\mathrm{rad}\,\frac{180}{\pi}
69
+ * $$
70
+ *
71
+ * **Why branded?**
72
+ * Brands a `number` to prevent accidentally mixing **degrees** and **radians**
73
+ * at compile time. Construct explicitly (via a helper or cast).
74
+ *
75
+ * **Units**
76
+ * - Stored as a JavaScript `number` whose unit is **degrees** (dimensionless).
23
77
  *
24
78
  * @example
25
79
  * ```ts
26
- * const angle: Radians = Math.PI / 2; // 90 degrees in radians
80
+ * // Simple factory (recommended)
81
+ * const deg = (x: number): DegreesType => x as DegreesType;
82
+ * const rightAngle: DegreesType = deg(90);
27
83
  * ```
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * // Converting to radians (using your own helper)
88
+ * type Radians = number & { readonly __unit: 'radians' };
89
+ * const toRadians = (d: DegreesType): Radians => ((d as number) * Math.PI / 180) as Radians;
90
+ *
91
+ * const heading: DegreesType = (45 as DegreesType);
92
+ * const headingRad: Radians = toRadians(heading);
93
+ * ```
94
+ *
95
+ * @see Radians - branded type for angles in radians
28
96
  * @group Numeric
29
97
  */
30
- export type Radians = number;
98
+ export type DegreesType = number & {
99
+ readonly __unit: 'degrees';
100
+ };
31
101
  //# sourceMappingURL=numeric.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"numeric.d.ts","sourceRoot":"","sources":["../src/numeric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"numeric.d.ts","sourceRoot":"","sources":["../src/numeric.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interstellar-tools/types",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Shared TypeScript types (e.g., 3D tuples, equation result interfaces) used across the monorepo to keep APIs predictable and safe.",
5
5
  "keywords": [
6
6
  "types",