Add type annotations in browser-main

This commit is contained in:
Matt Bierner 2022-02-28 15:38:35 -08:00
parent a68f5aa83e
commit f0d1c07417
No known key found for this signature in database
GPG key ID: 099C331567E11888

View file

@ -12,14 +12,28 @@ const { ipcRenderer } = require('electron');
const builtInExtensionsPath = path.join(__dirname, '..', '..', 'product.json');
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
/**
* @param {string} filePath
*/
function readJson(filePath) {
return JSON.parse(fs.readFileSync(filePath, { encoding: 'utf8' }));
}
/**
* @param {string} filePath
* @param {any} obj
*/
function writeJson(filePath, obj) {
fs.writeFileSync(filePath, JSON.stringify(obj, null, 2));
}
/**
* @param {HTMLFormElement} form
* @param {string} id
* @param {string} title
* @param {string} value
* @param {boolean} checked
*/
function renderOption(form, id, title, value, checked) {
const input = document.createElement('input');
input.type = 'radio';
@ -37,7 +51,14 @@ function renderOption(form, id, title, value, checked) {
return input;
}
/**
* @param {HTMLElement} el
* @param {any} state
*/
function render(el, state) {
/**
* @param {any} state
*/
function setState(state) {
try {
writeJson(controlFilePath, state.control);
@ -115,7 +136,9 @@ function main() {
control = {};
}
render(el, { builtin, control });
if (el) {
render(el, { builtin, control });
}
}
window.onload = main;