babel-plugin-transform-typescript-metadata
babel-plugin-transform-typescript-metadata copied to clipboard
ColumnTypeUndefinedError: Column type for Exercise#name is not defined and cannot be guessed.
Despite installing this plugin, I think I still have the same problem. Help is appreciated but honestly I want to give up.
ColumnTypeUndefinedError: Column type for Exercise#name is not defined and cannot be guessed. Make sure you have turned on an "emitDecoratorMetadata": true option in tsconfig.json. Also make sure you have imported "reflect-metadata" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.
Exercise.tsx
import {Entity,Column, PrimaryGeneratedColumn} from "typeorm/browser";
@Entity("Exercise")
export class Exercise{
@PrimaryGeneratedColumn()
id!:number;
@Column()
name!: Text;
@Column()
notes:Text;
@Column()
imageJSON:Text;
}
.babelrc
{
"plugins": [
"babel-plugin-transform-typescript-metadata",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
],
"presets": [
"@babel/preset-typescript"
]
}
snippet of package.json
...
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/node": "^18.0.0",
"@types/react": "~17.0.21",
"@types/react-native": "~0.66.13",
"babel-plugin-transform-typescript-metadata": "^0.2.2",
"typescript": "~4.3.5"
},
...
Okay I explicitly mentioned their types in the decorator, I guess that error seems to go away.
Hello, are you sure that you imported reflect-metadata
at the entrypoint of your application? It's a common issue.