-
Notifications
You must be signed in to change notification settings - Fork 249
Closed
Labels
fixed - please verifyIssue has been fixed. Please verify and close.Issue has been fixed. Please verify and close.
Description
version: 4ad0dde
Build environment: Windows
Target device: ESP32
Description
Should be possible to declare using const, but the let to be declared next will be treated as const.
Test case
function func(descriptors) {
const obj = {}
for (const [key, descriptor] of Object.entries(descriptors)) {
const type =
typeof descriptor.type == 'string'
? descriptor.type.toLowerCase()
: typeof descriptor.type.name == 'string'
? descriptor.type.name.toLowerCase()
: ''
if ((type == 'digital')) {
if (typeof descriptor.mode == 'string') {
// It should be possible to declare using const, but the let to be declared next will be treated as const.
const mode = descriptor.mode.toLowerCase()
if (mode == 'output') descriptor.mode = 1
}
if (descriptor.mode == 1) {
let value = descriptor.default || false
//value = !value // ERROR!! set value: const!
Object.defineProperty(obj, key, {
get() {
return value
},
set(val) {
value = val // ERROR!! set value: const!
},
enumerable: true,
})
}
}
}
return obj
}
const obj = func({
prop: {
type: 'Digital',
mode: 'Output',
}
})
obj.prop = trueSorry for not being able to provide the minimum test case
Behavior
Break: ?.prop: set value: const!
Steps to Reproduce
- Build and install the app using this build command:
mcconfig -d -m -p esp32 - See error
Expected behavior
Can update value.
Metadata
Metadata
Assignees
Labels
fixed - please verifyIssue has been fixed. Please verify and close.Issue has been fixed. Please verify and close.