Why any type is allowed in typescript? where it makes difficult to catch error at compile time

Why any type is allowed in typescript. It may generate bugs at runtime, and type any makes it difficult to detect bugs at compile-time.

const someValue: string = "Some string";

When I define its type string it shows a compilation error. Because toExponential() is not a function for string type data. But when I change its type to any.

const someValue: any = "string";

It does not show any compile-time error and generate an error at run-time. So, what is the exact use of type any? and how to avoid run-time error while using type any.

29 thoughts on “Why any type is allowed in typescript? where it makes difficult to catch error at compile time”

  1. My brother recommended I might like this web site.
    He was totally right. This post actually made my day. You
    cann’t imagine just how much time I had spent
    for this info! Thanks!

  2. Hey! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly?
    My weblog looks weird when browsing from my iphone. I’m
    trying to find a template or plugin that might be able to fix this issue.

    If you have any recommendations, please share. Thanks!

  3. I feel this is one of the such a lot important info for me.
    And i am glad reading your article. However want to remark on few common things, The site style is
    wonderful, the articles is actually excellent :
    D. Good job, cheers

  4. Hi would you mind letting me know which webhost you’re utilizing?
    I’ve loaded your blog in 3 different browsers and I must say this blog loads a lot quicker then most.
    Can you recommend a good hosting provider at a honest price?
    Thank you, I appreciate it!

  5. Hey there! This post could not be written any better! Reading through this post reminds me of my
    old room mate! He always kept chatting about this. I will forward this write-up to him.
    Pretty sure he will have a good read. Many thanks for

  6. Cool blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple tweeks would really make my blog stand out.
    Please let me know where you got your theme. Bless you

  7. Hey there would you mind letting me know which webhost you’re
    utilizing? I’ve loaded your blog in 3 completely different web browsers and I must say this blog
    loads a lot faster then most. Can you suggest a good
    internet hosting provider at a reasonable price? Thanks, I appreciate

  8. Hey there! This is kind of off topic but I need some
    guidance from an established blog. Is it very hard to set up your own blog?

    I’m not very techincal but I can figure things out
    pretty quick. I’m thinking about making my own but I’m not sure where to start.

    Do you have any ideas or suggestions? Cheers

  9. MENTERI Tingkah laku Lazim dan Perumahan Orang kebanyakan (PUPR) Basuki Hadimoeljono menginstruksikan percepatan penyelesaian penyusunan dengan bertahap (Gate to Gate) Rel (kereta api) Jakarta- Cikampek (Japek) II Daksina.
    Ruas tersebut mengaitkan Tarif Daerah khusus ibukota jakarta Outer Cincin Road
    (JORR) 1, JORR dua dan Tol Purwakarta-Bandung-Cileunyi
    (Purbaleunyi). Pembangunan lorong ini ditargetkantersambung di dalam November tahun itu.

    Sensual 1 Jatiasih-Setu seturut 9, 3 km, seksi 2 Setu-Taman Mekar sepanjang 24, 85 km, & seksi 3 Taman-Mekar Sadang seturut 27, 85 km.
    Ia memaparkan, Tol Japek II Daksina adalah Proyek Substansial Luar dengan dibangun dengan perantara pembiayaan APBN/APBD, BUMN,
    dan Swasta secara kerjasama Tubuh Bisnis Orbit (BUJT)
    PT Ladenan Marga & PT Wiranusantara Bumi. Penyusunan Upah Japek
    II Daksina diperkirakan mencita-citakan keseluruhan pendanaan senilai Rp14,
    69 triliun. Khusus untuk seksi 3 pembangunannya dilaksanakan sama pemborong PT Waskita Makalah serta pemandu supervisi PT Melahirkan Strada.

    my website; campuran aspal hotmix

  10. Incrível blog! Você tem alguma sugestões para aspirantes a escritores?

    Estou planejando começar meu próprio blog em breve, mas estou um pouco perdido em tudo.
    Você recomendar começar com uma plataforma gratuita como o WordPress ou optar por
    uma opção paga? Há tantas opções lá fora que estou completamente confuso ..
    Quaisquer recomendações ? Agradeço !

    my web-site faq-pt.day

  11. Hello exceptional website! Does running a blog similar to this take a large amount of work?
    I have absolutely no understanding of computer programming but I was hoping to start my own blog soon. Anyways, should you have any ideas or tips for new blog owners please
    share. I know this is off subject but I just had to ask.

  12. Hello there I am so glad I found your webpage, I really found you by mistake,
    while I was researching on Digg for something else, Nonetheless I am here now and would just like to say cheers for a marvelous
    post and a all round entertaining blog (I also love the theme/design), I don’t have time to read it all
    at the minute but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read
    a great deal more, Please do keep up the superb


Leave a Comment