Last active
May 8, 2021 17:56
-
-
Save alexbaumgertner/10fedeaa14b6847f371127850b2d93f9 to your computer and use it in GitHub Desktop.
This file contains 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
interface Page<T> { | |
title: string; | |
content: string; | |
lang: T; | |
} | |
function getPage<T> ( | |
title: string, | |
content: string, | |
lang: T, | |
): Page<T> { | |
return { | |
title, | |
content, | |
lang, | |
} | |
} | |
class AppPage<T> { | |
constructor ( | |
private title: string, | |
private content: string, | |
private lang: T, | |
) {} | |
public get page () { | |
return getPage( | |
this.title, | |
this.content, | |
this.lang, | |
) | |
} | |
} | |
enum lang { | |
ru = 'ru', | |
en = 'en', | |
} | |
const appPage = new AppPage( | |
'App', | |
'Hello, World!', | |
lang.en as const, | |
) | |
appPage.page | |
// WebStrom | |
AppPage<lang.en>.page(): Page<T> | |
// VSCode | |
AppPage<lang.en>.page: Page<lang.en> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WebStorm
VS Code