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
12 changes: 4 additions & 8 deletions src/builtin-addons/core/template-definition-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
15 changes: 3 additions & 12 deletions src/utils/walk-async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -98,16 +98,7 @@ function isDefined<T>(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;
}

Expand Down
36 changes: 18 additions & 18 deletions test/bultin-addons/core/intl-providers-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand All @@ -967,7 +967,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.hbs',
{ line: 0, character: 32 }
)) as any
)
).response
).toEqual([
{
Expand All @@ -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,
{
Expand All @@ -996,7 +996,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.js',
{ line: 0, character: 86 }
)) as any
)
).response
).toEqual([
{
Expand Down Expand Up @@ -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,
{
Expand All @@ -1129,7 +1129,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.hbs',
{ line: 0, character: 32 }
)) as any
)
).response
).toEqual([
{
Expand All @@ -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,
{
Expand All @@ -1158,7 +1158,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.js',
{ line: 0, character: 86 }
)) as any
)
).response
).toEqual([
{
Expand All @@ -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,
{
Expand All @@ -1190,7 +1190,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.hbs',
{ line: 0, character: 32 }
)) as any
)
).response
).toEqual([
{
Expand All @@ -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,
{
Expand All @@ -1219,7 +1219,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.js',
{ line: 0, character: 86 }
)) as any
)
).response
).toEqual([
{
Expand All @@ -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,
{
Expand All @@ -1248,7 +1248,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.js',
{ line: 0, character: 70 }
)) as any
)
).response
).toEqual([
{
Expand All @@ -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,
{
Expand All @@ -1286,7 +1286,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.hbs',
{ line: 0, character: 20 }
)) as any
)
).response
).toEqual({
contents: {
Expand All @@ -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,
{
Expand All @@ -1317,7 +1317,7 @@ for (const asyncFsEnabled of testCaseAsyncFsOptions) {
},
'app/components/test.js',
{ line: 0, character: 70 }
)) as any
)
).response
).toEqual({
contents: {
Expand Down
2 changes: 1 addition & 1 deletion test/integration-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown> | null = null;
const disposables: Disposable[] = [];

beforeAll(async () => {
Expand Down
5 changes: 2 additions & 3 deletions test/test_helpers/integration-helpers-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { normalizeToFs, flattenFsProject } from './integration-helpers';
import { normalizeToFs, flattenFsProject, RecursiveRecord } from './integration-helpers';

describe('normalizeToFs', () => {
it('support existing cases', () => {
Expand All @@ -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<RecursiveRecord<string>>)).toStrictEqual(JSON.parse(JSON.stringify(files)));
});
it('support new case', () => {
const expectedObj = {
Expand Down
26 changes: 21 additions & 5 deletions test/test_helpers/integration-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
FoldingRangeRequest,
Hover,
HoverRequest,
Location,
ReferencesRequest,
} from 'vscode-languageserver-protocol/node';

Expand Down Expand Up @@ -258,7 +259,7 @@ export async function initFileStructure(files: Tree) {
};
}

type RecursiveRecord<T> = Record<string, string | T>;
export type RecursiveRecord<T> = Record<string, string | T>;

export function flattenFsProject(obj: Record<string, unknown | string> | string) {
if (typeof obj === 'string') {
Expand Down Expand Up @@ -497,8 +498,23 @@ export async function getResult(
files,
fileToInspect: string,
position: { line: number; character: number },
projectName?: string[]
): Promise<IResponse<Hover[]>[]>;
projectName: string[]
): Promise<IResponse<Hover>[]>;
export async function getResult(
reqType: typeof HoverRequest.method,
connection: MessageConnection,
files,
fileToInspect: string,
position: { line: number; character: number },
projectName: string
): Promise<IResponse<Hover>>;
export async function getResult(
reqType: typeof HoverRequest.method,
connection: MessageConnection,
files,
fileToInspect: string,
position: { line: number; character: number }
): Promise<IResponse<Hover>>;
export async function getResult(
reqType: typeof CompletionRequest.method,
connection: MessageConnection,
Expand Down Expand Up @@ -537,8 +553,8 @@ export async function getResult(
files,
fileToInspect: string,
position: { line: number; character: number },
projectName?: string
): Promise<IResponse<Definition>>;
projectName: string
): Promise<IResponse<Definition[]>>;
export async function getResult(
reqType: typeof DefinitionRequest.method,
connection: MessageConnection,
Expand Down
2 changes: 1 addition & 1 deletion test/test_helpers/public-integration-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface ServerBucket {

export async function createServer({ asyncFsEnabled } = { asyncFsEnabled: false }): Promise<ServerBucket> {
const serverProcess = startServer(asyncFsEnabled);
let asyncFSProviderInstance!: any;
let asyncFSProviderInstance: Record<string, unknown> | null = null;
const disposables: Disposable[] = [];
const connection = createConnection(serverProcess);

Expand Down
Loading