Created
November 28, 2017 03:19
-
-
Save knjname/3c5c559ea5046688c385c8bd257c91cd to your computer and use it in GitHub Desktop.
TypeScriptのデコレータでクラス宣言順でハマる例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | |
| var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | |
| if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | |
| else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | |
| return c > 3 && r && Object.defineProperty(target, key, r), r; | |
| }; | |
| var __metadata = (this && this.__metadata) || function (k, v) { | |
| if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | |
| }; | |
| function methodDecorator(target, key, descriptor) { return target; } | |
| class Hoge { | |
| get(asdf) { | |
| } | |
| } | |
| __decorate([ | |
| methodDecorator, | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Asdf]), | |
| __metadata("design:returntype", void 0) | |
| ], Hoge.prototype, "get", null); | |
| class Asdf { | |
| } | |
| //# sourceMappingURL=index.js.map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function methodDecorator(target, key, descriptor) { return target} | |
| class Hoge { | |
| a: Asdf; | |
| @methodDecorator | |
| get(asdf: Asdf) { | |
| } | |
| } | |
| class Asdf { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "devDependencies": { | |
| "typescript": "^2.6.2" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "compilerOptions": { | |
| "sourceMap": true, | |
| "target": "es2017", | |
| "emitDecoratorMetadata": true, | |
| "experimentalDecorators": true, | |
| "declaration": false, | |
| "noImplicitAny": false, | |
| "noImplicitReturns": false, | |
| "strictNullChecks": false, | |
| "baseUrl": ".", | |
| "skipLibCheck": true, | |
| "lib": [ | |
| "es5", | |
| "es6", | |
| "es2015", | |
| "dom" | |
| ] | |
| }, | |
| "exclude": [ | |
| "node_modules" | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |
| # yarn lockfile v1 | |
| typescript@^2.6.2: | |
| version "2.6.2" | |
| resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ES5がターゲットだと下記のようになり、この現象は発生しなくなります。