alEX860111 / ngx-formly-material-file

2 stars 5 forks source link

Function calls are not supported in decorators but 'FileTypeModule' was called #1

Open its-dibo opened 4 years ago

its-dibo commented 4 years ago

following the instructions in readme exactly, but geeting an error: Function calls are not supported in decorators but 'FileTypeModule' was called.

references: https://stackoverflow.com/a/59823278/12577650

codemile commented 4 years ago

The forRoot() function is not compatible with 8.3 and up. It needs to be a pure function that contains only a return statement.

Please see this comment for instructions on how to fix it:

https://github.com/angular/angular/issues/23609#issuecomment-561615821

its-dibo commented 4 years ago

The forRoot() function is not compatible with 8.3 and up. It needs to be a pure function that contains only a return statement.

Please see this comment for instructions on how to fix it:

angular/angular#23609 (comment)

I read your comment, but how can I fix this issue in my project, I'm not the developer of ngx-formly-material-file, so I cannot make any modification in forRoot().

@codemile

codemile commented 4 years ago

@eng-dibo

You can try to manually provide the configuration in your module, and then import FileTypeModule normally without calling forRoot().

If you look at the source code for the module, then you can see how it is providing FILE_TYPE_CONFIG and so you can just handle this provider yourself.

@NgModule({
     import: [FileTypeModule],
     providers: [
           { 
                provide: FILE_TYPE_CONFIG, useValue: {
                      // your config settings here
                }
            }
     ]
})

See here as reference:

https://github.com/alEX860111/ngx-formly-material-file/blob/fb3de8a2a211f7c65cf7902ad75142c3f0182fa1/projects/ngx-formly-material-file/src/lib/file-type.module.ts#L52