Node v14.x, StencilJS (React) v2.3.x
I had a test-helper file with an exported function that converts string-arrays to number-arrays:
export function parseNumericStringOrStringArrayToIntegers(value: string | (string | string[])[]): number | (number | number[])[] {
if (typeof value === 'string') {
return parseInt(value);
} else {
return value.map((item) => parseNumericStringOrStringArrayToIntegers(item)) as number | (number | number[])[];
}
}
I decided that this function should be in index.d.ts
of the component, so I could use it more logically in the component itself. I moved it and changed export
to declare
, removed import {parseNumericStringOrStringArrayToIntegers} from "./index";
where it was altered by JetBrains IDE > move, and strangely expected stuff to 'just work'. It didn't...
It threw me two errors in npm run build
that seem relevant, but I have no clue how to fix it:
[ ERROR ] TypeScript: ./src/components/app/index.d.ts:46:108
An implementation cannot be declared in ambient contexts.
L46: declare function parseNumericStringOrStringArrayToIntegers(value: string | (string | string[])[]): ConfigIntValue {
L47: if (typeof value === 'string') {
[ ERROR ] TypeScript: ./src/components/app/index.d.ts:48:5
Statements are not allowed in ambient contexts.
L47: if (typeof value === 'string') {
L48: return parseInt(value);
L49: } else {
Apparently, I'm missing something obvious here, but what?