dsherret / ts-nameof

nameof in TypeScript
MIT License
492 stars 23 forks source link

Call expression must have one argument or type argument: nameof() #116

Open Yogoort opened 3 years ago

Yogoort commented 3 years ago

I faced with the same error: In this part of code nameof<SomeEntityModel>()

Call expression must have one argument or type argument: nameof()

      at Object.throwErrorForSourceFile (node_modules/@ts-nameof/common/dist/errors.js:9:11)
      at PluginPass.CallExpression (node_modules/@ts-nameof/transforms-babel/dist/index.js:19:33)
      at newFn (node_modules/@babel/traverse/lib/visitors.js:171:21)
      at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:53:20)
      at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:40:17)
      at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:90:31)
      at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:99:16)
      at TraversalContext.visitMultiple (node_modules/@babel/traverse/lib/context.js:68:17)
      at TraversalContext.visit (node_modules/@babel/traverse/lib/context.js:125:19)
      at Function.traverse.node (node_modules/@babel/traverse/lib/index.js:76:17) 

My package.json

{
        "@types/ts-nameof": "^4.2.1",
        "babel-plugin-ts-nameof": "^4.2.1",
        "ts-nameof": "^5.0.0",
}

babel.config

module.exports = {
    presets: [
        [
            "@babel/preset-env",
            {
                modules: false,
                useBuiltIns: "entry",
                corejs: {
                    version: "3.8",
                    proposals: true,
                },
            },
        ],
        "@babel/preset-flow",
        [
            "@babel/preset-typescript",
            {
                allowDeclareFields: true,
            },
        ],
        "@vue/cli-plugin-babel/preset",
    ],
    plugins: ["@babel/plugin-transform-typescript", "babel-plugin-ts-nameof"],
    env: {
        test: {
            plugins: ["require-context-hook"],
        },
    },
};

jest.config

transform: {
        ".*\\.vue$": "vue-jest",
        ".(ts|tsx)": "babel-jest",
    }

Originally posted by @Yogoort in https://github.com/dsherret/ts-nameof/issues/110#issuecomment-874193497