V
V
Vladimir2016-06-13 15:49:50
JavaScript
Vladimir, 2016-06-13 15:49:50

Where can I find good examples of Angular 1.5 projects using Typescript?

I'm trying to write an angular application using TypeScript, I literally shut up at the very beginning
I started by
doing typings install dt~angular --ambient --save in the project folder
I have a typings.json file and a typings folder at the root
I'm writing an app.ts file

module myappmodule{
    'use strict';

    var myapp=angular.module('myapp',[])
}

I get the response
app.ts(4,15): error TS2304: Cannot find name 'angular'.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene 222, 2016-06-13
@mik222

Add refs to the header file.
Download the header file here. definitelytyped.org
https://www.typescriptlang.org/docs/handbook/tripl...

S
Stanislav Makarov, 2016-06-13
@Nipheris

/// <reference path="../typings/angular/angular.d.ts"/>
import { angular } from "angular";

var myapp=angular.module('myapp',[])

1) 'use strict' is not needed since TS 1.8 (tsc adds itself now always);
2) instead of module, starting from TS 1.5, namespace is used so as not to conflict in terminology with module systems for JS;
3) you don’t need a module here, because the file itself is already a module;
4) if the name is not from the TS standard libraries, it must be imported before use. The exact path depends on where you put the d.ts-ki for Angular and than on what you generally assemble the project with.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question