mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Avoid bogus circularity error on context sensitive expando assingment (#50487)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
parent
e0124040f0
commit
cfd550e397
@ -28947,7 +28947,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left);
|
||||
return isInJSFile(decl) || decl === binaryExpression.left ? undefined : getTypeOfExpression(binaryExpression.left);
|
||||
}
|
||||
case AssignmentDeclarationKind.ExportsProperty:
|
||||
case AssignmentDeclarationKind.Prototype:
|
||||
|
||||
19
tests/baselines/reference/contextualReturnTypeOfIIFE2.js
Normal file
19
tests/baselines/reference/contextualReturnTypeOfIIFE2.js
Normal file
@ -0,0 +1,19 @@
|
||||
//// [contextualReturnTypeOfIIFE2.ts]
|
||||
declare namespace app {
|
||||
function foo(): void;
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
const someFun = (arg: number) => {};
|
||||
return { someFun };
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
|
||||
|
||||
//// [contextualReturnTypeOfIIFE2.js]
|
||||
app.foo.bar = (function () {
|
||||
var someFun = function (arg) { };
|
||||
return { someFun: someFun };
|
||||
})();
|
||||
app.foo.bar.someFun(1);
|
||||
@ -0,0 +1,33 @@
|
||||
=== tests/cases/compiler/contextualReturnTypeOfIIFE2.ts ===
|
||||
declare namespace app {
|
||||
>app : Symbol(app, Decl(contextualReturnTypeOfIIFE2.ts, 0, 0), Decl(contextualReturnTypeOfIIFE2.ts, 2, 1))
|
||||
|
||||
function foo(): void;
|
||||
>foo : Symbol(foo, Decl(contextualReturnTypeOfIIFE2.ts, 0, 23), Decl(contextualReturnTypeOfIIFE2.ts, 4, 4))
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
>app.foo.bar : Symbol(app.foo.bar, Decl(contextualReturnTypeOfIIFE2.ts, 2, 1))
|
||||
>app.foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE2.ts, 0, 23), Decl(contextualReturnTypeOfIIFE2.ts, 4, 4))
|
||||
>app : Symbol(app, Decl(contextualReturnTypeOfIIFE2.ts, 0, 0), Decl(contextualReturnTypeOfIIFE2.ts, 2, 1))
|
||||
>foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE2.ts, 0, 23), Decl(contextualReturnTypeOfIIFE2.ts, 4, 4))
|
||||
>bar : Symbol(app.foo.bar, Decl(contextualReturnTypeOfIIFE2.ts, 2, 1))
|
||||
|
||||
const someFun = (arg: number) => {};
|
||||
>someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE2.ts, 5, 7))
|
||||
>arg : Symbol(arg, Decl(contextualReturnTypeOfIIFE2.ts, 5, 19))
|
||||
|
||||
return { someFun };
|
||||
>someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE2.ts, 6, 10))
|
||||
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
>app.foo.bar.someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE2.ts, 6, 10))
|
||||
>app.foo.bar : Symbol(app.foo.bar, Decl(contextualReturnTypeOfIIFE2.ts, 2, 1))
|
||||
>app.foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE2.ts, 0, 23), Decl(contextualReturnTypeOfIIFE2.ts, 4, 4))
|
||||
>app : Symbol(app, Decl(contextualReturnTypeOfIIFE2.ts, 0, 0), Decl(contextualReturnTypeOfIIFE2.ts, 2, 1))
|
||||
>foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE2.ts, 0, 23), Decl(contextualReturnTypeOfIIFE2.ts, 4, 4))
|
||||
>bar : Symbol(app.foo.bar, Decl(contextualReturnTypeOfIIFE2.ts, 2, 1))
|
||||
>someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE2.ts, 6, 10))
|
||||
|
||||
41
tests/baselines/reference/contextualReturnTypeOfIIFE2.types
Normal file
41
tests/baselines/reference/contextualReturnTypeOfIIFE2.types
Normal file
@ -0,0 +1,41 @@
|
||||
=== tests/cases/compiler/contextualReturnTypeOfIIFE2.ts ===
|
||||
declare namespace app {
|
||||
>app : typeof app
|
||||
|
||||
function foo(): void;
|
||||
>foo : typeof foo
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
>app.foo.bar = (function () { const someFun = (arg: number) => {}; return { someFun };})() : { someFun: (arg: number) => void; }
|
||||
>app.foo.bar : { someFun: (arg: number) => void; }
|
||||
>app.foo : typeof app.foo
|
||||
>app : typeof app
|
||||
>foo : typeof app.foo
|
||||
>bar : { someFun: (arg: number) => void; }
|
||||
>(function () { const someFun = (arg: number) => {}; return { someFun };})() : { someFun: (arg: number) => void; }
|
||||
>(function () { const someFun = (arg: number) => {}; return { someFun };}) : () => { someFun: (arg: number) => void; }
|
||||
>function () { const someFun = (arg: number) => {}; return { someFun };} : () => { someFun: (arg: number) => void; }
|
||||
|
||||
const someFun = (arg: number) => {};
|
||||
>someFun : (arg: number) => void
|
||||
>(arg: number) => {} : (arg: number) => void
|
||||
>arg : number
|
||||
|
||||
return { someFun };
|
||||
>{ someFun } : { someFun: (arg: number) => void; }
|
||||
>someFun : (arg: number) => void
|
||||
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
>app.foo.bar.someFun(1) : void
|
||||
>app.foo.bar.someFun : (arg: number) => void
|
||||
>app.foo.bar : { someFun: (arg: number) => void; }
|
||||
>app.foo : typeof app.foo
|
||||
>app : typeof app
|
||||
>foo : typeof app.foo
|
||||
>bar : { someFun: (arg: number) => void; }
|
||||
>someFun : (arg: number) => void
|
||||
>1 : 1
|
||||
|
||||
21
tests/baselines/reference/contextualReturnTypeOfIIFE3.js
Normal file
21
tests/baselines/reference/contextualReturnTypeOfIIFE3.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [contextualReturnTypeOfIIFE3.ts]
|
||||
declare namespace app {
|
||||
var foo: {
|
||||
bar: {
|
||||
someFun: (arg: number) => void;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
return { someFun(arg) {} };
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
|
||||
|
||||
//// [contextualReturnTypeOfIIFE3.js]
|
||||
app.foo.bar = (function () {
|
||||
return { someFun: function (arg) { } };
|
||||
})();
|
||||
app.foo.bar.someFun(1);
|
||||
@ -0,0 +1,40 @@
|
||||
=== tests/cases/compiler/contextualReturnTypeOfIIFE3.ts ===
|
||||
declare namespace app {
|
||||
>app : Symbol(app, Decl(contextualReturnTypeOfIIFE3.ts, 0, 0))
|
||||
|
||||
var foo: {
|
||||
>foo : Symbol(foo, Decl(contextualReturnTypeOfIIFE3.ts, 1, 5))
|
||||
|
||||
bar: {
|
||||
>bar : Symbol(bar, Decl(contextualReturnTypeOfIIFE3.ts, 1, 12))
|
||||
|
||||
someFun: (arg: number) => void;
|
||||
>someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE3.ts, 2, 10))
|
||||
>arg : Symbol(arg, Decl(contextualReturnTypeOfIIFE3.ts, 3, 16))
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
>app.foo.bar : Symbol(bar, Decl(contextualReturnTypeOfIIFE3.ts, 1, 12))
|
||||
>app.foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE3.ts, 1, 5))
|
||||
>app : Symbol(app, Decl(contextualReturnTypeOfIIFE3.ts, 0, 0))
|
||||
>foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE3.ts, 1, 5))
|
||||
>bar : Symbol(bar, Decl(contextualReturnTypeOfIIFE3.ts, 1, 12))
|
||||
|
||||
return { someFun(arg) {} };
|
||||
>someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE3.ts, 9, 10))
|
||||
>arg : Symbol(arg, Decl(contextualReturnTypeOfIIFE3.ts, 9, 19))
|
||||
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
>app.foo.bar.someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE3.ts, 2, 10))
|
||||
>app.foo.bar : Symbol(bar, Decl(contextualReturnTypeOfIIFE3.ts, 1, 12))
|
||||
>app.foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE3.ts, 1, 5))
|
||||
>app : Symbol(app, Decl(contextualReturnTypeOfIIFE3.ts, 0, 0))
|
||||
>foo : Symbol(app.foo, Decl(contextualReturnTypeOfIIFE3.ts, 1, 5))
|
||||
>bar : Symbol(bar, Decl(contextualReturnTypeOfIIFE3.ts, 1, 12))
|
||||
>someFun : Symbol(someFun, Decl(contextualReturnTypeOfIIFE3.ts, 2, 10))
|
||||
|
||||
47
tests/baselines/reference/contextualReturnTypeOfIIFE3.types
Normal file
47
tests/baselines/reference/contextualReturnTypeOfIIFE3.types
Normal file
@ -0,0 +1,47 @@
|
||||
=== tests/cases/compiler/contextualReturnTypeOfIIFE3.ts ===
|
||||
declare namespace app {
|
||||
>app : typeof app
|
||||
|
||||
var foo: {
|
||||
>foo : { bar: { someFun: (arg: number) => void; }; }
|
||||
|
||||
bar: {
|
||||
>bar : { someFun: (arg: number) => void; }
|
||||
|
||||
someFun: (arg: number) => void;
|
||||
>someFun : (arg: number) => void
|
||||
>arg : number
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
>app.foo.bar = (function () { return { someFun(arg) {} };})() : { someFun(arg: number): void; }
|
||||
>app.foo.bar : { someFun: (arg: number) => void; }
|
||||
>app.foo : { bar: { someFun: (arg: number) => void; }; }
|
||||
>app : typeof app
|
||||
>foo : { bar: { someFun: (arg: number) => void; }; }
|
||||
>bar : { someFun: (arg: number) => void; }
|
||||
>(function () { return { someFun(arg) {} };})() : { someFun(arg: number): void; }
|
||||
>(function () { return { someFun(arg) {} };}) : () => { someFun(arg: number): void; }
|
||||
>function () { return { someFun(arg) {} };} : () => { someFun(arg: number): void; }
|
||||
|
||||
return { someFun(arg) {} };
|
||||
>{ someFun(arg) {} } : { someFun(arg: number): void; }
|
||||
>someFun : (arg: number) => void
|
||||
>arg : number
|
||||
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
>app.foo.bar.someFun(1) : void
|
||||
>app.foo.bar.someFun : (arg: number) => void
|
||||
>app.foo.bar : { someFun: (arg: number) => void; }
|
||||
>app.foo : { bar: { someFun: (arg: number) => void; }; }
|
||||
>app : typeof app
|
||||
>foo : { bar: { someFun: (arg: number) => void; }; }
|
||||
>bar : { someFun: (arg: number) => void; }
|
||||
>someFun : (arg: number) => void
|
||||
>1 : 1
|
||||
|
||||
13
tests/cases/compiler/contextualReturnTypeOfIIFE2.ts
Normal file
13
tests/cases/compiler/contextualReturnTypeOfIIFE2.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @lib: esnext
|
||||
// @noImplicitAny: true
|
||||
|
||||
declare namespace app {
|
||||
function foo(): void;
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
const someFun = (arg: number) => {};
|
||||
return { someFun };
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
16
tests/cases/compiler/contextualReturnTypeOfIIFE3.ts
Normal file
16
tests/cases/compiler/contextualReturnTypeOfIIFE3.ts
Normal file
@ -0,0 +1,16 @@
|
||||
// @lib: esnext
|
||||
// @noImplicitAny: true
|
||||
|
||||
declare namespace app {
|
||||
var foo: {
|
||||
bar: {
|
||||
someFun: (arg: number) => void;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
app.foo.bar = (function () {
|
||||
return { someFun(arg) {} };
|
||||
})();
|
||||
|
||||
app.foo.bar.someFun(1);
|
||||
Loading…
x
Reference in New Issue
Block a user