Check if container has locals before looking up properties
This commit is contained in:
parent
4e29b1883d
commit
b7c416cdeb
4 changed files with 50 additions and 1 deletions
|
@ -2401,7 +2401,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function lookupSymbolForName(name: string) {
|
||||
return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || container.locals.get(name);
|
||||
return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name));
|
||||
}
|
||||
|
||||
function bindPropertyAssignment(functionName: string, propertyAccessExpression: PropertyAccessExpression, isPrototypeProperty: boolean) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
=== tests/cases/compiler/foo.js ===
|
||||
module.exports = function () {
|
||||
>module : Symbol(export=, Decl(foo.js, 0, 0))
|
||||
>exports : Symbol(export=, Decl(foo.js, 0, 0))
|
||||
|
||||
class A { }
|
||||
>A : Symbol(A, Decl(foo.js, 0, 30))
|
||||
|
||||
return {
|
||||
c: A.b = 1,
|
||||
>c : Symbol(c, Decl(foo.js, 2, 10))
|
||||
>A : Symbol(A, Decl(foo.js, 0, 30))
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
=== tests/cases/compiler/foo.js ===
|
||||
module.exports = function () {
|
||||
>module.exports = function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; }
|
||||
>module.exports : any
|
||||
>module : any
|
||||
>exports : any
|
||||
>function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; }
|
||||
|
||||
class A { }
|
||||
>A : A
|
||||
|
||||
return {
|
||||
>{ c: A.b = 1, } : { [x: string]: any; c: number; }
|
||||
|
||||
c: A.b = 1,
|
||||
>c : number
|
||||
>A.b = 1 : 1
|
||||
>A.b : any
|
||||
>A : typeof A
|
||||
>b : any
|
||||
>1 : 1
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// @allowJs: true
|
||||
// @noEmit: true
|
||||
|
||||
// @filename: foo.js
|
||||
module.exports = function () {
|
||||
class A { }
|
||||
return {
|
||||
c: A.b = 1,
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue