Commit aad0114f authored by Jakob Moser's avatar Jakob Moser
Browse files

Improve type hints

parent 138a2948
Loading
Loading
Loading
Loading
+2 −2
Changes for static/js/cards.mjs: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ import { createElementWithClass } from "./util.mjs"

/**
 * Create an HTML card
 * @param {String} title The title the card should have (placed inside an <h2>)
 * @param {string} title The title the card should have (placed inside an <h2>)
 * @param {String | undefined} supplemental Optional: A supplemental text that is placed floating right to the title
 * @returns A div.card DOM element
 */
@@ -32,7 +32,7 @@ export function createCard(title, supplemental) {
 * and if the title bar should appear clickable.
 * 
 * @param {HTMLElement} cardEl The .card element
 * @param {String} text The text for the hover title
 * @param {string} text The text for the hover title
 * @param {Boolean} clickable If the title bar should appear clickable
 */
export function setCardHoverTitle(cardEl, text, clickable) {
+14 −4
Changes for static/js/exercises.api.mjs: 14 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ class Exercise {
    #execute = null
    #context = new ExerciseExecutionContext()

    /**
     * @param {string} name Human-readable name of the exercise
     * @param {number} index Index of the exercise in the list of exercises of the test
     * @param {Function} execute A function to configure and execute this exercise
     */
    constructor(name, index, execute) {
        this.name = name
        this.index = index
@@ -94,7 +99,7 @@ class ExerciseExecutionContext {
     * should know exactly what is expected of them and can start thinking
     * about a solution.
     * 
     * @param {String} description Description of the exercise
     * @param {string} description Description of the exercise
     */
    describe(description) {
        this._describeHandler(description)
@@ -170,7 +175,7 @@ class ExerciseExecutionContext {
     * When the praameter passed to `hasOutput` is a list, the verification succeeds iff
     * the output lines are exactly the ones in the list.
     * 
     * @param {String} command A command to execute
     * @param {string} command A command to execute
     * @returns An object that has the method "hasOutput"
     */
    verify(command) {
@@ -220,6 +225,11 @@ class ExerciseExecutionContext {
 * A test. It has a human-readable name and a list of exercises.
 */
class Test {

    /**
     * @param {string} name Human-readable name of the test
     * @param {Exercise[]} exercises The exercises this test consists of
     */
    constructor(name, exercises) {
        this.name = name
        this.exercises = exercises
@@ -245,7 +255,7 @@ class Test {
/**
 * Create a test. Returns the test object
 * 
 * @param {String} name A human-readable name of the test
 * @param {string} name A human-readable name of the test
 * @param {Function} exerciseCreationFunction A function that calls `exercise` to create exercise.
 * Note: This must be a function declared with the function keyword, arrow functions (()=>{...}) do not work.
 */
@@ -257,7 +267,7 @@ export function test(name, exerciseCreationFunction) {
        /**
         * Add an exercise.
         * 
         * @param {String} name A short name of the exercise
         * @param {string} name A short name of the exercise
         * @param {Function} execute A function that executes the exercise. 
         * Note: This must be a function declared with the function keyword, arrow functions (()=>{...}) do not work.
         */
+4 −4
Changes for static/js/jslinux.api.mjs: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
/**
 * Try to parse the given line as if it contained a prompt, maybe followed by user input.
 * 
 * @param {String} line A line that might contain a prompt, followed by optional user input
 * @param {string} line A line that might contain a prompt, followed by optional user input
 * @returns An object containing prompt and input, or null if the line wasn't a prompt line
 */
function parseAsPrompt(line) {
@@ -22,7 +22,7 @@ function parseAsPrompt(line) {
/**
 * Parse the given line as if it was a line of output.
 * 
 * @param {String} line A line containing output
 * @param {string} line A line containing output
 * @returns An object with an output property, which is a list containing only this line
 */
function parseAsOutput(line) {
@@ -35,7 +35,7 @@ function parseAsOutput(line) {
 * Try to parse the given line as if it contained a prompt, maybe followed by user input.
 * If this isn't successful, parse it as if it contained output.
 * 
 * @param {String} line A line containing either a prompt and optionally input or some output
 * @param {string} line A line containing either a prompt and optionally input or some output
 * @returns An object containing either prompt and input, or the output
 */
function parseAsPromptOrOutput(line) {
@@ -145,7 +145,7 @@ export function onEnterPressed(handler) {
/**
 * Types the given command into the terminal and simulates an Enter press
 * The command will then be executed, and the output will be shown in the terminal
 * @param {String} command A command to execute
 * @param {string} command A command to execute
 */
export function runCommand(command) {
    const textarea = document.querySelector(".term_textarea")
+1 −1
Changes for static/js/state.mjs: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ export const currentState = {

    /**
     * Mark the given exercise as solved
     * @param {Number} exerciseIndex The index of the exercise to be marked as solved
     * @param {number} exerciseIndex The index of the exercise to be marked as solved
     */
    markAsSolved(exerciseIndex) {
        if (this.solvedExercises.includes(exerciseIndex)) {
+1 −1
Changes for static/js/util.mjs: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ export function arrayEquals(array1, array2) {

/**
 * Create a DOM element with the given tag and the given classes
 * @param {String} tagName The tag name of the element to create
 * @param {string} tagName The tag name of the element to create
 * @param {Array<String>} classes The class(es) the element should have
 */
export function createElementWithClass(tagName, ...classes) {