-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect initial values for objects with array fields #1112
Comments
Hi @wight554. We're aware of how the non-null assertion work, and it's being used deliberately in there. And while we could change this code, it should never be the case, that your |
Sure, schema is: new SimpleSchema2Bridge(
new SimpleSchema({
string1: {
type: String,
label: 'Primary Objective',
},
object1: { type: Object, label: '' },
'object1.boolean1': { type: Boolean, label: 'label 1' },
'object1.array1': {
type: Array,
minCount: 1,
defaultValue:[{}],
},
'object1.array1.$': { type: Object },
'object1.array1.$.string1': { type: String },
'object1.array1.$.string2': { type: String },
'object1.array1.$.string3': { type: String },
})
) Easy to check, it breaks playground as well: |
Thank you! I've stripped it down a little and here's a minimal reproduction: new SimpleSchema2Bridge(
new SimpleSchema({
x: { type: Object },
'x.y': { type: Array },
'x.y.$': { type: String },
})
) |
seems like this schema might also break
default |
I've dug into it, and the problem is more complicated than I thought. First of all, the default (initial) value of Using the schema I posted in #1112 (comment), we see these
(The Of course, that's the expected order, because of the way how
To sum up, 1. is a workaround for the time being, if you need one. I'll think whether we can implement 2. in v3, as it's techincally a breaking change. If not, it'll definitely be there in v4. (I actually have a rework of the initial model logic in mind for a while.) |
When using array field (even with default value) I'm getting this:
Compiled module code:
Easiest workaround would be not to use it, here you can find possible replacements:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-non-null-assertion.md
For example:
The text was updated successfully, but these errors were encountered: