Skip to content

static toString with incorrect type breaks instanceof #12709

Closed
@kieferrm

Description

@kieferrm

See microsoft/vscode#16819

TypeScript Version: [email protected]

  • VSCode Version: Code - Insiders 1.8.0-insider (0d65ced, 2016-12-07T07:05:09.124Z)
  • OS Version: Darwin x64 15.6.0

Code

export abstract class Marker {
	static toString(markers: Marker[]): string {
		return '';
	}
}

export class Placeholder extends Marker {
	constructor(public name: string = '', public defaultValue: Marker[]) {
		super();
	}
}

function foo(marker: Marker) {
	if (marker instanceof Placeholder) {
		console.log(marker.name);
		console.log(marker.defaultValue);
	}
}

foo(null);

Expected behavior:
No erros are shown in the vscode editor

Actual behavior:
screen shot 2016-12-07 at 8 55 21 am

When the static toString is removed or renamed the problem goes away.

Metadata

Metadata

Assignees

Labels

FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions