- tsd 2世代前。
- typings 1世代前。
@types今の方法。
http://qiita.com/laco0416/items/ed1aadf335f12cd3618d
npm install -D @types/angularjs とか
| import React from 'react' | |
| import NavLink from './NavLink' | |
| import Repo from './Repo' | |
| export default React.createClass({ | |
| propTypes: { | |
| children: React.PropTypes.oneOfType([ | |
| React.PropTypes.arrayOf(React.PropTypes.instanceOf(Repo)), | |
| React.PropTypes.instanceOf(Repo) | |
| ]) |
| const DOMPurify = require('dompurify'); | |
| const React = require('react'); | |
| const ReactDOM = require('react-dom'); | |
| const Remarkable = require('remarkable'); | |
| const Comment = React.createClass({ | |
| propTypes: { | |
| author: React.PropTypes.string.isRequired, | |
| children: React.PropTypes.string.isRequired, | |
| }, |
| const Http = require('http'); | |
| const Url = require('url'); | |
| const Path = require('path'); | |
| const Fs = require('fs'); | |
| const COMMENTS_FILE = 'comments.json'; | |
| const server = Http.createServer(function requestListener(inComingMessage, serverResponse) { | |
| console.log(inComingMessage.method, inComingMessage.url, `at ${new Date()}`); | |
| console.log(inComingMessage.headers); |
| @function str-replace($string, $search, $replace: '') { | |
| $index: str-index($string, $search); | |
| @if $index { | |
| @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); | |
| } | |
| @return $string; | |
| } | |
| class Trip { | |
| destination: string; | |
| startDate: Date; | |
| constructor(destination, startDate) { | |
| this.destination = destination; | |
| this.startDate = startDate; | |
| } | |
| prepare(preparers) { |
@types 今の方法。http://qiita.com/laco0416/items/ed1aadf335f12cd3618d
npm install -D @types/angularjs とか
| { | |
| "compilerOptions": { | |
| "outDir": "./dist/", | |
| "module": "commonjs", | |
| "target": "es5", | |
| "noImplicitAny": true, | |
| "inlineSourceMap": true, | |
| "experimentalDecorators": true, | |
| "jsx": "react", | |
| "pretty": true, |
| let fs = require('fs'); | |
| function log(targat) { | |
| const target = targat.prototype; | |
| const fileName = __dirname + '/dist/' + target.constructor.name + '.txt'; | |
| const props = Object.getOwnPropertyDescriptors(target); | |
| const str = Object.keys(props).join('\n'); | |
| fs.createWriteStream(fileName).write(str); | |
| } |
| /* | |
| #1 関数宣言 | |
| function funcName() : returnType => {} | |
| */ | |
| function funcName (x) {} | |
| function funcNameTs(x: number): number { return x;} | |
| /* | |
| #2 関数式 | |
| */ |
| /* | |
| TSのインターフェースとは 以下2つのうちのいずれか。 | |
| 1. 抽象的な型。 プロパティの名前・型を指定した、JSオブジェクト。 | |
| 2. 引数と戻り値の型を明示した、Functionオブジェクト。 | |
| http://stackoverflow.com/questions/41082804/does-typescript-interface-have-anonymous-and-named-function/41082880#41082880 | |
| */ | |
| // 1. JSオブジェクト |