Redefine type always emit Object design:type
See original GitHub issueHello,
I have an issue, when I define a type like this:
export type Uuid = string;
The emit type is:
Object
The full case:
export type Uuid = string;
function Decorate() {
return (target: any, prop: string): any => {
const propertyType = Reflect.getMetadata("design:type", target, prop);
console.log('propertyType', propertyType); // emit the Object type
}
}
class Foo {
@Decorate()
public bar!: Uuid;
}
and my babel config:
// babel.config.js
module.exports = {
presets: [
["@babel/preset-env", { "targets": { "node": "current" }, "modules": "commonjs" }],
"@babel/preset-typescript"
],
"plugins": [
"babel-plugin-transform-typescript-metadata",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/proposal-class-properties", { "loose": true }],
"@babel/proposal-object-rest-spread"
]
};
I don’t know if it’s a defect coming from my Babel configuration, or a limitation from @babel/preset-typescript
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
leonardfactory/babel-plugin-transform-typescript-metadata
Babel plugin to emit decorator metadata like typescript compiler - Issues ... Redefine type always emit Object design:type babel limitation Issues generated ...
Read more >Typescript Reflect.getMetadata design:type returns Object ...
the test below is let's say the function Foo is a function based class,the typescript can't infer the Foo type so it emit...
Read more >Documentation - tsc CLI Options - TypeScript
Flag Type Default
‑‑allowJs boolean false
‑‑allowUmdGlobalAccess boolean false
‑‑allowUnreachableCode boolean
Read more >How to Emit Data in Vue: Beyond the Vue.js Documentation
Learn how to emit events from child components and nested child ... With all of this in mind, we're going to write an...
Read more >Understanding TypeScript Configuration Options
Normally it will be used as type checking in JavaScript project. ... TypeScript will always parse in strict mode and emit use strict...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve used it exactly with the same setup, but not in production, where we reverted to TypeScript only (no babel, but same toolkit). With TypeORM you should be careful to use
@Column()
, even if for plain cases it still works and for advanced cases you still need to declare it manually anyway. With NestJS it works properly but TS support is still better.@leonardfactory Thanks for the suggestion and quick reply. Just one more thing, I came here from the issue in the nestjs repo. I see that in the README this package can work well with Nest and TypeORM. Have you had any experiment project using this package for Nest? Is there any cautions that I need to take if I use this package in production with Nest and TypeORM?