diff --git a/src/builtin-addons/core/template-definition-provider.ts b/src/builtin-addons/core/template-definition-provider.ts index 11467b195..001028e62 100644 --- a/src/builtin-addons/core/template-definition-provider.ts +++ b/src/builtin-addons/core/template-definition-provider.ts @@ -383,17 +383,13 @@ export default class TemplateDefinitionProvider { return false; } - if ( - path.parent.type !== 'MustacheStatement' && - path.parent.type !== 'PathExpression' && - path.parent.type !== 'SubExpression' && - path.parent.type !== 'ElementModifierStatement' - ) { + if (path.parent.type !== 'MustacheStatement' && path.parent.type !== 'SubExpression' && path.parent.type !== 'ElementModifierStatement') { return false; } - // @ts-expect-error @todo - fix typings - if (!path.parent || path.parent.path.original !== 'action' || !path.parent.params[0] === node) { + const parent = path.parent as ASTv1.MustacheStatement | ASTv1.SubExpression | ASTv1.ElementModifierStatement; + + if (parent.path.type !== 'PathExpression' || parent.path.original !== 'action' || parent.params[0] !== node) { return false; } diff --git a/src/utils/walk-async.ts b/src/utils/walk-async.ts index f502cf829..065266ce3 100644 --- a/src/utils/walk-async.ts +++ b/src/utils/walk-async.ts @@ -35,7 +35,7 @@ class MatcherCollection { } } -export default async function walkAsync(baseDir: string, inputOptions?: Options | string[]) { +export default async function walkAsync(baseDir: string, inputOptions: Options) { const options = handleOptions(inputOptions); let mapFunct: (arg: Entry) => string; @@ -60,7 +60,7 @@ export default async function walkAsync(baseDir: string, inputOptions?: Options } } -export function entries(baseDir: string, inputOptions?: Options | string[]) { +export function entries(baseDir: string, inputOptions: Options) { const options = handleOptions(inputOptions); return _walkAsync(ensurePosix(baseDir), options, null, new Set()); @@ -98,16 +98,7 @@ function isDefined(val: T | undefined): val is T { return typeof val !== 'undefined'; } -function handleOptions(_options?: Options | string[]): Options { - // @ts-expect-error empty options - let options: Options = {}; - - if (Array.isArray(_options)) { - options.globs = _options; - } else if (_options) { - options = _options; - } - +function handleOptions(options: Options): Options { return options; } diff --git a/test/bultin-addons/core/intl-providers-test.ts b/test/bultin-addons/core/intl-providers-test.ts index ffffe2417..8f726b461 100644 --- a/test/bultin-addons/core/intl-providers-test.ts +++ b/test/bultin-addons/core/intl-providers-test.ts @@ -954,7 +954,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation definition in handlebars', async () => { expect( ( - (await getResult( + await getResult( DefinitionRequest.method, connection, { @@ -967,7 +967,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.hbs', { line: 0, character: 32 } - )) as any + ) ).response ).toEqual([ { @@ -983,7 +983,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation definition in js', async () => { expect( ( - (await getResult( + await getResult( DefinitionRequest.method, connection, { @@ -996,7 +996,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.js', { line: 0, character: 86 } - )) as any + ) ).response ).toEqual([ { @@ -1116,7 +1116,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation definition in handlebars', async () => { expect( ( - (await getResult( + await getResult( DefinitionRequest.method, connection, { @@ -1129,7 +1129,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.hbs', { line: 0, character: 32 } - )) as any + ) ).response ).toEqual([ { @@ -1145,7 +1145,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation definition in js', async () => { expect( ( - (await getResult( + await getResult( DefinitionRequest.method, connection, { @@ -1158,7 +1158,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.js', { line: 0, character: 86 } - )) as any + ) ).response ).toEqual([ { @@ -1177,7 +1177,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation definition in handlebars', async () => { expect( ( - (await getResult( + await getResult( DefinitionRequest.method, connection, { @@ -1190,7 +1190,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.hbs', { line: 0, character: 32 } - )) as any + ) ).response ).toEqual([ { @@ -1206,7 +1206,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation definition in js', async () => { expect( ( - (await getResult( + await getResult( DefinitionRequest.method, connection, { @@ -1219,7 +1219,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.js', { line: 0, character: 86 } - )) as any + ) ).response ).toEqual([ { @@ -1235,7 +1235,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation definitions from multiple files', async () => { expect( ( - (await getResult( + await getResult( DefinitionRequest.method, connection, { @@ -1248,7 +1248,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.js', { line: 0, character: 70 } - )) as any + ) ).response ).toEqual([ { @@ -1273,7 +1273,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation hover in handlebars', async () => { expect( ( - (await getResult( + await getResult( HoverRequest.method, connection, { @@ -1286,7 +1286,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.hbs', { line: 0, character: 20 } - )) as any + ) ).response ).toEqual({ contents: { @@ -1304,7 +1304,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { it('should provide translation hover in js', async () => { expect( ( - (await getResult( + await getResult( HoverRequest.method, connection, { @@ -1317,7 +1317,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) { }, 'app/components/test.js', { line: 0, character: 70 } - )) as any + ) ).response ).toEqual({ contents: { diff --git a/test/integration-test.ts b/test/integration-test.ts index 2cfe5549d..2f30f0419 100644 --- a/test/integration-test.ts +++ b/test/integration-test.ts @@ -40,7 +40,7 @@ describe('integration', function () { describe(`async fs enabled: ${asyncFsEnabled.toString()}`, function () { let connection: MessageConnection; let serverProcess: cp.ChildProcess; - let asyncFSProviderInstance!: any; + let asyncFSProviderInstance: Record | null = null; const disposables: Disposable[] = []; beforeAll(async () => { diff --git a/test/test_helpers/integration-helpers-test.ts b/test/test_helpers/integration-helpers-test.ts index 87b086d3a..0ba8c47ed 100644 --- a/test/test_helpers/integration-helpers-test.ts +++ b/test/test_helpers/integration-helpers-test.ts @@ -1,4 +1,4 @@ -import { normalizeToFs, flattenFsProject } from './integration-helpers'; +import { normalizeToFs, flattenFsProject, RecursiveRecord } from './integration-helpers'; describe('normalizeToFs', () => { it('support existing cases', () => { @@ -10,8 +10,7 @@ describe('normalizeToFs', () => { }, }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - expect(normalizeToFs(files as any)).toStrictEqual(JSON.parse(JSON.stringify(files))); + expect(normalizeToFs(files as RecursiveRecord>)).toStrictEqual(JSON.parse(JSON.stringify(files))); }); it('support new case', () => { const expectedObj = { diff --git a/test/test_helpers/integration-helpers.ts b/test/test_helpers/integration-helpers.ts index bd5561b24..4413a27de 100644 --- a/test/test_helpers/integration-helpers.ts +++ b/test/test_helpers/integration-helpers.ts @@ -17,6 +17,7 @@ import { FoldingRangeRequest, Hover, HoverRequest, + Location, ReferencesRequest, } from 'vscode-languageserver-protocol/node'; @@ -258,7 +259,7 @@ export async function initFileStructure(files: Tree) { }; } -type RecursiveRecord = Record; +export type RecursiveRecord = Record; export function flattenFsProject(obj: Record | string) { if (typeof obj === 'string') { @@ -497,8 +498,23 @@ export async function getResult( files, fileToInspect: string, position: { line: number; character: number }, - projectName?: string[] -): Promise[]>; + projectName: string[] +): Promise[]>; +export async function getResult( + reqType: typeof HoverRequest.method, + connection: MessageConnection, + files, + fileToInspect: string, + position: { line: number; character: number }, + projectName: string +): Promise>; +export async function getResult( + reqType: typeof HoverRequest.method, + connection: MessageConnection, + files, + fileToInspect: string, + position: { line: number; character: number } +): Promise>; export async function getResult( reqType: typeof CompletionRequest.method, connection: MessageConnection, @@ -537,8 +553,8 @@ export async function getResult( files, fileToInspect: string, position: { line: number; character: number }, - projectName?: string -): Promise>; + projectName: string +): Promise>; export async function getResult( reqType: typeof DefinitionRequest.method, connection: MessageConnection, diff --git a/test/test_helpers/public-integration-helpers.ts b/test/test_helpers/public-integration-helpers.ts index e69cea733..05776522f 100644 --- a/test/test_helpers/public-integration-helpers.ts +++ b/test/test_helpers/public-integration-helpers.ts @@ -25,7 +25,7 @@ export interface ServerBucket { export async function createServer({ asyncFsEnabled } = { asyncFsEnabled: false }): Promise { const serverProcess = startServer(asyncFsEnabled); - let asyncFSProviderInstance!: any; + let asyncFSProviderInstance: Record | null = null; const disposables: Disposable[] = []; const connection = createConnection(serverProcess);