Skip to content

How to publish a package that's compatible with projects using "moduleResolution": "nodenext" #53636

@jedwards1211

Description

@jedwards1211

Bug Report

I'm trying to use antlr4 in a project. I have this import:

import { CharStream, CommonTokenStream }  from 'antlr4';

If I use "moduleResolution": "nodenext" it says "Module '"antlr4"' has no exported member 'CommonTokenStream'."
This is using TS 5.0.3.

I'd like to make a PR to antlr4 to fix this, but I'm not sure what the correct solution is. There's no obvious best-practice package authoring guidance in the TS docs.

What should be changed in antlr4's package.json? It has "type": "module", "main" and "types" fields. It doesn't seem like the docs are of any help here except that they say "types" is a "Fall-back for older versions of TypeScript". Does this mean "nodenext" completely ignores "types" and the only option would be for antlr4 to provide an export map, or what?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions