Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

KVNamespace declared differently than other interfaces #33

Closed
jdanyow opened this issue May 26, 2020 · 1 comment · Fixed by #34
Closed

KVNamespace declared differently than other interfaces #33

jdanyow opened this issue May 26, 2020 · 1 comment · Fixed by #34

Comments

@jdanyow
Copy link
Contributor

jdanyow commented May 26, 2020

Why is the KVNamespace declared differently than the rest of the interfaces?

workers-types/index.d.ts

Lines 443 to 444 in 6340625

declare module '@cloudflare/workers-types' {
export interface KVNamespace {

Would it be better to reference the types like this?

{
  "extends": "../../tsconfig-base",
  "compilerOptions": {
    "target": "esnext",
    "lib": ["webworker", "esnext"],
    "composite": false,
    "types": ["@cloudflare/workers-types"]
  }
}

Just thinking the instructions in the README are strange with respect to the empty import:

Usage
Just supply an empty import in one of your source files to receive the workers types

import {} from '@cloudflare/workers-types'

Might be considered an unused import by formatters/linters.

@jdanyow jdanyow changed the title declare module interferes with ambient types KVNamespace declared differently than other interfaces May 26, 2020
@1000hz
Copy link
Contributor

1000hz commented May 28, 2020

I think this is a great suggestion. The usage of declare module here is definitely incorrect. I agree, our recommendation for usage is a bit clunky, including it via types is the way to go. I was initially unsure if that'd be a good idea since specifying types would preclude automatic inclusion of any @types/* packages, but I realize now that's largely irrelevant since most of those packages would be providing types for modules that are imported, not global.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants