Comments (6)
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.
I've got three questions.
-
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.
-
Why does the native
assert
package work?
- 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.
- This limitation is by design for performance reasons.
- 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).
- That would be a bad change. I'm sure it's intentional that it requires an assertion function.
from typescript.
This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
from typescript.
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.
I expect this is an issue with @types/node
instead and how it's typing TestContext
's assert:
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)
- Missing overload method on union types HOT 7
- JSDoc `@import` of "tslib" fails under `--moduleResolution bundler`
- Interface that extends another no longer constrains types like the original HOT 1
- Proposal: Allow isolated declarations to infer results of constructor calls HOT 10
- Property 'difference' does not exist on type 'Set' HOT 3
- Type narrowing of condition leads to unexpected error for assignment HOT 3
- Increase the distinction between class and interface properties when defining a class or interface
- Add adaptation to class and interface property prompts HOT 1
- Weird behavior with recursive generic types HOT 2
- Array of unions changed to union of arrays in conditional type HOT 4
- tsserver requires `npm` to be installed on `neovim` trough `mason` HOT 2
- RangeError: Maximum call stack size exceeded when calling `getJsDocTags` on getter of class that implements itself
- Class constructors that early return another object still require fields to be assigned HOT 2
- [NewErrors] 5.7.0-dev.20240922 vs 5.6.2 HOT 6
- [ServerErrors][JavaScript] 5.7.0-dev.20240922 vs 5.6.2 HOT 3
- [ServerErrors][TypeScript] 5.7.0-dev.20240922 vs 5.6.2 HOT 7
- IsolatedDeclarations: emitted declarations inconsistent between `transpileDeclaration` API and TypeScript Playground HOT 1
- Inconsistent typechecking with require() in JS and TS HOT 5
- TypeScript fails to narrow union of native Error types HOT 5
- Typed JSON imports HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.