363 Matching Annotations
  1. Jul 2025
  2. main.vitest.dev main.vitest.dev
  3. Jun 2025
  4. Apr 2025
  5. May 2024
  6. Oct 2023
  7. May 2023
    1. A type-script of 768 pages (labeled simply The Big Typescript) dated from 1933 had been in the estatesince 1951, but only in 1967 were the “Zettel” recognized from which it was compiled.Cut-and-paste was integral: “Usually he continued to work with the typescripts. A methodwhich he often used was to cut up the typed text into fragments (‘Zettel’) and to rearrangethe order of the remarks”.17

      via: Georg Henrik von Wright, “The Wittgenstein Papers,” The Philosophical Review 78:4 (1969), 483–563, here: 487.

      von Wright seems to indicate that Wittgenstein created typescripts which he cut up into zettel and then was able to rearrange them into final forms.

    1. secret

      From LAWLER 233: Stoddart cancelled the following lines in the typescript: "There was love in every line, and in every touch there was passion."

      From "Oscar Wilde's Dorian Gray, Annotated & Uncensored": This sentiment belongs to an established literary convention: the artistic process is being equated with sexual intimacy. Normally, however, the artist is male and his subject (or model) female. Wilde is adding an unmistakably homoerotic twist to this tradition.

    2. For a moment he thought of praying that the horrible sympathy that existed between him and the picture might cease. It had changed in answer to a prayer; perhaps in answer to a prayer it might remain unchanged. And, yet, who, that knew anything about Life, would surrender the chance of remaining always young, however fantastic that chance might be, or with what fateful consequences it might be fraught? Besides, was it really under his control? Had it indeed been prayer that had produced the substitution? Might there not be some curious scientific reason for it all? If thought could exercise its influence upon a living organism, might not thought exercise an influence upon dead and inorganic things? Nay, without thought or conscious desire, might not things external to ourselves vibrate in unison with our moods and passions, atom calling to atom, in secret love or strange affinity? But the reason was of no importance. He would never again tempt by a prayer any terrible power. If the picture was to alter, it was to alter. That was all. Why inquire too closely into it?

      From LAWLER 227: This paragraph was added in the typescript.

    3. Poor Sibyl! what a romance it had all been! She had often mimicked death on the stage, and at last Death himself had touched her, and brought her with him. How had she played that dreadful scene? Had she cursed him, as she died? No; she had died for love of him, and love would always be a sacrament to him now. She had atoned for everything, by the sacrifice she had made of her life. He would not think any more of what she had made him go through, that horrible night at the theatre. When he thought of her, it would be as a wonderful tragic figure to show Love had been a great reality. A wonderful tragic figure? Tears came to his eyes as he remembered her child-like look and winsome fanciful ways and shy tremulous grace. He wiped them away hastily, and looked again at the picture.

      From LAWLER 226: This paragraph was added in the typescript.

    4. Three o'clock struck, and four, and half-past four, but he did not stir. He was trying to gather up the scarlet threads of life, and to weave them into a pattern; to find his way through the sanguine labyrinth of passion through which he was wandering. He did not know what to do, or what to think.

      From LAWLER 220: Wilde added these sentences in the typescript.

    5. A long line of boys carrying crates of striped tulips, and of yellow and red roses, defiled in front of him, threading their way through the huge jade-green piles of vegetables. Under the portico, with its gray sun-bleached pillars, loitered a troop of draggled bareheaded girls, waiting for the auction to be over.

      From LAWLER 216: Added in the typescript.

      ZABROUSKI: After these sentences, Wilde revised the rest of the paragraph in 1891: "Others crowded round the swinging doors of the coffee-house in the piazza. The heavy cart-horses slipped and stamped upon the rough stones, shaking their bells and trappings. Some of the drivers were lying asleep on a pile of sacks. Iris-necked and pink-footed, the pigeons ran about picking up seeds. After a little while, he hailed a hansom and drove home. For a few moments he loitered upon the doorstep, looking round at the silent square, with its blank, close-shuttered windows and its staring blinds. The sky was pure opal now, and the roofs of the houses glistened like silver against it. From some chimney opposite a thin wreath of smoke was rising. It curled, a violet riband, through the nacre-coloured air."

    1. He had a special passion, also, for ecclesiastical vestments, as indeed he had for everything connected with the service of the Church. In the long cedar chests that lined the west gallery of his house he had stored away many rare and beautiful specimens of what is really the raiment of the Bride of Christ, who must wear purple and jewels and fine linen that she may hide the pallid macerated body that is worn by the suffering that she seeks for, and wounded by self-inflicted pain. He had a gorgeous cope of crimson silk and gold-thread damask, figured with a repeating pattern of golden pomegranates set in six-petalled formal blossoms, beyond which on either side was the pineapple device wrought in seed-pearls. The orphreys were divided into panels representing scenes from the life of the Virgin, and the coronation of the Virgin was figured in colored silks upon the hood. This was Italian work of the fifteenth century. Another cope was of green velvet, embroidered with heart-shaped groups of acanthus-leaves, from which spread long-stemmed white blossoms, the details of which were picked out with silver thread and colored crystals. The morse bore a seraph's head in gold-thread raised work. The orphreys were woven in a diaper of red and gold silk, and were starred with medallions of many saints and martyrs, among whom was St. Sebastian. He had chasubles, also, of amber-colored silk, and blue silk and gold brocade, and yellow silk damask and cloth of gold, figured with representations of the Passion and Crucifixion of Christ, and embroidered with lions and peacocks and other emblems; dalmatics of white satin and pink silk damask, decorated with tulips and dolphins and fleurs de lys; altar frontals of crimson velvet and blue linen; and many corporals, chalice-veils, and sudaria. In the mystic offices to which these things were put there was something that quickened his imagination.

      From LAWLER 251: Wilde added this paragraph on two handwritten pages to add to the typescript.

  8. Apr 2023
    1. Faithlessness is to the emotional life what consistency is to the intellectual life,—simply a confession of failure.

      From LAWLER 198: Wilde added this epigram to the typescript and followed it up with four additional sentences in 1891: "Faithfulness! I must analyze it someday. The passion for property is in it. There are many things that we would throw away if we were not afraid that others might pick them up."

    2. "How sad it is!" murmured Dorian Gray, with his eyes still fixed upon his own portrait. "How sad it is! I shall grow old, and horrid, and dreadful. But this picture will remain always young. It will never be older than this particular day of June. . . . . If it was only the other way! If it was I who were to be always young, and the picture that were to grow old! For this—for this—I would give everything! Yes, there is nothing in the whole world I would not give!"

      From LAWLER 191: Wilde altered this passage each time he revised his text. After "dreadful," he cancelled the following: "Life will send its lines across my face. Passion will create it and thought twist it from its form." For the typescript of this edition, Wilde added the last sentence of this paragraph. In 1891, Wilde added another sentence at the paragraph's end: "I would give my soul for that."

    3. "Stop!" murmured Dorian Gray, "stop! you bewilder me. I don't know what to say. There is some answer to you, but I cannot find it. Don't speak. Let me think, or, rather, let me try not to think."

      From LAWLER 186: Wilde added this sentence and the following five paragraphs to the typescript of this edition in a long marginal note ending with "...of the silence."

      ZABROUSKI: This addition plays into Wilde's interest in aestheticism, especially in regards to music, art, and linguistics.

    1. let fraseLegal = 'Bom dia!';fraseLegal = 9.5;

      O código apresentado irá gerar um erro de compilação, pois a variável "fraseLegal" foi inicializada com uma string ('Bom dia!'), mas depois é atribuído um valor numérico (9.5). Como o TypeScript é uma linguagem de tipagem estática, a tentativa de atribuir um valor de um tipo diferente do tipo original da variável resulta em um erro.

      Ou seja, o TypeScript irá indicar que há um erro de tipo devido à incompatibilidade entre os tipos de dados. É importante ressaltar que, em linguagens de tipagem dinâmica, esse erro só seria detectado em tempo de execução e poderia causar problemas de lógica ou falhas no sistema. Mas em linguagens de tipagem estática, como o TypeScript, esse erro é detectado em tempo de compilação, o que torna o código mais seguro e menos propenso a erros de tipo.

    2. [2, 4, 6]

      Esse código define uma função chamada segredo que recebe um array de números como argumento e retorna um novo array com cada elemento multiplicado por 2.

      A função usa o método map do array para iterar sobre cada elemento do array de entrada e aplicar a multiplicação por 2. O resultado é um novo array com os elementos transformados.

      A linha final console.log(segredo([1,2,3])); chama a função segredo com um array de entrada [1, 2, 3] e imprime o resultado da função no console, que seria o array [2, 4, 6].

  9. Feb 2023
    1. "languageServerExample.trace.server": "verbose"

      This is in the contributes part of the package.json

      json "contributes": { "configuration": { "type": "object", "title": "Example configuration", "properties": { "languageServerExample.maxNumberOfProblems": { "scope": "resource", "type": "number", "default": 100, "description": "Controls the maximum number of problems produced by the server." }, "languageServerExample.trace.server": { "scope": "window", "type": "string", "enum": [ "off", "messages", "verbose" ], "default": "off", "description": "Traces the communication between VS Code and the language server." } } } },

    1. If you want a workaround for the case where you can't just replace key with a string literal, you could write your own user-defined type guard function called hasProp(obj, prop). The implementation would just return prop in obj, but its type signature explicitly says that a true result should cause obj to be narrowed to just those union members with a key of type prop: function hasProp<T extends object, K extends PropertyKey>( obj: T, prop: K ): obj is Extract<T, { [P in K]?: any }> { return prop in obj; } and then in your function, replace key in a with hasProp(a, key): function f3(a: A) { const key = 'b'; if (hasProp(a, key)) { return a[key]; // okay } return 42; }
    1. The variable x initially has the type unknown: the type of all values. The predicate typeof x === "number" extracts dynamic information about the value bound to x, but the type-checker can exploit this information for static reasoning. In the body of the if statement the predicate is assumed to be true; therefore, it must be the case the value bound to x is a number. TypeScript exploits this information and narrows the type of x from unknown to number in the body of if statement.
  10. Dec 2022
    1. Notice that TypeScript not only knows that pet is a Fish in the if branch; it also knows that in the else branch, you don’t have a Fish, so you must have a Bird.

      Can you provide me with some examples of where type predicates can be helpful? Yes, definitely! Type predicates can be very useful in a variety of situations. Here are a few examples of where you might use a type predicate:

      When working with union types, type predicates can help you narrow the type of a value to one of the types in the union. For example, if you have a variable that can be either a string or a number, you can use a type predicate to check the type of the value and narrow it to either string or number depending on the result of the type check.

      Type predicates can also be useful when working with interfaces that have optional properties. For example, if you have an interface that has a optional name property of type string, you can use a type predicate to check whether the name property is present on a value before trying to access it. This can help you avoid runtime errors when accessing optional properties.

      Type predicates can also be useful when working with arrays and other iterable types. For example, if you have an array of values that can be either numbers or strings, you can use a type predicate to check the type of each element in the array and narrow the type of the array to an array of either number or string elements depending on the result of the type checks.

      Overall, type predicates can be very helpful for improving the type safety of your code and avoiding runtime errors. They are particularly useful when working with union types, optional properties, and iterable types.

  11. Sep 2022
  12. Aug 2022
    1. The unary plus operator (+) precedes its operand and converts it into a number. If it fails to convert the operand into a number, then it returns NaN. The unary (-) operator converts the operand into a number and negates it.

      an alternative to !!, in order to convert null, empty strings, boolean values into 0 or 1.

  13. May 2022
  14. Apr 2022
    1. In order to reflect this in the types I added an Either type to the helpers, because with Union Types only the values that the types have in common are directly accessible. So it would have been necessary to first check the returned type before accessing returned properties.

      What does this mean?

    1. In the caseof Wittgenstein, he worked with typescripts and would often cut upthe typed text into fragments so he could rearrange the order of theremarks jotted on them (Krapp, 2006: 362; von Wright, 1969).

      Wittgenstein worked with typescripts which he would often cut up into fragments so that he could reorder them for his particular needs. He had an unpublished work titled The Big Typescript of 768 pages which he created in this manner.

      Link this to: - Kevin Marks' media fragments and fragmentions work - blackout poetry - mid 1900s newspaper publishing workflows

  15. Feb 2022
    1. Common questions#

      It may be worth highlighting that if "module" = "commonjs" in tsconfig.json, imports such as import { something } from "module" will be transpiled to const module_1 = require("module"). As a result, something will not be available in the debug console, but module_1.something instead.

      One may change tsconfig.json to include "module" = "es6" and "moduleResolution" = "node", and package.json to include "type" = "module", but in this case imports must include the file extension.

  16. Dec 2021
  17. Nov 2021
    1. export interface TasksListSpecifics { 0: ('parallel' | 'sequential'); } export type TasksList = (string[] & TasksListSpecifics); Or more compact: export type TasksList = (string[] & { 0: ('parallel' | 'sequential'); }); The trick is to add your more specific properties on top of array of string type (Array<string>).
    1. I suggest renaming this to something like SomeInterfaceAsTypeWrittenByHand. Because one of the reasons for Simplify is so you don't have to write SomeType by hand. Then add the following to show that Simplify<SomeInterface> is the same as SomeInterfaceAsTypeWrittenByHand. declare const a: Simplify<SomeInterface>; expectType<SomeInterfaceAsTypeWrittenByHand>(a); // Interface is assignable to its Simplified type (created with Simplify, and by hand) expectType<Simplify<SomeInterface>>(someInterface); expectType<SomeInterfaceAsTypeWrittenByHand>(someInterface);
    1. Regarding mapped types, remember that { [K in T]: U } is a special form - it can't be combined with other properties within the { }. So there's not really a name for the [K in T: U] part because it's just part of the overall "mapped type" syntax { [K in T]: U }
    1. Like others have noted, your function does not conform to index signature. [key: string]: string means "all fields are strings" and on the next line you declare a field with function in it.This can be solved by using union types:type IFoo = { [foo: string]: string } & { fooMethod(fooParam: string): void }
    1. This PR adds a new top type unknown which is the type-safe counterpart of any. Anything is assignable to unknown, but unknown isn't assignable to anything but itself and any without a type assertion or a control flow based narrowing. Likewise, no operations are permitted on an unknown without first asserting or narrowing to a more specific type.
    1. So now the question is, why does Session, an interface, not get implicit index signatures while SessionType, an identically-structured typealias, *does*? Surely, you might again think, the compiler does not simply deny implicit index signatures tointerface` types? Surprisingly enough, this is exactly what happens. See microsoft/TypeScript#15300, specifically this comment: Just to fill people in, this behavior is currently by design. Because interfaces can be augmented by additional declarations but type aliases can't, it's "safer" (heavy quotes on that one) to infer an implicit index signature for type aliases than for interfaces. But we'll consider doing it for interfaces as well if that seems to make sense And there you go. You cannot use a Session in place of a WithAdditionalParams<Session> because it's possible that someone might merge properties that conflict with the index signature at some later date. Whether or not that is a compelling reason is up for rather vigorous debate, as you can see if you read through microsoft/TypeScript#15300.
    2. why is Session not assignable to WithAdditionalParams<Session>? Well, the type WithAdditionalParams<Session> is a subtype of Session with includes a string index signature whose properties are of type unknown. (This is what Record<string, unknown> means.) Since Session does not have an index signature, the compiler does not consider WithAdditionalParams<Session> assignable to Session.
  18. Oct 2021
  19. Sep 2021
    1. TypeScript is an extension of JavaScript. You can think of it as JavaScript with a few extra features. These features are largely focused on defining the type and shape of JavaScript objects. It requires that you be declarative about the code you're writing and have an understanding of the values your functions, variables, and objects are expecting.While it requires more code, TypeScript is a fantastic means of catching common JavaScript bugs while in development. And for just that reason, it's worth the extra characters.
    1. Use this to load modules whose location is specified in the paths section of tsconfig.json when using webpack. This package provides the functionality of the tsconfig-paths package but as a webpack plug-in. Using this plugin means that you should no longer need to add alias entries in your webpack.config.js which correspond to the paths entries in your tsconfig.json. This plugin creates those alias entries for you, so you don't have to!
    1. Let's not get over-excited. Actually, we're only part-way there; you can compile this code with the TypeScript compiler.... But is that enough?I bundle my TypeScript with ts-loader and webpack. If I try and use my new exciting import statement above with my build system then disappointment is in my future. webpack will be all like "import whuuuuuuuut?"You see, webpack doesn't know what we told the TypeScript compiler in the tsconfig.json.
  20. Aug 2021
    1. which seems to resolve the issue for me and makes no casts, ensuring that Typescript can keep doing its good job of widening as much as necessary and narrowing as much as possible without me having to claim I know better than the compiler. I'm posting it here since it doesn't seem to have been mentioned anywhere.

      makes no casts, ensuring that Typescript can keep doing its good job of widening as much as necessary and narrowing as much as possible without me having to claim I know better than the compiler.

    1. Now consider we want to handle numbers in our known value set: const KNOWN_VALUES = Object.freeze(['a', 'b', 'c', 1, 2, 3]) function isKnownValue(input?: string | number) { return typeof(input) === 'string' && KNOWN_VALUES.includes(input) } Uh oh! This TypeScript compiles without errors, but it's not correct. Where as our original "naive" approach would have worked just fine. Why is that? Where is the breakdown here? It's because TypeScript's type system got in the way of the developer's initial intent. It caused us to change our code from what we intended to what it allowed. It was never the developer's intention to check that input was a string and a known value; the developer simply wanted to check whether input was a known value - but wasn't permitted to do so.
    1. I believe he wants to use the as const feature while still type checking that the structure matches an interface. A workaround I'd use for something like that would be interface ITest { a: number; b: string; } let foo = { a: 5, b: "Hello" } as const;
    1. function strictIsDog<T extends Dog extends T ? unknown : never>( // like <T super Dog> candidate: Dog | T // if Dog extends T then Dog | T is T ): candidate is Dog { // compiler recognizes that Dog | T can narrow to T return "bark" in candidate; } if (strictIsDog(animal)) {} // okay if (strictIsDog(dog)) {} // okay if (strictIsDog(mixed)) {} // okay if (strictIsDog(cat)) {} // error! // ~~~ <-- Cat is not assignable to Dog
    1. Regarding the error message, the predicate type must be assignable to the value type because the type guard is used to check whether a value with a less-specific type is in fact a value with a more-specific type. For example, consider this guard: function isApe(value: Animal): value is Ape { return /* ... */ } Ape is assignable to Animal, but not vice versa.
  21. Jul 2021
  22. Jun 2021
  23. basarat.gitbook.io basarat.gitbook.io
    1. Having a member in a class and initializing it like below:class Foo { x: number; constructor(x:number) { this.x = x; }}is such a common pattern that TypeScript provides a shorthand where you can prefix the member with an access modifier and it is automatically declared on the class and copied from the constructor. So the previous example can be re-written as (notice public x:number):class Foo { constructor(public x:number) { }}
  24. May 2021
  25. Jan 2021
  26. Nov 2020
    1. The typescript compiler will not look at the actual typescript files from lib. Instead it will only use the typescript declaration files (*.d.ts) generated when building the lib project. That's why your lib/tsconfig.json file must contain: "declaration": true,