-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: nightly (Version 2.0.0-dev.20160707)
Code
interface IItem {
id: string;
}
interface ITextItem extends IItem {
text: string;
}
function isText(item: IItem): item is ITextItem {
return item['text'] != null;
}
interface IContent {
items: IItem[];
}
let contents = [] as IContent[];
let item = { id: 'id', text: '\n' } as IItem;
if (isText(item)) {
console.log(item.text);
contents.forEach(content => {
content.items.forEach(i => {
if (isText(i) && i.text === item.text) {
// do soemthing
}
});
});
}
Expected behavior:
Compilation without errors like with version 1.8.10
Actual behavior:
Error during compilation:
test.ts(24,49): error TS2339: Property 'text' does not exist on type 'Item'.
The first reference of item.text is working correctly. The second in the lambda function in the forEach not.
This might by related to #8010.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created