I just forked remark-docx from github to make a small minor change and now when I rebuild it, I am getting some TS2749 errors:
$ npm run build
> [email protected] build
> rollup -c
src/index.ts → lib/index.js, lib/index.mjs...
(!) Plugin typescript: @rollup/plugin-typescript TS2749: 'HeadingLevel' refers to a value, but is being used as a type here. Did you mean 'typeof HeadingLevel'?
src/transformer.ts: (360:16)
360 let heading: HeadingLevel;
~~~~~~~~~~~~
(!) Plugin typescript: @rollup/plugin-typescript TS2749: 'AlignmentType' refers to a value, but is being used as a type here. Did you mean 'typeof AlignmentType'?
src/transformer.ts: (427:21)
427 const cellAligns: AlignmentType[] | undefined = align?.map((a) => {
~~~~~~~~~~~~~
src/transformer.ts: (450:15)
450 cellAligns: AlignmentType[] | undefined
~~~~~~~~~~~~~
src/transformer.ts: (462:10)
462 align: AlignmentType | undefined
~~~~~~~~~~~~~
The HeadlingLevel is defined as:
(alias) const HeadingLevel: {
readonly HEADING_1: "Heading1";
readonly HEADING_2: "Heading2";
readonly HEADING_3: "Heading3";
readonly HEADING_4: "Heading4";
readonly HEADING_5: "Heading5";
readonly HEADING_6: "Heading6";
readonly TITLE: "Title";
}
import HeadingLevel
and AlignmentType is the same pattern.
For the first error, I got rid of it by removing the type. Any other attempt with typeof for example would cause an error further down.
As for the errors with AlignmentType, on the first I did the same thing and the others I used “any” instead.
But not being an expert here, nothing that I did here feel right to me coming from 25 years of mostly Java.
How should this be “casted” here and why are these errors showing up in a package that has obviously been build in the past.