Skip to content

Use correct imports in the documentation examples #579

@IcyFoxe

Description

@IcyFoxe

Imports without an extension

All examples in the documentation have relative imports without a file extension.
However freshly initialized app uses "module": "NodeNext" in tsconfig.json which requires these imports to have an extension.

If you try to use a relative import without an extension you get this error:

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'.

I think it should be fixed, to show correct examples that won't need to be fixed after copying by the user.

Imports without a type keyword

There are also some examples that import types without the type keyboard.
For example import { AppType } from './server' in the "Hono Stacks" page should've been import type { AppType } from './server', otherwise it will throw this error:

'AppType' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

Again, this is using the default configuration of the initialized app, so these examples should adhere to that configuration.


I'm new to Hono, and I just want to say that I really like it so far, and appreciate all the work you guys have put into it. I believe that the documentation is the most important part of any framework, so making sure that it is nicely categorized, has lots of examples and correct code is extremely helpful to every newcomer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions