Closed
Description
TypeScript Version: 2.1.1
Crash when calling getDocumentHighlights
on A
of const A = ({ B: { C } }: any) => 1;
Code
import * as ts from "typescript";
export function createLanguageServiceHost(fileName: string, source: string): ts.LanguageServiceHost {
return {
getCompilationSettings: () => null,
getCurrentDirectory: () => "",
getDefaultLibFileName: () => "lib.d.ts",
getScriptFileNames: () => [fileName],
getScriptSnapshot: (name: string) => ts.ScriptSnapshot.fromString(name === fileName ? source : ""),
getScriptVersion: () => "1",
log: () => { /* */ },
};
}
export function createLanguageService(fileName: string, source: string) {
const languageServiceHost = createLanguageServiceHost(fileName, source);
return ts.createLanguageService(languageServiceHost);
}
let languageService = createLanguageService("a.ts", "const A = ({ B: { C } }: any) => 1;");
languageService.getDocumentHighlights("a.ts", 6, ["a.ts"]);
Expected behavior:
no crash
Actual behavior:
crash
TypeError: Cannot read property 'flags' of undefined
at displayPartKind (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:62878:31)
at symbolPart (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:62876:34)
at Object.writeSymbol (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:62863:31)
at buildBindingElementDisplay (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:25225:28)
at /Volumes/git/customRules/node_modules/typescript/lib/typescript.js:25206:110
at buildDisplayForCommaSeparatedList (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:25252:21)
at buildBindingPatternDisplay (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:25206:21)
at buildParameterDisplay (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:25190:21)
at buildDisplayForParametersAndDelimiters (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:25280:21)
at buildSignatureDisplay (/Volumes/git/customRules/node_modules/typescript/lib/typescript.js:25326:17)