Skip to content

[Bug 馃悶 report]: Add Deno types configuration to eliminate IDE errors in edge functions#5087

Description

@codxbrexx

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:

// 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:

{
  "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?

  • I checked and didn't find a similar issue

Have you read the Contributing Guidelines?

Attach any resources that can help us understand the issue.

Image

Code of Conduct

  • 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/typescriptSpecify what technical area given issue relates to. Its goal is to ease filtering good first issues.triagedIssue has been reviewed and discussed

    Type

    No type

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions