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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type definition files should not attempt to be loaded #65

Closed
franky47 opened this issue Feb 19, 2020 · 1 comment 路 Fixed by #66
Closed

Type definition files should not attempt to be loaded #65

franky47 opened this issue Feb 19, 2020 · 1 comment 路 Fixed by #66

Comments

@franky47
Copy link
Contributor

franky47 commented Feb 19, 2020

馃悰 Bug Report

When using includeTypeScript: true, fastify-autload will attempt to load type definition files (.d.ts), causing syntax errors, such as Cannot use import statement outside a module.

This happens when Node is started into a directory built from TypeScript sources into a set of .js & .d.ts files.

To Reproduce

Reproduction repository available here:
https://github.com/franky47/fastify-autoload-65

Expected behavior

Since Node.js cannot understand type definition files, and they contain no runtime code, I believe the extension .d.ts should be ignored, even when includeTypeScript is true.

Your Environment

  • node version: 13.7.0
  • fastify version: 2.11.0
  • fastify-autoload version: 1.2.0
  • os: macOS
@SerayaEryn
Copy link
Contributor

I agree, we shouldn't load the .d.ts files. Would you like to open a PR?

franky47 added a commit to franky47/fastify-autoload that referenced this issue Feb 19, 2020
franky47 added a commit to franky47/fastify-autoload that referenced this issue Feb 19, 2020
franky47 added a commit to franky47/fastify-autoload that referenced this issue Feb 19, 2020
mcollina pushed a commit that referenced this issue Feb 20, 2020
* fix: Ignore TS definition files

Closes #65.

* doc: Mention in readme that .d.ts are ignored

Relates to #65.

* fix: Negative lookbehind does not work in Node 6

Use a more direct approach for the regex, from:
https://stackoverflow.com/a/43493203

* chore: Remove mention of issue #65 in comment
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