This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I'm in an old project that is too huge to easily convert to Typescript, so I've been using JSDoc instead. The Typescript feature that I can't figure out how to replicate in JSDoc is using as const
to fully type the property names and values of an object.
ts
// In Typescript
const anObject = {hello: 'world'} as const;
// (type shows as {hello:'world'} instead of {hello:string}
Is there any equivalent for this in JSDoc? I've been completely unable to find anything that does this, so instead I have to basically copy-paste any static object as a type to be able to properly type these cases, which certainly isn't DRY.
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/typescript/...