Provided herein are quinazoline compounds of formula (I): The compounds are useful for treatment of JAK kinase mediated diseases, including JAK2 kinase-, JAK3 kinase- or TYK2 kinase-mediated diseases. Also provided are pharmaceutical compositions comprising the compounds and methods of using the compounds and compositions.