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

A way to validate the typescript of assembled tutorial sections #395

Open
noam-honig opened this issue Oct 26, 2024 · 4 comments
Open

A way to validate the typescript of assembled tutorial sections #395

noam-honig opened this issue Oct 26, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@noam-honig
Copy link
Contributor

Is your feature request related to a problem?

Today, the actual lesson is a combination of files from the template and from the lesson itself. When I use vs code - or when I build astro typescript files - the build fails, because the template may refer to files that exist only on the lesson and vice versa.

I wish there was a way to validate that.

Describe the solution you'd like.

One "dummy" thought, is a cli command to "build" all the lessons with their files and template files into a temp folder and run typescript build there - to validate that all is ok

Describe alternatives you've considered.

The other way I can think of is duplicating many files - but that's maintanance hell.

Additional context

Love this project

@AriPerkkio
Copy link
Member

Could you set up minimal reproduction for this? For example using https://node.new and running npm create tutorial there to get started?

@AriPerkkio AriPerkkio added the needs reproduction Missing reproduction or unable to reproduce label Oct 27, 2024
@noam-honig
Copy link
Contributor Author

Hi, here it is:
https://stackblitz.com/edit/node-e7zju9

  • I change counter.js to counter.ts - to use typescript
  • I deleted counter.ts from the template (it's ok its in the lesson)
  • I imported in counter.ts a file called some-function that exists in the template and not in the lesson.

The lesson itself, that is the combination of the template and the lesson is valid but nore the templare nor the lesson are.

You can verify that its valid by using "open in stackblitz"

If I run astro build I get an error - and that's ok - I exclude template and content from the ts file.

I wish there was a way to generate to some temp folder, the "merged" lessons and build them to make sure its all ok.

@AriPerkkio AriPerkkio added help wanted Extra attention is needed and removed needs reproduction Missing reproduction or unable to reproduce labels Oct 28, 2024
@AriPerkkio
Copy link
Member

I'm not sure how this could be implemented. I thought tsconfig.json's paths would do this automatically, but looks like relative imports are not remapped via paths. So something like this does not work:

{
  "compilerOptions": {
    "paths": {
+     "./src/content/tutorial/1-basics/1-introduction/1-welcome/_files/*": [
+       "./src/templates/default/*"
+     ]
    }
  }
}

@noam-honig
Copy link
Contributor Author

I'm old school - if there was away to reuse the logic you use to build the source folder for the web container, and just output it to a tmp folder - with a folder for each lesson, and run the tsc there - that would be a good start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants