Coder Social home page Coder Social logo

Comments (8)

NobbZ avatar NobbZ commented on May 12, 2024

PS: totally the same behaviour when s/string/number/

from typescript.

NobbZ avatar NobbZ commented on May 12, 2024

OK, in the meantime I was able to find out, that tsc will complain about a syntax error:

hello-world.ts(2,33): error TS1005: ',' expected.

After some googling I found that correct syntax for the class were:

class HelloWorld {
    static hello(name: number = "World"): number {
        return "Hello, " + name + "!"
    }
}

compiling this, now successfully complains about types beeing incorrect:

hello-world.ts(2,18): error TS2322: Type '"World"' is not assignable to type 'number'.
hello-world.ts(3,9): error TS2322: Type 'string' is not assignable to type 'number'.
hello-world.test.ts(11,29): error TS2345: Argument of type '"Bob"' is not assignable to parameter of type 'number'.
hello-world.test.ts(15,29): error TS2345: Argument of type '"Sally"' is not assignable to parameter of type 'number'.

Therefore I have to assume, that the typescript-track currently doesn't even use typescript!

from typescript.

masters3d avatar masters3d commented on May 12, 2024

Good point. I filed a bug/feature question.
As a work around we could run the compiler every time we run the tests to catch this
"test": "tsc -p . && jest --no-cache",
I do think since ts-jest compiles the code before running jest that they should display any errors from the compiler and fail.

from typescript.

NobbZ avatar NobbZ commented on May 12, 2024

You filed a bug/feature where? Do you have a link/crossref?

from typescript.

masters3d avatar masters3d commented on May 12, 2024

kulshekhar/ts-jest#250

from typescript.

NobbZ avatar NobbZ commented on May 12, 2024

Also, a better way to alter the script line seems to be: tsc --noEmit -p . && jest --no-cache.

This way there is no javascript generated which leads to running the tests twice by jest

from typescript.

masters3d avatar masters3d commented on May 12, 2024

What rabbit hole. Others are also using --noEmit. I think that is what we are going to use too: ds300/react-native-typescript-transformer#13

from typescript.

thedevelopnik avatar thedevelopnik commented on May 12, 2024

@masters3d thanks for doing that PR! Looks like a good solution.

And thanks for catching this @NobbZ. Just implemented the tsc --noEmit in my own copy of the exercises and found out my Hello World solution didn't pass anymore hah.

from typescript.

Related Issues (20)

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.