diff --git a/src/globals-jsr.ts b/src/globals-jsr.ts index 08953088b3..5c4fbbda70 100644 --- a/src/globals-jsr.ts +++ b/src/globals-jsr.ts @@ -14,3 +14,52 @@ import * as _ from './index.ts' Object.assign(globalThis, _) + +declare global { + type ProcessPromise = _.ProcessPromise + type ProcessOutput = _.ProcessOutput + var ProcessPromise: typeof _.ProcessPromise + var ProcessOutput: typeof _.ProcessOutput + var $: typeof _.$ + var argv: typeof _.argv + var cd: typeof _.cd + var chalk: typeof _.chalk + var defaults: typeof _.defaults + var dotenv: typeof _.dotenv + var echo: typeof _.echo + var expBackoff: typeof _.expBackoff + var fs: typeof _.fs + var glob: typeof _.glob + var globby: typeof _.globby + var kill: typeof _.kill + var log: typeof _.log + var minimist: typeof _.minimist + var nothrow: typeof _.nothrow + var os: typeof _.os + var parseArgv: typeof _.parseArgv + var path: typeof _.path + var ps: typeof _.ps + var question: typeof _.question + var quiet: typeof _.quiet + var quote: typeof _.quote + var quotePowerShell: typeof _.quotePowerShell + var resolveDefaults: typeof _.resolveDefaults + var retry: typeof _.retry + var sleep: typeof _.sleep + var spinner: typeof _.spinner + var stdin: typeof _.stdin + var syncProcessCwd: typeof _.syncProcessCwd + var tempdir: typeof _.tempdir + var tempfile: typeof _.tempfile + var tmpdir: typeof _.tempdir + var tmpfile: typeof _.tempfile + var updateArgv: typeof _.updateArgv + var usePowerShell: typeof _.usePowerShell + var usePwsh: typeof _.usePwsh + var useBash: typeof _.useBash + var version: typeof _.version + var VERSION: typeof _.VERSION + var which: typeof _.which + var within: typeof _.within + var YAML: typeof _.YAML +} diff --git a/src/globals.ts b/src/globals.ts index 9afed3b212..3e596acd33 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -15,7 +15,7 @@ import * as _ from './index.ts' Object.assign(globalThis, _) -// TODO: global types not working with jsr.io + declare global { type ProcessPromise = _.ProcessPromise type ProcessOutput = _.ProcessOutput diff --git a/test/export.test.js b/test/export.test.js index eea5abebe6..58116245ac 100644 --- a/test/export.test.js +++ b/test/export.test.js @@ -242,12 +242,15 @@ describe('index', () => { assert.equal(typeof index.fs, 'object', 'index.fs') assert.equal(typeof index.fs.Dir, 'function', 'index.fs.Dir') assert.equal(typeof index.fs.Dirent, 'function', 'index.fs.Dirent') + assert.equal(typeof index.fs.F_OK, 'number', 'index.fs.F_OK') assert.equal(typeof index.fs.FileReadStream, 'function', 'index.fs.FileReadStream') assert.equal(typeof index.fs.FileWriteStream, 'function', 'index.fs.FileWriteStream') + assert.equal(typeof index.fs.R_OK, 'number', 'index.fs.R_OK') assert.equal(typeof index.fs.ReadStream, 'function', 'index.fs.ReadStream') assert.equal(typeof index.fs.Stats, 'function', 'index.fs.Stats') - assert.equal(typeof index.fs.Utf8Stream, 'function', 'index.fs.Utf8Stream') + assert.equal(typeof index.fs.W_OK, 'number', 'index.fs.W_OK') assert.equal(typeof index.fs.WriteStream, 'function', 'index.fs.WriteStream') + assert.equal(typeof index.fs.X_OK, 'number', 'index.fs.X_OK') assert.equal(typeof index.fs._toUnixTimestamp, 'function', 'index.fs._toUnixTimestamp') assert.equal(typeof index.fs.access, 'function', 'index.fs.access') assert.equal(typeof index.fs.accessSync, 'function', 'index.fs.accessSync') @@ -323,7 +326,6 @@ describe('index', () => { assert.equal(typeof index.fs.mkdirs, 'function', 'index.fs.mkdirs') assert.equal(typeof index.fs.mkdirsSync, 'function', 'index.fs.mkdirsSync') assert.equal(typeof index.fs.mkdtemp, 'function', 'index.fs.mkdtemp') - assert.equal(typeof index.fs.mkdtempDisposableSync, 'function', 'index.fs.mkdtempDisposableSync') assert.equal(typeof index.fs.mkdtempSync, 'function', 'index.fs.mkdtempSync') assert.equal(typeof index.fs.move, 'function', 'index.fs.move') assert.equal(typeof index.fs.moveSync, 'function', 'index.fs.moveSync') diff --git a/test/it/build-jsr.test.js b/test/it/build-jsr.test.js index 52bd1d6de9..98a426074a 100644 --- a/test/it/build-jsr.test.js +++ b/test/it/build-jsr.test.js @@ -48,6 +48,6 @@ describe('jsr artifact', () => { it('publish --dry-run`', async () => { await t$`node scripts/build-jsr.mjs` - await t$({ quiet: false })`jsr publish --dry-run` + await t$({ quiet: false })`jsr publish --dry-run --allow-slow-types` }) }) diff --git a/tsconfig.json b/tsconfig.json index d50e0eaad2..e31d7e90ea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,5 +14,7 @@ "types": ["node", "fs-extra"] }, "include": ["./src/**/*"], - "exclude": ["./src/globals.ts"] + "exclude": ["./src/globals.ts", "./src/globals-jsr.ts"] } +// globals-jsr.ts is excluded to prevent "Duplicate identifier" errors with globals.ts during the main build. +// It is used specifically for the JSR distribution.