Skip to content

Qualify chapter 09's module and declaration-lookup rules, and update chapter 08's details - #21

Merged
renrenmimi merged 2 commits into
masterfrom
fix/content-classes-modules
Oct 10, 2026
Merged

renrenmimi merged 2 commits into
masterfrom
fix/content-classes-modules

Conversation

@renrenmimi

Copy link
Copy Markdown
Owner

Branches from #9 (commit 2148ad8), so it can be merged before or after it, and independently of #10–#20.

It touches chapter 08 (app/classes/page.tsx, viz.tsx, lib/classes-data.tsx) and chapter 09 (app/modules/page.tsx, viz.tsx, lib/modules-data.tsx).

Summary

Fixes from the 2026-10-09 content audit (04-TSer-内容.md):

  • B8
    • What the chapter said: "The file decides this, not tsconfig.json". The quiz said whether a file is a module "is decided by the file itself".
    • What is missing: moduleDetection decides the rule as well. TypeScript 5.9's tsc --init, which the prologue tells readers to run, writes "force".
    • The effect: under that config, two scripts that both declare const TAX compile without the TS2451 that the quiz describes.
  • B9
    • What the chapter said: "Three places, checked in order. The compiler stops at the first one that answers."
    • What happens instead: a declare module "x" that you wrote takes precedence over the package's own types and over @types.
    • The real risk: a forgotten stopgap declaration silently turns a typed library into any.
  • B18
    • getter/setter: the explanation stopped at the TS 4.3 rule, but since 5.1 a getter and a setter may have unrelated types.
    • #field: the text said it is kept out of DevTools, but DevTools does show it.
  • B21 (quiz titles): both chapters used 通关测验.
  • B22 (register): colloquial Chinese, including 老老实实, 撞上 and 坑.
  • B23 (terms): 标注 was used where the course term is 注解, or 标记 for the import type marker.
  • A26 (these chapters): the segmented buttons did not expose their selected state.

Changes

  • Chapter 09:
    • Module-detection callout: retitled "By default the file decides; the module option does not". It explains moduleDetection and "force", and notes that .d.ts files are not affected.
    • Quiz: the question and its explanation now name the default setting.
    • Type-source rule: the section summary, the flow's first and last frames, the flow title and the key point present the three sources as a checklist. They state the precedence of a declaration you have already written, with the advice to delete it once real types exist.
  • Chapter 08:
    • getter/setter: a sentence on the TS 5.1 rule.
    • #field: the sentence now says it keeps a value out of JSON.stringify and logs, but not out of DevTools.
  • Both chapters:
    • Formal Chinese, using the course terms.
    • 本章测验 / Chapter quiz.
    • aria-pressed on the seg-btn buttons.

Verification

  • npx tsc --noEmit --incremental false: clean.
  • npm test: 6 files, 38 tests pass, including zh-copy-spacing.
  • npm run build: succeeds.
  • Claims checked during the audit with the real tsc 5.9.3 in scratch projects:
    • moduleDetection: the tsc --init config compiles the two scripts, and --moduleDetection auto reports TS2451.
    • Precedence: with an ambient declare module "boba-ui", the package's render is missing (TS2305), and a shorthand declare module "boba-ui"; hides a TS2554.
    • getter/setter: unrelated getter and setter types compile in TypeScript 5.9.
    • #field: the DevTools protocol lists #vaultCode in privateProperties.
  • Headless Chrome against a local next start, both languages: the new text is present, the old claims are gone, and there are 0 console errors.

🤖 Generated with Claude Code

renrenmimi and others added 2 commits October 9, 2026 16:07
JSX trims each line of a text block and joins the lines with one space.
The Chinese copy is wrapped across source lines throughout the course, so
it rendered with spaces between Chinese characters and around full-width
punctuation: 1,572 of them in 36 files.

- 1,548 line breaks are joined by a script that walks the TypeScript
  syntax tree and touches only JSX text and JSX attribute strings, never
  code samples, template literals or comments. Breaks next to Latin
  letters, digits, expressions, "——" or operators keep their space.
- 24 more spaces go: 20 after full-width punctuation, 3 between Chinese
  text and a tag whose text is Chinese, and one {" "} between a
  full-width mark and Chinese text.
- test/zh-copy-spacing.test.ts, the check DataData and AlgoAlgo use,
  scans every TSX file and fails on any new stray space; CLAUDE.md states
  the rule.

Apart from the one {" "}, the diff changes nothing but whitespace. The
text every edited file renders differs from master only by deleted
spaces, each next to Chinese text, so the English copy is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter 08's details

Chapter 09
- Whether a file is a module is decided by the file only with the default moduleDetection:
  with "force", which TypeScript 5.9's tsc --init writes, every non-declaration file is a
  module. The callout (title and text) and the quiz now say so; declaration files still
  follow the top-level import/export rule, so the .d.ts discussion is unchanged.
- The three sources of a library's types are a checklist, not the compiler's lookup order:
  a declare module you have already written takes precedence over the package's types and
  @types. The section summary, the flow's first and last frames and the key point say so,
  with the practical advice to delete a stopgap declaration once real types exist.

Chapter 08
- Since TypeScript 5.1 a getter and a setter may have unrelated types when both are
  annotated; #field keeps a value out of JSON.stringify and logs, but DevTools still shows
  it.

Both chapters
- Formal Chinese register (老老实实, 撞上, 坑) and the course terms 注解 / 标记 instead of
  标注; quiz titles 本章测验 / Chapter quiz; aria-pressed on the segmented buttons of the
  member, placement, erasure and output visuals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 05:58
@vercel

vercel Bot commented Oct 10, 2026

Copy link
Copy Markdown

Deployment failed for project tser with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/renrenmimis-projects?upgradeToPro=build-rate-limit

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T06:03:12.776017Z 06cb4c6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06cb4c6806

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/page.tsx
Comment on lines +766 to +770
not decide whether a given file is a module. By default the
file itself does that, by having a top-level import or export.
A separate option, <code>moduleDetection</code>, can change the
rule: with <code>&quot;force&quot;</code>, every non-declaration
file is treated as a module, and that is what{" "}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Account for all automatic module-detection signals

With the default moduleDetection: "auto", top-level imports and exports are not the only signals: under module: "node16"/"nodenext", a surrounding package.json with "type": "module" also makes an import-free .ts file a module, and automatic JSX modes provide another signal. Consequently, the new explanation and the corresponding quiz incorrectly classify such files as global scripts; describe the full auto behavior or explicitly qualify the rule as moduleDetection: "legacy".

Useful? React with 👍 / 👎.

Comment on lines +94 to +97
for (const m of raw.matchAll(/(\S)( +)(\S)/g)) {
const a = m[1], b = m[3];
const stray = (PUNCT.test(a) || (a === "…" && closesChinese(raw, m.index!))) && ZH.test(b) && b !== "—";
if (stray) at(start + m.index!, `space ${a} ${b}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect same-line spaces between Chinese characters

The same-line check only treats punctuation or an ellipsis as a problematic left edge, so an ordinary Han-space-Han sequence is silently accepted despite the test's stated invariant. For example, the current app/type-magic/page.tsx:1775 text 模板字面量类型 的 passes this test, leaving exactly the rendered stray space the new suite is intended to prevent.

Useful? React with 👍 / 👎.

@renrenmimi
renrenmimi merged commit ed18290 into master Oct 10, 2026
1 of 2 checks passed
@renrenmimi
renrenmimi deleted the fix/content-classes-modules branch October 10, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants