Skip to content

[FR] TypeScript support for leetcode's built-in data structures 力扣自定义数据结构(如ListNode、TreeNode)的TypeScript支持 #828

@DarrenDanielDay

Description

@DarrenDanielDay

🚀 Feature Proposal

Add TypeScript type declaration file of leetcode's built-in data structures to the workspace root (such as ~/.leetcode) automatically when users open a leetcode workspace with language typescript.

Motivation

The online editor has correct type inference of leetcode's built-in data structure, such as TreeNode and ListNode. It's reasonable to have the same experience with this vscode extension.

Contribution

I think there already exists a TypeScript declaration file for those built-in data structures for the online editor. Just create a copy of that file via vscode.workspace.fs.writeFile when users open a leetcode workspace with language typescript. Also create a tsconfig.json file if necessary, or just execute npx tsc --init.

More

Support running JavaScript/TypeScript test cases locally, since nodejs 10+ is required for this extension, possibly by using babel to transpile TypeScript code to JavaScript code and calling nodejs API like vm.runInContext to execute the JavaScript code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions