Repository navigation
[RFC] Towards Non-Fungible Types #48513
Description
Activity
- addedSuggestionAn idea for TypeScriptAn idea for TypeScriptIn DiscussionNot yet reached consensusNot yet reached consensusCommunity ToolingThis might be better handled by tooling from the community instead of built into TypeScriptThis might be better handled by tooling from the community instead of built into TypeScript
on Apr 1, 2022 craftytrickster commented
on Apr 1, 2022 More actionsAre these types open to manipulation like normal "fiat" JS types? For example, what would happen if I instantiated an object, and then some unscrupulous third party "manipulated" its
.prototypefield to point to a different class' prototype? Would I still be able to brag to my friends about my special NFT type and post selfies on social media, or would I simply be holding what amounts to be a very fancy pointer?Reacted by Daniel Rosenwasser, Robert Knight, Oren Elbaum, Joshua "Yoshi" Askharoun, Moja, Joe Pea and Salvatore PrevitiReacted by David Di Biase, Daniel Rosenwasser, Anna Spysz, Joe Pea and Mohamad Rahal (Mohal)nicolo-ribaudo commented
on Apr 1, 2022 ContributorMore actionsThere might be an uncountable number of types, but we can only define a countable quantity of them. They are still a lot, but this is a big step towards scarcity.
Reacted by Daniel Rosenwasser, Piotr Monwid-Olechnowicz, Moja, Tushar Sadhwani and Salvatore PrevitiReacted by David Di Biase and Daniel RosenwasserI would like to buy
symbol. Do you accept payment in pennies?Reacted by Daniel Rosenwasser, David Di Biase, Bruce Pascoe, Anna Spysz, Moja, Keanu Ashwell, timleg002, Intirior, SlurpTheo and Harry SolovayDanielRosenwasser commented
on Apr 1, 2022 MemberAuthorMore actionsAre these types open to manipulation like normal "fiat" JS types? For example, what would happen if I instantiated an object, and then some unscrupulous third party "manipulated" its
.prototypefield to point to a different class' prototype? Would I still be able to brag to my friends about my special NFT type and post selfies on social media, or would I simply be holding what amounts to be a very fancy pointer?I'm not sure, I hadn't put a lot of thought into what David Raifaizen (@craftytrickster)s like you might do with these.
Reacted by David Raifaizen and Aravind Reddy VWhat if a right-clicker just copies and pastes my types? 😕
Reacted by Daniel Rosenwasser, Anna Spysz, Morgan Touverey Quilling, Joshua "Yoshi" Askharoun, Moja, owocado, Tushar Sadhwani, Nate Levin, Syed Faraaz Ahmad, Joe Pea and 5 moreReacted by Daniel Rosenwasser, Kārlis Čerņavskis and Ganesh SittampalamTo make things more economically viable, owners of type
Ashould get a comission when someone mints a type that is assignable toA. With that said I would like to claiminterface { toString(): string }.Reacted by Daniel Rosenwasser, Gabriela Araujo Britto, Piotr Monwid-Olechnowicz, Anna Spysz, Joshua "Yoshi" Askharoun, Moja, Trevor Paley, Tushar Sadhwani, Morgan Touverey Quilling, Nate Levin and 1 moreCan we start calling type artists "tartists"? Who wouldn't want to be a tartist? 😉
Reacted by Daniel Rosenwasser, Anna Spysz, Joshua "Yoshi" Askharoun, Moja, Kojo Amoasi and Kelli RockwellReacted by Martin Johns and Piotr Monwid-OlechnowiczHas the environmental impact of this proposal been considered? I've heard "proof of steak" is better for that, should we leave steaks on TS team members' desks with a note of which type we wish to claim?
Reacted by Daniel Rosenwasser, Anna Spysz, Joshua "Yoshi" Askharoun, Moja, Nate Levin and David TalbotReacted by Daniel Rosenwasser, Nate Levin, James Bromwell and Gonzalo CurbeloReacted by Daniel RosenwasserIt should be noted that in order for types to be truly non-fungible, we first need to switch to nominal typing. Otherwise
class A {}andclass B {}are fungible!Reacted by Daniel Rosenwasser, Morgan Touverey Quilling, Joe Pea and Ganesh SittampalamReacted by Gabriela Araujo Britto and Daniel Rosenwassershould we leave steaks on TS team members' desks
There's prior art here courtesy of Josh Ghoulberg 👻 (@JoshuaKGoldberg): #29374 (comment)
Essentially, leave cakes not steaks. 🎂
Reacted by Connor Peet, Josh Ghoulberg 👻 and MojaReacted by Daniel Rosenwasser and Josh Ghoulberg 👻I've been waiting for this announcement:
export type OptionalCat = { cat?: string, name: string }; export type DefiniteCat = { cat: string, name: string }; export type OptionalDog = { dog?: string, name: string }; export type DefiniteDog = { dog: string, name: string };Up until now I was only able to assume nobody else had ever stolen these types.
Reacted by Daniel Rosenwasser, Anna Spysz and MojaCyrusNajmabadi commented
on Apr 1, 2022 ContributorMore actionsSimilar concept being considered over at csharplang: dotnet/csharplang#5976
Reacted by Daniel Rosenwasser, Moja and a11delavar1 remaining item
DanielRosenwasser commented
on Apr 1, 2022 MemberAuthorMore actionsA lot of you have raised the risk of right-clickers copying precious types.
I will reach out to partners on our editor teams to see if we can fix this. I think if Visual Studio and Visual Studio Code lead the pack, we may be able to disable right-clicking in TypeScript files in all editors!
Admittedly, I'm not that well-connected. To start small, does anyone have the phone number for the CEO of the nano editor corporation?
Reacted by Nick Nisi, Anna Spysz, Piotr Monwid-Olechnowicz, Trevor Paley, Morgan Touverey Quilling, Kelli Rockwell and Mohamad Rahal (Mohal)Admittedly, I'm not that well-connected. To start small, does anyone have the phone number for the CEO of the nano editor corporation?
You might have luck with
248-434-5508.Reacted by Daniel RosenwasserMartinJohns commented
on Apr 1, 2022 ContributorMore actionsdoes anyone have the phone number for the CEO of the nano editor corporation?
Try 0118 999 881 999 119 7253.
Reacted by Daniel RosenwasserReacted by James BromwellDanielRosenwasser commented
on Apr 1, 2022 MemberAuthorMore actionsMartin Johns (@MartinJohns) I think now that you mention it, I've seen this number for their hotline. It's a long one, but luckily they have a catchy jingle!
Reacted by James BromwellI have a concern about typeconomics.
Wouldn’t it help the adoption to pay tartists per error than per use? (based on error length ofc)
I’m a huge fan of this endeavor, and I’d like to ensure we are truly going to the moon 🚀🌙On another note, when is the Non-Fungible-Type Marketplace plugin coming to TS Playground?
Reacted by Morgan Touverey Quilling and Salvatore PrevitiAnd to think, up until now I've just been busking
UnionToIntersectiondefinitions in subways and public parks for spare change!Reacted by Piotr Monwid-Olechnowicz, Salvatore Previti and Grant DickinsonWhat if a right-clicker just copies and pastes my types? confused
Let's doubleclick it.
I'd like to make a bid for
WindowandDocument- I have a feeling these are going to see some use in the future.SalvatorePreviti commented
on Apr 3, 2022 More actionsTo ensure artificial scarcity to keep the Non Fungible Types values high, we could introduce a form of proof of work - I would propose that the typescript compiler will support mining types, for registering a type TSC will first try to find a 32 bit nonce that would satisfy sha256(sha256(source of the type without spaces + nonce)). Integrating WebGPU in TypeScript could be helpful to do it in a reasonable amount of time and seems fair that a developer has to have a powerful GPU to compile typescript code. A new command line argument "tsc --nft file.ts" would be handy to have an interactive NFT registration experience.
Reacted by Piotr Monwid-Olechnowiczinterface Monke { get ugliness(): number; eat(what: Banana): void; beHappy(): never; }
original type do not steal
MartinJohns commented
on Apr 3, 2022 ContributorMore actionsI'm starting to suspect this was an April Fools' joke and not the future of TypeScript. Perhaps you meant to add the tag
Community Foolinginstead ofCommunity Tooling?Reacted by Bruce Pascoe, Daniel Rosenwasser and John ReillyReacted by Salvatore PrevitiReacted by Daniel RosenwasserReacted by Joe CalzarettaBruce Pascoe (@fatcerberus) I made my own
Monketype, too!interface Monke { get ugliness(): number; eat(banana: Banana): void; beHappy(): never; }
plz no steel
Reacted by Bruce Pascoe and Harry SolovayRyanCavanaugh commented
on Apr 3, 2022 MemberMore actionsThanks for the feedback everyone! I see a bright future for the
--noImplicitFungingflag.We are looking into revoking Daniel's issue-filing permissions.
Reacted by Bruce Pascoe and Martin JohnsReacted by T6, John Reilly, Bruce Pascoe, Toni Villena, Sriram, Aleksey Levenstein, SlurpTheo, Trey Brisbane, Andrii Dieiev, Umed Khudoiberdiev and 4 moreSomeone else can use
symbol. It's whatever.I am gladly donating
neverandunknownto Anders Hejlsberg (@ahejlsberg) so that I never have to explain them again.🤣
For years TypeScript has strived to grow and support its community. We've seen some tremendous investment, innovation, creativity, and beauty from TypeScript developers.
But how will we ensure that creators of these innovative types are rewarded for their brilliance? How do we make sure people continue writing more beautiful types?
This question coincides with the advent of "WEB 3", a broader community shift which can be best explained by aggressively waving one's hands. Many fascinating ideas have come from the "WEB 3" world including NFTs - Non-Fungible Tokens, which are simply Tokens which caNnot be Funged.
This dovetails with another new concept which I would like to introduce today: Non-Fungible Types.
The Idea
Today we see the broader use of non-fungible tokens for breathtaking pictures of apes that look like they've just been laid off - the biggest explosion of art collection since pogs, Beanie Babies, Pokémon cards, and fidget spinners.
What a lot of people don't realize is that TypeScript code is art.
How do we figure?
Well, if you've ever heard the expression "ars longa, vita brevis" – Latin for "art is long, life is short" – then you almost immediately recalled a TypeScript type you saw in an error message. It really does seem obvious when you put it that way!
In fact, you have a wide variety, ranging from minimalist TypeScript art...
to surreal TypeScript art...
So TypeScript types are great candidates for NFTs! Users should be able to take NFTs of type declarations and annotations and build a thriving ecosystem of type system artisans.
Do individual types actually have value?
I've discussed this proposal with
my math friends from collegeexperts in the field who havekinda offhandedly postulated over chat appsassured me that thanks to Cantor's Diagonal Argument, there are an uncountably infinite number of types. So can we really induce shortage to ensure value for every type?Well growing up, I argued with my cantor all the time so I remain undeterred.
Thanks to the unfungibility of the types, the value comes from the convenience of the types! So imagine that you're writing a program that uses types like
string,number,boolean,null, orundefined. As an upstanding citizen of the non-fungible-type community, you would need to get permission from the NFT owner(s) of these types. You could consult a chain of blocked accounts on Twitter to figure out who must own it, DM them, and ask them for permission to use these types, at which point they might charge a reasonable fee.Imagine not just appropriately compensating this artist, but also the sort of community building that this will enable!
Won't this mean I can't write programs for free?
Like we mentioned, there's plenty of types to go around! Want to say you take a
stringwithout paying to usestring?Just use a structurally compatible type with an optional member of type
neverSee? It's still free! Freedom is a state of mind!
What about primitives like
string,number, andboolean? Who owns those?Currently I have the non-fungible-tokens for
string,number,boolean,bigint,null, andundefined. I also have{}and the non-primitive typeobject. As an early pioneer in this ground-breaking space, it only feels fair to lay an early claim to these.Someone else can use
symbol. It's whatever.Who owns
neverandunknown?I am gladly donating
neverandunknownto Anders Hejlsberg (@ahejlsberg) so that I never have to explain them again.Who owns
any?Technically someone on the core team does, but they seem to have lost access to their credentials and we don't want to tell you all who it was.
We recommend not using
anyuntil we can figure out how to access it again.Timeline
I would like to see this happen soon. The fact that we have only created this proposal as recent as April 1st, 2022 means that we are already at risk of falling behind. Now is the best time to act!