Skip to content

Commit

Permalink
Fix parsing issue with certain declarations for the microsoft/TypeScr…
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Feb 9, 2024
1 parent 56c1b08 commit fe013cf
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/fixes/ember.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,57 @@ describe('fixReferences', () => {

expect(result).toBe(code);
});

describe('https://github.com/machty/ember-concurrency/issues/564', () => {

test('declarations/helpers/cancel-all.d.ts', () => {
let code = stripIndent`
/// <reference types="ember-source/types/preview/@ember/component/-private/signature-utils" />
/// <reference types="ember-source/types/preview/@ember/component/helper" />
import type { Task } from '../index';
type CancelAllParams = [task: Task<any, any[]>];
export declare function cancelHelper(args: CancelAllParams): (...innerArgs: any[]) => any;
declare const _default: import("@ember/component/helper").FunctionBasedHelper<{
Args: {
Positional: CancelAllParams;
Named: import("@ember/component/helper").EmptyObject;
};
Return: (...innerArgs: any[]) => any;
}>;
export default _default;
`;

let result = fixEmberReferences(code);

expect(result).toMatchInlineSnapshot(`
"import type { Task } from '../index';
type CancelAllParams = [task: Task<any, any[]>];
export declare function cancelHelper(args: CancelAllParams): (...innerArgs: any[]) => any;
declare const _default: import("@ember/component/helper").FunctionBasedHelper<{
Args: {
Positional: CancelAllParams;
Named: import("@ember/component/helper").EmptyObject;
};
Return: (...innerArgs: any[]) => any;
}>;
export default _default;"
`);
});
})
test('declarations/-private/ember-environment.d.ts', () => {
let code = stripIndent`
export class EmberEnvironment extends Environment {
assert(...args: any[]): void;
reportUncaughtRejection(error: any): void;
defer(): any;
globalDebuggingEnabled(): any;
}
export const EMBER_ENVIRONMENT: EmberEnvironment;
import { Environment } from './external/environment';
`;

let result = fixEmberReferences(code);

expect(result).toMatchInlineSnapshot();
});
});

0 comments on commit fe013cf

Please sign in to comment.