Open SuperchupuDev opened 1 year ago
for anyone else running into this, I was able to work around it by casting the import as any
e.g. in the example above:
import { default as whateverTyped } from './whatever.json';
export const whatever = whateverTyped as any
export function something(): boolean {
return true;
}
having the following config:
and this (example) typescript code:
tsup adds the following to the declaration files when exporting a json file in one of the ts files:
this makes typescript throw
Initializers are not allowed in ambient contexts. ts(1039)
the solution would be to actually resolve the json type (just like how plain typescript does under
resolveJsonModule
) and type it as suchfor example:
another solution would be to just use valid dts syntax, this would be easier to implement as tsup wouldn't have to resolve the json type, but it would increase filesize
Upvote & Fund