denoland / denoland/dnt

`typeCheck` fails unexpectedly

Open
#196 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.3k
Forks
49
PR merge metrics
No merged PRs in 30d

Description

I'm wondering whether there's a way to disable typechecking of specific outputs? / what is the recommended approach to addressing the following (I'm making use of the ws and Deno shims, as well as the Deno std lib)?

```
src/_dnt.shims.ts:3:38 - error TS7016: Could not find a declaration file for module 'ws'. '/Users/harrysolovay/Desktop/capi/target/npm/node_modules/ws/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/ws` if it exists or add a new declaration (.d.ts) file containing `declare module 'ws';`

3 import { default as WebSocket } from "ws";
~~~~
src/_dnt.shims.ts:4:38 - error TS7016: Could not find a declaration file for module 'ws'. '/Users/harrysolovay/Desktop/capi/target/npm/node_modules/ws/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/ws` if it exists or add a new declaration (.d.ts) file containing `declare module 'ws';`

4 export { default as WebSocket } from "ws";
~~~~
src/deps/deno.land/std@0.127.0/async/debounce.ts:55:5 - error TS2322: Type 'Timeout' is not assignable to type 'number'.

55 timeout = setTimeout(flush, wait);
~~~~~~~
src/deps/deno.land/std@0.127.0/async/pool.ts:67:10 - error TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'ReadableStream'.
Property '[SymbolConstructor.asyncIterator]' does not exist on type 'ReadableStream'.

67 return res.readable[Symbol.asyncIterator]();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hashers/mod.ts:2:29 - error TS2307: Cannot find module './mod.generated.js' or its corresponding type declarations.

2 import { instantiate } from "./mod.generated.js";
~~~~~~~~~~~~~~~~~~~~
src/ss58/mod.ts:3:29 - error TS2307: Cannot find module './mod.generated.js' or its corresponding type declarations.

3 import { instantiate } from "./mod.generated.js";
~~~~~~~~~~~~~~~~~~~~
src/test-util/node.ts:13:23 - error TS2694: Namespace '"/Users/harrysolovay/Desktop/capi/target/npm/node_modules/@deno/shim-deno-test/dist/test"' has no exported member 'Process'.

13 inner: dntShim.Deno.Process;
~~~~~~~
src/test-util/node.ts:24:34 - error TS2339: Property 'run' does not exist on type 'typeof import("/Users/harrysolovay/Desktop/capi/target/npm/node_modules/@deno/shim-deno-test/dist/test")'.

24 const process = dntShim.Deno.run({
~~~
src/test-util/node.ts:41:22 - error TS2339: Property 'stdout' does not exist on type 'typeof import("/Users/harrysolovay/Desktop/capi/target/npm/node_modules/@deno/shim-deno-test/dist/test")'.

41 dntShim.Deno.stdout.write(log);
~~~~~~
src/test-util/node.ts:58:35 - error TS2339: Property 'errors' does not exist on type 'typeof import("/Users/harrysolovay/Desktop/capi/target/npm/node_modules/@deno/shim-deno-test/dist/test")'.

58 if (e instanceof dntShim.Deno.errors.NotFound) {
~~~~~~
src/test-util/sr25519/mod.ts:3:29 - error TS2307: Cannot find module './mod.generated.js' or its corresponding type declarations.

3 import { instantiate } from "./mod.generated.js";
~~~~~~~~~~~~~~~~~~~~
src/util/isPortAvailable.ts:4:35 - error TS2339: Property 'listen' does not exist on type 'typeof import("/Users/harrysolovay/Desktop/capi/target/npm/node_modules/@deno/shim-deno-test/dist/test")'.

4 const listener = dntShim.Deno.listen({
~~~~~~
src/util/isPortAvailable.ts:12:39 - error TS2339: Property 'errors' does not exist on type 'typeof import("/Users/harrysolovay/Desktop/capi/target/npm/node_modules/@deno/shim-deno-test/dist/test")'.

12 if (error instanceof dntShim.Deno.errors.AddrInUse) {
~~~~~~

error: Uncaught (in promise) Error: Had 13 diagnostics.
throw new Error(`Had ${diagnostics.length} diagnostics.`);
^
at build (https://deno.land/x/dnt@0.26.0/mod.ts:293:15)
at async Promise.all (index 0)
at async file:///Users/harrysolovay/Desktop/capi/_tasks/dnt.ts:9:1
```

Also, `mod.generated.js` contains JSDoc annotations (is actually the output of wasmbuild).

Any thoughts?

Contributor guide

Open the contributing guide

Research direction

Start with _tasks/dnt.ts and the dnt build entry point, then inspect the reported diagnostics from src/_dnt.shims.ts, src/deps/deno.land/std@0.127.0, src/hashers/mod.ts, src/ss58/mod.ts, src/test-util, and src/util/isPortAvailable.ts. Reproduce the typeCheck run and determine the supported behavior for generated JavaScript, shims, and external declarations. Done means the documented type-checking behavior matches the build result without these unexpected diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
deno, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.