tcoopman

tcoopman

Are typespecs deprecated? (Reddit thread answer from Jose)

I discovered this link on bluesky, and it was a bit of an accidental thing, but I think it contains some nice information that’s worth checking out if you’re interested in the type checking future of Elixir.

Most Liked

josevalim

josevalim

Creator of Elixir

If you don’t have a type signature, we will infer one for you and use it when type checking remote calls. The inferred signature can understand everything about your code, except calls to other modules in the same project. So they are a good approximation and give valuable benefit for whoever wants to be lazy and not type anything. If you want proper type checking, then you have to write the signatures for your public functions.

cevado

cevado

it actually says in the part you quote

type check will be done whenever you do the annotations, inference only for external stuff.

Eiji

Eiji

@tcoopman Keep in mind that changes even in nearest Elixir version would not affect whole community immediately. There would be months if not years of delay. That’s because many projects supports few Elixir versions back, so at best they may have both systems implemented (assuming the new one would not cause compilation errors in earlier versions) and in worst case they would replace new system after a longer time.

If said change would happen in ecto, phoenix, credo, excoveralls and many, many other most popular packages then the change to new type system would be rapid as there would be no sense to maintain both systems in long term especially if they are completely different while covering same things.

That’s said … new projects or those who focused on support latest Elixir versions would most likely switch to new system immediately as long as @type, @typep and @opaque would not be hard deprecated (if any). Unlike in packages shared on hex those projects would not cause problems with other projects and if they do (umbrella apps, internal dependencies) then most likely all related projects would have such changes soon as well.

However it would progress I would take a deep look from the very beginning as I wrote tons of typespecs and I’m willing to migrate asap (even if it would be 100% manual). I only wonder if Elixir core team plans to work in future on cover replacement. Similarly to dialyzer coverage does not works as good as it could (especially with macros) and modules with only types and struct definitions that have 0 relevant lines which is equal to 0% coverage!

Last Post!

Eiji

Eiji

I found what I remembered about macros. Looks like the issue is still open:
https://github.com/parroty/excoveralls/issues/59

Regarding the weird behaviour about 0% coverage it’s about a confusing coveralls defaults and it could be fixed simply by creating a file called coveralls.json with following content:

{
  "coverage_options": {
    "treat_no_relevant_lines_as_covered": true
  }
}

In my opinion those files should be by default skipped i.e. at the bottom of the report there should be a note that x files were skipped due to no relevant lines found. The other suggested solution is to print it such files with N/A, - or similar result. Of course it does not affect the final score, but the default look really weird and are very confusing …

Simply think that you realised such detail and see an open issue many years ago and after years you found that support for it has been added with some option. :sweat_smile:

Anyway, the coverage tool is limited a lot especially if you are creating using a lot of macros.

Where Next?

Popular in Discussions Top

AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31771 143
New
Crowdhailer
I’ve been hearing much about the new formatter and it’s something I have been keen to try. I find examples buy far the most illuminating...
248 19814 150
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
AstonJ
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement