Fix typo and remove unnecessary eslint comments#4055
Conversation
| // eslint-disable-next-line prefer-const | ||
| export let promptLabel = 'Terminal input'; | ||
|
|
||
| // eslint-disable-next-line prefer-const | ||
| export let tooMuchOutput = 'Too much output to announce, navigate to rows manually to read'; |
There was a problem hiding this comment.
This actually needs to be let, it's exposed to embedders of xterm.js so they can change the strings to localize xterm.js. It's exposed (as non-readonly) here
xterm.js/src/browser/public/Terminal.ts
Lines 242 to 244 in c0ef2cc
There was a problem hiding this comment.
Thanks for your reply.
I verified it myself within the project. Validation does not affect the original functional logic.
Verify 1: From the compilation results, the two are the same.
original code
export let promptLabel = 'Terminal input';
export let tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';after compilation code
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tooMuchOutput = exports.promptLabel = void 0;
exports.promptLabel = 'Terminal input';
exports.tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';
//# sourceMappingURL=LocalizableStrings.js.maporiginal code
export const promptLabel = 'Terminal input';
export const tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';after compilation code
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tooMuchOutput = exports.promptLabel = void 0;
exports.promptLabel = 'Terminal input';
exports.tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';
//# sourceMappingURL=LocalizableStrings.js.mapVerify 2: Use let to declare variables; the value cannot be modified in the import place. The two are the same.
Verify 3: The exported const variable can also be modified normally
export const promptLabel = 'Terminal input';
export const tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';and then, no error prompt
Terminal.strings.promptLabel = 'modify';There was a problem hiding this comment.
Ah I see, still using const shows the wrong intent here. const means this value should not change, and while currently TypeScript outputs is as mutable, it may not in the future. So I think we should keep this as it was
There was a problem hiding this comment.
I think your idea is good, and I suggest adding a comment. I re-updated the submission.
e30d324 to
ac81d3f
Compare

Description
fix typo and remove unnecessary eslint comments
What is the purpose of this pull request?