Skip to content

Commit 383bd1c

Browse files
committed
some more fixes
1 parent 4bb6839 commit 383bd1c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

internal/checker/checker.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5625,12 +5625,12 @@ func (c *Checker) checkExternalModuleExports(node *ast.Node) {
56255625
}
56265626

56275627
func (c *Checker) hasExportedMembers(moduleSymbol *ast.Symbol, isCommonJS bool) bool {
5628-
for id := range moduleSymbol.Exports {
5628+
for id := range moduleSymbol.Exports.Iter() {
56295629
if id != ast.InternalSymbolNameExportEquals {
56305630
if !isCommonJS {
56315631
return true
56325632
}
5633-
for _, declaration := range moduleSymbol.Exports[id].Declarations {
5633+
for _, declaration := range moduleSymbol.Exports.Get(id).Declarations {
56345634
if declaration.Kind != ast.KindJSTypeAliasDeclaration {
56355635
return true
56365636
}
@@ -11054,7 +11054,7 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l
1105411054
if !isUncheckedJS && c.isJSLiteralType(leftType) {
1105511055
return c.anyType
1105611056
}
11057-
if leftType.symbol == c.globalThisSymbol {
11057+
if leftType.symbol == c.denoGlobalThisSymbol {
1105811058
globalSymbol := c.denoGlobalThisSymbol.Exports.Get(right.Text())
1105911059
if globalSymbol != nil && globalSymbol.Flags&ast.SymbolFlagsBlockScoped != 0 {
1106011060
c.error(right, diagnostics.Property_0_does_not_exist_on_type_1, right.Text(), c.TypeToString(leftType))
@@ -12886,7 +12886,7 @@ func (c *Checker) checkObjectLiteral(node *ast.Node, checkMode CheckMode) *Type
1288612886
return result
1288712887
}
1288812888
// expando object literals have empty properties but filled exports -- skip straight to type creation
12889-
if len(node.Properties()) == 0 && node.Symbol() != nil && len(node.Symbol().Exports) != 0 {
12889+
if len(node.Properties()) == 0 && node.Symbol() != nil && node.Symbol().Exports.Len() != 0 {
1289012890
propertiesTable = node.Symbol().Exports
1289112891
return createObjectLiteralType()
1289212892
}
@@ -14293,7 +14293,7 @@ func (c *Checker) reportNonDefaultExport(moduleSymbol *ast.Symbol, node *ast.Nod
1429314293
return false
1429414294
}
1429514295
resolvedExternalModuleName := c.resolveExternalModuleName(decl, decl.ModuleSpecifier(), false /*ignoreErrors*/)
14296-
return resolvedExternalModuleName != nil && resolvedExternalModuleName.Exports[ast.InternalSymbolNameDefault] != nil
14296+
return resolvedExternalModuleName != nil && resolvedExternalModuleName.Exports.Get(ast.InternalSymbolNameDefault) != nil
1429714297
})
1429814298
if defaultExport != nil {
1429914299
diagnostic.AddRelatedInfo(createDiagnosticForNode(defaultExport, diagnostics.X_export_Asterisk_does_not_re_export_a_default))
@@ -15846,7 +15846,7 @@ func (c *Checker) getExportsOfModuleWorker(moduleSymbol *ast.Symbol) (exports as
1584615846
}
1584715847
var originalModule *ast.Symbol
1584815848
if moduleSymbol != nil {
15849-
if c.resolveSymbolEx(moduleSymbol.Exports[ast.InternalSymbolNameExportEquals], false /*dontResolveAlias*/) != nil {
15849+
if c.resolveSymbolEx(moduleSymbol.Exports.Get(ast.InternalSymbolNameExportEquals), false /*dontResolveAlias*/) != nil {
1585015850
originalModule = moduleSymbol
1585115851
}
1585215852
}
@@ -15857,10 +15857,10 @@ func (c *Checker) getExportsOfModuleWorker(moduleSymbol *ast.Symbol) (exports as
1585715857
exports = ast.NewSymbolTable()
1585815858
}
1585915859
// A CommonJS module defined by an 'export=' might also export typedefs, stored on the original module
15860-
if originalModule != nil && len(originalModule.Exports) > 1 {
15861-
for _, symbol := range originalModule.Exports {
15862-
if symbol.Flags&ast.SymbolFlagsType != 0 && symbol.Name != ast.InternalSymbolNameExportEquals && exports[symbol.Name] == nil {
15863-
exports[symbol.Name] = symbol
15860+
if originalModule != nil && originalModule.Exports.Len() > 1 {
15861+
for _, symbol := range originalModule.Exports.Iter() {
15862+
if symbol.Flags&ast.SymbolFlagsType != 0 && symbol.Name != ast.InternalSymbolNameExportEquals && exports.Get(symbol.Name) == nil {
15863+
exports.Set(symbol.Name, symbol)
1586415864
}
1586515865
}
1586615866
}
@@ -21642,23 +21642,23 @@ func (c *Checker) getDefaultOrUnknownFromTypeParameter(t *Type) *Type {
2164221642
}
2164321643

2164421644
func (c *Checker) getNamedMembers(members ast.SymbolTable, container *ast.Symbol) []*ast.Symbol {
21645-
if len(members) == 0 {
21645+
if members.Len() == 0 {
2164621646
return nil
2164721647
}
2164821648
// For classes and interfaces, we store explicitly declared members ahead of inherited members. This ensures we process
2164921649
// explicitly declared members first in type relations, which is beneficial because explicitly declared members are more
2165021650
// likely to contain discriminating differences. See for example https://github.com/microsoft/typescript-go/issues/1968.
21651-
result := make([]*ast.Symbol, 0, len(members))
21651+
result := make([]*ast.Symbol, 0, members.Len())
2165221652
var containedCount int
2165321653
if container != nil && container.Flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) != 0 {
21654-
for id, symbol := range members {
21654+
for id, symbol := range members.Iter() {
2165521655
if c.isNamedMember(symbol, id) && c.isDeclarationContainedBy(symbol, container) {
2165621656
result = append(result, symbol)
2165721657
}
2165821658
}
2165921659
containedCount = len(result)
2166021660
}
21661-
for id, symbol := range members {
21661+
for id, symbol := range members.Iter() {
2166221662
if c.isNamedMember(symbol, id) && (container == nil || container.Flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) == 0 || !c.isDeclarationContainedBy(symbol, container)) {
2166321663
result = append(result, symbol)
2166421664
}

internal/compiler/host.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package compiler
33
import (
44
"github.com/microsoft/typescript-go/internal/ast"
55
"github.com/microsoft/typescript-go/internal/core"
6+
"github.com/microsoft/typescript-go/internal/module"
67
"github.com/microsoft/typescript-go/internal/diagnostics"
78
"github.com/microsoft/typescript-go/internal/parser"
89
"github.com/microsoft/typescript-go/internal/tsoptions"

0 commit comments

Comments
 (0)