#javascript

6 entries tagged “javascript”.

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

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

Cannot find package: ESM bare specifiers in config

Cannot find package 'plugins' is Node treating a relative path as a package name. Here is the ESM specifier rule, and the one-character fix.

Read the entry →
vitest

A Vitest toThrow test that misses a JSON.parse error

A Vitest test using expect().toThrow() let a JSON.parse SyntaxError escape and fail the run instead of catching it. Here's why, and the fix.

Read the entry →
vitest

From proxyquire to Vitest: fixing "undefined" is not valid JSON

A git-proxy test failed with 'undefined' is not valid JSON after moving from proxyquire to Vitest. Let's look at the cause and how to fix.

Read the entry →