Skip to content
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

feat Serializable 支持 readonly #79

Closed
ninesunsabiu opened this issue Jul 3, 2023 · 4 comments
Closed

feat Serializable 支持 readonly #79

ninesunsabiu opened this issue Jul 3, 2023 · 4 comments

Comments

@ninesunsabiu
Copy link
Contributor

在使用 HistoryModule 时,由于范型 T extends SerializableArray | SerializableObject 导致无法使用

image

由于我项目中是搭配使用了 @effect/schema ,从中推断出来的类型都会带上 readonly 修饰,所以如果 Serializable 能够支持 readonly 的话,应该就可用。

考虑到 readonly 修饰的数据,并不会实际对序列化的实现或者语义造成影响,所以我觉得在库层面进行支持是有理由的。

https://github.com/remesh-js/remesh/blob/7b26fbff56f70c2de8e5398e13e7c4e9d2d3ce15/packages/remesh/src/remesh.ts#L5C1-L13

export type SerializableArray = Serializable[] | ReadonlyArray<Serializable>;
export type SerializableObject = {
    [key: string]: Serializable;
} | {
    readonly [key: string]: Serializable;
};
@github-actions
Copy link

github-actions bot commented Jul 3, 2023

Thank feedback. We will check it later:-)

@Lucifier129
Copy link
Collaborator

好的,我考察一下。

目前你可以通过复制 HistoryModule 的代码,并添加 ReadOnly 支持,在你们项目中尝试跑通~

@ninesunsabiu
Copy link
Contributor Author

没事的,目前我也已经参考 HistoryModule 的代码实现了带 readonly 的版本。如果有需要,请允许我做个 PR

@Lucifier129
Copy link
Collaborator

@ninesunsabiu 好的,赞👍~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants