[api-extractor] refactor import() type support, to support more cases#5332
Open
adventure-yunfei wants to merge 11 commits intomicrosoft:mainfrom
Open
[api-extractor] refactor import() type support, to support more cases#5332adventure-yunfei wants to merge 11 commits intomicrosoft:mainfrom
adventure-yunfei wants to merge 11 commits intomicrosoft:mainfrom
Conversation
Contributor
Author
|
seems pretty easy to support |
Collaborator
|
@adventure-yunfei 想不想来字节跳动一起工作啊?😸 |
Contributor
Author
才发现去 tiktok 了。现在还没换工作的想法。字节国内外都是好公司,后续有机会的话当然要试一下。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.Zimport type syntax, instead of create a newImportTypekind ofAstImport, creating a new synthetic entityAstSubPathImportto represent "importing nested part from an AstEntity".Some detail changes:
import()is handled as atype-onlyimport to an AstImport entityimport(), simplify code to parse the localAstModuleand 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