Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/ast/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,9 @@ func IsJSDocSingleCommentNodeList(nodeList *NodeList) bool {
return false
}
parent := nodeList.Nodes[0].Parent
if parent == nil {
return false
}
return IsJSDocSingleCommentNode(parent) && nodeList == parent.CommentList()
}

Expand Down
32 changes: 32 additions & 0 deletions internal/checker/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,35 @@ func (c *Checker) GetIndexInfosOfType(t *Type) []*IndexInfo {
func (c *Checker) IsContextSensitive(node *ast.Node) bool {
return c.isContextSensitive(node)
}

func (c *Checker) FillMissingTypeArguments(typeArguments []*Type, typeParameters []*Type, minTypeArgumentCount int, isJavaScriptImplicitAny bool) []*Type {
return c.fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny)
}

func (c *Checker) GetMinTypeArgumentCount(typeParameters []*Type) int {
return c.getMinTypeArgumentCount(typeParameters)
}

func (c *Checker) GetWidenedLiteralType(t *Type) *Type {
return c.getWidenedLiteralType(t)
}

func (c *Checker) IsTypeAssignableTo(source *Type, target *Type) bool {
return c.isTypeAssignableTo(source, target)
}

func (c *Checker) GetUnionTypeEx(types []*Type, unionReduction UnionReduction) *Type {
return c.getUnionTypeEx(types, unionReduction, nil, nil)
}

func (c *Checker) RequiresAddingImplicitUndefined(node *ast.Node) bool {
enclosingDeclaration := ast.FindAncestor(node, ast.IsDeclaration)
if enclosingDeclaration == nil {
enclosingDeclaration = ast.GetSourceFileOfNode(node).AsNode()
}
symbol := node.Symbol()
if symbol == nil {
return false
}
return c.GetEmitResolver().RequiresAddingImplicitUndefined(node, symbol, enclosingDeclaration)
}
5 changes: 5 additions & 0 deletions internal/checker/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ func (c *Checker) TypeToTypeNode(t *Type, enclosingDeclaration *ast.Node, flags
return nodeBuilder.TypeToTypeNode(t, enclosingDeclaration, flags, nodebuilder.InternalFlagsNone, nil)
}

func (c *Checker) TypeToTypeNodeEx(t *Type, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, idToSymbol map[*ast.IdentifierNode]*ast.Symbol) *ast.TypeNode {
nodeBuilder := c.getNodeBuilderEx(idToSymbol)
return nodeBuilder.TypeToTypeNode(t, enclosingDeclaration, flags, internalFlags, nil)
}

func (c *Checker) TypePredicateToTypePredicateNode(t *TypePredicate, enclosingDeclaration *ast.Node, flags nodebuilder.Flags, idToSymbol map[*ast.IdentifierNode]*ast.Symbol) *ast.TypePredicateNodeNode {
nodeBuilder := c.getNodeBuilderEx(idToSymbol)
return nodeBuilder.TypePredicateToTypePredicateNode(t, enclosingDeclaration, flags, nodebuilder.InternalFlagsNone, nil)
Expand Down
14 changes: 12 additions & 2 deletions internal/fourslash/_scripts/convertFourslash.mts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const IMPORT_UTIL = `. "github.com/microsoft/typescript-go/internal/fourslash/te
// Tests for code fixes not in this set will be skipped during conversion.
const allowedCodeFixIds = new Set([
"fixMissingImport",
"fixMissingTypeAnnotationOnExports",
]);

// File name prefixes for code fix tests that are allowed even without a fixId.
Expand All @@ -42,6 +43,15 @@ const allowedCodeFixDescriptionPrefixes = [
"Add import from ",
"Update import from ",
"Change 'import' to 'import type'",
"Add annotation of type",
"Add return type",
"Add satisfies and an inline type assertion",
"Annotate types of properties expando function",
"Extract default export to variable",
"Extract base class to variable",
"Extract binding expressions to variable",
"Extract to variable and replace with",
"Mark array literal as const",
];

function getManualTests(): Set<string> {
Expand Down Expand Up @@ -1857,7 +1867,7 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string {
break;
case "organizeImportsTypeOrder":
if (!ts.isStringLiteralLike(prop.initializer)) {
return undefined;
throw new Error(`Expected string literal for organizeImportsTypeOrder, got ${prop.initializer.getText()}`);
}
switch (prop.initializer.text) {
case "last":
Expand All @@ -1870,7 +1880,7 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string {
preferences.push(`OrganizeImportsTypeOrder: lsutil.OrganizeImportsTypeOrderFirst`);
break;
default:
return undefined;
throw new Error(`Unsupported organizeImportsTypeOrder value: ${prop.initializer.text}`);
}
break;
case "autoImportFileExcludePatterns":
Expand Down
Loading