Skip to content

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