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

Preparing the project for TypeScript #10595

Merged
merged 8 commits into from
Aug 22, 2022
Merged

Preparing the project for TypeScript #10595

merged 8 commits into from
Aug 22, 2022

Conversation

dangreen
Copy link
Collaborator

@dangreen dangreen commented Aug 11, 2022

  • swc is used for transpilation, as it is faster than tsc
  • were created temporary entry points for types, to take types from types definitions and sources
  • one file from helpers and one file from the core were refactored as examples of transition
  • types tests were fixed to test new entry points

@dangreen dangreen marked this pull request as ready for review August 11, 2022 13:25
@dangreen dangreen changed the title refactor: typescript base Preparing the project for TypeScript Aug 11, 2022
@dangreen
Copy link
Collaborator Author

@kurkle @LeeLenaleee @etimberg @benmccann Hi guys. Would you please do a review?

src/core/core.adapters.ts Outdated Show resolved Hide resolved
src/core/core.adapters.ts Outdated Show resolved Hide resolved
.size-limit.cjs Show resolved Hide resolved
Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to convince people to switch to TypeScript back when we started on Chart.js 3 and I remember there being some issue around class members. Could you switch one class that sets fields in the constructor so we can make sure there won't be problems?

.size-limit.cjs Show resolved Hide resolved
@dangreen
Copy link
Collaborator Author

I tried to convince people to switch to TypeScript back when we started on Chart.js 3 and I remember there being some issue around class members. Could you switch one class that sets fields in the constructor so we can make sure there won't be problems?

@benmccann I will make it on Monday 👌

etimberg
etimberg previously approved these changes Aug 13, 2022
Copy link
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Needs a rebase and a converted class to make sure it works.

@@ -3,6 +3,8 @@ import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '..
import {PI, _isBetween, _limitValue} from '../helpers/helpers.math';
import {_readValueToProps} from '../helpers/helpers.options';

/** @typedef {{ x: number, y: number, startAngle: number, endAngle: number, innerRadius: number, outerRadius: number, circumference: number }} ArcProps */
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work with an imported interface for some reason (maybe interface vs type), so I temporarily inlined it.

@dangreen dangreen requested review from benmccann, kurkle and etimberg and removed request for benmccann, kurkle and etimberg August 18, 2022 14:50
@dangreen dangreen requested review from etimberg, benmccann and kurkle and removed request for etimberg and benmccann August 18, 2022 14:52
@dangreen
Copy link
Collaborator Author

@benmccann @etimberg @kurkle review re-request is buggy 🤷‍♂️ Review pls 🙏

import {terser} from 'rollup-plugin-terser';
import { readFileSync } from "fs";
Copy link
Collaborator

@LeeLenaleee LeeLenaleee Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit]
Not sure what eslint is configured to but either keep the spaces here and in auto/auto.d.ts or also remove the spaces with all other import brackets.

But giving it a quick look it seems like there are a lot more with spacing as without

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benmccann
Copy link
Contributor

I compared the output of core.element before and after and it's about the same, so my concern about that is addressed.

The only thing I'd want to make sure everyone is aware of is that we're now forcing a bundle step to develop Chart.js, which we wouldn't need otherwise. I do like TypeScript more than JSDocs though. I'm happy with the tradeoff either way whatever the team decides

@etimberg
Copy link
Member

I compared the output of core.element before and after and it's about the same, so my concern about that is addressed.

The only thing I'd want to make sure everyone is aware of is that we're now forcing a bundle step to develop Chart.js, which we wouldn't need otherwise. I do like TypeScript more than JSDocs though. I'm happy with the tradeoff either way whatever the team decides

Thanks for checking the output @benmccann

I am ok with the bundle step. I am, personally, a big fan of TS these days and I think it can make our code a lot better

@etimberg etimberg merged commit 2031cdf into chartjs:master Aug 22, 2022
@dangreen dangreen deleted the refactor-typescript-base branch August 22, 2022 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants