Ngx-mask: Cannot find name 'IConfig'.

Created on 10 Jun 2019  Â·  8Comments  Â·  Source: JsDaddy/ngx-mask

Using Angular 8

I'm facing this error message when I add these 2 lines on app.module.ts:

import {NgxMaskModule} from 'ngx-mask';
export const options: Partial<IConfig> | (() => Partial<IConfig>);

Error Message:

ERROR in ./src/app/app.module.ts 16:20
Module parse failed: Unexpected token (16:20)
You may need an appropriate loader to handle this file type.
| import { LoginPageComponent } from './login-page/login-page.component';
| import { NgxMaskModule } from 'ngx-mask';
> export const options;
| let AppModule = class AppModule {
| };
ℹ 「wdm」: Failed to compile.

    ERROR in src/app/app.module.ts(22,14): error TS1155: 'const' declarations must be initialized.
    src/app/app.module.ts(22,31): error TS2304: Cannot find name 'IConfig'.
    src/app/app.module.ts(22,57): error TS2304: Cannot find name 'IConfig'.
question

Most helpful comment

Try with:

export const options: Partial<IConfig> | (() => Partial<IConfig>) = {}

it works for me

All 8 comments

@danilobatistaqueiroz Hi. We will check

import {NgxMaskModule, IConfig} from 'ngx-mask';

export let options: Partial | (() => Partial);

All working fine but, ng build not working and show this kind of error

ERROR in Error during template compile of 'AppModule'
Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler in 'options'
'options' is not initialized at app/app.module.ts(6,14).
src/app/app.module.ts(6,14): error TS1155: 'const' declarations must be initialized.

Try with:

export const options: Partial<IConfig> | (() => Partial<IConfig>) = {}

it works for me

Try with:

export const options: Partial<IConfig> | (() => Partial<IConfig>) = {}

it works for me

After your suggestion, there are still two problems for me:

ERROR in src/app/app.module.ts(9,31): error TS2304: Cannot find name 'IConfig'.
src/app/app.module.ts(9,57): error TS2304: Cannot find name 'IConfig'.

@Edit: I solved it this way:

import { NgxMaskModule } from 'ngx-mask';
import { IConfig } from 'ngx-mask';

export const options: Partial<IConfig> | (() => Partial<IConfig>) = {};

Why this 'options' required can I know?

That is causing and stopping me to create a production build?

Thank you!

This is working fine for me:
import { NgxMaskModule, IConfig } from 'ngx-mask'
export const options: Partial | (() => Partial) = {};

Following worked for me.

const options: Partial | (() => Partial) = {} = {};

Was this page helpful?
0 / 5 - 0 ratings