Merge pull request #29959 from Microsoft/noResolvedTypeOverwrite

Never overwrite resolved types of symbols
This commit is contained in:
Anders Hejlsberg 2019-02-19 12:22:44 -08:00 committed by GitHub
commit 071708f8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 11 deletions

View File

@ -5425,7 +5425,16 @@ namespace ts {
function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {
const links = getSymbolLinks(symbol);
return links.type || (links.type = getTypeOfVariableOrParameterOrPropertyWorker(symbol));
if (!links.type) {
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
// For a contextually typed parameter it is possible that a type has already
// been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
// to preserve this type.
if (!links.type) {
links.type = type;
}
}
return links.type;
}
function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol) {
@ -5469,7 +5478,7 @@ namespace ts {
if (symbol.flags & SymbolFlags.ValueModule) {
return getTypeOfFuncClassEnumModule(symbol);
}
return errorType;
return reportCircularityError(symbol);
}
let type: Type | undefined;
if (isInJSFile(declaration) &&
@ -5528,7 +5537,7 @@ namespace ts {
if (symbol.flags & SymbolFlags.ValueModule) {
return getTypeOfFuncClassEnumModule(symbol);
}
type = reportCircularityError(symbol);
return reportCircularityError(symbol);
}
return type;
}

View File

@ -4,11 +4,11 @@ export class StackOverflowTest {
constructor () {
this.testStackOverflow = this.testStackOverflow.bind(this)
>this.testStackOverflow = this.testStackOverflow.bind(this) : error
>this.testStackOverflow = this.testStackOverflow.bind(this) : any
>this.testStackOverflow : any
>this : this
>testStackOverflow : any
>this.testStackOverflow.bind(this) : error
>this.testStackOverflow.bind(this) : any
>this.testStackOverflow.bind : any
>this.testStackOverflow : any
>this : this

View File

@ -1,5 +1,5 @@
=== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts ===
for (var of of of) { }
>of : any
>of : error
>of : any

View File

@ -1,5 +1,5 @@
=== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts ===
for (var of in of) { }
>of : any
>of : error
>of : any

View File

@ -1,5 +1,5 @@
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement18.ts ===
for (var of of of) { }
>of : any
>of : error
>of : any

View File

@ -1,5 +1,5 @@
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts ===
for (var of in of) { }
>of : any
>of : error
>of : any

View File

@ -15,7 +15,7 @@ salt.pepper = function() {}
var cobalt = new cobalt.pitch();
>cobalt : any
>new cobalt.pitch() : error
>new cobalt.pitch() : any
>cobalt.pitch : any
>cobalt : any
>pitch : any

View File

@ -14,7 +14,7 @@ import self = require("recursiveExportAssignmentAndFindAliasedType7_moduleD");
var selfVar = self;
>selfVar : any
>self : error
>self : any
export = selfVar;
>selfVar : any