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

[Recitation Quiz 1] Fixing Import Issue in fibRoute #20

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

Conversation

a-khaldi
Copy link

@a-khaldi a-khaldi commented Aug 24, 2023

Aisha Al Khaldi, Anushka Satpute.

The error that I chose was as follows:

"Require statement not part of import statement."

I fixed this by first changing the first line in the fibRoute file from

"const fibonacci = require("./fib");" to "import fibonacci from "./fib";"
-> I converted the first line into a typescript format; my error stated that it was an import issue, which I fixed by not defining a variable for "fibonacci" but importing it from the module "./fib".

To make this work, I had to also change a line in the fib.ts file which stated the function fibonacci with a "module.exports", which is not compatible with typescript, so I defined the function as "function fibonacci (n: number): number" and at the end of the file placed the export line "export default fibonacci;".

I tested my work by running "npm run test" and "npm run lint" to ensure the error was solved!

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.

1 participant