chartjs / chartjs/chartjs-plugin-annotation

TypeScript type issues

Open
#977 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
623
Forks
377
PR merge metrics
No merged PRs in 30d

Description

I'm working on updating a Node.js TypeScript project to use TypeScript's [`"module": "nodenext"`](https://www.typescriptlang.org/tsconfig/#module) and [`"moduleResolution": "nodenext"`](https://www.typescriptlang.org/tsconfig/#moduleResolution) and am getting several compiler errors similar to the following:

```
error TS2614: Module '"chartjs-plugin-annotation"' has no exported member 'AnnotationOptions'.
Did you mean to use 'import AnnotationOptions from "chartjs-plugin-annotation"' instead?

import type { AnnotationOptions } from 'chartjs-plugin-annotation';
~~~~~~~~~~~~~~~~~
```

From what I can tell, the problem is caused by the relative imports within chartjs-plugin-annotation's `types` directory. Running tsc reveals that TypeScript expects to see, e.g., a `./options` file and doesn't check for `./options.d.ts`:

```
======== Resolving module './options' from '/Users/josh/src/app/node_modules/chartjs-plugin-annotation/types/index.d.ts'. ========
Explicitly specified module resolution kind: 'NodeNext'.
Resolving in ESM mode with conditions 'import', 'types', 'node'.
Loading module as file / folder, candidate module location '/Users/josh/src/app/node_modules/chartjs-plugin-annotation/types/options', target file types: TypeScript, JavaScript, Declaration, JSON.
Directory '/Users/josh/src/app/node_modules/chartjs-plugin-annotation/types/options' does not exist, skipping all lookups in it.
======== Module name './options' was not resolved. ========
```

The [Are the Types Wrong](https://arethetypeswrong.github.io/?p=chartjs-plugin-annotation%403.1.0) tool reports these as "internal resolution errors" and also points out issues with CJS versus ESM types.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.