collections: most functions that work on `Record` do not work with `interface`
See original GitHub issueMost of collections
’ functions that work on Record
do not work with interface
To Reproduce
import { deepMerge, filterEntries } from "https://deno.land/std/collections/mod.ts";
interface Foo {
bar: string;
}
const foo1: Foo = { bar: "deno" };
const foo2: Foo = { bar: "deno" };
const a = deepMerge(foo1, foo2);
const b = filterEntries(foo1, ([key]) => key !== "a");
Expected behavior
It compiles.
Current behaviour
It does not compile.
Argument of type 'Foo' is not assignable to parameter of type 'Record<PropertyKey, unknown>'.
Index signature is missing in type 'Foo'
Desktop (please complete the following information):
deno 1.13.0 (release, x86_64-unknown-linux-gnu)
v8 9.3.345.11
typescript 4.3.5
Additional context Possible workaround is to use type instead of interface, but that’s not ideal:
type Foo = {
bar: string;
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Collection classes
The Collection interface contains generic methods for adding and removing objects, testing whether or not a given element is present in the collection, ......
Read more >Collections In Java and How to Implement Them? [Updated]
Java Collections are the one-stop solutions for all the data manipulation jobs such as storing data, searching, sorting, insertion, ...
Read more >The List Interface (The Java™ Tutorials > Collections ...
This collections Java tutorial describes interfaces, implementations, and algorithms in the Java Collections framework.
Read more >collections — Container datatypes
Source code: Lib/collections/__init__.py This module implements specialized container datatypes providing alternatives to Python's general purpose built-in ...
Read more >Interface vs record of functions
Interfaces express a different intention - they are interface that can be satisfied and implemented. On the other hand, records are collections ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That is definitely debatable 😃
I do not think there is a reasonable solution on the API side though, so I would vote to close this issue.
I think this issue should probably be closed, though the discussion in this issue is very interesting.