ekg / fraction.js

A fraction math library in javascript.
http://hypervolu.me/~erik/fraction.js/
165 stars 43 forks source link

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

Open yatinsingla opened 6 years ago

yatinsingla commented 6 years ago

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 commented 6 years ago

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

Neikas commented 5 years ago

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

babak-bekhrad commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

atindra305 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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. :(

cobaltt7 commented 2 years ago

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.