Skip to content
Open
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
12 changes: 8 additions & 4 deletions tsc/internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14691,10 +14691,14 @@ func (c *Checker) getLateBoundSymbol(symbol *ast.Symbol) *ast.Symbol {
if links.lateSymbol == nil && core.Some(symbol.Declarations(), c.hasLateBindableName) {
// force late binding of members/exports. This will set the late-bound symbol
parent := c.getMergedSymbol(symbol.Parent())
if core.Some(symbol.Declarations(), ast.HasStaticModifier) {
c.getExportsOfSymbol(parent)
} else {
c.getMembersOfSymbol(parent)
// Parent can be nil for top-level script expandos (SourceFile has no symbol) when
// checking was skipped (--noCheck) and late binding has not run yet.
if parent != nil {
if core.Some(symbol.Declarations(), ast.HasStaticModifier) {
c.getExportsOfSymbol(parent)
} else {
c.getMembersOfSymbol(parent)
}
}
}
if links.lateSymbol == nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//// [tests/cases/compiler/noCheckExpandoElementAccessAssignment.ts] ////

//// [noCheckExpandoElementAccessAssignment.ts]
const k = "bar";
foo[k] = 1;
function foo() {}




//// [noCheckExpandoElementAccessAssignment.d.ts]
declare const k = "bar";
declare function foo(): void;
declare namespace foo {
var bar: number;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/noCheckExpandoElementAccessAssignment.ts] ////

=== noCheckExpandoElementAccessAssignment.ts ===
const k = "bar";
>k : Symbol(k, Decl(noCheckExpandoElementAccessAssignment.ts, 0, 5))

foo[k] = 1;
>foo : Symbol(foo, Decl(noCheckExpandoElementAccessAssignment.ts, 1, 11))
>k : Symbol(k, Decl(noCheckExpandoElementAccessAssignment.ts, 0, 5))

function foo() {}
>foo : Symbol(foo, Decl(noCheckExpandoElementAccessAssignment.ts, 1, 11))

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//// [tests/cases/compiler/noCheckExpandoElementAccessAssignment.ts] ////

=== noCheckExpandoElementAccessAssignment.ts ===
const k = "bar";
>k : "bar"
>"bar" : "bar"

foo[k] = 1;
>foo[k] = 1 : 1
>foo[k] : number
>foo : { (): void; bar: number; }
>k : "bar"
>1 : 1

function foo() {}
>foo : { (): void; bar: number; }

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @target: es2015
// @noCheck: true
// @emitDeclarationOnly: true
// @declaration: true

const k = "bar";
foo[k] = 1;
function foo() {}