Giter VIP home page Giter VIP logo

typescript-wiki's Introduction

The TypeScript wiki

This repo is a mirror of the TypeScript wiki. Changes on either the wiki or this repo are immediately mirrored to the other side. This is done in a GitHub Action here, and another in the TS repo, and the main work is done by a sync script.

The wiki root is Home.md.

You can run this locally if you have ruby installed via:

# Install the deps
gem install gollum

# Start the server
gollum

Then you can open: http://localhost:4567

Things to remember:

  • Gollum is a bit of a nightmare for testing, my current technique is:

    # before
    git branch -b thing_i_am_working_on
    
    # to iterate, amend the commit and re-run gollum against that bit of git
    git add .; git commit --amend --no-edit --no-verify; gollum --ref thing_i_am_working_on
  • Wikis don't support nesting, so filenames have to get a bit wild

    - compiler/testing/fourslash.md
    + compiler-testing-fourslash.md
  • You can use a custom link syntax for references to TypeScript code which will be looked up at deploy time:

    link to [`runFourSlashTest`][0]
    
    [0]: <src/harness/fourslash.ts - function runFourSlashTest(>
    

    Will look at the file src/harness/fourslash.ts in microsoft/TypeScript to find the line of code function runFourSlashTest and provide a direct link in the wiki. You can audit them via the script npm run lint.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Legal Notices

Microsoft and any contributors grant you a license to the Microsoft documentation and other content in this repository under the Creative Commons Attribution 4.0 International Public License, see the LICENSE file, and grant you a license to any code in the repository under the MIT License, see the LICENSE-CODE file.

Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.

Privacy information can be found at https://privacy.microsoft.com/en-us/

Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents, or trademarks, whether by implication, estoppel or otherwise.

typescript-wiki's People

Contributors

ahejlsberg avatar amcasey avatar aozgaa avatar billti avatar cyrusnajmabadi avatar danielrosenwasser avatar danquirk avatar elibarzilay avatar herringtondarkholme avatar holgerjeromin avatar jakebailey avatar jdevries3133 avatar jramsay avatar jsonfreeman avatar mhegazy avatar ngnijland avatar nycdotnet avatar orta avatar paulvanbrenk avatar ryancavanaugh avatar samb avatar sandersn avatar sheetalkamat avatar sophiajt avatar styfle avatar uniqueiniquity avatar vladima avatar weswigham avatar yuit avatar zhengbli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-wiki's Issues

Add sample for an incremental and watching program

The now very old still unmerged PR #225 has been very useful in creating an incrementally building program but now I want to set up an incrementally building program that also watches for changes so I can avoid the long file system scan that happens when I create the incremental program.

Unfortunately I don't understand how to combine the different host, program and configuration objects to achieve this.

Add example : how to extract Props / State interface from react component using compiler API

Hello.
I have this sources

import * as React from 'react';

export interface MyComponentProps{
    prop1: number;
    prop2: string;
}
/**
* descriptions for component
*/
export  class MyComponent extends React.Component<MyComponentProps,{}>{
   render(){
     return(
       <div>
       </div>
     );
   }
}

I use docgen from this wiki example

this is output

[
    {
        "name": "MyComponent",
        "documentation": "descriptions for component",
        "type": "typeof MyComponent",
        "constructors": [
            {
                "paramters": [],
                "returnType": "MyComponent",
                "documentation": ""
            }
        ]
    }
]

I want to extend this output by type of first generic passed to react.component.

How to extract generic type passed to parent class?
Thank you!

Confusing line in the `this` section of 2.0

Under the this section in 2.0 there is a line that says the following:

That means that this is of type Deck now, not any, so --noImplicitThis will not cause any errors.

Where is Deck even mentioned? It seems out of place.

[Documentation] Example in breaking changes doc is confusing.

https://github.com/microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#contextual-return-types-flow-in-as-contextual-argument-types

In the documentation it lists the "broken" version as:

function isEven(prom: Promise<number>): Promise<{ success: boolean }> {
    return prom.then<{success: boolean}>((x) => {
        return x % 2 === 0 ?
            { success: true } :
            Promise.resolve({ success: false });
    });
}

The work around is listed as:

function isEven(prom: Promise<number>): Promise<{ success: boolean }> {
    //               vvvvvvvvvvvvvvvvvv
    return prom.then<{success: boolean}>((x) => {
           return x % 2 === 0 ?
            { success: true } :
            Promise.resolve({ success: false });
    });
}

Both versions of the code are the same.

Roadmap does not mention version 3.8

Roadmap does not mention version 3.8.

I think it did at a moment in time but it went missing. I mentioned this here as well and I'm pretty sure I saw 3.8 on the roadmap at one time after that.

Wiki Page 1.5: Definitions linking to 1.4

On the wiki page:
https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API

The documentation is for 1.5:
First you'll need to install TypeScript >=1.5 from npm.

Definitions Raw File

The definitions file is pointing to the 1.4 on the line:
Going directly to the source on our repository.

This links to:
https://github.com/Microsoft/TypeScript/blob/release-1.4/bin/typescript.d.ts

It should link to:
https://github.com/Microsoft/TypeScript/blob/v1.5.0-alpha/bin/typescript.d.ts

Definitions Installer

Also the command:
tsd query typescript --action install

Installs the 1.4 definitions files

"What's new in TypeScript" wiki permalinks broken

The wiki page for What's new in TypeScript is now gone/moved as it got too big for Github to render(#226). That makes sense, but now all the bazillion links (like this one for readonly tuples) I and others have added to answers/comments on StackOverflow questions are broken. Would it be possible for the wiki page to be edited to preserve the existing permalinks? I mean, even if the old link points to a nothing but another link to the same content hosted elsewhere (e.g., pointing to an old revision) so that the user has to click twice, it's better than just the current "this page has moved". It would hopefully be small enough to actually render anyway.

Thoughts? I would make a PR but I'm not sure if the code here is where the actual wiki code comes from (it seems out of date?).

Clarify --diagnostics report units

I've been recently looking at parsing --diagnostics output to report to out metrics service so that we can monitor compile times and while attempting to normalize values to a common unit (e.g. durations to seconds and memory used to MB), I've noticed that the docs are not very clear about the metric definitions and their respective units.

I would love if the docs specified what are the possible units that may be reported for each metric. For instance, can Total time be reported in milliseconds or even minutes right now? I see that memory used is reported as K, I assume that is kilobytes, but I'm not sure.

Less importantly, but in a similar vein, the duration timings (parse, bind, check, emit and total time) do not specify if these metrics are reported in wall time or CPU time. (it doesnt make much difference for our purposes, but it would be good to know how the metric may be affected).

If someone can point me to the relevant files where these metrics are measured, I would happy to take a stab at opening a PR :)

Thanks so much!

Missing example how compile using tsconfig.json

this is what im having in mind:

var config = { // this is generated on the fly ... or JSON.parse(readFileAsText('tsConfig.json'))
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "outDir": "./lib",
        "jsx": "react",
    },
    "compileOnSave": false,
    "include": ["src"],
    "exclude": ["lib"]
}

var emitResult = tsc.compileByConfig(config); // this line is what im missing ..

currently i have no idea, how to resolve all files that will be compiled...

Wiki repo not up to date

I would like to create a PR fixing a typo and trying to make the What's new better but it seems like this repo is not up to date with what I can see in the actual Typescript repo's wiki.

Do we have a release schedule for the updates to this repo?

Not up to date with what's live?

Hey, I want to fix a typo (paragma) in https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#typescript-28, but this repository seems to be several months old without a change and the branch names do not indicate there is a different working branch from master, all of them seem to be branches for specific things.

The file I am interested in, What's-new-in-TypeScript.md is stuck at TS 2.6 whereas the link above is about 2.8. Where is the up to date file?

Can the Want to contribute to this Wiki? be redone so that it takes you to the actual source file and not just the wiki repo?

Delete extra text on Specifying the type of this for functions section

On Specifying the type of this for functions section in What's-new-in-TypeScript.md file, there are extra text under the first example of the section. The extra text is this:

That means that this is of type Deck now, not any, so --noImplicitThis will not cause any errors.

This text doesn't appear on the wiki's page of TypeScript Repo.

Wiki updates

Quick question - I know the process for updating the wikis is somewhat arduous, but do you do releases on a set schedule, or as needed?

I had added some documentation that I'd like to reference.

Using the Type Checker example gives type errors with typescript 3.6.4

This example gives type errors.

docGenerator.ts:65:53 - error TS2554: Expected 1 arguments, but got 0.
documentation: ts.displayPartsToString(symbol.getDocumentationComment()),
docGenerator.ts:99:36 - error TS2345: Argument of type 'Node' is not assignable to parameter of type 'Declaration'.
Property '_declarationBrand' is missing in type 'Node' but required in type 'Declaration'.
(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) !== 0 ||

Document output of --generateTrace

Hello everyone, happy ny and holidays!

I've recently been using a lot of --generateTrace to debug some performance issues of our codebase (successfully). While doing so, I often used the chrome://tracing along with @amcasey's library (https://github.com/amcasey/ts-analyze-trace). Since I work on a continuous profiling product where we display our own flamegraphs, I've been quietly hoping to add support for tsc traces.

I couldn't find any information of the actual format used, but I suppose it follows https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview, could someone maybe confirm? In the similar vein, having an explanation of the types.json that is generated would also be ❤️

Thanks so much!

Record mapped types example in TS 2.1 section of What's New is broken

In the What's New... page, the TS 2.1 mapped types example for the Record type is broken with respect to its current definition due to the | number part in K extends string | number of the mapObject signature.

Original:

// For every properties K of type T, transform it to U
function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>
const names = { foo: "hello", bar: "world", baz: "bye" };
const lengths = mapObject(names, s => s.length);  // { foo: number, bar: number, baz: number }

Corrected:

// For every properties K of type T, transform it to U
function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>
const names = { foo: "hello", bar: "world", baz: "bye" };
const lengths = mapObject(names, s => s.length);  // { foo: number, bar: number, baz: number }

What process are you following to allow PR's to Wiki?

We have been wanting to allow edit's to our wiki for Chocolatey, but we also want to "moderate" the submissions via pull requests. Having hunted around a bit, we hadn't found an "easy" way to do this, but it looks like you guys have.

Would it be possible for you to explain what you did to set this up so that this GitHub repo updates the wiki on the TypeScript GitHub Site. What process are you following?

Thanks in advance!

Are ESLint rules around performance worth advocating?

Hey @DanielRosenwasser,

I do hope you're well. First up, this is not directly an issue with the wiki at all, but I thought this was a good place to have a conversation about your wiki page on performance.

I was just talking with @dragomirtitian about me writing a blog post which would show how to take a few of the tips in here and apply them with ESLint; there’s ESLint rules out there that can help with this. Essentially the main ones of interest are:

Titian posed the (entirely helpful) question:

I'm sure these make difference.. By at what point.. 1K loc? 10Kloc? 100? If this is a concern for huge scale projects is it really worth it for smaller projects? I mean shaving off 0.2s in a build doesn't seem worth it if I have to maintain a type and an inferable return type.

This is a great question. And I have to state a personal stylistic preference fortypes over interfaces, as well as preferring return type inference. Much less noisy. But perf is royalty and style is secondary.

My own feeling is that if you want to go with these rules, it’s easier if you start with them at the beginning of a project that you expect to grow. As retro-fixing all of these in a codebase would not be fun!

Anyway, rambling done. I have two questions for you if have a moment:

  1. Is it worth blogging to advocate that people use the above ESLint rules? Or is this potentially transient advice? Something that’s useful now but could change as the compiler evolves?

  2. Do you have a feeling for what level of difference that following these standards can make? The answer will no doubt be "it depends", but I'm curious if you happen to have an idea for what the boundaries of success could look like here. So, is it possible to say something like "enforcing return types on functions has been observed to improve type checking performance by up to 40%", or "preferring interfaces over types has been observed to improve type checking performance by up to 20%"? Actually having an idea of the level of difference that could be made is a super helpful piece of info. (Essentially this is Titian's question 😄 )

I hope you don't mind me posting the question here. I did consider DMing you instead, but I thought I'd do a @swyx and "learn in public" 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.