Giter VIP home page Giter VIP logo

Comments (6)

MartinJohns avatar MartinJohns commented on September 27, 2024

This is working as intended per #32695. Assertions require every name in the call target to be declared with an explicit type annotation.

from typescript.

fidian avatar fidian commented on September 27, 2024

I've got three questions.

  1. Every name in the call target needs to be declared with an explicit type annotation. TypeScript knows the types involved. Why does the parameter need to be explicit? I've read the issue and others like it but I failed to find the underlying reason why explicitly typed parameters are required or a workaround.

  2. Why does the native assert package work?

image
TypeScript Playground

  1. Using the native assertions doesn't help with the test plan when one is required. Can @types/node be updated so the first example works? If so, is that a ticket for DefinitelyTyped/DefinitelyTyped?

I appreciate any extra detail or dumbing-down of the information that you can provide.

from typescript.

MartinJohns avatar MartinJohns commented on September 27, 2024
  1. This limitation is by design for performance reasons.
  2. This library does not require your passed function to be an assertion function, or there are no identifiers without declared type (didn't check which one).
  3. That would be a bad change. I'm sure it's intentional that it requires an assertion function.

from typescript.

typescript-bot avatar typescript-bot commented on September 27, 2024

This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

from typescript.

daviduzumeri avatar daviduzumeri commented on September 27, 2024

I don't think this is a TypeScript issue per se, but it is weird that this works when node:assert is imported directly, but it doesn't when it's used off of node:test's TestContext object which, as far as I know, just re-exports node:assert.

from typescript.

daviduzumeri avatar daviduzumeri commented on September 27, 2024

I expect this is an issue with @types/node instead and how it's typing TestContext's assert:

image
image

Note when it's off of node:assert it's a full function, but it's a lambda when it's on TestContext.

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.