diff --git a/.eslintignore b/.eslintignore index 9c1f61a0a..151e50ed8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ node_modules .github include/generated devhub-scraper-master +scripts diff --git a/include/tsconfig.json b/include/tsconfig.json index e93f36a52..78ecfa3bd 100644 --- a/include/tsconfig.json +++ b/include/tsconfig.json @@ -13,7 +13,7 @@ "rootDir": ".", "outDir": "out", // optional - "baseUrl": "src", + "baseUrl": ".", "declaration": false, "forceConsistentCasingInFileNames": true, "sourceMap": true, diff --git a/package.json b/package.json index de612251b..45442638e 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,12 @@ "publishConfig": { "access": "public" }, + "type": "module", "description": "TypeScript typings for the Roblox platform. Partially handwritten and partially automatically generated.", "scripts": { "build": "tsc && node out/index.js", - "check": "tsc include/**/*.d.ts --noEmit --skipLibCheck", + "precheck": "node ./scripts/link-self.js", + "check": "tsc -p include/tsconfig.json --noEmit", "eslint-src": "npx eslint \"src/**/*.ts\" --max-warnings 0", "eslint-include": "npx eslint \"include/*.ts\" --max-warnings 0", "eslint": "npm run eslint-src && npm run eslint-include" diff --git a/scripts/link-self.js b/scripts/link-self.js new file mode 100644 index 000000000..c02a90323 --- /dev/null +++ b/scripts/link-self.js @@ -0,0 +1,19 @@ +"use strict"; + +import fs from "fs"; +import path from "path"; + +// ensure @rbxts/compiler-types can resolve @rbxts/types when running local checks +const repoRoot = path.resolve(import.meta.dirname, ".."); +const scopeDir = path.join(repoRoot, "node_modules", "@rbxts"); +const linkPath = path.join(scopeDir, "types"); + +fs.mkdirSync(scopeDir, { recursive: true }); + +const existing = fs.existsSync(linkPath) ? fs.realpathSync(linkPath) : undefined; + +if (existing !== repoRoot) { + // replace any stale install with a symlink to the working copy + fs.rmSync(linkPath, { recursive: true, force: true }); + fs.symlinkSync(repoRoot, linkPath, "junction"); +}