Angular2 and lodash ... I can not find the name

Angular2 and lodash ... why so much drama? I really mean ...

The following describes how I install

npm install --save lodash
npm install --save @types/lodash

UPDATE:

I followed this blog and did it angular2 -and-lodash-can not-find-name : npm install @ types / lodash @ ts2.0 --save-dev

It worked. Only errors:

node_modules / @ types / jasmine

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:40:37 
A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:40:45 
Cannot find name 'keyof'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:40:51 
'=' expected.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:42:45 
A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:42:55 
Cannot find name 'keyof'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:42:61 
'=' expected.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:58:41 
Cannot find name 'Partial'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:99:21 
Cannot find name 'Partial'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/jasmine/index.d.ts:99:34 
Cannot find name 'Partial'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/lodash/index.d.ts:241:12 
Duplicate identifier '_'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/lodash/index.d.ts:241:15 
Cannot find namespace '_'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/lodash/index.d.ts:243:24 
Cannot find name 'Partial'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/lodash/index.d.ts:245:18 
Duplicate identifier '_'.

ERROR in [default] /Users/dude/Documents/frontend/qta-angular2/node_modules/@types/lodash/index.d.ts:362:38 
Cannot find namespace '_'.
+4
source share
5 answers

( "Partial" ), Partial variable, , , , , , .

, JavaScript, typescript, , .

var Partial : any;
+3

package.json, :

@types/jasmine@2.5.41 // Or 2.5.38

.

+2

typescript lodash angular.

  • angular 2.x typescript 2.0.x
  • angular 4.x typescript 2.2.x

, , .

, lodash typescript.

p.s ( ) - install @types/lodash --save-dev @types.

+1

angular -cli.json

"scripts": [
        "../node_modules/lodash/lodash.js" //make changes accordingly
      ],

lodash.

import {EventsService} from '../../core/broadcast-event/broadcaster';
declare var _: any;
+1

lodash ?
import * as _ from 'lodash'

LoDash, , , , .

_ @types.

0

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


All Articles