angular 5 noty and AOT

adrhc

I'm using noty (https://ned.im/noty) with angular 5.2.9 this way:

import { Injectable } from '@angular/core';
import Noty = require('noty');

@Injectable()
export class NotificationService {
    private noty(options) {
        return new Noty(options).show();
    }
    ...
}

and works fine.

but when I'm building with AOT (npm run build:aot) I get:

ERROR in src/app/sys/util/notification.service.ts(2,1): 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.

It's a project based on https://github.com/gdi2290/angular-starter.
When using import Noty from 'noty'; the AOT build is fine but when running npm run server I get ERROR TypeError: noty_1.default is not a constructor.

node_modules/noty/index.d.ts starts with:

declare module 'noty' {
    export = Noty;
}

declare class Noty {
    constructor(options?: Noty.Options);
...

How should I solve this?

adrhc

I found that is working this way:

/// <reference path="../../../../node_modules/noty/index.d.ts" />

import { Injectable } from '@angular/core';
import Noty = require('noty');

@Injectable()
export class NotificationService {
    private noty(options) {
        return new Noty(options).show();
    }
    ...
}

Because noty does not have the d.ts placed into node_modules/@types/... then I guess I have to manually reference it.

PS: also set "no-reference": false rule in tsling.json otherwise will mark the reference as an error

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jquery noty on close goto a url

From Dev

$.noty is not a function

From Dev

jQuery.noty is undefined

From Dev

Do the ngfactory files themselves have to be compiled in Angular 2 AOT compilation?

From Dev

`TypeError: providers.forEach is not a function` with Angular2 in AOT build

From Dev

Angular 2 AoT compile causes application issues and works fine in JiT

From Dev

Angular AOT failing at compilation (something with angular/compiler-cli)

From Dev

Angular 2 Aot Error: 'ToastsManager' is not exported

From Dev

angular-cli: "SyntaxError: Unexpected token" when compiling for production and AOT

From Dev

Bundle Angular2 AoT with systemjs-builder and rollup tree shaking

From Dev

Angular AOT/Rollup with modules which have no default export (like immutable.js, moment.js)

From Dev

Angular2 AOT ngtools/webpack failed on linux

From Dev

Running angular2 AOT and getting implicitly errors

From Dev

Angular interpolation causing AOT compile error

From Dev

Angular cli 2 Error Can't resolve all parameters for XXXXX by AOT build

From Dev

Angular2 AOT Compilation with static external js file

From Dev

Angular - Property 'email' does not exist on type '{}' with AoT compilation

From Dev

Angular AOT compiled app not tree shaking as expected

From Dev

Errors when attempting to compile AoT in Angular 4

From Dev

AOT Angular Module

From Dev

Angular 4 AOT Compiler

From Dev

Angular 4 with angular-cli - doesn't find 3rd party provider with AOT

From Dev

Angular. Aot. Error encountered resolving symbol values statically. Could not resolve

From Dev

Angular AOT build error - Maximum call stack size exceeded, resolving symbol XXX in Path

From Dev

Angular 4 inject console with AOT

From Dev

Angular 5 --aot Vs Angular 5 --aot=false

From Dev

Unable to create AOT ES5 compatible code using ngc and tsc

From Dev

The Angular AoT build failed when running the release command in Ionic 3

From Dev

MSAL for Angular Preview angular webpack AOT compilation not including resourceMap

Related Related

  1. 1

    jquery noty on close goto a url

  2. 2

    $.noty is not a function

  3. 3

    jQuery.noty is undefined

  4. 4

    Do the ngfactory files themselves have to be compiled in Angular 2 AOT compilation?

  5. 5

    `TypeError: providers.forEach is not a function` with Angular2 in AOT build

  6. 6

    Angular 2 AoT compile causes application issues and works fine in JiT

  7. 7

    Angular AOT failing at compilation (something with angular/compiler-cli)

  8. 8

    Angular 2 Aot Error: 'ToastsManager' is not exported

  9. 9

    angular-cli: "SyntaxError: Unexpected token" when compiling for production and AOT

  10. 10

    Bundle Angular2 AoT with systemjs-builder and rollup tree shaking

  11. 11

    Angular AOT/Rollup with modules which have no default export (like immutable.js, moment.js)

  12. 12

    Angular2 AOT ngtools/webpack failed on linux

  13. 13

    Running angular2 AOT and getting implicitly errors

  14. 14

    Angular interpolation causing AOT compile error

  15. 15

    Angular cli 2 Error Can't resolve all parameters for XXXXX by AOT build

  16. 16

    Angular2 AOT Compilation with static external js file

  17. 17

    Angular - Property 'email' does not exist on type '{}' with AoT compilation

  18. 18

    Angular AOT compiled app not tree shaking as expected

  19. 19

    Errors when attempting to compile AoT in Angular 4

  20. 20

    AOT Angular Module

  21. 21

    Angular 4 AOT Compiler

  22. 22

    Angular 4 with angular-cli - doesn't find 3rd party provider with AOT

  23. 23

    Angular. Aot. Error encountered resolving symbol values statically. Could not resolve

  24. 24

    Angular AOT build error - Maximum call stack size exceeded, resolving symbol XXX in Path

  25. 25

    Angular 4 inject console with AOT

  26. 26

    Angular 5 --aot Vs Angular 5 --aot=false

  27. 27

    Unable to create AOT ES5 compatible code using ngc and tsc

  28. 28

    The Angular AoT build failed when running the release command in Ionic 3

  29. 29

    MSAL for Angular Preview angular webpack AOT compilation not including resourceMap

HotTag

Archive