@nubjs/types 0.0.44 → 0.0.46

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 (2) hide show
  1. package/index.d.ts +17 -8
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -17,27 +17,36 @@
17
17
  // `declare var …`, `declare namespace …`) for the same reason.
18
18
 
19
19
  // ── Data-format module imports (Nub load hook; wiki/runtime/data-loaders.md) ──
20
- // Default export onlya wildcard cannot statically know per-key shapes, so
21
- // named imports (`import { host } from "./c.yaml"`) are not typed (they still RUN
22
- // on nub). `.json` is intentionally NOT declared: it's Node-native (resolveJsonModule).
20
+ // Default export ONLYdata modules expose no named exports (a named import
21
+ // like `import { host } from "./c.yaml"` is a load-time error on nub, the same
22
+ // as Node's JSON modules). The object formats default to `Record<string,
23
+ // unknown>` so the default can be destructured with sound `unknown` keys —
24
+ // `import cfg from "./c.yaml"; const { host, port } = cfg;` gives `host`/`port:
25
+ // unknown`. This is the sound, typeable equivalent of named imports.
26
+ //
27
+ // CAVEAT: a top-level array or scalar (e.g. a YAML document whose root is a list
28
+ // or a bare string) is mistyped as a record by `Record<string, unknown>`; cast
29
+ // the default in that case (`import data from "./list.yaml"; const items = data
30
+ // as unknown as string[];`). `.txt` is always a `string`; `.json` is
31
+ // intentionally NOT declared — it's Node-native (resolveJsonModule).
23
32
  declare module "*.yaml" {
24
- const data: unknown;
33
+ const data: Record<string, unknown>;
25
34
  export default data;
26
35
  }
27
36
  declare module "*.yml" {
28
- const data: unknown;
37
+ const data: Record<string, unknown>;
29
38
  export default data;
30
39
  }
31
40
  declare module "*.toml" {
32
- const data: unknown;
41
+ const data: Record<string, unknown>;
33
42
  export default data;
34
43
  }
35
44
  declare module "*.jsonc" {
36
- const data: unknown;
45
+ const data: Record<string, unknown>;
37
46
  export default data;
38
47
  }
39
48
  declare module "*.json5" {
40
- const data: unknown;
49
+ const data: Record<string, unknown>;
41
50
  export default data;
42
51
  }
43
52
  declare module "*.txt" {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubjs/types",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "description": "TypeScript ambient declarations for code authored against the Nub runtime",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/nubjs/nub",