NativeScript / worker-loader

36 stars 20 forks source link

Error in worker.service : no default export or cannot use 'new' #32

Closed pacome2017 closed 5 years ago

pacome2017 commented 5 years ago

I use a few workers in my project, I added webpack bundling recently and used the demo-angular in this project to check for the needed changes on workers. I'm blocked on this one : in my worker.service.ts, when I try to import a worker like this import * as SearchWorker from './search.worker'; then I get an error at const worker = new SearchWorker(); error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.

Or if I try to default import without * import ConfigWorker from './config.worker'; then I get an error error TS1192: Module "..." has no default export

anything on this ?

fhackenb commented 5 years ago

@pacome2017 what was the solution?

pacome2017 commented 5 years ago

I'm not sure but I think I was missing the custom.d.ts file. Then paths should be : import * as WorkerScript from "nativescript-worker-loader!./worker-script";

I say I'm not sure because I ended up redoing my workers following this : https://github.com/NativeScript/worker-loader#web-workers-withwithout-webpack