Comments (9)
We have had a lot of discussion about this over the past year, and some things were implemented, like AsJsonable. However, the general consensus has been that this requires too much "fancy type handling" and ultimately is more confusing than helpful.
The current plan is to close this, and possibly remove the things we put in place already with follow up issues.
from fluidframework.
Typescript complains abt. the circular reference if I attempt to support nested arrays like this (e.g., [[[ . ]]]):
export type JsonArray = (JsonPrimitive | JsonObject | JsonArray)[];
(Perhaps @skylerjokiel, @anthony-murphy or @jack-williams have a trick.)
from fluidframework.
it can be worked around with more interfaces, but recursive types are coming in typescript 3.7:
https://httptoolkit.tech/blog/5-big-features-of-typescript-3.7/
from fluidframework.
Yeah until microsoft/TypeScript#33050 lands it has to be done with an interface:
export interface JsonArray extends Array<JsonPrimitive | JsonObject | JsonArray> {}
from fluidframework.
Note: Json introduced in #165
from fluidframework.
The Jsonable definition works well for anonymous objects, but requires casting through 'unknown' in both directions when casting to/from a compatible interface. :-/
interface ICell {
text: JsonablePrimitive;
cache: JsonablePrimitive;
}
private loadCell(row: number, col: number): ICell {
return this.matrix.getItem(row, col) as unknown as ICell;
}
private storeCell(row: number, col: number, cell: ICell) {
return this.matrix.setItems(row, col, [cell as unknown as Jsonable]);
}
from fluidframework.
Yeah this is abit of a pain. You can always do:
type ICell = {
text: JsonablePrimitive;
cache: JsonablePrimitive;
}
or
interface ICell {
text: JsonablePrimitive;
cache: JsonablePrimitive;
[other: string]: unknown
}
The latter is probably more honest unless you're explicitly filtering out properties before serialising.
Could also do:
private loadCell(row: number, col: number): ICell {
return this.matrix.getItem(row, col) as Pick<ICell, keyof ICell>;
}
private storeCell(row: number, col: number, cell: Pick<ICell, keyof ICell>) {
return this.matrix.setItems(row, col, [cell as Jsonable]);
}
from fluidframework.
tagging myself for future developments on this issue
from fluidframework.
Because this issue is marked as "won't fix" and has not had activity for over 3 days, we're automatically closing it for house-keeping purposes.
from fluidframework.
Related Issues (20)
- ActivityTimeout event handling behavior not consistent in Deli HOT 2
- Deprecate mergeTree's findTile method HOT 1
- 6.1 release blocker: Add removed telemetry items HOT 1
- Remove type parameter from IntervalCollection's add method HOT 1
- Shredded summary upload service fails on compressed binary summary blobs. HOT 3
- Copy of the container with compressed binary summaries is failing. HOT 6
- Memory leak related to unbounded creation of debug loggers HOT 1
- Stop requiring guestDisplayName as pre-condition for requestSocketToken: true as part of joinSession payload HOT 2
- Browser - Database updates on a separate thread HOT 2
- SharedMatrix undefined cell values HOT 8
- Need to bump axios to 1.6.0+ (and test) to address vulnerability HOT 7
- Misbehaving driver can cause Fluid to hang on container open HOT 7
- Allow SharedTree to be passed across iframe boundary HOT 3
- Blazor SDK HOT 1
- Use @fluidframework/azure-client can not create container and get Error: 0x883 at app.js:125 HOT 3
- Intervals not at expected location sometimes after undo-ing HOT 3
- Issue at container connection : Provided user was not an "AzureUser" HOT 1
- Container issues at connection HOT 10
- Error fetching checkpoint for any document causes rest of the batch to fail in deleteSummarizedOps HOT 2
- FF client Buffer error under browser HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluidframework.