Skip to content

Commit

Permalink
fix Deno check and Deno test
Browse files Browse the repository at this point in the history
  • Loading branch information
bozdoz committed Oct 16, 2024
1 parent 123b6b0 commit 70b85dc
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 122 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
deno-version: v2.x
- run: deno install
- run: deno task build
- run: deno task check
- run: deno task lint
- run: deno task test:coverage
- uses: codecov/codecov-action@v4
Expand Down
45 changes: 45 additions & 0 deletions DENO.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,51 @@ Had to create a build.ts, but it seems successful at removing rollup; which mean

Created a watch mode for the build.ts script without much fuss at all. `deno run --watch` only watches the script and modules that you call directly, so I had to use the runtime API to use `Deno.watchFs`; it had a problem where it ran modify events three times in a row, so I also imported a recommended debounce script from the std library (versionless because we're all insane: https://jsr.io/@std/async/doc/debounce).

## Deno test

Needed a deno.json file, with "DOM" in "lib".

Needed to run with `unstable-sloppy-imports` to ignore lack of ".ts" extensions.

Needed to add to my tsconfig.json:

```json
"allowImportingTsExtensions": true,
"noEmit": true,
"module": "ES2020",
```

This is because I was running `require('index')` in the index test.

I needed to import tests to a single test file in order for Deno to pick up on Jest types:

`// @deno-types=npm:@types/jest`

## Deno Check

Needed a global.d.ts file to properly type check files, but I also needed to ignore the file for linting:

```ts
// deno-lint-ignore-file
declare var gtag: (...args: unknown[]) => void;

declare var dataLayer: unknown[];

declare var process: NodeJS.Process
```
If I didn't ignore the file for linting I would get:
> error[no-var]: `var` keyword is not allowed.
> --> /Users/delong/dev/typewritesomething/src/global.d.ts:6:1
> |
>6 | declare var process: NodeJS.Process
> | ^^^^^^^
>
> docs: https://lint.deno.land/rules/no-var



## Benchmarks

```
Expand Down
5 changes: 5 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"lib": ["DOM"]
}
}
Loading

0 comments on commit 70b85dc

Please sign in to comment.