Skip to content

Instantly share code, notes, and snippets.

@watiko
Created October 11, 2018 07:52
Show Gist options
  • Save watiko/0ff3c4335fe831464f13706ef54cdc6f to your computer and use it in GitHub Desktop.
Save watiko/0ff3c4335fe831464f13706ef54cdc6f to your computer and use it in GitHub Desktop.
namespace Ext {
export enum A {
One = 'one',
Two = 'two',
Three = 'three',
}
export namespace B {
export type Type = typeof One | typeof Two | typeof Three
export const One = 'one'
export const Two = 'two'
export const Three = 'three'
}
const one = 'one'
const two = 'two'
const three = 'three'
export const C = {
One: one as typeof one,
Two: two as typeof two,
Three: three as typeof three,
}
export type C = typeof C[keyof typeof C]
}
function a(p: Ext.A) {
return 'a'
}
a('one')
a(Ext.A.One)
function b(p: Ext.B.Type) {
return 'b'
}
b('one')
b(Ext.B.One)
function c(p: Ext.C) {
return 'c'
}
c('one')
c(Ext.C.One)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment