jquery / jquery/esprima

[Suggestion] Integrate typescript @types into project, built from source ts files

Open
#1,980 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.1k
Forks
773
PR merge metrics
No merged PRs in 30d

Description

Hello, I notice this project is using TypeScript, which is great - however the project.json file does not expose a types property, which is the preferred way to consume type definitions.

At the moment this project relies on @types/esprima which is extracted from the DefinitelyTyped repository. Unfortunately that doesn't expose some of the types esprima uses, such as the Error class.

It would be much better / cleaner if the type defs are built from the project source, and given the source is TypeScript this should be fairly easy to accomplish. It will also mean the two are kept in sync version wise.

The only minor inconvenience I can foresee is you will probably have to convert the Syntax object into a string enum in order for it to make it's way into the generated type definitions. However that should not be a breaking change as far as consumers are concerned. Ideally all the type properties should be changed from strings to the new Syntax enum type - but I realise this is a PITA.

The parse, parseScript and parseModule methods will also have to have return types, at the moment they return the any type.

At the moment, @types/esprima has a dependency on @types/estree, however I don't think this will be required as the types will flow from the type definitions defined in nodes.ts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting project.json and the TypeScript definitions in nodes.ts, then trace the parse, parseScript, and parseModule entry points. Done means the package exposes generated type definitions from its source, including the relevant enum and return types, and no longer depends on incomplete @types/esprima definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.