Skip to content

Commit be59552

Browse files
authored
Configure jsconfig.json and tsconfig.json (#47)
* Replace tsconfig.json with jsconfig.json * Remove @tsconfig/recommended dev dependency * Fix Qualified name 'options.wait.maxAttempts' is not allowed without a leading '@param {object} options.wait'.ts(8032) * Fix Property 'interval' does not exist on type '{ interval?: number | undefined; maxAttempts?: number | undefined; } | undefined'.ts(2339) * Fix Property 'version' does not exist on type '{ [key: string]: string; } | undefined'.ts(2339) * Add tsconfig.json and configure with ts-jest
1 parent f36a0e4 commit be59552

File tree

8 files changed

+32
-14
lines changed

8 files changed

+32
-14
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
overrides: [],
1414
parserOptions: {
1515
ecmaVersion: 'latest',
16-
project: './tsconfig.json',
16+
project: './jsconfig.json',
1717
},
1818
plugins: ['jest', 'jsdoc'],
1919
rules: {

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Replicate {
7070
* @param {string} identifier - Required. The model version identifier in the format "{owner}/{name}:{version}"
7171
* @param {object} options
7272
* @param {object} options.input - Required. An object with the model inputs
73-
* @param {boolean|object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
73+
* @param {object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
7474
* @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 250
7575
* @param {number} [options.wait.maxAttempts] - Maximum number of polling attempts. Defaults to no limit
7676
* @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output
@@ -83,7 +83,7 @@ class Replicate {
8383
/^(?<owner>[a-zA-Z0-9-_]+?)\/(?<name>[a-zA-Z0-9-_]+?):(?<version>[0-9a-fA-F]+)$/;
8484
const match = identifier.match(pattern);
8585

86-
if (!match) {
86+
if (!match || !match.groups) {
8787
throw new Error(
8888
'Invalid version. It must be in the format "owner/name:version"'
8989
);

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
module.exports = {
44
preset: 'ts-jest',
55
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.ts?$': ['ts-jest', {
8+
tsconfig: 'tsconfig.json'
9+
}],
10+
},
611
};

jsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"checkJs": true,
4+
"module": "ESNext",
5+
"moduleResolution": "Node",
6+
"target": "ES2020",
7+
"resolveJsonModule": true,
8+
"strictNullChecks": true,
9+
"strictFunctionTypes": true
10+
},
11+
"exclude": [
12+
"node_modules",
13+
"**/node_modules/*"
14+
]
15+
}

lib/predictions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @param {object} options
55
* @param {string} options.version - Required. The model version
66
* @param {object} options.input - Required. An object with the model inputs
7-
* @param {boolean|object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
7+
* @param {object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
88
* @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 250
99
* @param {number} [options.wait.maxAttempts] - Maximum number of polling attempts. Defaults to no limit
1010
* @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output
@@ -20,7 +20,7 @@ async function createPrediction(options) {
2020
});
2121

2222
if (wait) {
23-
const { maxAttempts, interval } = options.wait;
23+
const { maxAttempts, interval } = wait;
2424
return this.wait(await prediction, { maxAttempts, interval });
2525
}
2626

package-lock.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"test": "jest"
1313
},
1414
"devDependencies": {
15-
"@tsconfig/recommended": "^1.0.2",
1615
"@types/jest": "^29.5.0",
1716
"@typescript-eslint/eslint-plugin": "^5.56.0",
1817
"cross-fetch": "^3.1.5",

tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "@tsconfig/recommended/tsconfig.json"
2+
"compilerOptions": {
3+
"esModuleInterop": true
4+
},
5+
"exclude": [
6+
"node_modules",
7+
"**/node_modules/*"
8+
]
39
}

0 commit comments

Comments
 (0)