microsoft / microsoft/TypeScript

Add the possibility to import Types from global loaded Librarys

Open
#57,019 19 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔍 Search Terms

import types global

✅ Viability Checklist
⭐ Suggestion

In browser environemnt you often need to load librarys, wich are developed as ESM modules ans with ESM types globaly, cause they are only delivered as CJS, for example typescript, see: https://github.com/microsoft/TypeScript/issues/57010

There should be a way, so I can import typescript and use it, without loading the library (like import type), but there should be no error if I use instances from the import.

for example at the moment it is like this:

 import type ts form 'typescript'
 const a = ts.SyntaxKind.TaggedTemplateExpression

will error cause the import is only imported as type

maybe something like this:

 import global type ts form 'typescript'
 const a = ts.SyntaxKind.TaggedTemplateExpression

or

 import global ts form 'typescript'
 const a = ts.SyntaxKind.TaggedTemplateExpression

would be possible?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed import type examples and the related TypeScript issue 57010 to understand the global-library scenario and the desired runtime behavior. Define the supported syntax and semantics for accessing values such as ts.SyntaxKind.TaggedTemplateExpression without loading the library; the issue is done when the design is specified and validated against the stated constraints.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.