Skip to content

Small fix in getIsContextSensitiveAssignmentOrContextType #39053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2020
Merged
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
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22585,7 +22585,7 @@ namespace ts {
const id = lhs.expression;
const parentSymbol = resolveName(id, id.escapedText, SymbolFlags.Value, undefined, id.escapedText, /*isUse*/ true);
if (parentSymbol) {
const annotated = getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
const annotated = parentSymbol.valueDeclaration && getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
if (annotated) {
const nameStr = getElementOrPropertyAccessName(lhs);
if (nameStr !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests/cases/compiler/expandoFunctionContextualTypesNoValue.ts(2,17): error TS2307: Cannot find module 'blah' or its corresponding type declarations.


==== tests/cases/compiler/expandoFunctionContextualTypesNoValue.ts (1 errors) ====
// GH #38532
import Foo from "blah";
~~~~~~
!!! error TS2307: Cannot find module 'blah' or its corresponding type declarations.

export function Foo() { }

Foo.bar = () => { };

18 changes: 18 additions & 0 deletions tests/baselines/reference/expandoFunctionContextualTypesNoValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [expandoFunctionContextualTypesNoValue.ts]
// GH #38532
import Foo from "blah";

export function Foo() { }

Foo.bar = () => { };


//// [expandoFunctionContextualTypesNoValue.js]
"use strict";
exports.__esModule = true;
exports.Foo = void 0;
// GH #38532
var blah_1 = require("blah");
function Foo() { }
exports.Foo = Foo;
blah_1["default"].bar = function () { };
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/expandoFunctionContextualTypesNoValue.ts ===
// GH #38532
import Foo from "blah";
>Foo : Symbol(Foo, Decl(expandoFunctionContextualTypesNoValue.ts, 1, 23), Decl(expandoFunctionContextualTypesNoValue.ts, 1, 6))

export function Foo() { }
>Foo : Symbol(Foo, Decl(expandoFunctionContextualTypesNoValue.ts, 1, 23), Decl(expandoFunctionContextualTypesNoValue.ts, 3, 25))

Foo.bar = () => { };
>Foo.bar : Symbol(Foo.bar, Decl(expandoFunctionContextualTypesNoValue.ts, 3, 25))
>Foo : Symbol(Foo, Decl(expandoFunctionContextualTypesNoValue.ts, 1, 23), Decl(expandoFunctionContextualTypesNoValue.ts, 1, 6))
>bar : Symbol(Foo.bar, Decl(expandoFunctionContextualTypesNoValue.ts, 3, 25))

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
=== tests/cases/compiler/expandoFunctionContextualTypesNoValue.ts ===
// GH #38532
import Foo from "blah";
>Foo : any

export function Foo() { }
>Foo : typeof import("tests/cases/compiler/expandoFunctionContextualTypesNoValue").Foo

Foo.bar = () => { };
>Foo.bar = () => { } : () => void
>Foo.bar : () => void
>Foo : typeof import("tests/cases/compiler/expandoFunctionContextualTypesNoValue").Foo
>bar : () => void
>() => { } : () => void

6 changes: 6 additions & 0 deletions tests/cases/compiler/expandoFunctionContextualTypesNoValue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// GH #38532
import Foo from "blah";

export function Foo() { }

Foo.bar = () => { };