Reddit » TypeScript
14 FOLLOWERS
Come across ways to avoid explicitly casting object keys to numbers, find codes on how to get the return value, communicate about compiling issues, and more here. Also, ask questions and share video tutorials on TypeScript features.
Reddit » TypeScript
20h ago
Hi Reddit, Suppose we have
type GenFunc = <A = void, B = void>({ a?: A, b?: B }) => Promise<void>
I have written a IIFE to return a function that does something depending on an external variable
const num = 1 // substitue for an external variable const genFunc: GenFunc = (() => { switch (num) { case 1: return async ({ a, b }) => { console.log(a) console.log(b) await fetch("http://example.com") // just an awaited function, nothing to do with the code } case 2: ... ... ... default: return async({ body, params }) => {} } } })()
I'm not able to access the a and b de ..read more
Reddit » TypeScript
1d ago
I made this VS Code extension, which allows you to access documentation, frameworks, and libraries right within VS Code.
If you find it useful, you can get it from here: Code Pilot - VS Code Extension.
If you have any suggestions for websites to be added, please feel free to mention them in the comments. Alternatively, you are welcome to contribute to the extension yourself.
submitted by /u/ayushmaansingh304
[visit reddit] [comments ..read more
Reddit » TypeScript
3d ago
The monthly thread for people to post openings at their companies.
* Please state the job location and include the keywords REMOTE, INTERNS and/or VISA when the corresponding sort of candidate is welcome. When remote work is not an option, include ONSITE.
* Please only post if you personally are part of the hiring company—no recruiting firms or job boards **Please report recruiters or job boards**.
* Only one post per company.
* If it isn't a household name, explain what your company does. Sell it.
* Please add the company email that applications should be sent to, or the companies ..read more
Reddit » TypeScript
3d ago
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 ..read more
Reddit » TypeScript
4d ago
Hi, devs! I've been trying to achieve the following goal, but without success. I want to import object from a third party package, then use the keys as type and export the type. I want to build/compile (it is types only package in monorepo) and then use in other packages. Some of the imports are promises. Is there any good approach to do it? Here is quick pseudo code:
import { someObject } from "awesome-package" type someType = { [P in keyof typeof someObject\]: boolean; } export { someType }
submitted by /u/Devastion
[visit reddit] [comments ..read more
Reddit » TypeScript
4d ago
It seems the documentation suggests they are practically the same, and it's a matter of developer preference. Is that really so, or are there some rare cases where there's an actual difference?
Readonly<Type> example:
interface Todo { title: string; } const todo: Readonly<Todo> = { title: "Delete inactive users", }; todo.title = "Hello"; // Cannot assign to 'title' because it is a read-only property.
readonly Properties example:
interface SomeType { readonly prop: string; } function doSomething(obj: SomeType) { // We can read from 'obj.prop'. console.log(`prop has the value ..read more
Reddit » TypeScript
4d ago
i know its a dumb question but i will ask anyway, imagine you can write code like this : //math.ts function add(x: number, y: number): number { return x + y; }
//another.ts import type {add} from './math.ts' const foo : add and ts will extract the type definition from add function to foo const , and whenever i made change in add function thats will reflect with errors or warnings in 'another.ts' file ?
submitted by /u/lorens_osman
[visit reddit] [comments ..read more
Reddit » TypeScript
4d ago
I am searching for an alternative to Nest.js, but I haven't been able to find any framework that is as comprehensive as Nest. I'm looking for a solution that includes features such as Dependency Injection, ORM, Authentication, and Authorization. Are there any good alternatives to Nest or a suitable stack that meets these requirements that you would recommend?
submitted by /u/alexandreqo
[visit reddit] [comments ..read more