Open yatinsingla opened 6 years ago
I am not familiar with how to update the library to be compatible. Does anyone have a suggestion?
I have the same issue does anybody have a solution "Fraction is not defined"?
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 "?";
};
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 fileconst 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
@ChrisOxygen this shouldn't be an issue if you have used npm install fractional
instead of npm install fraction.js
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 fileconst 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 :-(
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 fileconst 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 ☹
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. :(
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.
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.