diff --git a/README.md b/README.md index 0b9d307..42641fc 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,64 @@ # ai-typescript-check -Lint, auto-complete, error check, and type check typescript, jsx/tsx, and javascript files using an API. -Uses a partially modified version of [`@typescript/twoslash`](https://shikijs.github.io/twoslash/). +`ai-typescript-check` is a ChatGPT plugin and API that provides linting, auto-completion, error checking, and type checking for TypeScript, JSX/TSX, and JavaScript files. It uses a modified version of [`@typescript/twoslash`](https://shikijs.github.io/twoslash/). -Example usage in Deno +While primarily designed as a ChatGPT plugin for type checking TypeScript code, `ai-typescript-check` can also be used as a standalone API for type checking in any coding environment. We welcome your feedback and suggestions. You can check out the OpenAPI Spec to learn more about the API [.well-known/open-api.yaml](./.well-known/open-api.yaml) or using the website at [ts-check.okikio.dev/.well-known/openapi.yaml](https://ts-check.okikio.dev/.well-known/openapi.yaml) + +## Example Usage in Deno + +You can use `ai-typescript-check` in Deno by sending a POST request to the API endpoint. Here's an example: ```ts +// Create a new FormData instance const formData = new FormData(); -formData.append("code", "import { hasTransferables } from \"transferables\"") +formData.append("code", "import { hasTransferables } from \"transferables\""); formData.append("extension", "ts"); +// Send a POST request to the API const res = await fetch("https://ts-check.okikio.dev/twoslash", { method: "POST", body: formData }) +// Log the response console.log({ json: await res.json() }) +``` -// OR +Alternatively, you can pass the options as a query parameter: +```ts +// Define the options const options = JSON.stringify({ "code": `import { hasTransferables } from "transferables"`, "extension": "ts" }); -// +// Send a GET request to the API const res = await fetch(`https://ts-check.okikio.dev/twoslash?options=${options}`) +// Log the response console.log({ json: await res.json() }) ``` -Results +## Response Format + +The API returns a JSON object with the following properties: + +- `code`: The original code that was sent to the API. +- `extension`: The file extension of the code. +- `highlights`: An array of highlights from the code. +- `queries`: An array of queries from the code. +- `staticQuickInfos`: An array of quick info objects, each containing details about a specific part of the code. +- `errors`: An array of errors found in the code. +- `warnings`: An array of warnings about the code. +- `playgroundURL`: A URL to the TypeScript playground with the code pre-loaded. +- `tags`: An array of tags associated with the code. + +Here's an example response: ```json {