pacc 9.3.2 → 9.3.3

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/package.json +1 -1
  2. package/src/types.mjs +9 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "9.3.2",
3
+ "version": "9.3.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
package/src/types.mjs CHANGED
@@ -105,22 +105,21 @@ export const types = {
105
105
  };
106
106
 
107
107
  /**
108
- *
109
- * @param {string|undefined} type
108
+ * Throw if type is not known.
109
+ * @param {Type|string|undefined} type
110
110
  * @param {any} origin
111
111
  * @returns {Type}
112
112
  */
113
113
  function raiseOnUnknownType(type, origin) {
114
- switch (typeof type) {
115
- case "string":
116
- if (types[type]) {
117
- return types[type];
118
- }
119
- case "undefined":
120
- throw new Error(`Unknown type ${type} in '${origin}'`, { cause: type });
114
+ if (types[type]) {
115
+ return types[type];
121
116
  }
122
117
 
123
- return type;
118
+ if (types[type?.name] === type) {
119
+ return type;
120
+ }
121
+
122
+ throw new Error(`Unknown type ${type} in '${origin}'`, { cause: type });
124
123
  }
125
124
 
126
125
  export function addType(type) {