-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
May i use typescript rewrite fabricjs? #6763
Comments
I m not interested in switching this repo to TS. For now a lot of people still just include the built file as it is. I do not want use time to add the tooling. We could use an officiale type definition file anyway, possibly generated from JSDOC |
I'm using it with TypeScript, Electron and Angular 10 now. For my naive use it seems OK. Rob |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Typescript could be a big win for a complicated project like this. It is a good way to avoid a lot of types of bugs. You can have it generate a build file downleveled to your desired es version. |
would be good to have a script that generates the td file starting from jsdocs. |
Compiling down to js will ALWAYS be accurate. Docs will ALWAYS have errors - that is just the nature of documentation...ever since the first caveman started documenting on cave walls. Guessing no persuasion here but just saying. |
That is true, but still:
Having a .ts file generated from jsdocs would still be better than nothing. |
I would appreciate an official type definition file. |
i would too, we need someone to start it. |
Hmm when creating an issue it says
So we can't create an issue to track progress/support |
You can, i m soft with issues that make sense. First verify that there isn't one open already |
Would have (and did) discouraged me from opening an issue like that. I would instead have tried to go to the DefinitelyTyped repo. But doing that means you basically have to open a PR yourself and fix it. And by then it's easier to just do quick and dirty cast in the code. There is traffic on the @types/fabric package. That counts for something :) |
I actively discourage people from opening random issues for asking
There is the discussion section for that. There are a lot of people using TS, i m not expert, i have no idea what does it take to maintain a .d.ts file, and i would love to be able to generate it from jsdocs |
I see. Haven't used github discussions yet. So not familiar with when to use it :)
I haven't done it from a JS source. But according to https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html it should be as easy as running
given that there's proper JSDoc I just tried to run it and it generates an empty type definition. I think the issue is the JS is written in the IIFE style. Not sure if it can be made to work with IIFEs. I couldn't find anything. Another option is to convert from IIFE to CommonJS or even better ES Modules. |
+1 |
There's an open discussion #7017 about how to get started on this |
Converting to ES6 would be great, then you can easily generate I used this config file to generate tsconfig.json {
// Change this to match your project
"include": [
"src/**/*"
],
"exclude": [
"*.d.ts"
],
"compilerOptions": {
"module": "CommonJS",
// Tells TypeScript to read JS files, as
// normally they are ignored as source files
"allowJs": true,
// Generate d.ts files
"declaration": true,
// This compiler run should
// only output d.ts files
"emitDeclarationOnly": true,
// Types should go into this directory.
// Removing this would place the .d.ts files
// next to the .js files
"rootDir": "src",
"outDir": "types"
}
} install ts globally first and then just type |
But instead of picking up what you need, you could try a custom build or you could try to improve our code splitting mechanism. Ultimately rewriting everything from es5 to es6 and named exports would utimately get to the point. |
I want to fork repo and rewrite it by typescript.
if i do it great, can you merge this PR ?
@asturur
The text was updated successfully, but these errors were encountered: