Satisfies Operator

August 22, 2023

Typescript

Satisfies Operator

Thuta Sann

Thuta Sann

Lets take a look at Satisfies Operator


Share This Snippet To :

Satisfies Operator

The TypeScript satisfies operator checks if a given type satisfies a specific condition or interface.

ps: Typescript version needs to be WorkSpace latest version in VsCode.

// ------------ lib.ts type Connection = {}; declare function createConnection( host: string, port: string, reconnect: boolean, poolSize: number, ): Connection; // ------------ app.ts type Config = { host: string; port: string | number; tryReconnect: boolean | (() => boolean); poolSize?: number; }; const config = { host: 'db.myapp.com', port: 134, tryReconnect: () => true, poolSize: 12, } satisfies Config; function start() { let { host, port, tryReconnect, poolSize }: Config = config; createConnection(host, `${port}`, tryReconnect(), poolSize); }

Cookie

I baked some cookies that you have to accept, if you want to enjoy my portfolio.
In order to gather information and make improvements, I should use some third-party cookies too, Can I?