Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## 2026-11-21 - version 1.4.12

- **Interview practice deck.** The last lesson ends with a flashcard deck of all 78 interview questions in the guide: one question at a time, the answer hidden until asked for, "Got it" to take a card out and "Ask again" to send it to the back, filterable by topic. The questions were scattered across twelve pages, a few at the bottom of each, which is no way to revise
- **Every lesson's questions live in one bank** (`interview-bank.ts`), keyed by lesson. Each lesson reads its own entry, and the deck reads all of them without importing twelve lesson components. A spec checks every lesson has at least five, none repeats, and each page renders its own. The cost: about 12 kB gzipped of question text now loads with the first lesson you open, instead of 1–3 kB per page
- **Angular guide, lesson 13: interview prep** (`/thoughts/angular-13-interview`). NgModule-era Angular side by side with the same component written today, the migration schematics, NgRx Store and SignalStore, and how to turn the bugs from this guide into interview answers
- **fix: the no-NgModules fitness test matched code samples.** Lesson 13 prints an `@NgModule` as an example, and the regex flagged it. It now reads real decorators with the TypeScript parser, the same fix the OnPush check got in 1.4.8

## 2026-11-21 - version 1.4.11

- **fix: prerendered pages showed the time the site was built.** The menu bar clock rendered on the server, so every Thoughts page shipped a frozen build-time clock until the JavaScript loaded. The clock now renders empty on the server and starts in `afterNextRender`, which only runs in the browser
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-paul",
"version": "1.4.11",
"version": "1.4.12",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
20 changes: 12 additions & 8 deletions src/app/architecture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ function staticRelativeImports(file: string): string[] {
}

/**
* Real `@Component(...)` decorators on classes, read with the TypeScript
* parser. A text search also matches the code samples the lessons print.
* Real `@Component(...)`, `@NgModule(...)` etc. decorators on classes, read
* with the TypeScript parser. A text search also matches the code samples the
* lessons print.
*/
function componentDecorators(file: string): { file: string; className: string; metadata: string }[] {
function classDecorators(
file: string,
decoratorName: string,
): { file: string; className: string; metadata: string }[] {
const source = ts.createSourceFile(file, readFileSync(file, 'utf-8'), ts.ScriptTarget.Latest, true);
const found: { file: string; className: string; metadata: string }[] = [];
const visit = (node: ts.Node) => {
if (ts.isClassDeclaration(node)) {
for (const decorator of ts.getDecorators(node) ?? []) {
const call = decorator.expression;
if (ts.isCallExpression(call) && ts.isIdentifier(call.expression) && call.expression.text === 'Component') {
if (ts.isCallExpression(call) && ts.isIdentifier(call.expression) && call.expression.text === decoratorName) {
found.push({ file, className: node.name?.text ?? '(anonymous)', metadata: call.arguments[0]?.getText(source) ?? '' });
}
}
Expand Down Expand Up @@ -89,8 +93,8 @@ describe('[ng-01] architecture', () => {

it('has no NgModules — every component, directive and pipe is standalone', () => {
const withNgModule = files
.filter((file) => /@NgModule\s*\(/.test(readFileSync(file, 'utf-8')))
.map((file) => relative(APP_ROOT, file));
.flatMap((file) => classDecorators(file, 'NgModule'))
.map(({ file, className }) => `${relative(APP_ROOT, file)} (${className})`);
expect(withNgModule).toEqual([]);
});

Expand All @@ -100,7 +104,7 @@ describe('[ng-01] architecture', () => {
// allowed only when written explicitly, so it is always a visible decision
// rather than a forgotten line.
it('every component sets OnPush, or opts into Eager explicitly', () => {
const decorators = files.flatMap(componentDecorators);
const decorators = files.flatMap((file) => classDecorators(file, 'Component'));
const missing = decorators
.filter(({ metadata }) => !/changeDetection:\s*ChangeDetectionStrategy\.(OnPush|Eager)\b/.test(metadata))
.map(({ file, className }) => `${relative(APP_ROOT, file)} (${className})`);
Expand All @@ -111,7 +115,7 @@ describe('[ng-01] architecture', () => {

it('the decorator finder skips @Component( inside code-sample strings', () => {
const lesson02 = join(APP_ROOT, 'thoughts-content/lessons/lesson-02-components.ts');
expect(componentDecorators(lesson02).map(({ className }) => className)).toEqual([
expect(classDecorators(lesson02, 'Component').map(({ className }) => className)).toEqual([
'DemoBadge',
'Lesson02Components',
]);
Expand Down
29 changes: 29 additions & 0 deletions src/app/thoughts-content/lessons/interview-bank.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { TestBed } from '@angular/core/testing';
import { INTERVIEW_BANK } from './interview-bank';
import { LESSON_PAGES } from './lessons';

describe('INTERVIEW_BANK', () => {
it('has questions for exactly the lessons that exist', () => {
expect(Object.keys(INTERVIEW_BANK).sort()).toEqual(Object.keys(LESSON_PAGES).sort());
});

it.each(Object.entries(INTERVIEW_BANK))('%s has at least five questions', (_slug, questions) => {
expect(questions.length).toBeGreaterThanOrEqual(5);
});

it('never repeats a question, since the practice deck and the lists track by its text', () => {
const all = Object.values(INTERVIEW_BANK).flatMap((questions) => questions.map(({ q }) => q));
const repeated = all.filter((q, index) => all.indexOf(q) !== index);
expect(repeated).toEqual([]);
});

it.each(Object.keys(LESSON_PAGES))('%s renders its questions from the bank', async (slug) => {
const fixture = TestBed.createComponent(await LESSON_PAGES[slug]());
await fixture.whenStable();

const summaries = [
...(fixture.nativeElement as HTMLElement).querySelectorAll('app-interview-questions summary'),
].map((summary) => summary.textContent?.trim());
expect(summaries).toEqual(INTERVIEW_BANK[slug].map(({ q }) => q));
});
});
Loading
Loading