denoland / website_feedback

For reporting issues & suggestions for deno.com and deno.land
9 stars 1 forks source link

deno.land/x/ package docs: using `import { type default }` with `const` is incorrect and confusing #53

Open rattrayalex opened 9 months ago

rattrayalex commented 9 months ago

See https://github.com/openai/openai-node/issues/477

The docs here: https://deno.land/x/openai@v4.16.1/mod.ts?s=default.ChatCompletion

recommend this code:

import { type default } from "https://deno.land/x/openai@v4.16.1/mod.ts";
const { ChatCompletion } = default;

which cause this error:

Identifier expected.

The code should instead be this:

import type OpenAI from "https://deno.land/x/openai@v4.16.1/mod.ts";
type ChatCompletion = OpenAI.ChatCompletion

Which involves a few changes:

  1. Use the name of the thing that is exported instead of default when possible
  2. don't use const for a type
rattrayalex commented 9 months ago

Ah, this should perhaps be merged into https://github.com/denoland/deno_doc/issues/395