Closed ericaskari closed 3 years ago
So I created an empty ts project with babel with this plugin and it worked fine! I guess it has something to do with nx or maybe other plugins that are used there.
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",
}
I had a rollup setup while using ts-nameof.
and I could use ts-nameof like:
nameof<PageContainer>()
which would turn toPageContainer
recently I changed to nx monorepo setup and I installed
and .babelrc:
I don't know why but global nameof wasn't avaiable so I added ts-nameof to types in tsconfig as following
and when I build the project I get:
seems like a bug because in rollup it works.
and if I select a method from interface it works fine but empty it doesn't
console.log(nameof<Provider>(x => x.Something))
printsSomething