Skip to content

TypeScript / package.json configurations #191

@rajsite

Description

@rajsite

Describe the issue

We should consider creating a package or documenting recommended TypeScript Config and package.json export configs. For now using this issue to capture some common guidance today:

  • use strict
  • Do not enable skipLibCheck: true, see: https://github.com/remcohaszing/skiplibcheck
  • Prefer "moduleResolution": "Node16" (or higher) for web+node / node-only libraries or "moduleResolution": "bundler" for web-only libraries. Related have a package.json structure of:
     "type": "module",
     "exports": {
      "./package.json": "./package.json",
      ".": {
        "types": "./dist/esm/index.d.ts",
        "import": "./dist/esm/index.js"
      },
      "./*": {
        "types": "./dist/esm/*.d.ts",
        "import": "./dist/esm/*/index.js"
      }
     },
     "typesVersions": {
      "*": {
        "*": [
          "dist/esm/*",
          "dist/esm/*/index.d.ts"
        ]
      }
     },
    
    Which enables base and secondary entrypoints from index files and is a file structure / package.json configuration compatible with modern and legacy node import behaviors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions