Closed
Description
Using v1.6.0-dev.20150805
.
For the following code, LanguageServices.getDocumentHighlights
reports only 1 highlight span for onChange
, where it should really report 2:
test.tsx
import * as React from "react";
export class Foo extends React.Component<{}, {}> {
public render() {
return (
<div>
<input onChange={this.onChange.bind(this)} />
</div>
);
}
onChange() {
console.log("changed");
}
}
You can reproduce this error with the sample code from #3688 (copied below):
var ts = require('typescript');
var fs = require('fs');
var source = fs.readFileSync('test.tsx').toString();
var sourceFile = ts.createSourceFile('test.tsx', source, 1, false);
var host = {
getCompilationSettings: function() {
return {
noResolve: true,
target: ts.ScriptTarget.ES5
};
},
getCurrentDirectory: function() {
return '';
},
getDefaultLibFileName: function() {
return 'lib.d.ts';
},
getScriptFileNames: function() {
return ['test.tsx'];
},
getScriptIsOpen: function() {
return true;
},
getScriptVersion: function() {
return '1';
},
getScriptSnapshot: function() {
return ts.ScriptSnapshot.fromString(source);
}
};
var documentRegistry = ts.createDocumentRegistry();
var languageServices = ts.createLanguageService(host, documentRegistry);
var onChangeFn = sourceFile.statements[1].members[1];
var highlights = languageServices.getDocumentHighlights('test.tsx', onChangeFn.name.pos, ['test.tsx']);
console.log(highlights[0].highlightSpans.length);