False positive error report for interface type missing index signature, thus not assignable to object type with `unknown` values.
See original GitHub issueTypeScript Version: 3.6.0-dev.20190704 (3.4.3
doesn’t have this bug)
Search Terms: index signature, unknown, assignable, interface
Code
interface A {
properties?: { [Key: string]: unknown };
}
type Bar = {
key?: "value";
};
interface Baz {
key?: "value";
}
interface B extends A { // ok
properties?: Bar;
}
interface C extends A { // error: Baz is not assignable to { [Key: string]: unknown } -> Index signature is missing
properties?: Baz;
}
Expected behavior: No error expected, interface C extends A correctly.
Actual behavior: Error because interface C does not extend interface A
Related Issues:
#30977 (this one is specifically for enums
)
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Index signature is missing in type - Stack Overflow
Type 'TestEvents' does not satisfy the constraint 'Record<string, EventHandler>'. Index signature is missing in type 'TestEvents'. typescript.
Read more >Index signature for type 'X' is missing in type 'Y' in TS
The error "Index signature for type is missing in type" occurs when TypeScript doesn't consider a type that uses an index signature and...
Read more >Index Signatures - TypeScript Deep Dive - Gitbook
Index Signatures. An Object in JavaScript (and hence TypeScript) can be accessed with a string to hold a reference to any other JavaScript...
Read more >Understanding and using interfaces in TypeScript
Types of variables are not predictable in JavaScript. ... find this property in the second function call, it throws an error at runtime....
Read more >private instance variables c# - Durbuy tourisme
This class implements the Serializable interface, and defines a method This ... IO stream object, does not assign it to any TQ: Value...
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
The reason intellisense for TypeScript is so performant is because the TypeScript team want to have auto-completion while editing
checker.ts
[1] - so if anything, we should be encouraging them to make it larger.[1] I made that up
Thanks @jack-williams , I didn’t know about this specific assignability rule. Do you know if there is a comprehensive list of type assignability rules out there? I tried to search for one but couldn’t find.