premailex icon indicating copy to clipboard operation
premailex copied to clipboard

Fix Dialyzer typing for to_inline_css options

Open meeq opened this issue 3 months ago • 0 comments

I tried to specify the css_selector option in Premailex.to_inline_css and Dialyzer complained:

lib/project/mailer.ex:17:22:call
The function call will not succeed.

Premailex.to_inline_css(binary(), [
  {:css_selector, binary()}
])

will never return since the 2nd arguments differ
from the success typing arguments:

(binary(), nil | [%{:rules => [map()], :selector => binary(), :specificity => number()}]) ::
  :ok
def a() do
  :ok
end

This patch improves the spec for Premailex.HTMLInlineStyles.process to allow the second argument to be either a list of CSS Parser rule sets or a keyword list, which matches the implementation.

meeq avatar Oct 03 '25 18:10 meeq