Skip to content

chore(client): typescript migration - utils/frame.js - #46075

Merged
Sembauke merged 3 commits into
freeCodeCamp:mainfrom
raditotev:chore/ts-migrate-frame
May 20, 2022
Merged

Sembauke merged 3 commits into
freeCodeCamp:mainfrom
raditotev:chore/ts-migrate-frame

Conversation

@raditotev

Copy link
Copy Markdown
Contributor

Checklist:

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the main branch of freeCodeCamp.
  • I have tested these changes either locally on my machine, or GitPod.

Closes #43778

@raditotev
raditotev requested a review from a team May 19, 2022 16:44
@gitpod-io

gitpod-io Bot commented May 19, 2022

Copy link
Copy Markdown

@github-actions github-actions Bot added the platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. label May 19, 2022
@ghost

ghost commented May 19, 2022 •

Copy link
Copy Markdown

👀 Review this PR in a CodeSee Review Map

Preview the Review Map

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@raditotev
raditotev force-pushed the chore/ts-migrate-frame branch from 80f7b7b to f77e75d Compare May 20, 2022 06:51
@raditotev

Copy link
Copy Markdown
Contributor Author

Tests are failing with this error. I have checked type definitions and the tsconfig configuration and everything seems to be as it should be. I don't have a clue as to what the problem might be.

Error: Cannot find module './frame'
Require stack:
- /Users/radi.totev/Projects/freeCodeCamp/client/src/templates/Challenges/utils/build.js
- /Users/radi.totev/Projects/freeCodeCamp/curriculum/test/test-challenges.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.Module._load (/Users/radi.totev/Projects/freeCodeCamp/node_modules/mock-require/index.js:30:22)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/radi.totev/Projects/freeCodeCamp/client/src/templates/Challenges/utils/build.js:6:1)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Module._compile (/Users/radi.totev/Projects/freeCodeCamp/node_modules/pirates/lib/index.js:136:24)
    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Object.newLoader [as .js] (/Users/radi.totev/Projects/freeCodeCamp/node_modules/pirates/lib/index.js:141:7)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.Module._load (/Users/radi.totev/Projects/freeCodeCamp/node_modules/mock-require/index.js:30:22)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/radi.totev/Projects/freeCodeCamp/curriculum/test/test-challenges.js:32:5)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:168:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at formattedImport (/Users/radi.totev/Projects/freeCodeCamp/node_modules/mocha/lib/nodejs/esm-utils.js:7:14)
    at Object.exports.requireOrImport (/Users/radi.totev/Projects/freeCodeCamp/node_modules/mocha/lib/nodejs/esm-utils.js:48:32)
    at Object.exports.loadFilesAsync (/Users/radi.totev/Projects/freeCodeCamp/node_modules/mocha/lib/nodejs/esm-utils.js:103:20)
    at singleRun (/Users/radi.totev/Projects/freeCodeCamp/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at Object.exports.handler (/Users/radi.totev/Projects/freeCodeCamp/node_modules/mocha/lib/cli/run.js:374:5)

@raditotev
raditotev force-pushed the chore/ts-migrate-frame branch from e9f2c03 to 6a8fd5a Compare May 20, 2022 07:44
@ojeytonwilliams

Copy link
Copy Markdown
Contributor

The issue is that frame is used in two contexts, the client and the tests. While the client can parse TypeScript, the tests are just run in node, so can't.

Ideally we should migrate test-challenges.js to TS, but that's a long job. In the mean time we have two options:

  1. Move frame out of client into utils, so that it gets compiled into JS
  2. Run mocha through ts-node

Neither is ideal, but 2. seems preferable, because frame.ts really does belong in the client and utils seems like a confusing place to put it.

So, I'd recommend trying replacing the current curriculum test script with ts-node ../node_modules/mocha/bin/mocha --delay --exit --reporter progress --bail and seeing how that goes!

@raditotev

raditotev commented May 20, 2022 •

Copy link
Copy Markdown
Contributor Author

@ojeytonwilliams thanks for your help 🙌 . I've tested suggested script and it worked fine locally. I'll push the changes now.

@raditotev raditotev changed the title chore: typescript migration - utils/frame.js chore(client): typescript migration - utils/frame.js May 20, 2022
@Sembauke Sembauke added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label May 20, 2022

@ojeytonwilliams ojeytonwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really nice job @raditotev. This looks great!

@Sembauke
Sembauke merged commit ea4cedd into freeCodeCamp:main May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript Migration

3 participants