dandv
dandv
DDeno
Created by dandv on 3/3/2025 in #help
Deno check/lint doesn't warn against obvious bugs
type Point = {
[key: string]: number
};

function processPoints(points: Point[]): string[] {
// Should error on Object.keys(number), TS2345: Argument of type 'number' is not assignable to parameter of type 'object'.
// Should warn on points[3] possibly being undefined
return Object.keys(points[3].foo);
}

console.log(processPoints([ { bar: 2 } ]));
type Point = {
[key: string]: number
};

function processPoints(points: Point[]): string[] {
// Should error on Object.keys(number), TS2345: Argument of type 'number' is not assignable to parameter of type 'object'.
// Should warn on points[3] possibly being undefined
return Object.keys(points[3].foo);
}

console.log(processPoints([ { bar: 2 } ]));
I've run deno lint --rules-tags=recommended but it doesn't detect anything. This is quite worrying. PS: should there be a Lint tag when posting here, now that we have lint plugins?
7 replies
DDeno
Created by dandv on 1/29/2025 in #help
Tell `deno outdated` to show patch level updates
Is there a way to tell deno outdated to show ALL updates, even those affecting only the patch level? I fI have "@std/cli": "jsr:@std/cli@^1.0.0" in deno.json, deno outdated won't say anything, even though the current version is 1.0.11. It's also unclear what version will actually be used in that case since the ^ is specified. The most recent in the cache? Does deno outdated silently update to the last patch level?
1 replies
DDeno
Created by dandv on 1/19/2025 in #help
Is assertObjectMatch too type-strict?
If you have two typed objects, actual and expect, of the same type, assertObjectMatch doesn't let you use the expect object:
import { assertObjectMatch } from '@std/assert';

interface FirstLast {
first: string
last: string
}

Deno.test('assertObjectMatch', () => {
const expected: FirstLast = {
first: 'John',
last: 'Doe',
};

const actual = expected;

// passes
assertObjectMatch(actual, {
first: 'John',
last: 'Doe',
});

// fails because `expected` is too typed now?
assertObjectMatch(actual, expected);
// Argument of type 'FirstLast' is not assignable to parameter of type 'Record<PropertyKey, unknown>'.
// Index signature for type 'string' is missing in type 'FirstLast'.

// casting is ugly:
assertObjectMatch(actual, expected as unknown as Record<PropertyKey, unknown>);
});
import { assertObjectMatch } from '@std/assert';

interface FirstLast {
first: string
last: string
}

Deno.test('assertObjectMatch', () => {
const expected: FirstLast = {
first: 'John',
last: 'Doe',
};

const actual = expected;

// passes
assertObjectMatch(actual, {
first: 'John',
last: 'Doe',
});

// fails because `expected` is too typed now?
assertObjectMatch(actual, expected);
// Argument of type 'FirstLast' is not assignable to parameter of type 'Record<PropertyKey, unknown>'.
// Index signature for type 'string' is missing in type 'FirstLast'.

// casting is ugly:
assertObjectMatch(actual, expected as unknown as Record<PropertyKey, unknown>);
});
What am I doing wrong here?
1 replies