Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDocumentHighlights crashes on function w/ destructured argument #12451

Closed
nchen63 opened this issue Nov 22, 2016 · 1 comment
Closed

getDocumentHighlights crashes on function w/ destructured argument #12451

nchen63 opened this issue Nov 22, 2016 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created

Comments

@nchen63
Copy link
Contributor

nchen63 commented Nov 22, 2016

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)
@mhegazy mhegazy added the Bug A bug in TypeScript label Dec 16, 2016
@mhegazy mhegazy added this to the TypeScript 2.2 milestone Dec 16, 2016
@sheetalkamat sheetalkamat added the Duplicate An existing issue was already created label Dec 19, 2016
@sheetalkamat
Copy link
Member

This is duplicate of #12166 and is fixed by #12691

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants