Skip to content

Configure jsconfig.json and tsconfig.json #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 11, 2023
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
project: './tsconfig.json',
project: './jsconfig.json',
},
plugins: ['jest', 'jsdoc'],
rules: {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Replicate {
* @param {string} identifier - Required. The model version identifier in the format "{owner}/{name}:{version}"
* @param {object} options
* @param {object} options.input - Required. An object with the model inputs
* @param {boolean|object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
* @param {object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
* @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 250
* @param {number} [options.wait.maxAttempts] - Maximum number of polling attempts. Defaults to no limit
* @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output
Expand All @@ -83,7 +83,7 @@ class Replicate {
/^(?<owner>[a-zA-Z0-9-_]+?)\/(?<name>[a-zA-Z0-9-_]+?):(?<version>[0-9a-fA-F]+)$/;
const match = identifier.match(pattern);

if (!match) {
if (!match || !match.groups) {
throw new Error(
'Invalid version. It must be in the format "owner/name:version"'
);
Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.ts?$': ['ts-jest', {
tsconfig: 'tsconfig.json'
}],
},
};
15 changes: 15 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"checkJs": true,
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"resolveJsonModule": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
4 changes: 2 additions & 2 deletions lib/predictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @param {object} options
* @param {string} options.version - Required. The model version
* @param {object} options.input - Required. An object with the model inputs
* @param {boolean|object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
* @param {object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false
* @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 250
* @param {number} [options.wait.maxAttempts] - Maximum number of polling attempts. Defaults to no limit
* @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output
Expand All @@ -20,7 +20,7 @@ async function createPrediction(options) {
});

if (wait) {
const { maxAttempts, interval } = options.wait;
const { maxAttempts, interval } = wait;
return this.wait(await prediction, { maxAttempts, interval });
}

Expand Down
7 changes: 0 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"test": "jest"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
"@types/jest": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"cross-fetch": "^3.1.5",
Expand Down
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"extends": "@tsconfig/recommended/tsconfig.json"
"compilerOptions": {
"esModuleInterop": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}