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

Use Typescript? #559

Open
isidornygren opened this issue Apr 13, 2022 · 7 comments
Open

Use Typescript? #559

isidornygren opened this issue Apr 13, 2022 · 7 comments

Comments

@isidornygren
Copy link

Couldn't find anything regarding a possible implementation using Typescript instead of vanilla JavaScript, would that be preferable? Considering its large use as well as webpack handling it easy-peasy, I think it would probably not be difficult to integrate or create a separate repo specifically for Typescript.
I'd be happy to open up a PR with a poc.

@martinpitt
Copy link
Member

I'm not sure if it would be preferable -- this repo is mostly for people other than "ourselves" (i.e. the Cockpit development team), so it's hard for us to anticipate such preferences. But having a PoC available would certainly be great.

I'm afraid none of us in the team currently have any experience with TS, so I can't judge about the learning curve, difficulties with integration into webpack, React, JSX, etc.

@isidornygren
Copy link
Author

That makes sense to me. I definitely prefer TS as I find it much easier and extremely helpful on larger projects (although this might not be awfully large, I still think it would be immensely helpful to have types), but I understand that might be down to personal preference.

I added a simple PoC which should hopefully build just as it did before: #565 (Opened as a PR, I'm unsure of what the workflow looks like).
I'd be happy to provide any further help if you need it.

@martinpitt
Copy link
Member

As I said in cockpit-project/cockpit-ostree#338 , moving to .ts is fine in general, but it's a lot of work. If you or someone else is interested in working on this, this would be much appreciated!

@anup-chandak
Copy link

I am interested in working on this enhancement. As you said earlier there will be some learning curve for other developers who are not familiar with TypeScript but in the tsconfig.json file, if we enable allowJs then we can use javascript and typescript together. Also how to add a .ts annotation for the cockpit API for it to work and should I start working on the starter-kit repo to add TypeScript?

@KKoukiou
Copy link
Contributor

KKoukiou commented Mar 1, 2023

@chandakanup just for the clarification, I would not consider the Typescript move a GSoC main project as it's not as much educative and quite a lot of repetitive work. I hope that's understandable.

@anup-chandak
Copy link

Alright, I understand now. I want to contribute to the cockpit project for GSoC 2023 but I am not able to understand codes and issues very well. @KKoukiou can you please guide me on how should I start contributing.

@gbraad
Copy link

gbraad commented Jun 17, 2023

Are there type declarations for cockpit? that would be one of the first steps to allow the use of typescript for the starter-kit.

src/app.tsx:1:21 - error TS2307: Cannot find module 'cockpit' or its corresponding type declarations.

1 import cockpit from 'cockpit';
                      ~~~~~~~~~

A good start can be found at: https://github.com/ALTinners/cockpit-typescript-react-boilerplate/blob/master/%40types/CockpitJS/index.d.ts (which is 6 years old now).

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

5 participants