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

Erroneous error when index.d.ts is included in the files list as "/index.d.ts" #79

Closed
chocolateboy opened this issue Sep 21, 2020 · 3 comments · Fixed by #116
Closed

Comments

@chocolateboy
Copy link

tsd: 0.13.1 | Node.js: v14.9.0 | OS: Linux (Arch)

I have a files array which includes "/index.d.ts", e.g.:

{
    "files": [
        "dist/index.esm.js",
        "dist/index.js",
        "/index.d.ts"
    ]
}

The leading slash is needed to include the index.d.ts file in the package's root directory and to exclude other files of the same name, e.g. in the dist directory (an unqualified "index.d.ts" pattern matches all files with that name).

tsd is not picking this up and is failing with an error:

TypeScript type definition index.d.ts is not part of the files list.

The error goes away if the forward slash is removed.

@fregante

This comment has been minimized.

@chocolateboy
Copy link
Author

chocolateboy commented Oct 2, 2020

The documentation says "file patterns follow a similar syntax to .gitignore". In .gitignore, forward slash just means directory separator:

The slash / is used as the directory separator. Separators may occur at the beginning, middle or end of the .gitignore search pattern.

If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself.

And, no, "./index.d.ts" doesn't work. It adds ./dist/index.d.ts but not ./index.d.ts.

@fregante
Copy link

fregante commented Oct 2, 2020

Regardless of documentation (which says "similar", but doesn't commit to the same exact format), I confirm that npm@6.14.5 also includes files starting with a slash.

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 a pull request may close this issue.

2 participants