Lately, I've been facing a recurring issue that goes as follows:
TS2339: Property 'activityTime' does not exist on type 'typeof import...'
When it comes to importing our parameters.js file in the project, we usually do it like this:
import * as params from 'parameters'
However, the parameters.js file is stored locally and may not always contain optional configurations. As a result, code like the following tends to raise errors:
if (params.activityTime) {
// do something
}
We have numerous instances of this scenario scattered throughout the project, and constantly adding @ts-ignore annotations can become quite messy.
I had considered a workaround by doing something like const p: any = params; whenever importing params, but this resulted in unnecessary constants being added to most files, so I decided against pursuing that approach.
Is there a way to cast params as any without modifying our parameters.js file?