diff --git a/packages/core/src/volar/ember-language-plugin.ts b/packages/core/src/volar/ember-language-plugin.ts index 667f646b5..07bf473e0 100644 --- a/packages/core/src/volar/ember-language-plugin.ts +++ b/packages/core/src/volar/ember-language-plugin.ts @@ -15,6 +15,7 @@ export type TS = typeof ts; export function createEmberLanguagePlugin( glintConfig: GlintConfig, ): LanguagePlugin { + 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 @@ -43,6 +44,7 @@ export function createEmberLanguagePlugin( // 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 diff --git a/packages/vscode/__fixtures__/template-imports-app-ts-plugin/src/file.ts b/packages/vscode/__fixtures__/template-imports-app-ts-plugin/src/file.ts new file mode 100644 index 000000000..45a49ea64 --- /dev/null +++ b/packages/vscode/__fixtures__/template-imports-app-ts-plugin/src/file.ts @@ -0,0 +1 @@ +export let greeting = 'hello'; diff --git a/packages/vscode/__fixtures__/template-imports-app-ts-plugin/tsconfig.json b/packages/vscode/__fixtures__/template-imports-app-ts-plugin/tsconfig.json index f20ee6fa3..e34aa93c7 100644 --- a/packages/vscode/__fixtures__/template-imports-app-ts-plugin/tsconfig.json +++ b/packages/vscode/__fixtures__/template-imports-app-ts-plugin/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../../../tsconfig.compileroptions.json", "glint": { - "environment": ["ember-loose", "ember-template-imports"] + "environment": ["ember-template-imports"] }, "compilerOptions": { "baseUrl": "." diff --git a/packages/vscode/__tests__/ts-plugin-tests/smoketest-template-imports-ts-plugin.test.ts b/packages/vscode/__tests__/ts-plugin-tests/smoketest-template-imports-ts-plugin.test.ts index 298bed6be..dbead5d29 100644 --- a/packages/vscode/__tests__/ts-plugin-tests/smoketest-template-imports-ts-plugin.test.ts +++ b/packages/vscode/__tests__/ts-plugin-tests/smoketest-template-imports-ts-plugin.test.ts @@ -55,6 +55,31 @@ describe('Smoke test: ETI Environment (TS Plugin Mode)', () => { ]); }); + test.only('gives diagnostics for TypeScript file', async () => { + 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`);