Closed
Description
TypeScript Version: 3.9.0-dev.20200327
Search Terms:
Expected behavior:
No error
Actual behavior:
Error:
Property 'name' does not exist on type 'object | Function'.
Property 'name' does not exist on type 'object'.(2339)
Related Issues:
Code
function foo(instance: Function | object) {
if (typeof instance === 'function') {
if (instance.prototype == null || instance.prototype.constructor == null) {
return instance.name;
}
}
}
Output
"use strict";
function foo(instance) {
if (typeof instance === 'function') {
if (instance.prototype == null || instance.prototype.constructor == null) {
return instance.name;
}
}
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": 2,
"target": "ES2017",
"jsx": "React",
"module": "ESNext"
}
}
Playground Link: Provided