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

build: Add typescript support #703

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

marlonkeating
Copy link
Contributor

Jira Ticket

This change adds build support for TypeScript, plus several files converted to TypeScript.

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

Copy link
Contributor

@johnnagro johnnagro left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

A couple things:

  • I'm a bit concerned at the amount of formatting/ESLint-type changes throughout the PR. Are these changes a potential code smell that the ESLint config isn't set up to support TypeScript (e.g., requiring a .ts(x) file extension on imports, splitting already reasonably short lines into multiple)?
  • The changes for TypeScript previously introduced in @edx/frontend-build v12.5.0 (installed in this PR). was since reverted in v12.6.2. As such, it feels risky to depend on v12.5.0 as when @edx/frontend-build gets upgraded beyond v12.6.2, we'd lose the TS changes that are now reverted.
    • Note @edx/frontend-build is now getting installed with a ^, which means the installed version of the package might not actually match the explicit version defined in the package.json file (though it'll match the defined semantic version range). For example, running npm i on your branch, I get v12.6.1 of @edx/frontend-build installed despite ^12.5.0 listed in the package.json file.

src/components/course/CourseAssociatedPrograms.jsx Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/components/course/data/hooks.tsx Outdated Show resolved Hide resolved
Comment on lines 129 to 130
allRecommendations.length < 1 &&
samePartnerRecommendations.length < 1
Copy link
Member

Choose a reason for hiding this comment

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

[curious] What is causing all these unnecessary splitting of lines into multiple lines throughout this file and PR? In many instances, the original lines are well under the max line length of 120 per the ESLint config specified in @edx/frontend-build, but they are getting split into multiple lines? Not trying to be nitpicky on formatting, but these formatting changes feel a bit erroneous.

tsconfig.json Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/components/course/data/hooks.tsx Outdated Show resolved Hide resolved
src/components/course/data/hooks.tsx Outdated Show resolved Hide resolved
Comment on lines +390 to +411
return `${
config.LMS_BASE_URL
}/enterprise/grant_data_sharing_permissions/?${queryParams.toString()}`;
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: I realize many of the formatting changes like this one are generated by your use of Prettier; that said, I disagree with Prettier's opinion here. Changes like this to go from 1 to 3 lines is unnecessary given our ESLint config allows lines up to 120 characters.

build: Use updated frontend-build typescript config

chore: Merge from master and reconcile with new typescript lint config

chore: Remove unnecessary typescript packages and fix tsconfig formatting
@@ -45,7 +45,7 @@ FEATURE_ENABLE_AUTO_APPLIED_LICENSES='true'
LEARNING_TYPE_FACET='true'
LEARNER_SUPPORT_URL='https://support.edx.org/hc/en-us'
FEATURE_ENABLE_PATHWAYS='true'
FEATURE_ENABLE_COURSE_REVIEW='true'
FEATURE_ENABLE_COURSE_REVIEW=''
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Is this change intentional/necessary? Just wondering if changing this from true to false might cause confusion for the Markhors team who may expect the feature to be enabled locally.

@@ -99,7 +99,7 @@ const CourseHeader = () => {
<Col xs={12} lg={12}>
{catalog.containsContentItems ? (
<>
{features.ENABLE_COURSE_REVIEW && <CourseReview />}
{enableReviewSection && <CourseReview />}
Copy link
Member

Choose a reason for hiding this comment

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

This should be changed back to the original, relying on the feature flag.

Comment on lines -229 to -232
// Only users buckted in `Variation 1` can see the change.
const isExperimentVariation1 = isExperimentVariant(config.EXPERIMENT_2_ID, config.EXPERIMENT_2_VARIANT_1_ID);
// For our experiment, we should trigger our Optimizely event only when this condition is true
const triggerLicenseSubsidyEvent = shouldShowLicenseSubsidyPriceText;
Copy link
Member

Choose a reason for hiding this comment

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

We probably shouldn't be removing these? 🤔

@@ -36,40 +36,38 @@ const EnrollAction = ({
userEnrollment,
subscriptionLicense,
courseRunPrice,
triggerLicenseSubsidyEvent,
Copy link
Member

Choose a reason for hiding this comment

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

Why was this prop removed?

@@ -47,7 +42,6 @@ const ToDataSharingConsentPage = ({ enrollLabel, enrollmentUrl, triggerLicenseSu
onClick={(e) => {
analyticsHandler(e);
optimizelyHandler(e);
if (triggerLicenseSubsidyEvent) { optimizelyLicenseSubsidyHandler(e); }
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Why is this logic getting removed?

const isShortLengthCourse = isShortCourse(course);

const primaryPartnerLogo = getPrimaryPartnerLogo(partnerDetails);

const handleCourseAboutPageVisitClick = useCourseAboutPageVisitClickHandler({
Copy link
Member

Choose a reason for hiding this comment

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

Why is this getting removed?

*
* @returns Click handler function for course about page visit click events.
*/
export const useCourseAboutPageVisitClickHandler = ({ href, courseKey, enterpriseId }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this getting removed?

Comment on lines +2 to +4
const content: string;
export default content;
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: indenting is off.

return this.cachedAuthenticatedHttpClient.get(url);
}

fetchUserLicenseSubsidy(courseKey = this.activeCourseRun.key) {
fetchUserLicenseSubsidy(courseKey = this?.activeCourseRun?.key) {
Copy link
Member

Choose a reason for hiding this comment

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

[curious] When would this be undefined/null where it requires a ??

@@ -1,4 +1,5 @@
import React from 'react';
import isNumber from 'lodash.isnumber';
Copy link
Member

Choose a reason for hiding this comment

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

Nice refactor to bring this library in.

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

Successfully merging this pull request may close these issues.

4 participants