Skip to content

Quick fix for "Implement interface" crashes for optional types #16707

Description

@prashaantt

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.20170621)

Code

interface IPerson {
    name: string;
    birthday?: Date;
}

class Person implements IPerson { }

Expected behavior:
The quick fix suggestion for "Implement interface 'IPerson'" shows up.

Actual behavior:
The quick fix bulb doesn't light up.

Explanation
The optional property birthday? seems to crash and breaks the "implement interface" auto-fix for the rest of the project, and it doesn't start working again unless I restart VS Code.

If I change it to birthday: Date;, the auto-fix works consistently as expected.

If I read this right, this is the corresponding piece from tsserver.log:

Exception on executing command {"seq":9,"type":"request","command":"getCodeFixes","arguments":{"file":"...","startLine":31,"endLine":31,"startOffset":7,"endOffset":13,"errorCodes":[2420]}}:
Debug Failure. False expression: position cannot precede the beginning of the file
Error: Debug Failure. False expression: position cannot precede the beginning of the file
    at Object.computeLineAndCharacterOfPosition (.../node_modules/typescript/lib/tsserver.js:9935:22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Quick FixesEditor-provided fixes, often called code actions.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions