How do I define a knockout binding handler in typescript?

Defining a custom binding handler Its actually pretty easy, just add it (myBindingHandler) to the KnockoutBindingHandlers interface right before you define your custom binding handler. Please note that you have to do make this addition to the interface, within a .d.ts file as of version 1.0 (or possibly earlier). bindingHandlers.d.ts /// <reference path=”typings/knockout/knockout.d.ts” /> interface … Read more

Using getInitialProps in Next.js with TypeScript

Edit 2021/04/23: My answer below is also out of date Please see the Next.js docs for the current recommendation for typing data fetching methods using new types and named exports. tl;dr: import { GetStaticProps, GetStaticPaths, GetServerSideProps } from ‘next’ export const getStaticProps: GetStaticProps = async (context) => { // … } export const getStaticPaths: GetStaticPaths … Read more

Extend interface defined in .d.ts file

// How to extend Validator interface adding isArray() method?? You cannot do this in a file that is a module (some guidance here) and your file is a module because you have import expressValidator. Instead create a extendedValidator.d.ts and add the new stuff for TypeScript’s engine: declare module ExpressValidator { export interface Validator { isArray: … Read more

Relationship between the version of node.js and the version of @types/node

Simply, the major version and minor version tagged in the semver string of @types/node is exactly corresponding to the node’s version. If you check the index.d.ts file of @types/node in DefinitelyTyped repository, you’ll see what type of node is this declaration file for through the first line comment at the top of the file: // … Read more

Is there a way to “extract” the type of TypeScript interface property?

It wasn’t possible before but luckily it is now, since TypeScript version 2.1. It has been released on the 7th of December 2016 and it introduces indexed access types also called lookup types. The syntax looks exactly like element access but written in place of types. So in your case: interface I1 { x: any; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)