Skip to content

Commit f7d20b6

Browse files
Copilotweswigham
andauthored
Preserve synthesized signature semantics in owned template AST
Co-authored-by: weswigham <[email protected]>
1 parent a6da8d9 commit f7d20b6

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎tsc/internal/checker/checker.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31161,6 +31161,8 @@ func (c *Checker) newSetterFunctionType(t *Type) *Type {
3116131161

3116231162
// Creates a synthetic `Signature` corresponding to a call signature.
3116331163
func (c *Checker) newCallSignature(typeParameters []*Type, thisParameter *ast.Symbol, parameters []*ast.Symbol, returnType *Type) *Signature {
31164+
// The shared declaration supplies syntax and source-file identity only;
31165+
// parameter and return types are stored on the signature.
3116431166
decl := GetSyntheticSignatureSourceFile().Statements.Nodes[0].Type()
3116531167
return c.newSignature(SignatureFlagsNone, decl, typeParameters, thisParameter, parameters, returnType, nil, len(parameters))
3116631168
}

‎tsc/internal/checker/syntheticsignature.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ import (
1212
const SyntheticSignatureFileName tspath.RootedFilePath = "tsgo://synthetic/signatures.d.ts"
1313

1414
var syntheticSignatureSourceFile = sync.OnceValue(func() *ast.SourceFile {
15-
return parser.ParseSourceFile(ast.SourceFileParseOptions{
15+
file := parser.ParseSourceFile(ast.SourceFileParseOptions{
1616
FileName: SyntheticSignatureFileName,
1717
PathKey: tspath.CaseSensitive.PathKey(tspath.RootedPath(SyntheticSignatureFileName)),
1818
}, "type SyntheticSignature = () => any;", core.ScriptKindTS)
19+
// Keep the placeholder synthesized so declaration serialization uses the
20+
// signature's types rather than treating this as a bound source declaration.
21+
declaration := file.Statements.Nodes[0].Type()
22+
declaration.Loc = core.UndefinedTextRange()
23+
declaration.Type().Loc = core.UndefinedTextRange()
24+
return file
1925
})
2026

2127
// GetSyntheticSignatureSourceFile provides an immutable, shared AST for synthetic

0 commit comments

Comments
 (0)