How to use jQuery with TypeScript

Most likely you need to download and include the TypeScript declaration file for jQuery—jquery.d.ts—in your project. Option 1: Install the @types package (Recommended for TS 2.0+) In the same folder as your package.json file, run the following command: npm install –save-dev @types/jquery Then the compiler will resolve the definitions for jquery automatically. Option 2: Download … Read more

How can I declare a global variable in Angular 2 / Typescript? [closed]

Here is the simplest solution w/o Service nor Observer: Put the global variables in a file an export them. // // ===== File globals.ts // ‘use strict’; export const sep=”https://stackoverflow.com/”; export const version: string=”22.2.2″; To use globals in another file use an import statement: import * as myGlobals from ‘globals’; Example: // // ===== File … Read more

How to use a typescript enum value in an Angular2 ngSwitch statement

You can create a reference to the enum in your component class (I just changed the initial character to be lower-case) and then use that reference from the template (plunker): import {Component} from ‘angular2/core’; enum CellType {Text, Placeholder} class Cell { constructor(public text: string, public type: CellType) {} } @Component({ selector: ‘my-app’, template: ` <div … Read more

How to get argument types from function in Typescript [duplicate]

Typescript now comes with a predefined Parameters<F> type alias in the standard library which is almost the same as ArgumentTypes<> below, so you can just use that instead of creating your own type alias. type TestParams = Parameters<(a: string, b: number) => void> // [string, number] Then to get for example the second parameter’s type … Read more

How does interfaces with construct signatures work?

Construct signatures in interfaces are not implementable in classes; they’re only for defining existing JS APIs that define a ‘new’-able function. Here’s an example involving interfaces new signatures that does work: interface ComesFromString { name: string; } interface StringConstructable { new(n: string): ComesFromString; } class MadeFromString implements ComesFromString { constructor (public name: string) { console.log(‘ctor … Read more

How to define static property in TypeScript interface

Follow @Duncan’s @Bartvds’s answer, here to provide a workable way after years passed. At this point after Typescript 1.5 released (@Jun 15 ’15), your helpful interface interface MyType { instanceMethod(); } interface MyTypeStatic { new():MyType; staticMethod(); } can be implemented this way with the help of decorator. /* class decorator */ function staticImplements<T>() { return … Read more

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