Commit 0ac9c055 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Lint jsdoc in media_app_ui/resources/js

Mostly this is missing nullability modifiers picked up by
jscomp_error=lintChecks. Also clean up some white space in closure
annotations.

This just addresses the release code (test code to be done later after
consolidating all the flags better).

Bug: 892530
Change-Id: Ibb8c250bf7b5e3950f9bc477bad0fcffc3254bff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2253258Reviewed-by: default avatarBugs Nash <bugsnash@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780090}
parent 69a16ffc
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
# Lint checks are not well documented, but pick up some useful stuff. Currently
# require it to be requested in developer builds only.
enable_lint_checks = false
# Note we compile with reportUnknownTypes while it works, but if dependencies # Note we compile with reportUnknownTypes while it works, but if dependencies
# get more complex, we should remove it and only enable in developer builds. # get more complex, we should remove it and only enable in developer builds.
media_closure_flags = default_closure_args + [ media_closure_flags = default_closure_args + [
...@@ -22,6 +26,13 @@ media_closure_flags = default_closure_args + [ ...@@ -22,6 +26,13 @@ media_closure_flags = default_closure_args + [
"hide_warnings_for=chromeos/components/media_app_ui/media_app_ui.mojom-lite-for-compile.js", "hide_warnings_for=chromeos/components/media_app_ui/media_app_ui.mojom-lite-for-compile.js",
] ]
if (enable_lint_checks) {
media_closure_flags += [
"jscomp_error=lintChecks",
"hide_warnings_for=mojo/public/interfaces/bindings",
]
}
group("closure_compile") { group("closure_compile") {
deps = [ deps = [
":closure_compile_app", ":closure_compile_app",
......
...@@ -66,12 +66,12 @@ guestMessagePipe.registerHandler(Message.OPEN_FEEDBACK_DIALOG, () => { ...@@ -66,12 +66,12 @@ guestMessagePipe.registerHandler(Message.OPEN_FEEDBACK_DIALOG, () => {
}); });
guestMessagePipe.registerHandler(Message.OVERWRITE_FILE, async (message) => { guestMessagePipe.registerHandler(Message.OVERWRITE_FILE, async (message) => {
const overwrite = /** @type {OverwriteFileMessage} */ (message); const overwrite = /** @type {!OverwriteFileMessage} */ (message);
await saveBlobToFile(fileHandleForToken(overwrite.token), overwrite.blob); await saveBlobToFile(fileHandleForToken(overwrite.token), overwrite.blob);
}); });
guestMessagePipe.registerHandler(Message.DELETE_FILE, async (message) => { guestMessagePipe.registerHandler(Message.DELETE_FILE, async (message) => {
const deleteMsg = /** @type{DeleteFileMessage} */ (message); const deleteMsg = /** @type {!DeleteFileMessage} */ (message);
const {handle, directory} = const {handle, directory} =
assertFileAndDirectoryMutable(deleteMsg.token, 'Delete'); assertFileAndDirectoryMutable(deleteMsg.token, 'Delete');
...@@ -97,7 +97,7 @@ guestMessagePipe.registerHandler(Message.DELETE_FILE, async (message) => { ...@@ -97,7 +97,7 @@ guestMessagePipe.registerHandler(Message.DELETE_FILE, async (message) => {
/** Handler to rename the currently focused file. */ /** Handler to rename the currently focused file. */
guestMessagePipe.registerHandler(Message.RENAME_FILE, async (message) => { guestMessagePipe.registerHandler(Message.RENAME_FILE, async (message) => {
const renameMsg = /** @type{RenameFileMessage} */ (message); const renameMsg = /** @type {!RenameFileMessage} */ (message);
const {handle, directory} = const {handle, directory} =
assertFileAndDirectoryMutable(renameMsg.token, 'Rename'); assertFileAndDirectoryMutable(renameMsg.token, 'Rename');
...@@ -131,7 +131,7 @@ guestMessagePipe.registerHandler(Message.RENAME_FILE, async (message) => { ...@@ -131,7 +131,7 @@ guestMessagePipe.registerHandler(Message.RENAME_FILE, async (message) => {
}); });
guestMessagePipe.registerHandler(Message.NAVIGATE, async (message) => { guestMessagePipe.registerHandler(Message.NAVIGATE, async (message) => {
const navigate = /** @type {NavigateMessage} */ (message); const navigate = /** @type {!NavigateMessage} */ (message);
await advance(navigate.direction); await advance(navigate.direction);
}); });
...@@ -276,7 +276,7 @@ async function refreshFile(fd) { ...@@ -276,7 +276,7 @@ async function refreshFile(fd) {
fd.lastError = ''; fd.lastError = '';
try { try {
fd.file = (await getFileFromHandle(fd.handle)).file; fd.file = (await getFileFromHandle(fd.handle)).file;
} catch (/** @type{!DOMException} */ e) { } catch (/** @type {!DOMException} */ e) {
fd.lastError = e.name; fd.lastError = e.name;
// A failure here is only a problem for the "current" file (and that needs // A failure here is only a problem for the "current" file (and that needs
// to be handled in the unprivileged context), so ignore known errors. // to be handled in the unprivileged context), so ignore known errors.
...@@ -347,7 +347,7 @@ function assertFileAndDirectoryMutable(editFileToken, operation) { ...@@ -347,7 +347,7 @@ function assertFileAndDirectoryMutable(editFileToken, operation) {
* Returns whether `handle` is in `currentDirectoryHandle`. Prevents mutating a * Returns whether `handle` is in `currentDirectoryHandle`. Prevents mutating a
* file that doesn't exist. * file that doesn't exist.
* @param {!FileSystemFileHandle} handle * @param {!FileSystemFileHandle} handle
* @return {!Promise<!boolean>} * @return {!Promise<boolean>}
*/ */
async function isHandleInCurrentDirectory(handle) { async function isHandleInCurrentDirectory(handle) {
// Get the name from the file reference. Handles file renames. // Get the name from the file reference. Handles file renames.
...@@ -359,7 +359,7 @@ async function isHandleInCurrentDirectory(handle) { ...@@ -359,7 +359,7 @@ async function isHandleInCurrentDirectory(handle) {
/** /**
* Returns if a`filename` exists in `currentDirectoryHandle`. * Returns if a`filename` exists in `currentDirectoryHandle`.
* @param {string} filename * @param {string} filename
* @return {!Promise<!boolean>} * @return {!Promise<boolean>}
*/ */
async function filenameExistsInCurrentDirectory(filename) { async function filenameExistsInCurrentDirectory(filename) {
return (await getFileHandleFromCurrentDirectory(filename, true)) !== null; return (await getFileHandleFromCurrentDirectory(filename, true)) !== null;
...@@ -369,7 +369,7 @@ async function filenameExistsInCurrentDirectory(filename) { ...@@ -369,7 +369,7 @@ async function filenameExistsInCurrentDirectory(filename) {
* Returns the `FileSystemFileHandle` for `filename` if it exists in the current * Returns the `FileSystemFileHandle` for `filename` if it exists in the current
* directory, otherwise null. * directory, otherwise null.
* @param {string} filename * @param {string} filename
* @param {boolean} suppressError * @param {boolean=} suppressError
* @return {!Promise<!FileSystemHandle|null>} * @return {!Promise<!FileSystemHandle|null>}
*/ */
async function getFileHandleFromCurrentDirectory( async function getFileHandleFromCurrentDirectory(
...@@ -379,7 +379,7 @@ async function getFileHandleFromCurrentDirectory( ...@@ -379,7 +379,7 @@ async function getFileHandleFromCurrentDirectory(
} }
try { try {
return (await currentDirectoryHandle.getFile(filename, {create: false})); return (await currentDirectoryHandle.getFile(filename, {create: false}));
} catch (/** @type {Object} */ e) { } catch (/** @type {?Object} */ e) {
if (!suppressError) { if (!suppressError) {
console.error(e); console.error(e);
} }
...@@ -392,7 +392,7 @@ async function getFileHandleFromCurrentDirectory( ...@@ -392,7 +392,7 @@ async function getFileHandleFromCurrentDirectory(
* expected to be files should be passed to this function. Throws a DOMException * expected to be files should be passed to this function. Throws a DOMException
* if opening the file fails - usually because the handle is stale. * if opening the file fails - usually because the handle is stale.
* @param {?FileSystemHandle} fileSystemHandle * @param {?FileSystemHandle} fileSystemHandle
* @return {!Promise<!{file: !File, handle: !FileSystemFileHandle}>} * @return {!Promise<{file: !File, handle: !FileSystemFileHandle}>}
*/ */
async function getFileFromHandle(fileSystemHandle) { async function getFileFromHandle(fileSystemHandle) {
if (!fileSystemHandle || !fileSystemHandle.isFile) { if (!fileSystemHandle || !fileSystemHandle.isFile) {
...@@ -450,7 +450,7 @@ async function setCurrentDirectory(directory, focusFile) { ...@@ -450,7 +450,7 @@ async function setCurrentDirectory(directory, focusFile) {
let entry = null; let entry = null;
try { try {
entry = await getFileFromHandle(handle); entry = await getFileFromHandle(handle);
} catch (/** @type{!DOMException} */ e) { } catch (/** @type {!DOMException} */ e) {
// Ignore exceptions thrown trying to open "other" files in the folder, // Ignore exceptions thrown trying to open "other" files in the folder,
// and skip adding that file to `currentFiles`. // and skip adding that file to `currentFiles`.
// Note the focusFile is passed in as `File`, so should be openable. // Note the focusFile is passed in as `File`, so should be openable.
...@@ -495,7 +495,7 @@ async function launchWithDirectory(directory, handle) { ...@@ -495,7 +495,7 @@ async function launchWithDirectory(directory, handle) {
let asFile; let asFile;
try { try {
asFile = await getFileFromHandle(handle); asFile = await getFileFromHandle(handle);
} catch (/** @type{!DOMException} */ e) { } catch (/** @type {!DOMException} */ e) {
console.warn(`${handle.name}: ${e.message}`); console.warn(`${handle.name}: ${e.message}`);
sendSnapshotToGuest([{token: -1, file: null, handle, error: e.name}]); sendSnapshotToGuest([{token: -1, file: null, handle, error: e.name}]);
return; return;
...@@ -515,7 +515,7 @@ async function launchWithMultipleSelection(directory, handles) { ...@@ -515,7 +515,7 @@ async function launchWithMultipleSelection(directory, handles) {
currentFiles.length = 0; currentFiles.length = 0;
for (const handle of handles) { for (const handle of handles) {
if (handle && handle.isFile) { if (handle && handle.isFile) {
const fileHandle = /** @type{!FileSystemFileHandle} */ (handle); const fileHandle = /** @type {!FileSystemFileHandle} */ (handle);
currentFiles.push({ currentFiles.push({
token: generateToken(fileHandle), token: generateToken(fileHandle),
file: null, // Just let sendSnapshotToGuest() "refresh" it. file: null, // Just let sendSnapshotToGuest() "refresh" it.
...@@ -549,7 +549,7 @@ async function advance(direction) { ...@@ -549,7 +549,7 @@ async function advance(direction) {
/** /**
* The launchQueue consumer. This returns a promise to help tests, but the file * The launchQueue consumer. This returns a promise to help tests, but the file
* handling API will ignore it. * handling API will ignore it.
* @param {LaunchParams} params * @param {?LaunchParams} params
* @return {!Promise<undefined>} * @return {!Promise<undefined>}
*/ */
function launchConsumer(params) { function launchConsumer(params) {
...@@ -567,7 +567,7 @@ function launchConsumer(params) { ...@@ -567,7 +567,7 @@ function launchConsumer(params) {
return Promise.resolve(); return Promise.resolve();
} }
const directory = const directory =
/** @type{!FileSystemDirectoryHandle} */ (params.files[0]); /** @type {!FileSystemDirectoryHandle} */ (params.files[0]);
// With a single file selected, launch with all files in the directory as // With a single file selected, launch with all files in the directory as
// navigation candidates. Otherwise, launch with all selected files (except // navigation candidates. Otherwise, launch with all selected files (except
......
...@@ -58,7 +58,7 @@ let DefensiveError; ...@@ -58,7 +58,7 @@ let DefensiveError;
* defensively assign '' if the attribute is undefined. Without explicitly * defensively assign '' if the attribute is undefined. Without explicitly
* extracting fields, `Errors` are sent as `{}` across the pipe. * extracting fields, `Errors` are sent as `{}` across the pipe.
* @param {!DefensiveError} error * @param {!DefensiveError} error
* @return {GenericErrorResponse} * @return {!GenericErrorResponse}
*/ */
function serializeError(error) { function serializeError(error) {
return { return {
......
...@@ -27,7 +27,7 @@ class ReceivedFile { ...@@ -27,7 +27,7 @@ class ReceivedFile {
* @param{!Blob} blob * @param{!Blob} blob
*/ */
async overwriteOriginal(blob) { async overwriteOriginal(blob) {
/** @type{OverwriteFileMessage} */ /** @type {!OverwriteFileMessage} */
const message = {token: this.token, blob: blob}; const message = {token: this.token, blob: blob};
await parentMessagePipe.sendMessage(Message.OVERWRITE_FILE, message); await parentMessagePipe.sendMessage(Message.OVERWRITE_FILE, message);
...@@ -143,7 +143,11 @@ const DELEGATE = { ...@@ -143,7 +143,11 @@ const DELEGATE = {
await parentMessagePipe.sendMessage(Message.OPEN_FEEDBACK_DIALOG); await parentMessagePipe.sendMessage(Message.OPEN_FEEDBACK_DIALOG);
return /** @type {?string} */ (response['errorMessage']); return /** @type {?string} */ (response['errorMessage']);
}, },
async saveCopy(/** !mediaApp.AbstractFile */ abstractFile) { /**
* @param {!mediaApp.AbstractFile} abstractFile
* @return {!Promise<?string>}
*/
async saveCopy(abstractFile) {
/** @type {!SaveCopyMessage} */ /** @type {!SaveCopyMessage} */
const msg = {blob: abstractFile.blob, suggestedName: abstractFile.name}; const msg = {blob: abstractFile.blob, suggestedName: abstractFile.name};
const response = const response =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment