mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-23 10:29:01 -06:00
Fix crash caused by cyclic defaults (#30532)
This commit is contained in:
parent
e72f006664
commit
b86dea03f2
@ -5474,9 +5474,6 @@ namespace ts {
|
||||
}
|
||||
return type;
|
||||
}
|
||||
if (declaration.kind === SyntaxKind.ExportAssignment) {
|
||||
return widenTypeForVariableLikeDeclaration(checkExpressionCached((<ExportAssignment>declaration).expression), declaration);
|
||||
}
|
||||
|
||||
// Handle variable, parameter or property
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
@ -5487,7 +5484,10 @@ namespace ts {
|
||||
return reportCircularityError(symbol);
|
||||
}
|
||||
let type: Type | undefined;
|
||||
if (isInJSFile(declaration) &&
|
||||
if (declaration.kind === SyntaxKind.ExportAssignment) {
|
||||
type = widenTypeForVariableLikeDeclaration(checkExpressionCached((<ExportAssignment>declaration).expression), declaration);
|
||||
}
|
||||
else if (isInJSFile(declaration) &&
|
||||
(isCallExpression(declaration) || isBinaryExpression(declaration) || isPropertyAccessExpression(declaration) && isBinaryExpression(declaration.parent))) {
|
||||
type = getWidenedTypeFromAssignmentDeclaration(symbol);
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
tests/cases/compiler/QSpinner.js(3,1): error TS7022: 'default' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
|
||||
|
||||
|
||||
==== tests/cases/compiler/QSpinner.js (1 errors) ====
|
||||
import DefaultSpinner from './QSpinner'
|
||||
|
||||
export default {
|
||||
~~~~~~~~~~~~~~~~
|
||||
mixins: [DefaultSpinner],
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
name: 'QSpinner'
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~
|
||||
!!! error TS7022: 'default' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
//// [QSpinner.js]
|
||||
import DefaultSpinner from './QSpinner'
|
||||
|
||||
export default {
|
||||
mixins: [DefaultSpinner],
|
||||
name: 'QSpinner'
|
||||
}
|
||||
|
||||
|
||||
//// [QSpinner.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var QSpinner_1 = require("./QSpinner");
|
||||
exports["default"] = {
|
||||
mixins: [QSpinner_1["default"]],
|
||||
name: 'QSpinner'
|
||||
};
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/QSpinner.js ===
|
||||
import DefaultSpinner from './QSpinner'
|
||||
>DefaultSpinner : Symbol(DefaultSpinner, Decl(QSpinner.js, 0, 6))
|
||||
|
||||
export default {
|
||||
mixins: [DefaultSpinner],
|
||||
>mixins : Symbol(mixins, Decl(QSpinner.js, 2, 16))
|
||||
>DefaultSpinner : Symbol(DefaultSpinner, Decl(QSpinner.js, 0, 6))
|
||||
|
||||
name: 'QSpinner'
|
||||
>name : Symbol(name, Decl(QSpinner.js, 3, 27))
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/QSpinner.js ===
|
||||
import DefaultSpinner from './QSpinner'
|
||||
>DefaultSpinner : any
|
||||
|
||||
export default {
|
||||
>{ mixins: [DefaultSpinner], name: 'QSpinner'} : { mixins: any[]; name: string; }
|
||||
|
||||
mixins: [DefaultSpinner],
|
||||
>mixins : any[]
|
||||
>[DefaultSpinner] : any[]
|
||||
>DefaultSpinner : any
|
||||
|
||||
name: 'QSpinner'
|
||||
>name : string
|
||||
>'QSpinner' : "QSpinner"
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @strict: true
|
||||
// @outDir: ./out
|
||||
// @filename: QSpinner.js
|
||||
import DefaultSpinner from './QSpinner'
|
||||
|
||||
export default {
|
||||
mixins: [DefaultSpinner],
|
||||
name: 'QSpinner'
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user