diff --git a/.projenrc.ts b/.projenrc.ts index 1bcd3d72..acafdb65 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -7,7 +7,6 @@ const project = new typescript.TypeScriptProject({ copyrightOwner: 'Yarn Community', projenrcTs: true, deps: ['@babel/preset-env'], - entrypoint: 'dist/yarn-bound.js', description: 'Quality of life wrapper around bondage.js', devDeps: ['eslint-plugin-prettier', 'esbuild', 'prettier', 'eslint-plugin-sonarjs', 'ts-node'], tsconfig: { diff --git a/package.json b/package.json index 4bfa38b4..590ae1c2 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "dependencies": { "@babel/preset-env": "^7.20.2" }, - "main": "dist/yarn-bound.js", + "main": "lib/index.js", "license": "MIT", "version": "0.0.0", "jest": { @@ -90,6 +90,6 @@ } } }, - "types": "dist/yarn-bound.d.ts", + "types": "lib/index.d.ts", "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." } diff --git a/src/yarn-bound.ts b/src/yarn-bound.ts index 05097443..dc8a5a6b 100755 --- a/src/yarn-bound.ts +++ b/src/yarn-bound.ts @@ -1,17 +1,37 @@ -// @ts-nocheck import bondage from './bondage'; import parseLine from './line-parser'; + +interface props { + dialogue: string; + variableStorage: any; + functions: any; + handleCommand: any; + combineTextAndOptionsResults: any; + locale: any; + startAt: string; +} + export default class YarnBound { + public handleCommand: any; + public combineTextAndOptionsResults: any; + public bondage: any; + public bufferedNode: any; + public currentResult: any; + public history: any; + public locale: any; + public runner: any; + private generator: any; + constructor({ dialogue, variableStorage, functions, handleCommand, combineTextAndOptionsResults, - locale, + locale = undefined, startAt = 'Start', - }) { + }: props) { this.handleCommand = handleCommand; this.combineTextAndOptionsResults = combineTextAndOptionsResults; this.bondage = bondage; @@ -37,14 +57,14 @@ export default class YarnBound { this.jump(startAt); } - jump(startAt) { + jump(startAt: string) { this.generator = this.runner.run(startAt); this.bufferedNode = null; this.advance(); } // eslint-disable-next-line sonarjs/cognitive-complexity - advance(optionIndex: number) { + advance(optionIndex: undefined | number = undefined) { if (typeof optionIndex !== 'undefined' && this.currentResult && this.currentResult.select) { this.currentResult.select(optionIndex); } @@ -85,6 +105,7 @@ export default class YarnBound { if (next instanceof bondage.TextResult) { parseLine(next, this.locale); } else if (next instanceof bondage.OptionsResult) { + // @ts-ignore if (next.text) { parseLine(next, this.locale); } @@ -97,7 +118,7 @@ export default class YarnBound { this.bufferedNode = buffered; } - registerFunction(name: string, func) { + registerFunction(name: string, func: any) { this.runner.registerFunction(name, func); } }