Skip to content

Commit

Permalink
Upgrade to Volar 2.4.11 (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
machty authored Jan 9, 2025
1 parent eabfa3c commit 37ba065
Show file tree
Hide file tree
Showing 15 changed files with 377 additions and 269 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"eslint": "^8.27.0",
"prettier": "^3.3.2",
"release-it": "^15.5.0",
"typescript": ">=5.4.0"
"typescript": ">=5.6.0"
},
"resolutions:notes": {
"@glimmer/validator": "Newer versions of @glimmer/* are ESM-only, and Glint is compiled to CJS, so newer versions of @glimmer/* are not compatible",
Expand Down
37 changes: 31 additions & 6 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,40 @@ This package contains core functionality to power template-aware typechecking on

## CLI

The `glint` CLI tool is a thin wrapper around `tsc` and hence all documentation / use cases / flags that apply to `tsc` also apply to `glint`.

Because `glint` is only used for type-checking purposes (or generating declaration files), and not for producing compiled JS output, the emitting of JS should always be disabled by providing either the `--noEmit` or `--emitDeclarationOnly` flags, depending on your use case.

### Usage

Gemeral Usage:

```sh
glint --noEmit [--build] [--watch|-w] [--declaration|-d] [--emitDeclarationOnly] [--project path/to/tsconfig.json]
```

Type-checking:

```sh
glint [--build] --noEmit
```

Type-checking in watch mode:

```sh
glint [--watch|-w] [--declaration|-d] [--project path/to/tsconfig.json]
glint [--build] --noEmit --watch
```

### Flags
Build declaration files:

```
glint --build --declaration --emitDeclarationOnly
```

Build declaration files in watch mode:

```
glint --build --declaration --emitDeclarationOnly --watch
```

- `--watch` If passed, `glint` will perform a watched typecheck, re-checking your project as files change.
- `--preserveWatchOutput` Used with `--watch`. If passed, `glint` will not clear the screen each time the project is re-checked.
- `--declaration` If passed, `glint` will emit `.d.ts` files according to the configuration in your `tsconfig.json`
- `--project` Overrides where `glint` will look to find your project's `tsconfig.json`
Please refer to `tsc` docs for other use cases and flags.
68 changes: 59 additions & 9 deletions packages/core/__tests__/cli/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,13 @@ describe('CLI: single-pass build mode typechecking', () => {
2 const A = 2 * C;
~
src/index.gts:2:15 - error TS2307: Cannot find module '@glint-test/a' or its corresponding type declarations.
Found 1 error.
2 import A from '@glint-test/a';
~~~~~~~~~~~~~~~
Found 2 errors.
"
`);

Expand Down Expand Up @@ -573,8 +578,13 @@ describe('CLI: single-pass build mode typechecking', () => {
4 const A = <template>{{double C}}</template>;
~
src/index.gts:2:15 - error TS2307: Cannot find module '@glint-test/a' or its corresponding type declarations.
Found 1 error.
2 import A from '@glint-test/a';
~~~~~~~~~~~~~~~
Found 2 errors.
"
`);

Expand Down Expand Up @@ -702,8 +712,13 @@ describe('CLI: single-pass build mode typechecking', () => {
1 const B: number = 'ahoy';
~
src/index.gts:3:15 - error TS2307: Cannot find module '@glint-test/b' or its corresponding type declarations.
Found 1 error.
3 import B from '@glint-test/b';
~~~~~~~~~~~~~~~
Found 2 errors.
"
`);

Expand Down Expand Up @@ -807,8 +822,13 @@ describe('CLI: single-pass build mode typechecking', () => {
2 const Usage = <template>{{double "hello"}}</template>;
~~~~~~~
src/index.gts:3:15 - error TS2307: Cannot find module '@glint-test/b' or its corresponding type declarations.
Found 1 error.
3 import B from '@glint-test/b';
~~~~~~~~~~~~~~~
Found 2 errors.
"
`);

Expand Down Expand Up @@ -895,8 +915,18 @@ describe('CLI: single-pass build mode typechecking', () => {
1 const C: number = 'world';
~
../a/src/index.gts:1:15 - error TS2307: Cannot find module '@glint-test/c' or its corresponding type declarations.
Found 1 error.
1 import C from '@glint-test/c';
~~~~~~~~~~~~~~~
src/index.gts:2:15 - error TS2307: Cannot find module '@glint-test/a' or its corresponding type declarations.
2 import A from '@glint-test/a';
~~~~~~~~~~~~~~~
Found 3 errors.
"
`);

Expand All @@ -915,8 +945,13 @@ describe('CLI: single-pass build mode typechecking', () => {
1 const C: number = 'world';
~
src/index.gts:1:15 - error TS2307: Cannot find module '@glint-test/c' or its corresponding type declarations.
Found 1 error.
1 import C from '@glint-test/c';
~~~~~~~~~~~~~~~
Found 2 errors.
"
`);

Expand Down Expand Up @@ -1040,8 +1075,18 @@ describe('CLI: single-pass build mode typechecking', () => {
2 const useDouble = <template>{{double "hello"}}</template>;
~~~~~~~
../a/src/index.gts:1:15 - error TS2307: Cannot find module '@glint-test/c' or its corresponding type declarations.
Found 1 error.
1 import C from '@glint-test/c';
~~~~~~~~~~~~~~~
src/index.gts:2:15 - error TS2307: Cannot find module '@glint-test/a' or its corresponding type declarations.
2 import A from '@glint-test/a';
~~~~~~~~~~~~~~~
Found 3 errors.
"
`);

Expand All @@ -1060,8 +1105,13 @@ describe('CLI: single-pass build mode typechecking', () => {
2 const useDouble = <template>{{double "hello"}}</template>;
~~~~~~~
src/index.gts:1:15 - error TS2307: Cannot find module '@glint-test/c' or its corresponding type declarations.
Found 1 error.
1 import C from '@glint-test/c';
~~~~~~~~~~~~~~~
Found 2 errors.
"
`);

Expand Down Expand Up @@ -1614,7 +1664,7 @@ describe('CLI: --build --dry', () => {
let buildResult = await projects.root.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`A non-dry build would build project '${projects.main.filePath('tsconfig.json')}'`,
` A non-dry build would update timestamps for output of project '${projects.main.filePath('tsconfig.json')}'`,
);
expect(stripAnsi(buildResult.stdout)).toMatch(
`A non-dry build would build project '${projects.children.a.filePath('tsconfig.json')}'`,
Expand Down
4 changes: 1 addition & 3 deletions packages/core/__tests__/cli/incremental.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ describe('CLI: --incremental', () => {

expect(existsSync(project.filePath(BUILD_INFO))).toBe(true);
let contents = JSON.parse(readFileSync(project.filePath(BUILD_INFO), { encoding: 'utf-8' }));
expect(contents).toHaveProperty('program');
expect(contents.program).toHaveProperty('fileNames');
expect(contents.program.fileNames.length).not.toEqual(0);
expect(contents.fileNames.length).not.toEqual(0);
});

describe('when a build has occurred', () => {
Expand Down
42 changes: 0 additions & 42 deletions packages/core/__tests__/cli/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ describe('CLI: watched typechecking', () => {
output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');

expect(watch.allOutput).toMatch(/\033c/); // output should include screen reset control sequence

await watch.terminate();
});

Expand Down Expand Up @@ -290,44 +288,4 @@ describe('CLI: watched typechecking', () => {

await watch.terminate();
});

test('reports on errors introduced and cleared during the watch with --preserveWatchOutput', 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}}.
The current time is {{this.startupTime}}.
</template>
}
`;

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

let watch = project.checkWatch({ flags: ['--preserveWatchOutput'], reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');

project.write('index.gts', code.replace('this.startupTime', 'this.startupTimee'));

output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 1 error.');

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

output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');

expect(watch.allOutput).not.toMatch(/\033c/); // output should not include screen reset control sequence

await watch.terminate();
});
});
41 changes: 35 additions & 6 deletions packages/core/__tests__/language-server/custom-extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,24 @@ describe('Language Server: custom file extensions', () => {
const { uri } = await server.openTextDocument(tsPath, 'typescript');
let diagnostics = await server.sendDocumentDiagnosticRequest(uri);

expect(definitions).toMatchObject([
{ targetUri: 'file:///path/to/EPHEMERAL_TEST_PROJECT/index.ts' },
]);
expect(definitions).toMatchInlineSnapshot(`
[
{
"range": {
"end": {
"character": 29,
"line": 0,
},
"start": {
"character": 0,
"line": 0,
},
},
"uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.ts",
},
]
`);

expect(diagnostics.items).toEqual([]);

project.remove('index.ts');
Expand All @@ -162,9 +177,23 @@ describe('Language Server: custom file extensions', () => {
definitions = await server.sendDefinitionRequest(consumerURI, { line: 2, character: 4 });
diagnostics = await server.sendDocumentDiagnosticRequest(uri);

expect(definitions).toMatchObject([
{ targetUri: 'file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts' },
]);
expect(definitions).toMatchInlineSnapshot(`
[
{
"range": {
"end": {
"character": 29,
"line": 0,
},
"start": {
"character": 0,
"line": 0,
},
},
"uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts",
},
]
`);
expect(diagnostics.items).toEqual([]);

project.remove('index.gts');
Expand Down
Loading

0 comments on commit 37ba065

Please sign in to comment.