KubeJS TFC

KubeJS TFC

476k Downloads

KubeJS TFC's type hints are incorrect.

EvanHsieh0415 opened this issue ยท 3 comments

commented

ItemProviderComponent.java#L54-L59

- return TypeDescJS.any(
-                 TypeDescJS.STRING.or(ctx.javaType(ItemStack.class)),
-                 TypeDescJS.MAP.withGenerics(TypeDescJS.STRING.or(ctx.javaType(JsonObject.class)))
-         );
+ return TypeDescJS.any(
+                 TypeDescJS.STRING, 
+                 ctx.javaType(ItemStack.class), 
+                 TypeDescJS.MAP.withGenerics(
+                          TypeDescJS.STRING, 
+                          TypeDescJS.STRING.or(ctx.javaType(JsonObject.class))
+                 );
commented

hmm, I don't know why I have a map description there, it should theoretically be an array type to match how it's processed. Would this work:

- return TypeDescJS.any(
-                 TypeDescJS.STRING.or(ctx.javaType(ItemStack.class)),
-                 TypeDescJS.MAP.withGenerics(TypeDescJS.STRING.or(ctx.javaType(JsonObject.class)))
-         );
+ return TypeDescJS.any(
+                 TypeDescJS.STRING, 
+                 ctx.javaType(ItemStack.class), 
+                 TypeDescJS.fixedArray(
+                         TypeDescJS.STRING,
+                         ctx.javaType(JsonObject.class)
+                 ));
commented

hmm, I don't know why I have a map description there, it should theoretically be an array type to match how it's processed. Would this work:

- return TypeDescJS.any(
-                 TypeDescJS.STRING.or(ctx.javaType(ItemStack.class)),
-                 TypeDescJS.MAP.withGenerics(TypeDescJS.STRING.or(ctx.javaType(JsonObject.class)))
-         );
+ return TypeDescJS.any(
+                 TypeDescJS.STRING, 
+                 ctx.javaType(ItemStack.class), 
+                 TypeDescJS.fixedArray(
+                         TypeDescJS.STRING,
+                         ctx.javaType(JsonObject.class)
+                 ));

It should work.

commented

Thank you for reporting!