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

Could not find a declaration file for module 'fractional'. #19

Open
yatinsingla opened this issue Oct 8, 2018 · 9 comments
Open

Could not find a declaration file for module 'fractional'. #19

yatinsingla opened this issue Oct 8, 2018 · 9 comments

Comments

@yatinsingla
Copy link

I am using ES6 and while importing i.e. import { Fraction } from 'fractional', code does not compile and error says could not find a declaration file for module 'fractional.' I also tried import * as fraction from 'fractional'.
But dint work.

@ekg
Copy link
Owner

ekg commented Oct 9, 2018

I am not familiar with how to update the library to be compatible. Does anyone have a suggestion?

@Neikas
Copy link

Neikas commented Aug 19, 2019

I have the same issue does anybody have a solution "Fraction is not defined"?

@babak-bekhrad
Copy link

babak-bekhrad commented Jan 12, 2020

First of all, make sure the NodeJs is installed in your computer. after that you must install a package by this command nmp install fractional in terminal. so you must add this code to the top of your Js file
const Fraction = require('fractional').Fraction and you can use this example 👍

 const formatCount = count => {
  if (count) {
    const [int, dec] = count
      .toString()
      .split(".")
      .map(e => parseInt(e));
    if (!dec) return count;
    if (int === 0) {
      const fr = new fraction(count);
      return console.log(`${fr.numerator}/${fr.denominator}`);
    }
    if (int > 0) {
      const fr = new fraction(count - int);
      return `${int} ${fr.numerator}/${fr.denominator}`;
    }
  }
  return "?";
};

@ChrisOxygen
Copy link

First of all, make sure the NodeJs is installed in your computer. after that you must install a package by this command nmp install fractional in terminal. so you must add this code to the top of your Js file
const Fraction = require('fractional').Fraction and you can use this example 👍

 const formatCount = count => {
  if (count) {
    const [int, dec] = count
      .toString()
      .split(".")
      .map(e => parseInt(e));
    if (!dec) return count;
    if (int === 0) {
      const fr = new fraction(count);
      return console.log(`${fr.numerator}/${fr.denominator}`);
    }
    if (int > 0) {
      const fr = new fraction(count - int);
      return `${int} ${fr.numerator}/${fr.denominator}`;
    }
  }
  return "?";
};

does not work

@manojkken
Copy link

@ChrisOxygen this shouldn't be an issue if you have used npm install fractional instead of npm install fraction.js

@atindra305
Copy link

First of all, make sure the NodeJs is installed in your computer. after that you must install a package by this command nmp install fractional in terminal. so you must add this code to the top of your Js file
const Fraction = require('fractional').Fraction and you can use this example 👍

 const formatCount = count => {
  if (count) {
    const [int, dec] = count
      .toString()
      .split(".")
      .map(e => parseInt(e));
    if (!dec) return count;
    if (int === 0) {
      const fr = new fraction(count);
      return console.log(`${fr.numerator}/${fr.denominator}`);
    }
    if (int > 0) {
      const fr = new fraction(count - int);
      return `${int} ${fr.numerator}/${fr.denominator}`;
    }
  }
  return "?";
};

does not work

Same error again :-(

@Poirei
Copy link

Poirei commented Aug 8, 2020

First of all, make sure the NodeJs is installed in your computer. after that you must install a package by this command nmp install fractional in terminal. so you must add this code to the top of your Js file
const Fraction = require('fractional').Fraction and you can use this example 👍

 const formatCount = count => {
  if (count) {
    const [int, dec] = count
      .toString()
      .split(".")
      .map(e => parseInt(e));
    if (!dec) return count;
    if (int === 0) {
      const fr = new fraction(count);
      return console.log(`${fr.numerator}/${fr.denominator}`);
    }
    if (int > 0) {
      const fr = new fraction(count - int);
      return `${int} ${fr.numerator}/${fr.denominator}`;
    }
  }
  return "?";
};

does not work

Same error again :-(

doesn't work ☹

@aeriallistique
Copy link

Could not find a declaration file for module 'fractional'. '/Users/andi/Downloads/funny/node_modules/fractional/index.js' implicitly has an 'any' type.

Up to this point I haven't found a solution to fix this. :(

@RedGuy12
Copy link

This is a typescript error.

Could not find a declaration file for module 'fractional'. '.../node_modules/fractional/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/fractional` if it exists or add a new declaration (.d.ts) file containing `declare module 'fractional';`ts(7016)

As the end user, you can create a declare.d.ts file with the content declare module 'fractional'; to ignore the error. Note that you would not get any type checking - no types exist currently.

As the package maintainer, you can write types, add them to the project, and publish a new version.

As a friendly open-source contributor, you can write types and PR to either this repo (although it looks kinda dead) or to https://github.com/DefinitelyTyped/DefinitelyTyped.

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

No branches or pull requests

10 participants