Тэги:
#typescript #web_development #advanced_typescriptКомментарии:
WOOHOO, I cant wait to bother my bossman to upgrade to version 5
Ответитьtypescript getting f**cking complex
ОтветитьHey Matt, thank you for a great video! I appreciate your effort. Today I just stumbled upon a use case for that feature, and I cannot wrap my head around solving it with the existing approaches. Given:
type Column = {
name: string;
}
type Template<C extends Column = Column> = {
sortBy: Template['schema'][number]['name'];
schema: C[];
}
const template: Template = {
sortBy: 'help',
schema: [{name: 'hello'}, {name: 'there'}],
}
is there any way to make it complain about the passed value to sortingColumnName and allow only 'hello' | 'there'?
Any help would be greatly appreciated!
Ok, so I really don't want to get beat up here. But I work with TS and other langs day-to-day. What's the big benefit of this? I get the "feeling" its about "Intellisense". True | False?
ОтветитьExtremely helpful. Thanks
ОтветитьTypescript is bureaucracy .
ОтветитьI'm at a loss for words. great. thank you
ОтветитьI thought I knew typescript because I know how to use "interface"
Now I feel like I don't know it at all.
It this point, I'm surprised MS hasn't just made a C# to JavaScript transpiler....
ОтветитьWe can still have a working "makeRoles" function in the current typescript version by sprinkling some "readonly" and "as const". So is "const T" just some syntactic sugar?
ОтветитьHey Matt,
I have a question
Is there any way to write a mongo query which can be typed .
I tried FilterQuery but it accepts any value which is not in the interface
So weird, I was struggling with a LocalStorage implementation that uses Generics last night and this perfectly solves the problem. Thanks!
ОтветитьGreat video! New to the channel, subbed
ОтветитьSeems like a nice improvement! Any idea why the extra 'const' keyword is necessary in the generic since you're defining the object 'as const' already?
ОтветитьCould you not just `return T as const`
ОтветитьDo you have a super secret version of the playground? As I can't get 'insider' only 'nightly' ?
ОтветитьThis is so awesome
ОтветитьI always use Jimi Hendrix as a mock name on my drafts lol
Ответитьfinally, Narrow trick is not reliable at times. This feature is great, you can infer as const and then remap type omitting "readonly" recursively. This is same as Narrow but more stable
ОтветитьAny idea why it defaults to erasing most of the inferred type information in the first place?? 🤷♂️
ОтветитьI am getting error while using this in typescritpt playground
I selected nigly build but I get error like this
function something<const T>(data: T) {
return data
}
Variable 'T' implicitly has an 'any' type.(7005)
This EXACT issue has been the bane of my existence. I cannot even begin to describe how many times I've googled something akin to "infer generic as const."
ОтветитьBefore you had to write
function a<T>(...tuple: readonly [...T]) {}
const is much more clean and idiomatic
i fucking love TypeScript, playing around with the genius typing system is fun
ОтветитьYour TypeScript course is already out?
ОтветитьI don't like polluting TypeScript with more gobbidy goop cos it makes things less readable
ОтветитьThanks, Matt! Just purchased your Total Typescript course today :)
ОтветитьIt’s taken too long
ОтветитьI wish this feature were available now, would've saved me a lot of grief XD
ОтветитьGreat video, thanks.
ОтветитьIs there any other language with a type system more insane than Typescript's?
ОтветитьHomie Matt cranking out those videos. You love to see it. Low key learn something from everyone.
ОтветитьStuff's great. I didn't know about either technique, so making toy libraries for myself I just had to remember to <const> my own objects I pass into functions, definitely not something you'd want to force your users to do :)
Ответитьamazing feature!
ОтветитьI just want one feature: i)structural pattern matching
ОтветитьGreat stuff as always. Thanks for the update!
ОтветитьThis is so cool
ОтветитьI just needed this exact feature yesterday for the first time, what a coincidence.
I wish the same thing happened to all features I felt the need for...
I'd it possible to get that code example shown in the TS playground?
ОтветитьThe flags when you pass admin has canCreatePost as optional and undefined, surely it shouldn't exist because it doesn't exist in the flags object for an admin?
ОтветитьMaya nimo opawa oi biliba
ОтветитьI can't wait for v5 to drop.
ОтветитьWoW TS is more and more versatile, my only concern is will it's performance improvement would catch up with these changes thou or the server will still clanky as before
ОтветитьAnother TS frustration gone.
Now I just need to get rid of all the hacks from my code that previously made this possible.
Niceee
Ответитьfirst
Ответить