andykais
andykais•3y ago

npm specifier import types

so when I do something like
import * as rx from 'npm:rxjs'

console.log(rx)
import * as rx from 'npm:rxjs'

console.log(rx)
I do have the correct code imported, but types are all any. Is this the expected state of npm imports, or is there a bug here? I am running
deno 1.26.1 (release, x86_64-unknown-linux-gnu)
v8 10.7.193.3
typescript 4.8.3
deno 1.26.1 (release, x86_64-unknown-linux-gnu)
v8 10.7.193.3
typescript 4.8.3
11 Replies
dan.the.discloser
dan.the.discloser•3y ago
document says that typescript is not in the current release of npm compatibility but is expected to be in the next one
dan.the.discloser
dan.the.discloser•3y ago
Deno
Node Compatibility Mode | Manual | Deno
Starting with v1.15 Deno provides Node compatibility mode that makes it possible to run a subset of programs authored for Node directly in Deno. Compatibility mode can be activated by passing `--comp
dan.the.discloser
dan.the.discloser•3y ago
can take the type files from
dan.the.discloser
dan.the.discloser•3y ago
GitHub
rxjs/api_guard/dist/types at master · ReactiveX/rxjs
A reactive programming library for JavaScript. Contribute to ReactiveX/rxjs development by creating an account on GitHub.
andykais
andykaisOP•3y ago
thanks for that clarification
bartlomieju
bartlomieju•3y ago
@dsherret is working on types support, it will probably ship in V1.27
andykais
andykaisOP•3y ago
@.bartlomieju / @dsherret are npm types supported in 1.28? It seems like they are https://github.com/denoland/deno/issues/15960, but imports like
import * as rx from 'npm:rxjs'
import * as rx from 'npm:rxjs'
or
import { ScriptServer } from 'npm:@scriptserver/core'
import { ScriptServer } from 'npm:@scriptserver/core'
seem to still have any types
dsherret
dsherret•3y ago
if you get a chance could you open a bug (i'm just heading out)? It looks like rxjs has an entry for "types": "index.d.ts",, but then that file doesn't exist in the package, so it looks like in that scenario we should use the exports -> . -> types entry for @scriptserver/core it distributes its types, but then it doesn't have a "types" entry in its package.json, but it seems like typescript still figures it out by resolving the "main" entrypoint and looking for the corresponding declaration file
andykais
andykaisOP•3y ago
sure! Sorry for asking questions right before thanksgiving 😅. Ill make an issue
andykais
andykaisOP•3y ago
GitHub
npm specifiers types not working · Issue #16782 · denoland/deno
I have two packages here that appear to be packaged with typescript types, but may provide them in unexpected ways. import * as scriptserver from 'npm:@scriptserver/core' import * a...
dsherret
dsherret•3y ago
no, it's ok. I'm in Canada so we already celebrated last month 🙂 also, thanks for creating the issue!