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

Method bindClassLikeDeclaration

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

Source from the content-addressed store, hash-verified

943}
944
945func (b *Binder) bindClassLikeDeclaration(node *ast.Node) {
946 name := node.Name()
947 switch node.Kind {
948 case ast.KindClassDeclaration:
949 b.bindBlockScopedDeclaration(node, ast.SymbolFlagsClass, ast.SymbolFlagsClassExcludes)
950 case ast.KindClassExpression:
951 nameText := ast.InternalSymbolNameClass
952 if name != nil {
953 nameText = name.Text()
954 b.classifiableNames.Add(nameText)
955 }
956 b.bindAnonymousDeclaration(node, ast.SymbolFlagsClass, nameText)
957 }
958 symbol := node.Symbol()
959 // TypeScript 1.0 spec (April 2014): 8.4
960 // Every class automatically contains a static property member named 'prototype', the
961 // type of which is an instantiation of the class type with type Any supplied as a type
962 // argument for each type parameter. It is an error to explicitly declare a static
963 // property member with the name 'prototype'.
964 //
965 // Note: we check for this here because this class may be merging into a module. The
966 // module might have an exported variable called 'prototype'. We can't allow that as
967 // that would clash with the built-in 'prototype' for the class.
968 prototypeSymbol := b.newSymbol(ast.SymbolFlagsProperty|ast.SymbolFlagsPrototype, "prototype")
969 symbolExport := ast.GetExports(symbol)[prototypeSymbol.Name]
970 if symbolExport != nil {
971 b.errorOnNode(symbolExport.Declarations[0], diagnostics.Duplicate_identifier_0, ast.SymbolName(prototypeSymbol))
972 }
973 ast.GetExports(symbol)[prototypeSymbol.Name] = prototypeSymbol
974 prototypeSymbol.Parent = symbol
975}
976
977func (b *Binder) bindPropertyOrMethodOrAccessor(node *ast.Node, symbolFlags ast.SymbolFlags, symbolExcludes ast.SymbolFlags) {
978 if !b.file.IsDeclarationFile && node.Flags&ast.NodeFlagsAmbient == 0 && ast.IsAsyncFunction(node) {

Callers 1

bindMethod · 0.95

Calls 10

newSymbolMethod · 0.95
errorOnNodeMethod · 0.95
GetExportsFunction · 0.92
SymbolNameFunction · 0.92
NameMethod · 0.65
TextMethod · 0.65
AddMethod · 0.65
SymbolMethod · 0.65

Tested by

no test coverage detected