-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Create type aliases for unresolved type symbols #45976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
981cbb3
17332e1
3d34ca7
8f828c4
891f961
e949c85
5314074
9d01571
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4523,6 +4523,8 @@ namespace ts { | |||||
| const noTruncation = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation; | ||||||
| const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | (noTruncation ? NodeBuilderFlags.NoTruncation : 0), writer); | ||||||
| if (typeNode === undefined) return Debug.fail("should always get typenode"); | ||||||
| // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. | ||||||
| // Otherwise, we always strip comments out. | ||||||
| const options = { removeComments: type !== unresolvedType }; | ||||||
| const printer = createPrinter(options); | ||||||
| const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration); | ||||||
|
|
@@ -8270,6 +8272,8 @@ namespace ts { | |||||
| } | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just this? Seems like it'd be cheaper too.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that wouldn't work. I'll add a clarifying comment, but basically we want to identify the special |
||||||
| function isErrorType(type: Type) { | ||||||
| // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for | ||||||
| // a reference to an unresolved symbol. We want those to behave like the errorType. | ||||||
| return type === errorType || !!(type.flags & TypeFlags.Any && type.aliasSymbol); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be helpful to leave a comment on this one (pun intended).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll add a comment.