Issue
Auto import by VS Code:
import deepEqual = require('deep-equal');
Doesn't work:
error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
Then I tried to do like this:
import * as deepEqual from 'deep-equal';
error TS2497: Module '"path/@types/deep-equal/index"' resolves to a non-module entity and cannot be imported using this construct.
And like this:
import {deepEqual} from 'deep-equal';
error TS2305: Module '"C:/Projects/ManagerServer/Src-LoyaltyCoin.ManagerServer.Core/ManagerWeb/ClientApp/node_modules/@types/deep-equal/index"' has no exported member 'deepEqual'.
I haven't got ideas how can I import this. If there's no solution for this, please suggest me another library to compare objects for Angular 7.
Solution
Add the script to your angular.json
file :
scripts: [
"node_modules/deep_import/name.of.minified.file.js"
]
And declare a variable in your component :
import { Component } from '@angular/core';
....
declare const deepEqual: any;
Or, you can find typings for it and install them, and import it like any other dependency :
import * as deepEqual from 'deep-equal';
EDIT Just a syntax issue. I suggest you open the repository and see the syntax. The correct one is
import deepEqual from 'deep-equal';
as you can see in this stackbltiz
Answered By - user4676340
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.