mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Small fix in getIsContextSensitiveAssignmentOrContextType
Test that `parentSymbol.valueDeclaration` exists. Fixes #38532
This commit is contained in:
parent
8231519b85
commit
0432954f2d
@ -22589,7 +22589,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) {
|
||||
|
||||
@ -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 = () => { };
|
||||
|
||||
@ -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 () { };
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
// GH #38532
|
||||
import Foo from "blah";
|
||||
|
||||
export function Foo() { }
|
||||
|
||||
Foo.bar = () => { };
|
||||
Loading…
x
Reference in New Issue
Block a user