Skip to content

Commit 5316d6d

Browse files
committed
chore: updates TS to fix ci errors
1 parent 79962ec commit 5316d6d

9 files changed

+533
-31
lines changed

addon/utils/mung-options-for-fetch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function mungOptionsForFetch(
1818

1919
for (const key in options) {
2020
if (Object.prototype.hasOwnProperty.call(options, key)) {
21-
fetchOptions[key] = options[key];
21+
(fetchOptions as any)[key] = (options as any)[key];
2222
}
2323
}
2424

errors.d.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Checks if the given response represents an unauthorized request error
3+
*/
4+
export declare function isUnauthorizedResponse(response: Response): boolean;
5+
/**
6+
* Checks if the given response represents a forbidden request error
7+
*/
8+
export declare function isForbiddenResponse(response: Response): boolean;
9+
/**
10+
* Checks if the given response represents an invalid request error
11+
*/
12+
export declare function isInvalidResponse(response: Response): boolean;
13+
/**
14+
* Checks if the given response represents a bad request error
15+
*/
16+
export declare function isBadRequestResponse(response: Response): boolean;
17+
/**
18+
* Checks if the given response represents a "not found" error
19+
*/
20+
export declare function isNotFoundResponse(response: Response): boolean;
21+
/**
22+
* Checks if the given response represents a "gone" error
23+
*/
24+
export declare function isGoneResponse(response: Response): boolean;
25+
/**
26+
* Checks if the given error is an "abort" error
27+
*/
28+
export declare function isAbortError(error: DOMException): boolean;
29+
/**
30+
* Checks if the given response represents a conflict error
31+
*/
32+
export declare function isConflictResponse(response: Response): boolean;
33+
/**
34+
* Checks if the given response represents a server error
35+
*/
36+
export declare function isServerErrorResponse(response: Response): boolean;

package.json

+35-9
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"lint:js:fix": "eslint . --fix",
2626
"start": "ember serve",
2727
"test": "ember test",
28-
"test:node": "ember ts:precompile && mocha && ember ts:clean",
28+
"test:node": "yarn prepack && mocha && yarn postpack",
2929
"test:all": "yarn run test:node && ember try:each",
30-
"prepublishOnly": "ember ts:precompile",
31-
"postpublish": "ember ts:clean"
30+
"prepack": "ember ts:precompile",
31+
"postpack": "ember ts:clean"
3232
},
3333
"dependencies": {
3434
"abortcontroller-polyfill": "^1.7.3",
@@ -42,7 +42,7 @@
4242
"caniuse-api": "^3.0.0",
4343
"ember-cli-babel": "^7.26.11",
4444
"ember-cli-htmlbars": "^6.2.0",
45-
"ember-cli-typescript": "^4.1.0",
45+
"ember-cli-typescript": "^5.2.1",
4646
"ember-cli-version-checker": "^5.1.2",
4747
"node-fetch": "^2.6.1",
4848
"whatwg-fetch": "^3.6.2"
@@ -56,10 +56,35 @@
5656
"@embroider/test-setup": "^2.1.1",
5757
"@glimmer/component": "^1.1.2",
5858
"@glimmer/tracking": "^1.1.2",
59-
"@types/ember": "^4.0.8",
60-
"@types/ember-data": "^4.4.0",
61-
"@types/qunit": "^2.11.1",
62-
"@types/rsvp": "^4.0.3",
59+
"@tsconfig/ember": "^3.0.2",
60+
"@types/ember": "^4.0.9",
61+
"@types/ember-data": "^4.4.14",
62+
"@types/ember-data__adapter": "^4.0.5",
63+
"@types/ember-data__model": "^4.0.4",
64+
"@types/ember-data__serializer": "^4.0.5",
65+
"@types/ember-data__store": "^4.0.6",
66+
"@types/ember-qunit": "^6.1.1",
67+
"@types/ember-resolver": "^9.0.0",
68+
"@types/ember__application": "^4.0.10",
69+
"@types/ember__array": "^4.0.8",
70+
"@types/ember__component": "^4.0.20",
71+
"@types/ember__controller": "^4.0.10",
72+
"@types/ember__debug": "^4.0.7",
73+
"@types/ember__destroyable": "^4.0.4",
74+
"@types/ember__engine": "^4.0.9",
75+
"@types/ember__error": "^4.0.5",
76+
"@types/ember__object": "^4.0.10",
77+
"@types/ember__polyfills": "^4.0.5",
78+
"@types/ember__routing": "^4.0.18",
79+
"@types/ember__runloop": "^4.0.8",
80+
"@types/ember__service": "^4.0.7",
81+
"@types/ember__string": "^3.0.13",
82+
"@types/ember__template": "^4.0.5",
83+
"@types/ember__test": "^4.0.5",
84+
"@types/ember-test-helpers": "^1.0.0",
85+
"@types/ember__utils": "^4.0.6",
86+
"@types/qunit": "^2.19.8",
87+
"@types/rsvp": "^4.0.7",
6388
"@typescript-eslint/eslint-plugin": "^6.9.1",
6489
"@typescript-eslint/parser": "^6.9.1",
6590
"babel-eslint": "^10.0.2",
@@ -92,6 +117,7 @@
92117
"eslint-plugin-qunit": "^7.3.4",
93118
"fs-extra": "^9.0.1",
94119
"glob": "^7.1.7",
120+
"jquery": "^3.7.1",
95121
"lerna-changelog": "^1.0.1",
96122
"loader.js": "^4.2.3",
97123
"mocha": "^8.4.0",
@@ -104,7 +130,7 @@
104130
"stylelint": "^15.4.0",
105131
"stylelint-config-standard": "^32.0.0",
106132
"stylelint-prettier": "^3.0.0",
107-
"typescript": "^5.0.0",
133+
"typescript": "^5.2.2",
108134
"webpack": "^5.78.0"
109135
},
110136
"peerDependencies": {

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"noEmit": true,
1818
"strictFunctionTypes": true,
1919
"pretty": true,
20+
"skipLibCheck": true,
2021
"stripInternal": true,
2122
"strict": true,
2223
"inlineSourceMap": true,

types.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Mix from '@ember/polyfills/types';
2+
export type Nullable<T> = T | null | undefined;
3+
export type PlainObject<T = string | number | boolean> = {
4+
[key: string]: T | PlainObject<T> | PlainObject<T>[] | undefined | null;
5+
};
6+
export type PlainHeaders = {
7+
[key: string]: string;
8+
};
9+
export type Method = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
10+
export type AjaxOptions = {
11+
url: string;
12+
type: Method;
13+
data?: PlainObject | BodyInit;
14+
headers?: PlainHeaders;
15+
};
16+
export type Credentials = 'omit' | 'same-origin' | 'include';
17+
export type FetchOptions = Mix<AjaxOptions, {
18+
body?: BodyInit | null;
19+
method?: Method;
20+
credentials: Credentials;
21+
}>;
22+
export declare function isPlainObject(obj: any): obj is PlainObject;

utils/determine-body-promise.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="jquery" />
2+
/**
3+
* Function that always attempts to parse the response as json, and if an error is thrown,
4+
* returns `undefined` if the response is successful and has a status code of 204 (No Content),
5+
* or 205 (Reset Content) or if the request method was 'HEAD', and the plain payload otherwise.
6+
*/
7+
export default function determineBodyPromise(response: Response, requestData: JQueryAjaxSettings): Promise<object | string | undefined>;

utils/mung-options-for-fetch.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { FetchOptions, AjaxOptions } from 'ember-fetch/types';
2+
/**
3+
* Helper function that translates the options passed to `jQuery.ajax` into a format that `fetch` expects.
4+
*/
5+
export default function mungOptionsForFetch(options: AjaxOptions): FetchOptions;

utils/serialize-query-params.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Helper function that turns the data/body of a request into a query param string.
3+
* This is directly copied from jQuery.param.
4+
*/
5+
export declare function serializeQueryParams(queryParamsObject: object | string): string;
6+
export default serializeQueryParams;

0 commit comments

Comments
 (0)