LoginSignup
0
0

More than 3 years have passed since last update.

Typescript + node-configで「プロパティ 'hogehoge' は型 'IConfig' に存在しません。」問題に対処する

Last updated at Posted at 2020-05-18
import * as config from 'config'

console.log(config.hogehoge)

と書くと、

TS2339: Property 'hogehoge' does not exist on type 'IConfig'

とエラーが出てしまう。コンパイルはできるけどエラー表示は消したい。
config.get()を使うと

TS1259: Module '"D:\\node_modules\\@types\\config\\index"' can only be default-imported using the 'esModuleInterop' flag

と別のエラーになってしまう。
ひとまずの対処で

import * as config from 'config'

const myConfig: any = config

console.log(myConfig.hogehoge)

ウーン、代入しなおすしかないのか...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0