there is no way to declare a “vector of maps” with clj-kondo type system? seems that the collections have just type :vector
.
would be happy to emit {:op :vector :elements {:op :keys, :req {:id :int}}
for clj-kondo
currently not supported
it's not a higher order type system
the likelihood of catching these types of errors with static analysis is also rather small I'd say
because clj-kondo can only look at the literal forms
Hum, I thought it used type hints as well no? Wouldn't it catch:
(def ^String foo (get-foo-from-config))
(+ 10 foo)
It could catch that, but currently it doesn't look at var types, only function return values.
but the example ikitommi was referring to was a vector of maps
and clj-kondo only cares about the outer type
Ah I see. Ya, I know no support for generic types yet. I was more commenting to the literal comment. So I guess it looks at literal and function return types for now? Which is slightly more than just literals 😛
But I assumed it was looking at Var and local binding types as well.
yes, it does. this gives a warning:
(defn foo ^String []) (inc (foo))
true that, most likely not declared as literal, right
I believe “maybe string” is :nilable/string
, is there a way to say “maybe map”?
does :nilable/map
work? :)
else #{nil :map}
will also work
oh, I was thinking about a :keys
thing. but #{nil {:op :keys, :req {:id :int}}}
is ok?
it seems that if it can be nil, then all keys are optional is the same?
oh, op keys assumes it is a map and not nil, I see
If someone is looking for some OSS issues to work on, here's a list: https://gist.github.com/borkdude/18af5d96c6465ce64144f03636fda3dc
I find the "feature" template a little awkward for suggesting new lints for clj-kondo. I don't know how to phrase a "problem statement" in the way it seems to suggest. Nor do I have an idea for what to put in for alternatives.
Well, it would be nice if a linting rule solves a particular problem, else it's pretty useless right? ;)
But feel free to discuss new rules here first, then we can always decide if this should become an issue or not
Ah I see you already posted them. One of them was already implemented. Nice :)