Skip to content

globally declared types are not recognized in the language server unless the file declaring them is opened #33289

@DetachHead

Description

@DetachHead
// foo.ts
declare global {
    const a: number
}

export { }
// bar.ts
console.log(a) // error: Cannot find name 'a'.

to reproduce

  1. close foo.ts in vscode
  2. restart the deno language server
  3. wait for the error to appear in bar.ts
  4. open foo.ts and watch the error disappear

vscode's built in typescript language server seems to have the same issue but creating a tsconfig.json file fixes it because it allows it to detect which files to include in the project without having to rely on which files the user opens.

in deno-ts however, doing the equivalent with deno.jsonc does not seem to have any impact.

deno check does not report any error.

workaround

add an import './foo.ts' or /// <reference path="./foo.ts" /> to the top of bar.ts, but this shouldn't be necessary since it should just use the typescript settings in deno.jsonc to determine which files to include in the project

Version: Deno 2.7.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions