Diagnostics

2 min·Assumes: lists

A diagnostic is the message Markless gives when it can't
your code: what broke, why, how to fix it, and where to read more.
MARKLESS_COMPILE_BLOCKED: pages/list.tsrx has 1 compiler error(s).

MARKLESS_REPEAT_KEY_REQUIRED: @for (const item of items) repeats reactive state without a key. When items changes, the rows of this list have no identity to update, reorder, or resume by. (pages/list.tsrx:8:4)

MARKLESS_REPEAT_KEY_REQUIRED is the code, and every code has its own page. The sentence after it says what broke, and pages/list.tsrx:8:4 is the file, line and column.

An error has four parts

An error stops the page. In the dev server, the browser shows it on top of the page. Remove the key, then add it back:

pages/list.tsrx

6 <section>

7 <ul>

8

8 @for (const item of items) {

<li>{item}</li>

✕ MARKLESS_REPEAT_KEY_REQUIRED

localhost:3000/list
  • Milk
  • Eggs
MARKLESS_REPEAT_KEY_REQUIRED

@for (const item of items) repeats reactive state without a key. When items changes, the rows of this list have no identity to update, reorder, or resume by.

pages/list.tsrx:8:4

Why

A keyed loop item keeps its state, events, and DOM attached to the same logical item across reorder, insert, and delete; without a key there is no stable identity root.

Suggested fix

Add a stable domain key such as `@for (const item of items; key item.id)`, or key by position with `index i; key i` when state should follow the slot.

   6 | 	<section>
   7 | 		<ul>
>  8 | 			@for (const item of items) {
     |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   9 | 				<li>{item}</li>
  10 | 			}
Read MARKLESS_REPEAT_KEY_REQUIRED documentation

Edit the @for line, or hover the error code.

  • The code, what broke, and where.
  • Why Markless can't build it.
  • Suggested fix: the first fix to try.
  • A link to the page for that code.

A key fixes this list

Linus Torvolts reviews your patches, and every rejection lands on a list. The list builds. Try it:

PlaygroundRestored your edit

Linus reviewed your patch

  1. Who taught you tabs?
Try this
  1. To do: Press Send a patch. Linus stamps it NAK with a fresh insult.
  2. To do: Try breaking it: delete ; key item from the @for line. The build stops and the error shows under the result.
  3. To do: Put ; key item back, and press Send a patch twice. The list builds and keeps growing.

A reason silences a warning

A warning is a wavy line in your editor, and the page still builds. To accept one on purpose, write // markless-allow CODE: reason above it:

// markless-allow MARKLESS_REPEAT_KEY_IS_INDEX: a fixed list
@for (const item of items; index i; key i) {

A comment with no reason doesn't silence anything; the figure above shows what happens instead.

All error codes lists every one, grouped by the package that raises it, and each has a page with its fix.