Skip to content

Instantly share code, notes, and snippets.

View horiuchi's full-sized avatar

Horiuchi Hiroki horiuchi

View GitHub Profile
import ts from 'typescript';
const typeNode = ts.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);
ts.addSyntheticLeadingComment(
typeNode,
ts.SyntaxKind.MultiLineCommentTrivia,
'A Type Node Comment',
false
);
const prop = ts.createPropertySignature(
@horiuchi
horiuchi / gen.ts
Last active April 25, 2021 12:42
Generate Single Quote string by TypeScript AST
import * as ts from 'typescript';
const data = ts.createModuleDeclaration(
undefined,
[ts.createModifier(ts.SyntaxKind.DeclareKeyword)],
ts.createIdentifier("Components"),
ts.createModuleBlock([ts.createModuleDeclaration(
undefined,
undefined,
ts.createIdentifier("Schemas"),
import * as ts from 'typescript';
const source = ts.createSourceFile('declare.d.ts', '', ts.ScriptTarget.ES2015);
const syntheticNode = ts.createClassDeclaration(
undefined,
undefined,
ts.createIdentifier('C'),
undefined,
undefined,
@horiuchi
horiuchi / superagent-tests.ts
Created February 12, 2015 10:07
Duplicate identifier
/// <reference path="./superagent.d.ts" />
/// <reference path="../node/node.d.ts" />
// via: http://visionmedia.github.io/superagent/
import request = require('superagent')
import fs = require('fs');
request
.post('/api/pet')
@horiuchi
horiuchi / gist:5106615
Created March 7, 2013 09:04
Answer of Scala exercises for beginners
// You are not permitted to use these List methods:
// * length
// * map
// * filter
// * ::: (and variations such as ++)
// * flatten
// * flatMap
// * reverse (and variations i.e. reverseMap, reverse_:::)
// This also means you are not permitted to use for-comprehensions on Lists.
// You are permitted to use the functions you write yourself. For example, Exercise 2 may use Exercise 1 or Exercise 3.
#include <array>
template <typename T, typename ...Args>
inline std::array<T, sizeof...(Args)> make_array(Args &&...args) {
return std::array<T, sizeof...(Args)>{ std::forward<Args>(args)... };
}
#define MAKE_ARRAY(T, ...) decltype(make_array<T>(__VA_ARGS__)){__VA_ARGS__}
#include <typeinfo>