#typescript types
Explore tagged Tumblr posts
Video
youtube
TypeScript Tutorial on Array Tuples Special Types Any Unknown Null for J... Full Video Link - https://youtu.be/kIWYyQoDJU0 Check out this new video on the CodeOneDigest YouTube channel! Learn Array tuple in typescript & Special types like any unknown null undefined. Learn how to use tuple array & special types in typescript language. #video #typescript #array #tuple #any #unknown #null #undefined #nodejs #javascript #codeonedigest@java @awscloud @AWSCloudIndia @YouTube @codeonedigest #typescript #javascript #typescript #javascript #typescripttutorial #typescriptforbeginners #learntypescript #typescriptarraymap #tuplesintypescript #typescripttuples #typescriptanyvsunknown #typescriptcompletetutorial #typescriptcompleteplaylist #typescriptcompleteguide #typescriptjavascript #typescriptprogramminglanguage #typescriptfullcourse #typescripttutorialforbeginners #typescriptunknowntype #typescriptnull #typescriptundefined #typescriptundefinedvsnull #array
#youtube#typescript#typescript array#typescript development#typescript programming language#typescript types
1 note
·
View note
Text
more generative stuff: hedge mazes, figured out how to import and do fun stuff with pixel art so i will probably gnaw on this for a while
#mine#generative art#p5js#using a typescript fork with my own type injections so i don't lose my mind
17 notes
·
View notes
Text
JSON To Type Generator is a code convert tool for generating types from JSON data for Golang, Rust, Kotlin and TypeScript. I.e. you just give it some JSON data, and it gives you the type definitions necessary to use that JSON in a program.
#JSON To Type Generator#JSON To TypeScript Interfaces#JSON To Golang Structs#JSON To Rust Structs#JSON to JSON Schema#JSON To Type Definitions Code#free online tools#online tools#web tools#online web tools#free web tools#online tool
0 notes
Text
Purecode reviews | The strong typing in TypeScript
Learning RxJS Observables is vital for handling asynchrony in Angular, representing a significant aspect of its framework. The strong typing in TypeScript, although initially a hurdle, proves beneficial in preventing errors and maintaining large-scale Angular applications.
#strong typing#purecode ai company reviews#purecode ai reviews#purecode software reviews#purecode company#purecode#purecode reviews#typescript#large-scale Angular#handling asynchrony
0 notes
Text
Javascript is a late twentieth century, early twenty-first century programming language most often used for client side functionality on the internet (that is to say, a webserver will send code to a vistor's browser, and the visitor will be the one using it). There are many quirks to Javascript that make it distinct among programming languages. One of which is its lack of type enforcement. Similar to other type unsafe languages (such as Python), Javascript allows users to use and abuse objects without mandating structure. By analogy, if you had an aquarium, a type-safe language would only let you put fish in it. Javascript would allow you to put anything in the aquarium and let you see if it actually can swim (or it it would explode the glass).
Typescript is an early twenty-first century open source extension of Javascript maintained by Javascript. Typescript code is essentially a shoving javascript in a type-checking suit. The code is nearly identical, but every single variable needs to have a type. The type script engine will read through the code and determine if any rules are violated. If they are, it will tell you what is broken. If it is not, it will produce the equivalent Javascript code to be handled by browsers.
Typescript is restrictive and can lead to some convoluted type logic to get things working that would just be permitted in Javascript. It also prevents many errors that are especially common in collaborative work. Its egregious safety also causes some annoying errors.
Most people in the early twenty-first century would be familiar with neither.
@typescript-official oh hello bitch
#period novel details#does this count as explaining the joke or was I too oblique?#if you write server code in Javascript OR Typescript then your bloodline is weak#it should be for client code only!#I want to write Javascript so I don't have to deal with Typescript BS#but I want everyone else to be forced to write Typescript so I don't have to deal with THEIR Javascript BS#my own personal Javascript messes are perfectly fine#but I am willing to work in a type-safe language if everyone else is forced to as well
90 notes
·
View notes
Text
JAVASCRIPT YOUR ARE MY FUCKING ENEMY
#I CANT STAND THIS FUCKING LANGUAGE FOR FUCKS SAKE#LITERALLY TOOK ME HALF AN HOUR TO DEBUG THIS STUPID BUG AND IT WAS A FUCKING TYPO#TYPESCRIPT WOULDVE NEVER TREATED ME LIKE THIS#I MISS TYPES SO MUCH I MISS THE COMPILATION STEP SO MUCH#TYPESCRIPT WHY DID YOU HAVE TO LEAVE ME LIKE THIS I NEED YOU#for context it’s 5 am and i’m programming#AT MY FUCKING JOB#AT 5 FUCKING AM#IN GOD DAMN JAVASCRIPT#UNHINGED PROGRAMMER MODE: ON
0 notes
Text
Baby's first enum
I've been learning Rust, which is exciting, difficult, and strangely wonderful. It is my first static language.
So of course my brain rusts a bit, and when I go back to Typescript, I try
enum CompareOps {Equal, UnstrictEqual, GreaterThan, LessThan, GreaterOrEqual, LesserOrEqual} enum SetOps {Superset, Subset, Equal} function compare<T extends number | string>(a: T, b: T, op: CompareOps): boolean; function compare(a: Set, b: Set, op: SetOps): boolean; function compare(a: T | Set, b: T | Set, op: CompareOps | SetOps): boolean { const areSets = b instanceof Set && a instanceof Set switch (op) { case CompareOps.Equal: return a === b; case SetOps.Superset: return areSets && [...b].every((element) => a instanceof Set && a.has(element)); } return false }
It's not ideal, since I couldn't figure out how to make it only valid typescript if a and b must be Set when we pass in SetOps as op, but it looks okay!
And then you run it
console.log(compare(new Set([1,2,3]), new Set([1,2]), SetOps.Superset))
false
Well, I probably had a logic bug. Let's check
console.log({areSets, op}) {areSets: true, op: 0}
Ummm…
console.log(CompareOps.Equal === SetOps.Superset)
oh hey, it gives a warning, nice:
This comparison appears to be unintentional because the types 'CompareOps' and 'SetOps' have no overlap.ts(2367)
well, it's just debugging, so i'll use any
console.log(CompareOps.Equal === SetOps.Superset) true
>:/
#brain rust#tumblr editor why#why can't I have markdown code blocks in the markdown editor?#typescript#learning static typing for the first time
0 notes
Text
Every TypeScript example and tutorial I've come across so far mainly focuses on language features, static typing, and working with Visual Studio. However, I couldn't find much guidance on how to use TypeScript effectively with JavaScript and the DOM.
I remember having the same question a while back, just like Johnny on Stack Overflow. "Can we use TypeScript to manipulate the DOM?" This question motivated me to dive deeper and figure it out, and I'm here to share what I've learned.
Configuration: Using TypeScript for DOM manipulation is straightforward, but it does require some configuration. You'll need to include the specific types for DOM access, which aren't available by default in TypeScript. To do this, you must explicitly configure the TypeScript compiler to include the "dom" library in the compilerOptions section of your tsconfig.json file. It's worth noting that the decision not to include these types by default might suggest that TypeScript's creators initially intended it more for server-side development with Node.js than for front-end work.
/** tsconfig.json - Configuration file in the project folder for the TypeScript compiler */ { "compilerOptions": { "lib": [ "es2015", "dom" ], "strict": true, "target": "es2015" } }
Hello World: In this article, I'll create a simple "Hello, world!" program to demonstrate how to use the DOM in TypeScript. Since this is my first post about TypeScript, I'll cover the basics of working with DOM types and address a common challenge that beginners might encounter. Please note that I won't be discussing DOM events in this post; that's a topic for a future article.
Let's start with the basics by changing the inner text value of an existing HTML element. I began by creating an HTML file with a standard HTML5 boilerplate, including an <h1> element with the id "greeter" in the body.
<!DOCTYPE html> <html lang="en"> <head> <!-- ... --> </head> <body> <h1 id="greeter">Hello</h1> </body> </html>
Next, I opened a new TypeScript file and added the following code:
let greeter: HTMLHeadingElement = document.getElementById("greeter") as HTMLHeadingElement; greeter.innerText = "Hello world!";

In this code, I created a variable called greeter and assigned the type HTMLHeadingElement to it. The HTMLHeadingElement type is defined in the "dom" library we added to the configuration. It tells the TypeScript compiler that greeter expects an HTML heading element and nothing else. Then, I assigned the greeter to the value returned by the getElementById function, which selects an element by its ID. Finally, I set the inner text of the greeter element to "Hello world."
When I compiled the code with the following command:
tsc script.ts

It produced the following error:
Type 'HTMLElement | null' is not assignable to type 'HTMLHeadingElement'. Type 'null' is not assignable to type 'HTMLHeadingElement'.
It's a bit frustrating, but TypeScript is doing its job. This error means that I tried to assign a greeter, which is of type HTMLHeadingElement, with an object of type HTMLElement that the getElementById method returned. The HTMLElement | null in the error message indicates that the method's return value can be either of type HTMLElement or null.
To address this, I used TypeScript's type assertion feature to tell the compiler that the element returned by getElementById is indeed a heading element, and it doesn't need to worry about it. Here's the updated code:
let greeter: HTMLHeadingElement = document.getElementById("greeter") as HTMLHeadingElement; greeter.innerText = "Hello world!";

With this change, the compilation was successful. I included the script.js file generated by the compiler in the HTML document and opened it in a browser.
Decoration Time: Now that I've confirmed that everything works as intended, it's time to make the page more visually appealing. I wanted a font style that was informal, so I chose the "Rock Salt" font from Google Fonts. I imported it into my stylesheet, along with "Dancing Script" as a secondary font, using CSS imports. I then added a few more elements to the HTML document, centered all the text using CSS flexbox, added a background from UI gradients, and adjusted the positions of some elements for proper arrangement. The page now looked beautiful.
Animation: To add a finishing touch, I wanted to include a background animation of orbs rising to the top like bubbles. To create the orbs, I decided to use <div> elements. Since I wanted several orbs with different sizes, I split the task into two steps to simplify the work.
First, I created a common style for all the orbs and defined a custom animation for the orbs in CSS. Then, I created the orbs dynamically using TypeScript. I created a set number of <div> elements, assigned them the pre-defined style, and randomized their sizes, positions, and animation delays to make them appear more natural.
Here's an excerpt of the code for creating the bubbles:
function createBubbles() { for (let i = 0; i < bubbleCount; i++) { let div: HTMLDivElement = document.createElement("div") as HTMLDivElement; let divSize = getSize(); div.style.left = getLeftPosition() + "px"; div.style.width = divSize + "px"; div.style.height = divSize + "px"; div.style.animationDelay = i * randomFloat(0, 30) + "s"; div.style.filter = "blur(" + randomFloat(2, 5) + "px)"; div.classList.add("bubble"); bubbleBuffer.push(div); } console.log("Bubbles created"); }
After creating the orbs, I added them to the DOM and started the animation:
function releaseBubbles() { createBubbles(); for (let i = 0; i < bubbleCount; i++) { containerDiv.appendChild(bubbleBuffer[i]); } console.log("Bubbles released"); }
And with that, the animation of orbs rising like bubbles was set in motion.
Here's the final output:
youtube
You can find the complete code in this repository.
Conclusion: While writing this article and creating the example, I realized the involvement of advanced concepts like type assertion and union types. I now understand why the authors of those tutorials didn't include them; introducing them could confuse beginners. It's best to learn TypeScript thoroughly before venturing into DOM manipulation.
In my example, I skipped null checking when fixing the type mismatch error, as it seemed unnecessary for the demonstration. However, in real projects, it's important to check for null values to avoid runtime errors. I also didn't
#While writing this article and creating the example#I realized the involvement of advanced concepts like type assertion and union types. I now understand why the authors of those tutorials di#beginner#typescript#dom manipulation#Youtube
0 notes
Text
Harnessing the Power of TypeScript for Building a Simple Backend Application
Introduction In the realm of web development, choosing the right technology stack for your backend application can significantly impact its efficiency, maintainability, and scalability. TypeScript, a superset of JavaScript, has emerged as a robust choice for crafting backend solutions that are not only powerful but also developer-friendly. In this article, we’ll delve into the benefits of using…
View On WordPress
0 notes
Note
Typescript and Rust are 21st century imperative programming languages. While all well-designed imperative programming languages are very similar in the core functionality, there are some key factors that flavor the entire language.
One of them is type-safety. In programming, there is a semi-optional feature called a type system. In a "typed" language, every single thing you work with has a "type." That is to say, some variables are numbers, some are words, some are dogs, some are marshmallows. (Numbers and words would be existing types, but you can create new ones). If a programming language is "type-safe" then it will prevent you from adding two dogs together or feeding words to marshmallows. This enforced level of intentionality prevents MANY common errors in programming that "unsafe" languages might run into, and makes the program more readable. It also takes extra time and prevents you from doing intentional breaks that you know would work.
Both Rust and Typescript are type-safe languages. Rust was designed from the ground up to be as safe a language as possible, trying to make it impossible for programmers to run into common issues. Typescript, on the other hand, is a different programming language (Javascript) wearing a straitjacket. Javascript is notorious for letting you do almost everything. TypeScript forces that 'everything' to conform to a standard before you can run the code.
Another difference in programming languages is compiled vs interpreted. In compiled languages, when a programmer writes code, they feed it into another program to optimize it. That optimized code is what you actually run. Interpreted programming languages just run the code directly. Compiled programming languages tend to be faster and use less memory, but they take a lot of time to recompile, and the benefits are reduced when computers are cheap. Typescript is interpreted. Rust is compiled.
Structural typing, which typescript supports is when a type system evaluates based on the contents of the thing, as opposed to the specific label. A structural typing language could, for example, allow the type of 'people who like things that eat marshmallows.' A language like Rust would need to explicitly define a type (MarshmallowEaterLikers) and explicitly explain how that type likes things that eat marshmallows. It is more awkward and explicit.
Structural typing also allows you to do things like make 'people who can blorp' blorp, without ever defining what 'blorping' is until later, and with insisting that 'blorping' is the same thing for every person. That is not possible in Rust.
To explain why the post is an unpopular opinion, Rust is an extremely specialized language with low usage. People who use Rust chose it with intentionality, and they tend to think of themselves and other people who use Rust as 'good programmers.' It is less a statement of elitism and more that people who program in Rust went out of their way to intentionally program in Rust, meaning they selected it for the benefits and appreciate the benefits.
In comparison, Typescript is the language of choice for React, the one of the most common frameworks for mobile apps and websites. As with many nerdy internet subcultures, there is a sense that 'popular' and 'default' equate to 'bad.' Some of this is a matter of frequency: if everyone who programs defaults to a specific language (especially as their FIRST language), there is going to be far more bad and ugly programs in that language. Even though it also means more 'good code,' the 'bad code' (which is perfectly normal as people learn by doing) will leave the language with a negative reputation, fostering into the natural elitism dynamic.
So, any claim that Typescript is superior to Rust in anyway, ESPECIALLY in a manner that Rust is supposedly designed to be superior in, will be seen as an unpopular opinion by people who have the niche knowledge to know what both Typescript and Rust are. This is independent of the truth of these statements.
It would be unusual for the average person in the early twenty-first century to know about Typescript and Rust, or to have an opinion on them. It is an eclectic detail confined to the software world.
🔥 programming languages?
oh this is a fun one
typescript has a better type system than rust, though much of that is because ts makes heavy use of structural typing and i dont think rust can really do that due to the fact that it's compiled
#period novel details#the reason Typescript suchs is because it is built on top of Javascript which basically lets you do everything#and then Typescript imposes rules after the fact#which leads to people writing bad javascript code and then lazily declaring the types to be 'any' ruining the point of Typescript#because programmers aren't trying to write good Typescript they are just trying to make the typescript evaluator stop complaining#when working in a big team having some level of enforced consistency is VITAL in producing a big piece of software#otherwise you spend all your time tripping over each other#but the OP is correct in that Typescript AT ITS BEST can be the superior typed language#but I've found that if you are working on a team you need to consider languages at their worst
8 notes
·
View notes
Text
The letters of the writer and groundbreaking neurological investigator Oliver Sacks–now collected in a volume that displays on every page his boundless curiosity and love of the human animal in its myriad ways of perceiving the world–include several to the poet W. H. Auden, among other literary lights. We unfortunately have no record of the Coleridge quote Sacks refers to in this missive to Auden of August 18, 1971, but the line he mentions from the German Romantic poet Novalis was surely a favorite aphorism of Oliver’s: “Every disease is a musical problem; its care a musical solution.” We also share below the typescript of Auden’s poem “Anthem,” which the poet had enclosed in his foregoing letter to Sacks, written on August 2, where he ended by saying: “Overleaf a little poem about the Cosmos. Yours ever, Wystan.”
Letter to W. H. AudenAugust 18,1971 [37 Mapesbury Rd., London]
Dear Wystan,
Your letter was forwarded to me a few days ago, and it (or your poem, or you) was the best of palliatives. Does there come a point (if one is very lucky, or has the right gifts, or grace, or works at it) when style, feeling, content, judgement all flow together and assume the right form? Your “Anthem” seems instinctively and effortlessly lyrical, and absolutely natural, like an organic growth; and yet obviously has the most careful and sophisticated and exquisite choice of words—and no feeling of any “joins” anywhere, of artifice, of manipulation. Marvellous. I will treasure it. Yes, I thought the Coleridge quote was a real find, and so to the point. And I agree (I feel) absolutely with the Novalis one. In some sense, I think, my medical sense is a musical one. I diagnose by the feeling of discordancy, or of some peculiarity of harmony. And it’s immediate, total, and gestalt. My sleeping-sickness patients have innumerable types of strange “crises,” immensely complex, absolutely specific, yet completely indescribable. I recognize them all now as I recognize a bar of Brahms or Mahler. And so do the patients. Such strange physiological harmonies—I hope I can find some way to describe these, because they are unique states, at the edges of being, beyond imaginable being, beneath comprehension, and when the last of the sleeping-sickness patients die (they are very old now) no memory will be left of their extraordinary states. Writing seems more of a struggle now—maybe I’m trying something harder—I find meanings go out of focus, or there is some sort of “slippage” between word and meaning, and the phrase which seemed right, yesterday, is dead today. [. . .] And medical jargon is so awful. It conveys no real picture, no impression whatever, of what—say—it feels like to be Parkinsonian. And yet it’s an absolutely specific, and intolerable feeling. A feeling of confinement, but of an inner constraint and confinement and cramp and crushedness, which is closely analogous to depression (although it is not emotional as such), and, of course, is very depressing. And a painful inner conflict—one patient called it the push-and-pull, another the goad-and-halter. It’s a most hateful condition, although it has a sort of elegant formal structure. But no book that I know of brings home that Parkinsonism feels like this—they just reduce it to an unevocative listing of symptoms. I hope Osbert Sitwell didn’t have it too badly. I’ve been reading some Goethe (for the first time, really) in the last week or two. Starting with his Italian Journey—thank God I did start with that, or I might not have got any further. And then the Pelican Faust—maybe it’s the same with any translation. I must learn German. And Mann’s fabulous essay on Goethe and Tolstoy. And Elective Affinities. And that great, meandering, affectionate Lewes biography. There is one point (I think in his chapter on Goethe’s philanthropy) where Lewes says that he could “eat Goethe for love”—and I think these are beginning to be my sentiments too. I hope I can join Orlan on a lightning visit to Vienna. There is nothing I would like more, but I am awfully fretted with my current book, and may not be at liberty (or feel myself at liberty) until I have finished it. I would love to see you in your own Kirchstetten, but if I cannot come I will surely see you in New York a few weeks later.
Yours ever, [Oliver]

More on this book and author:
Learn more about Letters by Oliver Sacks.
Read “Anthem” and more of W. H. Auden’s poems in Collected Poems.
Browse other books by Oliver Sacks and follow the Oliver Sacks Foundation on Instagram @oliversacksfdn.
Visit our Tumblr to peruse poems, audio recordings, and broadsides in the Knopf poem-a-day series.
To share the poem-a-day experience with friends, pass along this link.
#poetry#knopf#books#poem-a-day#knopf poetry#national poetry month#knopfpoetry#poem#aaknopf#Oliver Sacks#W. H. Auden#Auden#SacksAudio
54 notes
·
View notes
Video
youtube
TypeScript Object Type & Enum Tutorial for JavaScript Developers | #type... Full Video Link - https://youtu.be/KZd95dMA_bo Check out this new video on the CodeOneDigest YouTube channel! Learn Enum & Object type in typescript. Learn how to use Enum & Object types in typescript language. #video #typescript #enum #object #nodejs #javascript #codeonedigest@java @awscloud @AWSCloudIndia @YouTube @codeonedigest #typescript #javascript #typescript #javascript #typescripttutorial #typescriptforbeginners #learntypescript #typescripttutorialforbeginners #typescriptenum #typescripttypedeclaration #typescripttypeinference #typescripttypesystem #typescriptobjecttype #typescriptcrashcourse #typescriptfullcourse #typescriptfulltutorial #typescriptexplained #typescriptcompleteguide #typescriptexample #typescriptproject #typescriptprojectsforbeginners #typescriptprojectfromscratch #enumray
#youtube#typescript#typescript enum#typescript object type#typescript tutorial#typescript explained#typescript guide#typescript full course
1 note
·
View note
Text
here's how I think moral worth works.
if you like types, and Typescript helps you avoid mistakes, you have moral worth and will go to heaven.
if you hate types, they only ever get in your way and confuse you – if you swear two things are the same type because you hovered over the variable you're trying to pass in from the parent component and over the argument that the child expects, and they look the same ("Data[]"), but the compiler says they're definitely not and won't let you build, and you don't know what to do – and this kind of thing is your only experience with types – you do not have moral worth and will go to hell.
the types know who is bad and who is good; they will aid those with pure hearts and torment those without
#rambl#i showed 81k and the giant my second-most-recent torment and they looked up some details and started saying 'oh this is actually so useful'#and I think the reason I'm still mystified by the choices of the TS designers is: the discerning cosmic forces of good and evil
104 notes
·
View notes
Quote
それこそ俺は、中学時代からプログラミングをやっていて、アセンブラからやっていました。その頃、C言語が出たときに、ものすごくC言語をバカにする人が出てきたんですよ。 「中身を見ないと信用できない」「コンパイラが出すコードなんて信用できない」みたいに、Cの悪いところばっかり指摘する人が。もちろん最初のCってあまりよくなかったんだけど、結局、蓋を開けると誰もアセンブラなんて書かなくなっちゃって。だって楽だから。 その後も、ウェブでCを書く人なんていないし、PerlやPHPが出てきて、今はNode.jsとか、JavaScriptとかTypeScriptに進化していったじゃないですか。 だから同じなんですよ。皆さん、ここまで追っかけてきましたよねって。新しいものに触れて、バカにしなければ生き残れる。逆に「AIの出すコードは使えねえ」みたいに言ってると、あっという間に捲られます。 もちろん最初はなんだって使えないんですよ。よちよち歩きの赤ちゃんと一緒。でもその赤ちゃんの成長曲線がやばいよっていう話です。昨日までバブーって言ってたのが、急に2足歩行し出して、数学の話をし出す――飛び級状態です。なぜかというと、AIがAIを学習する時代に入っているからです。
プライドも、サンクコストも捨てろ「健康診断」しないエンジニアは死滅する - エンジニアtype | 転職type
26 notes
·
View notes
Text
purecode ai company reviews | TypeScript vs JavaScript for Future-Proof Development
TypeScript and JavaScript have their distinct strengths. JavaScript’s flexibility and ubiquity make it a reliable choice for web development. However, TypeScript offers powerful features like static typing, classes, and interfaces, making it an excellent alternative for larger, complex projects.
#purecode#purecode ai company reviews#purecode software reviews#purecode ai reviews#purecode company#purecode reviews#TypeScript vs JavaScript#web development#static typing
0 notes