From 2179f65fd95451279bcc0f32dc721e267979f2ef Mon Sep 17 00:00:00 2001 From: Chet Corcos Date: Wed, 12 Oct 2022 12:55:01 -0700 Subject: [PATCH] Build typescript types --- .gitignore | 2 ++ package.json | 5 ++++- tsconfig.json | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 76ebcfa0..2112712d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ build/ *.mobileprovision dist/ package-lock.json + +types/ \ No newline at end of file diff --git a/package.json b/package.json index 18ac7c49..87143bc7 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "lint": "standardx -v", "readme": "node ./bin/generate-docs.js", + "build-types": "tsc", "test": "cd test && npm install --silent --no-audit && npm test", "test:node": "node ./test/node/index.js", "test:ios-simulator": "cd test && npm install --silent --no-audit && npm run test:ios-simulator", @@ -29,10 +30,12 @@ "homepage": "https://github.com/socketsupply/io#readme", "description": "Socket Runtime JavaScript interface", "devDependencies": { + "@types/node": "18.8.5", "acorn": "8.8.0", "acorn-walk": "8.2.0", "esbuild": "0.15.9", - "tapzero": "*" + "tapzero": "*", + "typescript": "4.8.4" }, "dependencies": { "buffer": "6.0.3" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..d1bb944b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,24 @@ +{ + // Change this to match your project + "include": ["**/*"], + "exclude": ["test", "bin", "repl", "types"], + "compilerOptions": { + // Includes BigInt, among other features. + "lib": ["es2020"], + // Tells TypeScript to read JS files, as + // normally they are ignored as source files + "allowJs": true, + // Generate d.ts files + "declaration": true, + // This compiler run should + // only output d.ts files + "emitDeclarationOnly": true, + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + // go to js file when using IDE functions like + // "Go to Definition" in VSCode + "declarationMap": true + } +}