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

Fix types #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix types #27

wants to merge 3 commits into from

Conversation

oBusk
Copy link

@oBusk oBusk commented Jun 22, 2022

The type export is malformed and gives errors in current versions of typescript

image

node_modules/gitdiff-parser/index.d.ts(36,16): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context.
node_modules/gitdiff-parser/index.d.ts(37,34): error TS1005: '{' expected.

This also does not work if you want to use gitDiffParser globally (not importing). Since the index.js exports as a UMD, I followed the example https://devblogs.microsoft.com/typescript/writing-dts-files-for-types/

With this type, all the following works

// Reference for `<script>`-imported library
/// <reference path="gitdiff-parser" />

gitDiffParser.parse(gitContent);
import { parse } from "gitdiff-parser";

parse(gitContent);
import gitDiffParser from "gitdiff-parser";

gitDiffParser.parse(gitContent);

As a bonus I added exports for FileType and ChangeType.

@ciaran1344
Copy link

Any update here? Am running into the same compilation warnings on typescript@4.9.4

@oBusk
Copy link
Author

oBusk commented Apr 12, 2023

There was some improvements to the type surrounding the ChangeType and FileType, but the default export is still the same, so I've rebased this PR let's see if we can get it in 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants