#Any way to import a json file array and have it show as correctly typed once built

4 messages · Page 1 of 1 (latest)

abstract saddle
#

I want to import a json file that contains an array in my typescript package. Once I run the tsc command I'd like to have an output file that shows the contents of the array correctly.

E.g.

// someArray.json
[
 "hello",
 "world"
]
// src/someFile.ts
export {default as variableSomeArray} from '../someArray.json'

Would love for output of someFile.d.ts to show variableSomeArray as ["hello", "world"] even if the json file is copied into the output it's fine for me.

faint badger
#

if so, it doesn't exist (which is why the issue is still open)

#

do you need to use a .json file for this? could you instead use a .ts file containing a single export of the array value?