Hello
While developing a watchface, I found out that the declaration of const variables is not enforced later on.
For example:
const foo = "foo"; foo = "bar"; console.log(foo);
Will print "bar" (since the declaration is transpiled to "var foo")
I'm not familiar enough with the Javascript ecosystem.
Is there a way to enforce a syntax check during the build?
Best AnswerFound out a solution that is working for my particular case:
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-console": "off",
// unused vars should be stripped by the transpile step
"no-unused-vars": "warn",
}
};
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
The watch only supports ES5, which predates const being added to JavaScript. If you use const in companion/settings, it'll behave as you expect.
In the future, we might be able to detect at compile time with the help of TypeScript when you've attempted to modify a const value.
Best Answer