This repository was archived by the owner on Sep 21, 2023. It is now read-only.
File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,32 @@ package:
48
48
import express from "npm:express@^4.17";
49
49
```
50
50
51
+ ### Module resolution
52
+
53
+ The official TypeScript compiler ` tsc ` supports different
54
+ [ moduleResolution] ( https://www.typescriptlang.org/tsconfig#moduleResolution )
55
+ settings. Deno only supports the modern ` node16 ` resolution. Unfortunately many
56
+ NPM packages fail to correctly provide types under node16 module resolution,
57
+ which can result in ` deno check ` reporting type errors, that ` tsc ` does not
58
+ report.
59
+
60
+ If a default export from an ` npm: ` import appears to have a wrong type (with the
61
+ right type seemingly being available under the ` .default ` property), it's most
62
+ likely that the packaged types do not support node16. You can verify this by
63
+ checking if the error also occurs with ` tsc --module node16 ` or by consulting
64
+ the [ Are the types wrong?] ( https://arethetypeswrong.github.io/ ) website
65
+ (particularly the "node16 from ESM" row).
66
+
67
+ If you want to use a package that doesn't support TypeScript's node16 module
68
+ resolution, you can:
69
+
70
+ 1 . Open an issue at the issue tracker of the package about the problem. (And
71
+ perhaps contribute a fix :)
72
+ 2 . Use a [ CDN] ( ./cdns.md ) , that rebuilds the packages for Deno support, instead
73
+ of an ` npm: ` identifier.
74
+ 3 . Ignore the type errors you get in your code base with ` // @ts-expect-error `
75
+ or ` // @ts-ignore ` .
76
+
51
77
### Including Node types
52
78
53
79
Node ships with many built-in types like ` Buffer ` that might be referenced in an
You can’t perform that action at this time.
0 commit comments