Fix crash when the element instance type was undefined
This commit is contained in:
parent
649e40b171
commit
ddd78fb609
|
@ -7261,7 +7261,7 @@ namespace ts {
|
|||
if (links.jsxFlags & JsxFlags.ClassElement) {
|
||||
let elemInstanceType = getJsxElementInstanceType(node);
|
||||
|
||||
if (isTypeAny(elemInstanceType)) {
|
||||
if (!elemInstanceType || isTypeAny(elemInstanceType)) {
|
||||
return links.resolvedJsxType = anyType;
|
||||
}
|
||||
|
||||
|
|
27
tests/baselines/reference/jsxViaImport.errors.txt
Normal file
27
tests/baselines/reference/jsxViaImport.errors.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
tests/cases/compiler/consumer.tsx(5,17): error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures.
|
||||
|
||||
|
||||
==== tests/cases/compiler/consumer.tsx (1 errors) ====
|
||||
/// <reference path="component.d.ts" />
|
||||
import BaseComponent = require('BaseComponent');
|
||||
class TestComponent extends React.Component<any, {}> {
|
||||
render() {
|
||||
return <BaseComponent />;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2604: JSX element type 'BaseComponent' does not have any construct or call signatures.
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/component.d.ts (0 errors) ====
|
||||
|
||||
declare module JSX {
|
||||
interface ElementAttributesProperty { props; }
|
||||
}
|
||||
declare module React {
|
||||
class Component<T, U> { }
|
||||
}
|
||||
declare module "BaseComponent" {
|
||||
var base: React.Component<any, {}>;
|
||||
export = base;
|
||||
}
|
||||
|
43
tests/baselines/reference/jsxViaImport.js
Normal file
43
tests/baselines/reference/jsxViaImport.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
//// [tests/cases/compiler/jsxViaImport.tsx] ////
|
||||
|
||||
//// [component.d.ts]
|
||||
|
||||
declare module JSX {
|
||||
interface ElementAttributesProperty { props; }
|
||||
}
|
||||
declare module React {
|
||||
class Component<T, U> { }
|
||||
}
|
||||
declare module "BaseComponent" {
|
||||
var base: React.Component<any, {}>;
|
||||
export = base;
|
||||
}
|
||||
|
||||
//// [consumer.tsx]
|
||||
/// <reference path="component.d.ts" />
|
||||
import BaseComponent = require('BaseComponent');
|
||||
class TestComponent extends React.Component<any, {}> {
|
||||
render() {
|
||||
return <BaseComponent />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [consumer.jsx]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
/// <reference path="component.d.ts" />
|
||||
var BaseComponent = require('BaseComponent');
|
||||
var TestComponent = (function (_super) {
|
||||
__extends(TestComponent, _super);
|
||||
function TestComponent() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
TestComponent.prototype.render = function () {
|
||||
return <BaseComponent />;
|
||||
};
|
||||
return TestComponent;
|
||||
})(React.Component);
|
23
tests/cases/compiler/jsxViaImport.tsx
Normal file
23
tests/cases/compiler/jsxViaImport.tsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
//@jsx: preserve
|
||||
//@module: commonjs
|
||||
|
||||
//@filename: component.d.ts
|
||||
declare module JSX {
|
||||
interface ElementAttributesProperty { props; }
|
||||
}
|
||||
declare module React {
|
||||
class Component<T, U> { }
|
||||
}
|
||||
declare module "BaseComponent" {
|
||||
var base: React.Component<any, {}>;
|
||||
export = base;
|
||||
}
|
||||
|
||||
//@filename: consumer.tsx
|
||||
/// <reference path="component.d.ts" />
|
||||
import BaseComponent = require('BaseComponent');
|
||||
class TestComponent extends React.Component<any, {}> {
|
||||
render() {
|
||||
return <BaseComponent />;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue