Skip to content
Merged
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
2 changes: 2 additions & 0 deletions packages/core/src/volar/ember-language-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type TS = typeof ts;
export function createEmberLanguagePlugin<T extends URI | string>(
glintConfig: GlintConfig,
): LanguagePlugin<T> {
const hasEmberLoose = glintConfig.environment.names.indexOf('ember-loose') !== -1;
return {
/**
* For files that are not opened in the IDE, the language ID will not be provided
Expand Down Expand Up @@ -43,6 +44,7 @@ export function createEmberLanguagePlugin<T extends URI | string>(

// See: https://github.com/JetBrains/intellij-plugins/blob/11a9149e20f4d4ba2c1600da9f2b81ff88bd7c97/Angular/src/angular-service/src/index.ts#L31
if (
hasEmberLoose &&
languageId === 'typescript' &&
!scriptIdStr.endsWith('.d.ts') &&
scriptIdStr.indexOf('/node_modules/') < 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export let greeting = 'hello';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../../../tsconfig.compileroptions.json",
"glint": {
"environment": ["ember-loose", "ember-template-imports"]
"environment": ["ember-template-imports"]
},
"compilerOptions": {
"baseUrl": "."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ describe('Smoke test: ETI Environment (TS Plugin Mode)', () => {
]);
});

test.only('gives diagnostics for TypeScript file', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This .only() needs to be removed so that other tests run. Normally vitest catches this on CI but these VSCode tests I think use mocha or something that doesn't catch cases like these.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bah. I missed this :(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix here #852

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry!

let scriptURI = Uri.file(`${rootDir}/src/file.ts`);
let scriptEditor = await window.showTextDocument(scriptURI, { viewColumn: ViewColumn.One });

await hackishlyWaitForTypescriptPluginToActivate(scriptEditor, scriptURI);

// Comment out a property in the script that's referenced in the template
await scriptEditor.edit((edit) => {
edit.delete(new Range(0, 0, 0, 7));
});

// Wait for the diagnostic to show up
await waitUntil(() => languages.getDiagnostics(scriptURI).length);

// Verify it's what we expect
expect(languages.getDiagnostics(scriptURI)).toMatchObject([
{
message: "'greeting' is declared but its value is never read.",
source: 'ts',
code: 6133,
range: new Range(new Position(0, 4), new Position(0, 12)),
},
]);
});

describe('codeactions args', () => {
test('adds missing args from template into Args type', async () => {
let scriptURI = Uri.file(`${rootDir}/src/Greeting.gts`);
Expand Down
Loading