Comments (9)
resolve the problem , thanks
from figlet.js.
Hi @patorjk , How about adding an index.d.ts in the package, would you like a PR?
from figlet.js.
Hello,
Until the TypeScript definition on DefinitelyTyped is updated, you can use something like that in your project (inspired from DefinitelyTyped/DefinitelyTyped#38318 and https://github.com/aplr/DefinitelyTyped/commit/099f9bea0641922116078c2421e234e72e3a2cb6):
// src/types/figlet.d.ts
// Extended type definitions for figlet 1.2
// Project: https://github.com/patorjk/figlet.js
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as figlet from 'figlet';
declare global {
export namespace figlet {
/*
* Parses data from a FIGlet font file and places it into the figFonts object.
*/
function parseFont(fontName: string, data: string): FontOptions;
declare module 'figlet/importable-fonts/*' {
const value: string;
export default value;
}
}
}
// Important to have this line (even if empty...)
declare module 'figlet' {}
Of course, you'll need to update your TypeScript project configuration to load custom types. For example:
// tsconfig.json
{
"compilerOptions": {
(...)
"typeRoots": [
"src/types",
"node_modules/@types"
]
},
}
from figlet.js.
Hi @Nightbr, as you mentioned, DefinitelyTyped/DefinitelyTyped#38318 has been opened over on DefinitelyTyped for this. However, I don't think it'll be worked unless someone submits a PR.
I'm not really familar with TypeScript, but this is what I think the new file should look like:
https://github.com/patorjk/DefinitelyTyped/blob/figlet_fix/types/figlet/index.d.ts
However, I'm not on a computer where I can run the DefinitelyTyped code. If you want to put in PR for this fix definitely do so. Otherwise if I get some time tonight I'll try and put in a PR with the above branch (all I did for that was put in the line I think is missing).
from figlet.js.
Hi there. I got a similar error. I'm building a npm package, which should contain figlet. If I test it I get following error:
http://localhost:4200/fonts/Standard.flf 404 (Not Found)
somehow the npm package does not find the correct font.
index.js file
var figlet = require('figlet');
figlet('Hello World!!', function(err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
console.log(data)
});
Does someone has an idea what I'm doing wrong?
Edit: If I import both figlet
and a font like following it works. Is there a method I don't have to import the font seperately? Is it possible to expose all fonts per default?
import figlet from 'figlet';
import standard from 'figlet/importable-fonts/Standard.js'
figlet.parseFont('Standard', standard);
figlet.text('test', {
font: 'Standard',
}, function(err, data) {
console.log(data);
});
from figlet.js.
I would accept a PR.
from figlet.js.
It's 2021, why do we still want to support webpack. Why not just support native ES code and everybody can use it without webpack?
from figlet.js.
@elgs sure thing, make a PR to refactor this lib into a native ES module and it could be bundle with any ES bundler 👌
from figlet.js.
Does this have es support now then?
from figlet.js.
Related Issues (20)
- Add "ANSI Regular" font to the font directory HOT 3
- Examples directory of the repository is part of the NPM package HOT 3
- can't find font file HOT 3
- Slant front weird rendering HOT 13
- How to use different colors HOT 3
- [ PLS HELP ] want to change the header text , but in bash.bashrc file there is no written text HOT 1
- Possibility to add one empty line at the top/beginning HOT 2
- Can this library be used in ES without webpack? HOT 4
- Cannot read property 'reduce' of undefined HOT 2
- Can blank lines be preserved?
- Problem with code that pollute array prototype
- small slant.flf does not work in Ubuntu HOT 1
- TypeError: Cannot read properties of undefined (reading 'reduce') HOT 6
- Typo in README.md
- Readability issues in README.md
- TTF -> FLF? HOT 2
- Cannot find module figlet HOT 1
- [README] Build Status Shield Button Not Working HOT 1
- Question: Why doesn't figlet return the new text and why is error the first parameter of the callback? HOT 1
- [Suggestion] Way to import every font using Webpack
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from figlet.js.