Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5b35212
extract ts plugin builder
machty Feb 6, 2025
b9cfd21
rename
machty Feb 6, 2025
c4d689f
begin directive reworking
machty Feb 17, 2025
b9d4c0a
see what breaks when splitting CodeMapping
machty Feb 17, 2025
e35f41c
intro codefeatures
machty Feb 19, 2025
10e5215
dissolve into single context obj
machty Feb 19, 2025
75f38c3
rm old approach to expect-error
machty Feb 19, 2025
cf49827
progress
machty Feb 19, 2025
eff3360
something working
machty Feb 19, 2025
f30267c
refine node termination
machty Feb 20, 2025
b566d48
add tests
machty Feb 20, 2025
efa2624
fix "unused expect error" not firing
machty Feb 20, 2025
5f438a7
reinstate and test glint-ignore
machty Feb 20, 2025
9370e63
reinstate nocheck
machty Feb 20, 2025
bb40f85
rm legacy areaOfEffect
machty Feb 20, 2025
fb04a3c
rm unused range
machty Feb 20, 2025
a0a0ed1
fix end-of-template unsued expect-error
machty Feb 20, 2025
e0e9bf9
comments and cleanup
machty Feb 20, 2025
58eba7e
simplify and lint
machty Feb 20, 2025
6c14279
more lints
machty Feb 20, 2025
c76408d
expect error corner cases
machty Feb 20, 2025
b9adff5
fix snapshots
machty Feb 20, 2025
863a096
pre weakmap
machty Feb 26, 2025
77581bf
reinstate reverse error mapping in a few cases of component invocation
machty Feb 26, 2025
01e33ca
add test
machty Feb 26, 2025
aa1562c
cleanup
machty Feb 26, 2025
34f4172
add test
machty Feb 26, 2025
f667af0
add test
machty Feb 26, 2025
2c77fbe
add test
machty Feb 26, 2025
fde0c76
more tests
machty Feb 26, 2025
6ab5a25
clarify
machty Mar 3, 2025
b483758
prettier
machty Mar 3, 2025
e8eacfe
update snapshots after newlines introduced
machty Mar 3, 2025
1ccd44d
fix
machty Mar 3, 2025
ad9537f
tmp remove wrapping open tag
machty Mar 3, 2025
8e96fca
fix test
machty Mar 3, 2025
2c15109
fix snapshots for cli
machty Mar 3, 2025
519784e
fix local/CI snapshot path disagreement
machty Mar 3, 2025
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
16 changes: 13 additions & 3 deletions packages/core/__tests__/cli/build-watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('CLI: watched build mode typechecking', () => {
await watch.terminate();
});

test.skip('reports on errors introduced after removing a glint-nocheck directive', async () => {
test('reports on errors introduced after removing a glint-nocheck directive', async () => {
let code = stripIndent`
import '@glint/environment-ember-template-imports';
import Component from '@glimmer/component';
Expand Down Expand Up @@ -460,7 +460,12 @@ describe('CLI: watched build mode typechecking', () => {
stripped.indexOf('index.gts'),
stripped.lastIndexOf(`~~~${os.EOL}`) + 3,
);
expect(error).toMatchInlineSnapshot(`""`);
expect(error).toMatchInlineSnapshot(`
"index.gts:15:5 - error TS2554: Expected 0 arguments, but got 1.

15 <A @foo="bar" />
~~~~~~~~~~~~~~~~"
`);

await pauseForTSBuffering();

Expand Down Expand Up @@ -488,7 +493,12 @@ describe('CLI: watched build mode typechecking', () => {
stripped.indexOf('index.gts'),
stripped.lastIndexOf(`~~~${os.EOL}`) + 3,
);
expect(error).toMatchInlineSnapshot(`""`);
expect(error).toMatchInlineSnapshot(`
"index.gts:3:28 - error TS2554: Expected 0 arguments, but got 1.

3 const A = <template>Hello! <C @foo="bar" /></template>;
~~~~~~~~~~~~~~~~"
`);

await pauseForTSBuffering();

Expand Down
2 changes: 1 addition & 1 deletion packages/core/__tests__/cli/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ describe('CLI: single-pass build mode typechecking', () => {
});
});

describe.skip('for a type error covered by `@glint-nocheck`', () => {
describe('for a type error covered by `@glint-nocheck`', () => {
beforeEach(async () => {
let aCode = stripIndent`
import C from '@glint-test/c';
Expand Down
110 changes: 110 additions & 0 deletions packages/core/__tests__/cli/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,116 @@ describe('CLI: single-pass typechecking', () => {
`);
});

test('ignores @glint-ignored errors', async () => {
let code = stripIndent`
import Component from '@glimmer/component';

type ApplicationArgs = {
version: string;
};

export default class Application extends Component<{ Args: ApplicationArgs }> {
private startupTime = new Date().toISOString();

<template>
Welcome to app v{{@version}}.

{{! @glint-ignore 'unknown property' }}
The current time is {{this.startupTimeError}}.

{{! @glint-ignore 'if this were expect-error this would be an unused expect-error' }}
The current time is {{this.startupTime}}.
</template>
}
`;

project.write('index.gts', code);

let checkResult = await project.check({ reject: false });

expect(checkResult.exitCode).toBe(0);

expect(stripAnsi(checkResult.stdout)).toMatchInlineSnapshot(`
""
`);
});

test('reports unused @glint-expect-error', async () => {
let code = stripIndent`
import Component from '@glimmer/component';

type ApplicationArgs = {
version: string;
};

export default class Application extends Component<{ Args: ApplicationArgs }> {
private startupTime = new Date().toISOString();

<template>
Welcome to app v{{@version}}.
{{! @glint-expect-error 'no error here' }}
The current time is {{this.startupTime}}.
</template>
}
`;

project.write('index.gts', code);

let checkResult = await project.check({ reject: false });

expect(checkResult.exitCode).not.toBe(0);

expect(stripAnsi(checkResult.stdout)).toMatchInlineSnapshot(`
"index.gts:12:5 - error TS2578: Unused '@ts-expect-error' directive.

12 {{! @glint-expect-error 'no error here' }}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in index.gts:12
"
`);
});

test('does not report errors skipped by @glint-expect-error', async () => {
let code = stripIndent`
import Component from '@glimmer/component';

type ApplicationArgs = {
version: string;
};

export default class Application extends Component<{ Args: ApplicationArgs }> {
private startupTime = new Date().toISOString();

<template>
Welcome to app v{{@version}}.
{{! @glint-expect-error 'skipping this error' }}
The current time is {{this.startupTimee}}.

{{this.otherError}}
</template>
}
`;

project.write('index.gts', code);

let checkResult = await project.check({ reject: false });

expect(checkResult.exitCode).not.toBe(0);

expect(stripAnsi(checkResult.stdout)).toMatchInlineSnapshot(`
"index.gts:15:12 - error TS2339: Property 'otherError' does not exist on type 'Application'.

15 {{this.otherError}}
~~~~~~~~~~


Found 1 error in index.gts:15
"
`);
});

test.skip('reports diagnostics for a companion template type error', async () => {
project.setGlintConfig({ environment: 'ember-loose' });

Expand Down
Loading