Reputation: 47088
I'm upgrading a project to Angular 12 and the following code snippet used to work fine
worker.postMessage(csvFile.data)
worker.onmessage = ({ data }: { data: ParseResult<any> }) => {
Now the line worker.onmessage = ({ data }: { data: ParseResult<any> }
has the error:
Not all code paths return a value.ts(7030)
(alias) interface ParseResult<T>
import ParseResult
data: is an array of rows. If header is false, rows are arrays; otherwise they are objects of data keyed by the field name. errors: is an array of errors meta: contains extra information about the parse, such as delimiter used, the newline sequence, whether the process was aborted, etc. Properties in this object are not guaranteed to exist in all situations
And the project will not compile. Any ideas?
If I set tsconfig.json
noImplicityReturns
to false
it compiles ... but I was wondering if there's a more "Correct" way to fix this?
Upvotes: 0
Views: 179
Reputation: 3664
From my comment, the suggestion was that the expression being assigned to worker.onmessage
might have had an early return
statement with some value, whilst there isn't a catch-all return
at the conclusion of the expression. This would be sufficient to trigger the TS compiler error which would otherwise be suppressed by --noImplicitReturns
.
Upvotes: 1