Code Monkey home page Code Monkey logo

typescript-twoslash-repro-action's Introduction

Twoslash Verify GitHub Action

Runs as a part of a nightly task in GitHub's CI. This action will:

  • Download the last 5 major releases of TypeScript
  • Looks through all issues which have a specific label (default: "Has Repro")
  • Uses extracts code samples in the issue from markdown in the body and comments (codeblocks with repro)
  • Loops through the code samples with
  • Leave / Updates a comment on the state of all the different results from the twoslash sample

Codebase

All of the code lives in src, and the filenames are decided so that they represent the passage of data through the pipeline. So if its at the top alphabetically, then it's at the top of the process.

To Work On This

Install the dependencies

yarn

Build the typescript and package it for distribution

$ yarn build && yarn pack

Run the tests ✔️

$ yarn test

 PASS  src/__tests__/issuesToTwoslashRuns.test.ts
  ✓ NOOPs with no issues (5ms)
  ...

Run or debug locally

yarn build

GITHUB_WORKSPACE=/absolute/path/to/TypeScript \
GITHUB_TOKEN=$token \          # will comment without DRY!
DRY=1 \                        # do not post results comment
ISSUE=50635 \                  # optional
BISECT="good 4.7.3 bad main" \ # optional
node lib/_main.js

To publish

Actions are run from GitHub repos so we will check-in the packed dist folder.

Then run ncc and push the results:

yarn build
yarn deploy
git add dist
git commit -a -m "prod dependencies"
git push

Your action is now published! 🚀

See the versioning documentation

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.opensource.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., status check, 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.

typescript-twoslash-repro-action's People

Contributors

andrewbranch avatar jakebailey avatar microsoft-github-operations[bot] avatar microsoftopensource avatar orta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-twoslash-repro-action's Issues

Completions bug

function returnFoo<T extends {a: 1, b: 2}>(foo: T): T {
    return foo;
}

// ✅ auto-completion works
returnFoo({  })
//          ^|
// ❌ auto-completion broken
returnFoo({  } as const)
//          ^|

Example issue with twoslash repros

A description of my bug, I took this from one of mine on TS

// @noImplicitAny: false

type Entity = {
  someDate: Date | null;
} & ({ id: string; } | { id: number; })

type RowRendererMeta<TInput extends {}> = {
  [key in keyof TInput]: { key: key; caption: string; formatter?: (value: TInput[key]) => string; };
}
type RowRenderer<TInput extends {}> = RowRendererMeta<TInput>[keyof RowRendererMeta<TInput>];

const test: RowRenderer<Entity> = {
  key: 'someDate',
  caption: 'My Date',
  formatter: (value) => value ? value.toString() : '-' // value: any
//            ^?
}

const thisIsNotTheIssue: Partial<RowRendererMeta<Entity>> = {
  someDate: {
    key: 'someDate',
    caption: 'My Date',
    formatter: (value) => value ? value.toString() : '-' // value: Date | null
//              ^?
  }
}

From the workbench

A failing then passing issue

type State
    = {tag: "one"}
    | {tag: "two"}
    | {tag: "three"}

function notallowed(arg: number) {
    let state: State = {tag: "one"};
    try {
        state = {tag: "two"};
        try { // <- this inner try causes a problem
            state = {tag: "three"}; // <- this should make "three" be a possibility but when inside a try, typescript "forgets" it.
        }
        finally {}
    }
    catch (err) {
        state.tag; // <- this should be "one" | "two" | "three" but typescript says it is "one" | "two"
        if (state.tag !== "one" && state.tag !== "two") {
            console.log(state.tag); // <- typescript reports a type error here
        }
    }
}

Workbench Repro

Emit changed example

This looks like it might get merged soon: microsoft/TypeScript#39337

// @filename: service.ts
export class Service {}

// @filename: component.ts
 import type { Service } from "./service";

 declare var decorator: any;

 @decorator
 class MyComponent {
     constructor(public Service: Service) {
     }

     @decorator
     method(x: this) {
     }
 }

// @emitDecoratorMetadata
// @experimentalDecorators
// @showEmit
// @showEmittedFile: component.js

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.