Skip to content

Commit 6c70985

Browse files
authored
jasmine: do not map expect(string) to array-like matchers (DefinitelyTyped#73412)
1 parent a01c9fb commit 6c70985

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

types/jasmine/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ declare function afterAll(action: jasmine.ImplementationCallback, timeout?: numb
109109
*/
110110
declare function expect<T extends jasmine.Func>(spy: T | jasmine.Spy<T>): jasmine.FunctionMatchers<T>;
111111

112+
/**
113+
* Create an expectation for a spec.
114+
* @checkReturnValue see https://tsetse.info/check-return-value
115+
* @param actual Actual computed value to test expectations against.
116+
*/
117+
declare function expect(actual: string): jasmine.Matchers<string>;
118+
112119
/**
113120
* Create an expectation for a spec.
114121
* @checkReturnValue see https://tsetse.info/check-return-value

types/jasmine/jasmine-tests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ describe("Included matchers:", () => {
9494

9595
expect(value).toBe(12);
9696
});
97+
98+
it("should not consider strings as array-like", () => {
99+
// @ts-expect-error
100+
expect("abc").toEqual(["a", "b", "c"]);
101+
});
97102
});
98103

99104
describe("The 'toEqual' matcher", () => {

0 commit comments

Comments
 (0)