-
Notifications
You must be signed in to change notification settings - Fork 1
chore(ci): upgrade to typescript 7 #87
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| import { execSync } from 'node:child_process'; | ||
| import { resolve } from 'path'; | ||
| import { execFileSync } from 'node:child_process'; | ||
| import { createRequire } from 'node:module'; | ||
| import { dirname, resolve } from 'node:path'; | ||
|
|
||
| const require = createRequire(import.meta.url); | ||
| const tsgoPath = resolve(dirname(require.resolve('@typescript/native-preview/package.json')), 'bin/tsgo.js'); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some projects (mostly starters) rely on TS6. This allows our libraries/projects to be type checked with TS7 and get the benefits while preserving ts6 until those projects can be upgrades.
coryrylan marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Runs TSC type check on intial build | ||
|
|
@@ -10,11 +14,17 @@ export function tsc() { | |
| apply: 'build', | ||
| async buildStart() { | ||
| if (process.env.VITE_INITIAL_BUILD) { | ||
| execSync( | ||
| `tsc --project ${resolve(process.cwd(), './tsconfig.lib.json')} --noEmit --emitDeclarationOnly false`, | ||
| { | ||
| stdio: 'inherit' | ||
| } | ||
| execFileSync( | ||
| process.execPath, | ||
| [ | ||
| tsgoPath, | ||
| '--project', | ||
| resolve(process.cwd(), './tsconfig.lib.json'), | ||
| '--noEmit', | ||
| '--emitDeclarationOnly', | ||
| 'false' | ||
| ], | ||
| { stdio: 'inherit' } | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,12 @@ export class Markdown extends LitElement { | |
| */ | ||
| @state() private renderedHtml = ''; | ||
|
|
||
| /** | ||
| * Tracks the currently pending markdown parse so tests and consumers can await | ||
| * `updateComplete` before reading rendered output. | ||
| */ | ||
| #pendingMarkdownParsing: Promise<void> = Promise.resolve(); | ||
|
|
||
| /** | ||
| * Query assigned elements in the default slot | ||
| */ | ||
|
|
@@ -83,21 +89,23 @@ export class Markdown extends LitElement { | |
| `; | ||
| } | ||
|
|
||
| protected override async getUpdateComplete(): Promise<boolean> { | ||
| const result = await super.getUpdateComplete(); | ||
| const pendingMarkdownParsing = this.#pendingMarkdownParsing; | ||
|
|
||
| await pendingMarkdownParsing; | ||
| await super.getUpdateComplete(); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| protected updated(changedProperties: Map<string | number | symbol, unknown>) { | ||
| if (changedProperties.has('source')) { | ||
| if (this.source) { | ||
| // Process markdown content from source property | ||
| void this.#parseMarkdown(this.source) | ||
| .then(parsed => { | ||
| this.renderedHtml = parsed; | ||
| }) | ||
| .catch(_error => { | ||
| // Don't update renderedHtml on parsing error - keep previous content | ||
| console.debug('Markdown parsing failed, keeping previous content'); | ||
| }); | ||
| this.#renderMarkdown(this.source); | ||
| } else { | ||
| // Source cleared, check for slotted content or clear rendered output | ||
| this.renderedHtml = ''; | ||
| this.#clearRenderedHtml(); | ||
| this.#processSlottedContent(); | ||
| } | ||
| } | ||
|
|
@@ -114,13 +122,17 @@ export class Markdown extends LitElement { | |
| const templateElement = this.slotElements.find(e => e.localName === 'template') as HTMLTemplateElement | undefined; | ||
|
|
||
| if (!templateElement) { | ||
| this.renderedHtml = ''; | ||
| this.#clearRenderedHtml(); | ||
| return; | ||
| } | ||
|
|
||
| const content = templateElement.innerHTML.trim(); | ||
|
|
||
| void this.#parseMarkdown(content) | ||
| this.#renderMarkdown(content); | ||
| } | ||
|
|
||
| #renderMarkdown(markdown: string): void { | ||
| this.#pendingMarkdownParsing = this.#parseMarkdown(markdown) | ||
| .then(parsed => { | ||
| this.renderedHtml = parsed; | ||
| }) | ||
|
|
@@ -130,6 +142,11 @@ export class Markdown extends LitElement { | |
| }); | ||
| } | ||
|
|
||
| #clearRenderedHtml(): void { | ||
| this.#pendingMarkdownParsing = Promise.resolve(); | ||
| this.renderedHtml = ''; | ||
| } | ||
|
|
||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This improves the getUpdateComplete check so tests can reliably use it for render completion instead of a flakey timeout |
||
| /** | ||
| * Parse markdown content to HTML using markdown-it. | ||
| * Lazy-loads the markdown-it instance only when needed for better performance. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noUncheckedSideEffectImports forces the compiler to verify that side-effect-only imports (import "./style.css") point to an actual existing file