Skip to content

Upgrade typescript, fix json import error #404

Closed
@raykyri

Description

@raykyri

On [email protected], importing package.json inside examples/chat-explorer or examples/common-explorer will no longer work, and fail with this error:

Named imports from a JSON file into an ECMAScript module are not allowed when 'module' is set to 'Node16'.

This can be seen in: https://github.com/search?q=repo%3Amicrosoft%2FTypeScript+%22named+imports+are+not+allowed%22&type=issues

Not using a named import (using import * as pkg from "package.json") also fails:

examples/chat-explorer/src/HomePage.tsx:1:22 - error TS1543: Importing a JSON file into an ECMAScript module requires a 'type: "json"' import attribute when 'module' is set to 'Node16'.

import * as pkg from "../package.json"

Adding with { type: "json" } can't be used to fix this because it doesn't work with Node16 resolution:

examples/chat-explorer/src/HomePage.tsx:1:40 - error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.

import * as pkg from "../package.json" with { type: "json" }

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