{"id":233931,"date":"2021-08-12T11:00:35","date_gmt":"2021-08-12T18:00:35","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=233931"},"modified":"2021-08-12T18:10:04","modified_gmt":"2021-08-13T01:10:04","slug":"the-new-javascript-typescript-experience-in-vs-2022-preview-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/the-new-javascript-typescript-experience-in-vs-2022-preview-3\/","title":{"rendered":"The New JavaScript\/TypeScript Experience in Visual Studio 2022 Preview 3"},"content":{"rendered":"<p>Today we are excited to announce a new experience for JavaScript and TypeScript developers\u00a0in Visual Studio.\u00a0We are bringing new tooling to enhance the experience for SPA applications and front-end development.<\/p>\n<h2>What\u2019s\u00a0New?<\/h2>\n<p>With Visual Studio 2022, we really wanted to make our JavaScript &amp; TypeScript experience shine. We spoke with many developers to understand their expectations and experiences. What we heard was that while our editing features \u2013 IntelliSense, Quick Info, Go-to-Definition, etc. \u2013 worked well, Visual Studio still had a few gaps when it came to\u00a0<em>integrated<\/em>\u00a0workloads like testing and getting started on front-end projects.<\/p>\n<p>To better support front-end development in Visual Studio 2022, we\u2019re introducing a new JavaScript\/TypeScript project type.\u00a0 With this new project type, you will be able to develop standalone Angular, React, and Vue projects. You will also be able to easily integrate your front-end projects with an ASP.NET Core backend, and even leverage existing tools in Visual Studio like the Test Explorer.<\/p>\n<h3>CLI-Based Front-End\u00a0Project Templates<\/h3>\n<p>The current Angular, React, and Vue templates included with Visual Studio were often not up to date, and users told us they wanted to choose the version of the framework they are using. To address this feedback, we\u2019re leveraging each framework\u2019s native CLIs to create these front-end project templates:<\/p>\n<ul>\n<li><a href=\"https:\/\/angular.io\/cli\" target=\"_blank\" rel=\"noopener\">Angular CLI<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/facebook\/create-react-app\" target=\"_blank\" rel=\"noopener\">Create React App<\/a><\/li>\n<li><a href=\"https:\/\/cli.vuejs.org\/\" target=\"_blank\" rel=\"noopener\">Vue CLI<\/a><\/li>\n<\/ul>\n<p>Visual Studio will\u00a0discover and use\u00a0the version of the\u00a0CLI\u00a0installed on your\u00a0path to scaffold the project.<\/p>\n<p>When creating your project, Visual Studio will open a command prompt so you can see the CLI\u2019s progression.<\/p>\n<p><img decoding=\"async\" class=\"wp-image-233956\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/text-description-automatically-generated.png\" alt=\"Text Description automatically generated\" width=\"869\" height=\"309\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/text-description-automatically-generated.png 1429w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/text-description-automatically-generated-300x107.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/text-description-automatically-generated-1024x364.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/text-description-automatically-generated-768x273.png 768w\" sizes=\"(max-width: 869px) 100vw, 869px\" \/><\/p>\n<p>Note: If you do not have the CLI of choice installed, you\u00a0will\u00a0get an error in the New Project Dialog Window, for example:<\/p>\n<p><em>React cannot be found on your device.<\/em><\/p>\n<p>That\u2019s okay! You\u2019ll just need to run the appropriate\u00a0<code>npm<\/code>\u00a0install command:<\/p>\n<p>Angular:<\/p>\n<p><code>npm\u00a0install -g @angular\/cli<\/code><\/p>\n<p>React:<\/p>\n<p><code>npm\u00a0install -g create-react-app<\/code><\/p>\n<p>Vue:<\/p>\n<p><code>npm\u00a0install -g @vue\/cli<\/code><\/p>\n<p>As\u00a0React and Vue\u00a0support both TypeScript and\u00a0JavaScript, you also\u00a0can\u00a0specify\u00a0whichever\u00a0language\u00a0you prefer\u00a0during\u00a0project\u00a0creation.\u00a0Visual Studio will add the proper flags to the CLI commands for your choice.<\/p>\n<p><img decoding=\"async\" class=\"wp-image-233957\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-description.png\" alt=\"Graphical user interface, application Description automatically generated\" width=\"616\" height=\"237\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-description.png 1101w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-description-300x116.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-description-1024x394.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-description-768x296.png 768w\" sizes=\"(max-width: 616px) 100vw, 616px\" \/><\/p>\n<h3>ASP.NET Core Integration<\/h3>\n<p>Many\u00a0of our JavaScript and TypeScript developers are building their\u00a0front-end\u00a0projects alongside\u00a0their\u00a0ASP.NET Core backend projects.\u00a0In one of our user studies, participants\u00a0mentioned\u00a0they like to keep their\u00a0front-end\u00a0and backend projects separated, and\u00a0that\u00a0they would open them in\u00a0multiple\u00a0editors.\u00a0To\u00a0create\u00a0a similar setup, we\u00a0moved to a\u00a0two\u00a0project in one solution model,\u00a0where\u00a0JavaScript\/TypeScript\u00a0projects\u00a0can be easily integrated with ASP.NET Core\u00a0Web APIs.\u00a0You\u00a0will be able to choose if you want to run, debug and edit your projects together or separately while having access to tooling for both\u00a0the front-end and backend.<\/p>\n<p>Starting the two-project solution is as easy as\u00a0selecting\u00a0the \u201cAdd integration for Empty ASP.NET Web API project\u201d\u00a0option\u00a0while\u00a0setting up the project in the New Project Dialog:<\/p>\n<p><img decoding=\"async\" class=\"wp-image-233958\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-text-application-descr.png\" alt=\"Graphical user interface, text, application Description automatically generated\" width=\"494\" height=\"213\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-text-application-descr.png 935w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-text-application-descr-300x129.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-text-application-descr-768x331.png 768w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/p>\n<p>When you select the\u00a0integration,\u00a0you\u00a0will notice\u00a0files that have been added or modified\u00a0in the\u00a0JavaScript projects, that will make them differ slightly from\u00a0the\u00a0original templates:<\/p>\n<ul>\n<li>Additional JavaScript files with an aspnetcore prefix<\/li>\n<li>Slightly modified package.json that will include additional npm commands to start up the front\u2013end and the backend<\/li>\n<li>Slightly modified application files that automatically use the data created in the .NET Core project\u2019s demo weather API<\/li>\n<\/ul>\n<p>These files will allow you to add a .NET Core project to your solution and be able to run the two together, without having to add any\u00a0added\u00a0code.<\/p>\n<p><img decoding=\"async\" class=\"wp-image-233959\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-description-automaticall.png\" alt=\"Graphical user interface Description automatically generated with medium confidence\" width=\"229\" height=\"299\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-description-automaticall.png 624w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-description-automaticall-229x300.png 229w\" sizes=\"(max-width: 229px) 100vw, 229px\" \/><\/p>\n<h2>JavaScript\/TypeScript Testing<\/h2>\n<p>Unit testing with the Test Explorer is one of the new features enabled when creating a JavaScript\/TypeScript project. We leverage Jest for React and Vue projects, and Karma and Jasmine for Angular projects. By default, you will be able to run the default tests provided by each framework, as well as any additional tests you write. \u00a0Just hit the play button in the Test Explorer. If you don\u2019t already have your Test Explorer\u00a0open,\u00a0you can find it by opening\u00a0the Test menu in the menu bar.<\/p>\n<p><img decoding=\"async\" class=\"wp-image-233960\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-word-descr.png\" alt=\"Graphical user interface, application, Word Description automatically generated\" width=\"1045\" height=\"284\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-word-descr.png 1431w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-word-descr-300x82.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-word-descr-1024x278.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/08\/graphical-user-interface-application-word-descr-768x209.png 768w\" sizes=\"(max-width: 1045px) 100vw, 1045px\" \/><\/p>\n<p>We also support the Mocha and Tape test libraries. To use one of these, simply change the default test library in\u00a0package.json\u00a0to the appropriate\u00a0test library\u2019s package.<\/p>\n<h2>Easily\u00a0Work with VS\u00a0Code<\/h2>\n<p>To allow JavaScript\/TypeScript projects to also be easily debugged using Visual Studio Code, we\u2019ve included a\u00a0launch.json\u00a0file to the project template. This file will be used to set your launch configurations in Visual Studio, as well as in VS Code. As a result, you will be able to seamlessly open, edit, and debug your JavaScript\/TypeScript projects in both VS and VS Code.<\/p>\n<h2>Getting Started<\/h2>\n<p>If you have Visual Studio 2022 Preview 3 installed and you would like to get started, head over to\u00a0our\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/javascript\/?view=vs-2022\" target=\"_blank\" rel=\"noopener\">JavaScript &amp; TypeScript documentation page<\/a>\u00a0for all updated tutorials and overviews!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we are excited to announce a new experience for JavaScript and TypeScript developers\u00a0in Visual Studio.\u00a0We are bringing new tooling to enhance the experience for SPA applications and front-end development. What\u2019s\u00a0New? With Visual Studio 2022, we really wanted to make our JavaScript &amp; TypeScript experience shine. We spoke with many developers to understand their expectations [&hellip;]<\/p>\n","protected":false},"author":36368,"featured_media":233891,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[],"class_list":["post-233931","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio"],"acf":[],"blog_post_summary":"<p>Today we are excited to announce a new experience for JavaScript and TypeScript developers\u00a0in Visual Studio.\u00a0We are bringing new tooling to enhance the experience for SPA applications and front-end development. What\u2019s\u00a0New? With Visual Studio 2022, we really wanted to make our JavaScript &amp; TypeScript experience shine. We spoke with many developers to understand their expectations [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/233931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/36368"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=233931"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/233931\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/233891"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=233931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=233931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=233931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}