Imaginary programming: implementation-free TypeScript functions for GPT-powered web development is a project we built to allow web developers to use GPT to easily add AI features to their existing web user interfaces. All a developer does is declares a function prototype in TypeScript with a good comment saying what the function should do, and then they can call the function from other TypeScript and JavaScript code, even though they’ve never implemented the function in question. It looks something like:

* This function takes in a blog post text and returns at least 5 good titles for the blog post.
* The titles should be snappy and interesting and entice people to click on the blog post.
* @param blogPostText - string with the blog post text
* @returns an array of at least 5 good, enticing titles for the blog post.
* @imaginary

declare function titleForBlogPost(blogPostText: string): Promise<Array<string>>;

Under the covers, we’ve written a TypeScript and Babel plugin that replaces these “imaginary function” declarations with runtime calls to GPT asking GPT what the theoretical function would return for a particular set of inputs. So it’s not using GPT to write code (like CoPilot or Ghostwriter); it’s using GPT to act as the runtime. This gives you freedom to implement things that you could never do in traditional programming: classification, extraction of structured information out of human language, translation, spell checking, creative generation, etc.

Here’s a quick screencast where I show off adding intelligent features to a simple blog post web app: Loom | Free Screen & Video Recording Software | Loom

Let me know what you think. Is this useful? Is this something you think you’d enjoy using? Is this a good direction to take web development? Happy to hear any and all feedback!

More info on the idea: