TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ts-morph – programmatically manipulate TypeScript source code with TypeScript

43 pointsby aabbcc1241almost 2 years ago

6 comments

no_wizardalmost 2 years ago
Eventually I wonder if the TypeScript team will revert their stance on not allowing compiler plugins. It seems like such a waste not to have a standard package interface. All this is doing is exposing the already provided compiler tools, its not using Babel or anything, its just a nicer API over the raw TS compiler API.<p>Arguably, the TypeScript team should be supplying that nicer API. Its the only thing missing to me from TypeScript that it really needs.
评论 #35996186 未加载
评论 #35998098 未加载
评论 #35999561 未加载
klysmalmost 2 years ago
Is it possible to use ts-morph to generate new code or is it mostly aimed at modifying existing code? I want to generate some boilerplate in a project im working on but not sure what the best tool is
评论 #36080293 未加载
funnymunnyalmost 2 years ago
I’ve always wanted a tool that could search ts code using types &amp; logic, e.g. you could search for every instance where an object of a particular type has a value assigned to one of its properties.
评论 #36012684 未加载
nomurrcyalmost 2 years ago
This is a great tool. The api surface takes a bit to figure out, and navigating manipulating the syntax tree can require some trial and error, but I’ve used this to do large scale refactors that would have been very time consuming if done by hand.<p>99% of the time the tools provided by jetbrains &#x2F; vscode are more than sufficient, but 1% of the time a tool like this saves you a bunch of time, both searching for what you need to change and making the changes you want.
neilvalmost 2 years ago
For people who want to do similar programmatic manipulation using Racket: <a href="https:&#x2F;&#x2F;www.neilvandyke.org&#x2F;racket&#x2F;progedit&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.neilvandyke.org&#x2F;racket&#x2F;progedit&#x2F;</a><p>(Not just manipulation of Lisp-like languages: any language can be parsed to Racket syntax objects.)
raydiatianalmost 2 years ago
I used this to build an inhouse dev tool that generates boilerplate code once.
评论 #35999492 未加载