-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fix emit issue regarding null/undefined in type annotations #11653
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -504,15 +504,29 @@ const _super = (function (geti, seti) { | |
|
||
// Contextual keywords | ||
case SyntaxKind.AbstractKeyword: | ||
case SyntaxKind.AsKeyword: | ||
case SyntaxKind.AnyKeyword: | ||
case SyntaxKind.AsyncKeyword: | ||
case SyntaxKind.AwaitKeyword: | ||
case SyntaxKind.BooleanKeyword: | ||
case SyntaxKind.ConstructorKeyword: | ||
case SyntaxKind.DeclareKeyword: | ||
case SyntaxKind.NumberKeyword: | ||
case SyntaxKind.GetKeyword: | ||
case SyntaxKind.IsKeyword: | ||
case SyntaxKind.ModuleKeyword: | ||
case SyntaxKind.NamespaceKeyword: | ||
case SyntaxKind.NeverKeyword: | ||
case SyntaxKind.ReadonlyKeyword: | ||
case SyntaxKind.RequireKeyword: | ||
case SyntaxKind.NumberKeyword: | ||
case SyntaxKind.SetKeyword: | ||
case SyntaxKind.StringKeyword: | ||
case SyntaxKind.SymbolKeyword: | ||
case SyntaxKind.TypeKeyword: | ||
case SyntaxKind.UndefinedKeyword: | ||
case SyntaxKind.FromKeyword: | ||
case SyntaxKind.GlobalKeyword: | ||
case SyntaxKind.OfKeyword: | ||
writeTokenText(kind); | ||
return; | ||
|
||
|
@@ -1198,12 +1212,14 @@ const _super = (function (geti, seti) { | |
|
||
function emitCallExpression(node: CallExpression) { | ||
emitExpression(node.expression); | ||
emitTypeArguments(node, node.typeArguments); | ||
emitExpressionList(node, node.arguments, ListFormat.CallExpressionArguments); | ||
} | ||
|
||
function emitNewExpression(node: NewExpression) { | ||
write("new "); | ||
emitExpression(node.expression); | ||
emitTypeArguments(node, node.typeArguments); | ||
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. I can see why this is necessary, but do we have cases today when we need to emit type arguments or type annotations - asking because It will be nice to test this functionality 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. Primarily it helped me catch other possible future errors. |
||
emitExpressionList(node, node.arguments, ListFormat.NewExpressionArguments); | ||
} | ||
|
||
|
@@ -1575,6 +1591,7 @@ const _super = (function (geti, seti) { | |
|
||
function emitVariableDeclaration(node: VariableDeclaration) { | ||
emit(node.name); | ||
emitWithPrefix(": ", node.type); | ||
emitExpressionWithPrefix(" = ", node.initializer); | ||
} | ||
|
||
|
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.
can you add a test to check this condition?
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.
The only new functionality is the test for
node.type
, which is covered bytransformsElideNullUndefinedType