Import AngularJS into Typescript as AMD

I am trying to follow a github tutorial to stop the build process for typescript and angularjs. I have to be honest, I'm really fighting. I took the project from github and added angularjs to the bower file, the files and the lib directory with the angular.ts file (after setting up jQuery):

/// <reference path="../typings/tsd.d.ts"/>

var angular= angular;
export = angular;

Unfortunately, when I try to do the following, I was not lucky in registering my application module:

import JQuery = require("../lib/JQuery");
import angular = require("../lib/angular");

class A{
  public add(number1:number, number2:number):number{
    return number1+number2;
  }

  public colorBG():void{
    var app = angular.module('myapp',[]);
    $("body").css({"background-color":"black"})
  }
}

export = A;

, angular AMD, AMD, ? gulp , angular.module , -. angular typescript, html? requirejs AMD, tsify/browsify commonjs, . .

+4
1

:

:

tsd install angular jquery --save

npm:

npm init
npm install angular jquery --save

, lib. node_modules.

/typings/tsd.d.ts :

/// <reference path="./jquery/jquery.d.ts"/>
/// <reference path="./angular/angular.d.ts"/>

/typings/tsd.d.ts :

/// <reference path="../typings/tsd.d.ts"/>

import { $ } from "jquery";
import { angular } from "angular";

class A {
  public add(number1:number, number2:number):number{
    return number1+number2;
  }

  public colorBG():void{
    var app = angular.module('myapp',[]);
    $("body").css({"background-color":"black"})
  }
}

export { A };

TypeScript 1.5, ES6.

Update

2.0, - npm:

$ npm install jquery --save
$ npm install @types/jquery --save-dev

tsd .

+3

Source: https://habr.com/ru/post/1608882/


All Articles