Skip to content

Instantly share code, notes, and snippets.

View ksaldana1's full-sized avatar

Kevin Saldaña ksaldana1

View GitHub Profile
@ksaldana1
ksaldana1 / models.ts
Last active January 30, 2019 16:35
ts-alias-1
import { protos } from './my_company_protos'
export type User = protos.user.User;
@ksaldana1
ksaldana1 / example.ts
Last active January 30, 2019 04:01
ts-alias problem
/*
In node_module package 'my_company_protos'
export namespace protos {
export namespace user {
export interface User {
username: string;
info: protos.Info.User;
}
}
{
"type": "Program",
"start": 0,
"end": 80,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
@ksaldana1
ksaldana1 / route.ts
Last active June 25, 2018 22:59
#25157 Repro - File 2
import { PathPart, Route } from './interfaces/types';
export function isParam(i: any): i is PathParam<any> {
return i.param != null;
}
export function param<T extends string>(t: T): PathParam<T> {
return { param: t };
}
@ksaldana1
ksaldana1 / interfaces.ts
Last active June 25, 2018 23:15
#25157 Repro - File 1
// Interface returned by our RouteCreator function
export interface Route<Parts extends PathPart<any>> {
template(): string;
create(params: UnionToIntersection<OnlyParams<Parts>>): string;
}
export type PathPart<T extends string> = string | PathParam<T>;
export function param<T extends string>(t: T): PathParam<T> {
return { param: t };
@ksaldana1
ksaldana1 / interfaces.types
Created June 25, 2018 22:47
#25157 Repro - File 1
// Interface returned by our RouteCreator function
export interface Route<Parts extends PathPart<any>> {
template(): string;
create(params: UnionToIntersection<OnlyParams<Parts>>): string;
}
export interface PathParam<T extends string> {
param: T;
}