← Fundamentals
Fundamentals

Syntax and meaning

Does the visibility flag control everything the editor shows?

Read the structure the language recognizes before judging the behavior it describes.

Outcome

Predict how native brace, semicolon and return boundaries change acceptance and behavior, then repair those boundaries in a notice preview.

Terminology (4)Terms used in this lesson

Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.

Syntax
The language’s rules for forming source text and grouping it into constructs. An accepted shape can still express the wrong action.
Meaning
The behavior assigned to that accepted structure. Whether the behavior is wanted depends on the program’s intended result.
Conditional body
The statement or block selected by a condition. Indentation alone does not move statements into it in these four languages.
Automatic semicolon insertion
Language rules that insert statement boundaries at specified positions. TypeScript follows JavaScript’s rules; Go has its own rules.

Structure and meaning

Syntax is the grammar that determines whether source has a valid structure and how its parts fit together. Semantics gives that structure meaning: which operation a statement performs, what a condition controls and which value a function returns. Type rules can reject a grammatically valid program before it runs.

Indentation helps a reader see intended structure, but the language’s punctuation, keywords and statement boundaries determine the structure it actually recognizes. Read those boundaries first, then trace the resulting behavior. A parse error, a type error and an accepted program that does the wrong job require different explanations.

01Hide the whole notice

Does an audience mismatch hide the whole notice?

Before publishing an in-app notice, an editor lets staff preview it for a selected audience. You are reviewing its text renderer: an audience mismatch must hide the whole notice. Can the source look guarded while still emitting part of it?

Before inspecting the frame, check the audience decision in isolation. The preview inspector can report hidden or preview for one notice. This diagnostic prints that status; the notice itself is omitted when hidden. With visible false, predict whether the selected native accepts the single-statement body and what it prints.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
let visibilityText = "hidden";
const visible = false;

if (visible) visibilityText = "preview";

console.log(visibilityText);
The notice does not match the audience: visible is false. What happens to this diagnostic status?
TypeScript · terminal.sh
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
npx tsc main.ts --noEmit && node main.ts

Use the selected language’s existing setup. The C++ command uses the reading track’s C++26 mode; this example requires no new language feature. Compiler wording varies by toolchain.

02Return the preview text

The frame works. Does its caller receive the chosen text?

The message helper now has to choose text: preview when preview data is available, unavailable when it has not loaded. It must return that text to the caller for framing. The next reduction keeps only the preview-text path; Go also shows its fallback branch. Replace the main file with the selected example. Does the caller actually receive preview, or does a native boundary prevent it?

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
function previewText() {
  return;
  ("preview");
}

console.log(previewText());
What happens with the exact source shown?

Read a diagnostic’s category as well as its location. The highlighted token can be where the tool discovered a problem caused by the preceding boundary. Malformed grammar, a type mismatch and an accepted function returning the wrong value require different repairs. Once this helper returns the intended text, the message renderer can pass it to the working frame; an ineligible notice still returns an empty string.

03Turn the preview off

Can the outer setting turn the preview off?

The editor also has a switch that turns the entire preview off. A disabled preview should show offline, regardless of the notice’s audience match. This reduction starts with a pending placeholder. Will the nested conditions replace it with the right text?

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
let text = "pending";
const enabled = false;
const eligible = true;

if (enabled)
  if (eligible) text = "preview";
  else text = "offline";

console.log(text);
What does this exact source print?

04Finish the preview renderer

Make the text preview reliable for audience checks

Finish the renderer the editor will use for audience checks. First ensure that a hidden notice leaves no fragment. Then return the framed preview or unavailable message for each eligible notice. Finally connect the outer preview setting to the complete batch result. Every custom type and input reader is supplied; later levels keep earlier correct helpers.

Finish the notice preview renderer

Preserve audience filtering and fallback text when the preview-wide setting wraps the notice loop.

  1. easy · F-SYNTAX-V4-1 Repair the native if body
  2. medium · F-SYNTAX-V4-2 Recover the returned notice
  3. hard · F-SYNTAX-V4-3 Repair nested boundaries
Sources

Report a problem in this lesson

For typos, mistakes and things that don’t work. We read every report and fix what’s wrong, but we don’t reply here, so a question won’t get an answer.