@requestBody throwing build error because of not matching schema, but it is matching #7474
Replies: 1 comment 3 replies
-
It's a bit difficult to spot at first glance, but they are actually quite different; The
More correctly (if we space out the quote marks), the error message is:
Q: But isn't it implied that the object is No; TypeScript will not infer types as constants because, in most cases, the developers' intent is to use a generic string. This means that the value of the object properties can change (such as in a controller's constructor) to a value outside of the enum. Q: How could the value change? Isn't the variable a In JavaScript, a // Try this in Node.js or a web browser console
const mutateMe = {foo: 'bar'}
mutateMe.foo = 'baz';
console.log(mutateMe.foo); This rule applies to any non-primitives such as arrays and class instances. To force a constant, it's possible to do
That's because it's type casting, which tells TypeScript to assume that the type is Instead, use type declarations: // Add `: SchemaObject`
export const PutOwnPasswordSchema: SchemaObject = {/* ,,, */}; |
Beta Was this translation helpful? Give feedback.
-
Hello, i need a bit of support. I recently made a npm and lb4 update for the packages. Now, while building the project i get a few errors for the @responseBody-Decorator usage.
The strange fact is, if i take a look into the last line Type 'string' is not assignable to type '"string" | "number" | "boolean" | "object" | "array" | "integer" | "null" | undefined'. It states, that 'string' is not assignable to 'string'. Uhm? What?
The following is my code for the specifiaction:
If i make a small modification on the PutOwnPasswordSchema definition (adding
<SchemaObject>
):The error from the build is gone and it works fine. It seems to me, that the build just cannot match it correctly without. But why?
Could need some help.
Beta Was this translation helpful? Give feedback.
All reactions