Skip to content

Fix MathML emit #882

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ jobs:
- run: pnpm lint
- uses: wyvox/action-setup-pnpm@v3

# type-tests:
# name: "Type Tests"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: pnpm/action-setup@v2
# - uses: actions/setup-node@v4
# with:
# cache: pnpm
# - run: pnpm reset
type-tests:
name: "Type Tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v4
with:
cache: pnpm
- run: pnpm reset
- run: pnpm --filter './test-packages/ts-template-imports-app' test:typecheck
# - run: "pnpm --filter '*' run test:typecheck"
# - run: "pnpm --filter '*' run test:tsc"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,4 +636,37 @@ describe('Language Server: Diagnostics (ts plugin)', () => {
]
`);
});

test('MathML context is retained and popped', async () => {
let componentA = stripIndent`
export const MathMLExample = <template>
<span>x</span>

<math display="block">
<mfrac>
<mrow>
<mi>a</mi>
<mo>+</mo>
<mn>2</mn>
</mrow>
<mrow>
<mn>3</mn>
<mo>−</mo>
<mi>b</mi>
</mrow>
</mfrac>
</math>

<span>x</span>
</template>
`;

const diagnostics = await requestDiagnostics(
'ts-template-imports-app/src/ephemeral-index.gts',
'glimmer-ts',
componentA,
);

expect(diagnostics).toMatchInlineSnapshot(`[]`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ describe('Language Server: Hover (ts plugin)', () => {
`);
});

describe('MathML', () => {
test('empty <math>', async () => {
const [offset, content] = extractCursor(stripIndent`
<template>
<ma%th>
</math>
</template>
`);

const doc = await prepareDocument(
'ts-template-imports-app/src/ephemeral.gts',
'glimmer-ts',
content,
);

expect(await performHoverRequest(doc, offset)).toMatchInlineSnapshot();
});
});

describe.skip('JS in a TS project', () => {
test('with allowJs: true', async () => {
const [offset, content] = extractCursor(stripIndent`
Expand Down
1 change: 1 addition & 0 deletions test-packages/ts-template-imports-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@glint/environment-ember-loose": "workspace:*",
"@glint/environment-ember-template-imports": "workspace:*",
"@glint/template": "workspace:*",
"@glint/tsserver-plugin": "workspace:*",
"@glint/core": "workspace:*",
"@types/rsvp": "^4.0.9",
"@glint/tsserver-plugin": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion test-packages/ts-template-imports-app/src/Greeting.gts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@glimmer/component';
import { TOC } from '@ember/component/template-only';
import type { TOC } from '@ember/component/template-only';

export interface GreetingSignature {
Args: { target: string };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This test used for testing auto-imports

// @ts-expect-error
let C = Greeting;
4 changes: 2 additions & 2 deletions test-packages/ts-template-imports-app/src/NoTemplate.gts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*NoTemplate*/
import Component from '@glimmer/component';
import { TOC } from '@ember/component/template-only';
import type { TOC } from '@ember/component/template-only';
import { Other } from './other';

export class Foo {}

let o: Other
let o: Other
4 changes: 2 additions & 2 deletions test-packages/ts-template-imports-app/src/Playground.gts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@glimmer/component';
import { TOC } from '@ember/component/template-only';
import type { TOC } from '@ember/component/template-only';
import { hash } from '@ember/helper';
import { ComponentLike, ModifierLike, HelperLike } from '@glint/template';
import type { ComponentLike, ModifierLike, HelperLike } from '@glint/template';

const lib = {
MaybeComponent: undefined as TOC<{ Args: { arg: string } }> | undefined
Expand Down
16 changes: 16 additions & 0 deletions test-packages/ts-template-imports-app/src/math-ml.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const MathMLExample = <template>
<math display="block">
<mfrac>
<mrow>
<mi>a</mi>
<mo>+</mo>
<mn>2</mn>
</mrow>
<mrow>
<mn>3</mn>
<mo>−</mo>
<mi>b</mi>
</mrow>
</mfrac>
</math>
</template>
10 changes: 0 additions & 10 deletions test-packages/ts-template-imports-app/src/normal.ts

This file was deleted.

Loading