[Bug 🐞 report]: Add Deno types configuration to eliminate IDE errors in edge functions
- Dominant language
- TypeScript
- Stars
- 716
- Forks
- 1.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 35
Description
### Describe the bug you found in AsyncAPI Docs.
### What changes are you proposing?
I propose adding a `netlify/edge-functions/deno.json` configuration file to properly set up the Deno environment for edge functions.
This change will:
1. **Configure** the TypeScript compiler for the `netlify/edge-functions/` directory.
2. **Recognize** Deno-specific globals (like `Deno.env`) and imports.
3. **Eliminate** false positive TypeScript errors in the IDE.
### Why do we need this improvement?
The `netlify/edge-functions/` directory runs on the **Deno runtime**, but the project defaults to a **Node.js** environment.
**The Problem:**
Currently, when a developer opens a file like `serve-definitions.ts`, the IDE reports numerous "Critical" errors that are actually false positives:
1. **Missing Modules**: `Cannot find module 'https://...'` (Node doesn't support URL imports).
2. **Unknown Globals**: `Cannot find name 'Deno'` (TypeScript expects Node types).
This creates a "broken window" effect where valid code appears to be incorrect, potentially confusing new contributors who might question their local setup.
### How will this change help?
This change significantly improves the **DX**:
* **Clean Workspace**: Removes distracting error indicators, allowing developers to focus on actual issues.
* **Faster Onboarding**: Contributors can trust that the absence of errors indicates the code is valid.
* **Better Type Safety**: Formatting and linting will function correctly for Deno-specific syntax.
### Screenshots
**Current State (IDE Errors):**
Opening `netlify/edge-functions/serve-definitions.ts` currently displays errors such as:
```typescript
// Error: Cannot find module 'https://edge.netlify.com/v1/index.ts' or its corresponding type declarations.
import type { Context } from "https://edge.netlify.com/v1/index.ts";
export default async (request: Request, context: Context) => {
// Error: Cannot find name 'Deno'.
const GITHUB_TOKEN = Deno.env.get("GITHUB_TOKEN_NR");
// ...
}
```
### How could it be implemented/designed?
**Implementation Plan:**
Create a `netlify/edge-functions/deno.json` with the following configuration:
```json
{
"compilerOptions": {
"lib": ["deno.window"],
"types": [
"https://edge.netlify.com/v1/index.ts"
]
}
}
```
This instructs the editor to treat this specific directory as a Deno environment.
I have verified this fix locally. **I am ready to implement this immediately upon approval.**
### Breaking changes
No
### Have you checked for similar open issues?
- [x] I checked and didn't find a similar issue
### Have you read the Contributing Guidelines?
- [x] I have read the [Contributing Guidelines](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)
### Attach any resources that can help us understand the issue.
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
### Are you willing to work on this issue ?
Yes I am willing to submit a PR!
Contributor guide
Research direction
Start with netlify/edge-functions/serve-definitions.ts and inspect the existing project TypeScript configuration, then compare the proposed netlify/edge-functions/deno.json settings with the Deno runtime used there. Verify the editor recognizes the URL import and Deno.env without false-positive errors, and confirm formatting and linting still work for the edge-function files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- deno, typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100