nitrogen 0.36.0 → 0.36.2

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.
@@ -260,9 +260,8 @@ export function createType(language, type, isOptional, typeNode) {
260
260
  // - of string literals (then it's an enum)
261
261
  // - of type `T | undefined` (then it's just optional `T`)
262
262
  // - of different types (then it's a variant `A | B | C`)
263
- const unionConstituents = getUnionConstituents(type, typeNode);
264
- const nonNullTypes = unionConstituents
265
- .map((c) => c.type)
263
+ const nonNullTypes = type
264
+ .getUnionTypes()
266
265
  .filter((t) => !t.isNull() && !t.isUndefined() && !t.isVoid());
267
266
  const isEnumUnion = nonNullTypes.every((t) => t.isStringLiteral());
268
267
  if (isEnumUnion) {
@@ -278,6 +277,7 @@ export function createType(language, type, isOptional, typeNode) {
278
277
  }
279
278
  else {
280
279
  // It consists of different types - that means it's a variant!
280
+ const unionConstituents = getUnionConstituents(type, typeNode);
281
281
  let variants = unionConstituents
282
282
  // Filter out any undefineds/voids, as those are already treated as `isOptional`.
283
283
  .filter(({ type: t }) => !t.isUndefined() && !t.isVoid())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitrogen",
3
- "version": "0.36.0",
3
+ "version": "0.36.2",
4
4
  "description": "Code generator for React Native Nitro Modules that turns TypeScript specs into C++, Swift, and Kotlin bindings.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "chalk": "^5.3.0",
38
- "react-native-nitro-modules": "^0.36.0",
38
+ "react-native-nitro-modules": "^0.36.2",
39
39
  "ts-morph": "^28.0.0",
40
40
  "yargs": "^18.0.0",
41
41
  "zod": "^4.4.3"
@@ -339,9 +339,8 @@ export function createType(
339
339
  // - of string literals (then it's an enum)
340
340
  // - of type `T | undefined` (then it's just optional `T`)
341
341
  // - of different types (then it's a variant `A | B | C`)
342
- const unionConstituents = getUnionConstituents(type, typeNode)
343
- const nonNullTypes = unionConstituents
344
- .map((c) => c.type)
342
+ const nonNullTypes = type
343
+ .getUnionTypes()
345
344
  .filter((t) => !t.isNull() && !t.isUndefined() && !t.isVoid())
346
345
  const isEnumUnion = nonNullTypes.every((t) => t.isStringLiteral())
347
346
  if (isEnumUnion) {
@@ -358,6 +357,7 @@ export function createType(
358
357
  return new EnumType(typename, type)
359
358
  } else {
360
359
  // It consists of different types - that means it's a variant!
360
+ const unionConstituents = getUnionConstituents(type, typeNode)
361
361
  let variants = unionConstituents
362
362
  // Filter out any undefineds/voids, as those are already treated as `isOptional`.
363
363
  .filter(({ type: t }) => !t.isUndefined() && !t.isVoid())