Skip to content

No longer possible to use TS API globally in types (5.0.0) #53402

@talks2much

Description

@talks2much

Bug Report

Hi! We have TypeScript plugin and after recent update to latest TypeScript version to 5.0.2 we no longer can use ts in types in our files e.g.:

// In TS 4.9.5 we could: // File: index.ts import 'typescript/lib/tsserverlibrary' // or ///<ref ... // File: other.ts export const decorateLs = (languageService: ts.LanguageService) => {...}

We don't like to rewrite everything to use imports (import('typescript').LanguageService) and we more like the current state of codebase with concise type declarations

🔎 Search Terms

Type import module use globally, define type module globally, declare global type

We tried this workaround:

// File: ts.d.ts type ts = typeof import('typescript') // or declare global { ... } export { }

But in other.ts:

type A = ts.LanguageService // Error: 'ts' only refers to a type, but is being used as a namespace here.ts(2702)

But I personally have no idea why it doesn't capture module's type into declared type

//cc @zardoy

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