[api-extractor] refactor import() type support, to support more cases #5332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactor
import()
type syntax support. Fixes cases in #5326 (except for one very rare case that requires more code changes: typeof import("./foo")").Details
For
import("foo").X.Y.Z
import type syntax, instead of create a newImportType
kind ofAstImport
, creating a new synthetic entityAstSubPathImport
to represent "importing nested part from an AstEntity".Some detail changes:
import()
is handled as atype-only
import to an AstImport entityimport()
, simplify code to parse the localAstModule
and its first export, instead of parsing the right-most symbol.DtsEmitHelper
, decouple code to modify import type node only by related entity info. (no assumption that always importing from top namespace. that may changes in some optimization cases which is not implemented yet.)AstNamespaceImport
, remove declaration symbol (use module symbol instead) and use ts.SourceFile declaration forimport()
type syntaxI also plan to use
AstSubPathImport
(or a better name?) to support import equal syntaximport Foo = X.Y.Z
(which implemented in another way in adventure-yunfei#4.)How it was tested
Add more test cases for dymanic import type.
Impacted documentation