`Cannot find type 'Key' in scope` when extending optional Dictionaries

I am surprised that “extension [Any?: Any?]? {}” compiles at all.

The compiler correctly prohibits declaring a variable of that type:

let x: [Any? : Any?]?
// error: 'Dictionary' requires that 'Any' conform to 'Hashable'

It is not clear to me what exactly you are trying to do. What type or types are you trying to extend? What type do you expect “Key” to represent?

Are you trying to create a parameterized extension of Optional where Wrapped is a Dictionary with unspecified generics?

…or where Wrapped is a Dictionary for which both Key and Value are themselves Optional types with unspecified Wrapped values? That seems inadvisable even if it were to become possible.