#typescript

9 entries tagged “typescript”.

javascript

Losing this by passing a method as a callback

Passing obj.exec into a list strips this, so stateful plugins crash. Bind it, wrap it, or use an arrow field. Here is the GitProxy fix.

Read the entry →
javascript

Optional chaining as an accidental deny

p.chains?.includes(name) dropped every plugin that omitted chains. Optional chaining in a filter is an accidental deny; default with ?? instead.

Read the entry →
typescript

Record<string, T> hid a missing key as defined

Record<string, T> types every key as present, so a typo compiled and getChain returned undefined. Thirteen tests failed from one missing key.

Read the entry →
GitProxy

How to write a GitProxy plugin: a diff-scanning example

How to write a GitProxy plugin: a complete diff-scanning example, how to pick the right chain phase, and why a plugin can load and still never run.

Read the entry →
typescript

TypeScript class fields wipe values set in super()

A subclass field declaration overwrites what the base constructor assigned. useDefineForClassFields is why, and declare is the one-line fix.

Read the entry →
node

Package subpath is not defined by exports

Package subpath is not defined by exports, plus ts(2307): the file exists, the exports map hides it. Here's how to import a public type instead.

Read the entry →
plugins

How to design a plugin system for your project

How to design a plugin system: named phases instead of positions, deny-by-default placement, and the defaults that must live outside your constructor.

Read the entry →
vitest

Vitest: vi.mocked(...).mockResolvedValue is not a function

Vitest 3 test fails with vi.mocked(...).mockResolvedValue is not a function after restoreAllMocks. Here's how to fix it in one line.

Read the entry →
vitest

Migrating GitProxy's tests from Mocha and Chai to Vitest

How to fix all the ESM mocking errors when moving GitProxy's test suite from Mocha, Chai, Sinon and proxyquire to Vitest + TypeScript

Read the entry →