mobxjs / serializr

Serialize and deserialize complex object graphs to and from JSON and Javascript classes
MIT License
766 stars 52 forks source link

Serializing an string array #89

Closed andreaslarssen closed 6 years ago

andreaslarssen commented 6 years ago

Hi.

Quick question: Is raw() the way to go for serializing a TypeScript string array?

@serializable(raw()) stuff: string[];

alexggordon commented 6 years ago

By string array do you just mean an array of strings? If so, then you just need

@serializable(list())

that's technically short for

@serializable(list(primitive()))

andreaslarssen commented 6 years ago

Yes, but list() expects a PropSchema parameter. Should that be optional?

primitive() won't do, as it's not a primitive...

alexggordon commented 6 years ago

I'm not sure what you mean that it's not a primitive. Strings are primitive.

Here's a runkit example. If that isn't what you're referring to can you modify/fork that example to explain?

andreaslarssen commented 6 years ago

So I see you wrap the primitive() in the list(). That's my weekend cue. Thanks.