MCPcopy Create free account
hub / github.com/microsoft/typescript-go / bindFunctionOrConstructorType

Method bindFunctionOrConstructorType

internal/binder/binder.go:991–1004  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

989}
990
991func (b *Binder) bindFunctionOrConstructorType(node *ast.Node) {
992 // For a given function symbol "<...>(...) => T" we want to generate a symbol identical
993 // to the one we would get for: { <...>(...): T }
994 //
995 // We do that by making an anonymous type literal symbol, and then setting the function
996 // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
997 // from an actual type literal symbol you would have gotten had you used the long form.
998 symbol := b.newSymbol(ast.SymbolFlagsSignature, b.getDeclarationName(node))
999 b.addDeclarationToSymbol(symbol, node, ast.SymbolFlagsSignature)
1000 typeLiteralSymbol := b.newSymbol(ast.SymbolFlagsTypeLiteral, ast.InternalSymbolNameType)
1001 b.addDeclarationToSymbol(typeLiteralSymbol, node, ast.SymbolFlagsTypeLiteral)
1002 typeLiteralSymbol.Members = make(ast.SymbolTable)
1003 typeLiteralSymbol.Members[symbol.Name] = symbol
1004}
1005
1006func (b *Binder) addLateBoundAssignmentDeclarationToSymbol(node *ast.Node, symbol *ast.Symbol) {
1007 exports := ast.GetExports(symbol)

Callers 1

bindMethod · 0.95

Calls 4

newSymbolMethod · 0.95
getDeclarationNameMethod · 0.95
makeFunction · 0.50

Tested by

no test coverage detected