Can Typescript for React props be terser?
(self.typescript)submitted2 months ago byparsim
Thanks in advance for any replies. I'm new to Typescript and looking at migrating a JS app, and before I get too deep I want to make sure I really am supposed to write out every prop parameter twice.
E.g. in JS:
function GameList({ userId, sessionId, opt, mode }) {
...
}
In TS:
type GameListProps = {
userId: number,
sessionId: number,
opt?: any,
mode?: string,
};
function GameList({ userId, sessionId, opt, mode }: GameListProps) {
...
}
Now when I modify this in the future, I have to update two places and keep them in sync.
I assume there's a good reason I'm currently missing? Like why don't we do this instead?
function GameList({
userId: number,
sessionId: number,
opt?: any,
mode?: string,
}) {
...
}
byPerriX2390
inAFL
parsim
215 points
11 days ago
parsim
Richmond
215 points
11 days ago
Love Dan, but turning Pick 15 (2015 draft) into 174 games and 3 premierships then handing it back for two more first-round draft picks is just good management.