Comments (4)
It repros in the playground too: TS playground. To repro you need to hover over AssertionError
. An interesting fact is that the first hover after a source edit triggers the error but the second one doesn't and it renders a good tooltip content.
from typescript.
Failing test case:
// @strict: true
// @moduleResolution: node
// @noEmit: true
// @filename: node_modules/@types/node/index.d.ts
/// <reference path="assert.d.ts" />
/// <reference path="assert/strict.d.ts" />
// @filename: node_modules/@types/node/assert/strict.d.ts
declare module "node:assert/strict" {
import { strict } from "node:assert";
export = strict;
}
// @filename: node_modules/@types/node/assert.d.ts
declare module "assert" {
function assert(value: unknown, message?: string | Error): asserts value;
namespace assert {
class AssertionError extends Error {
actual: unknown;
expected: unknown;
code: "ERR_ASSERTION";
constructor(options?: {
message?: string | undefined;
actual?: unknown | undefined;
expected?: unknown | undefined;
});
}
namespace strict {
type AssertionError = assert.AssertionError;
}
const strict: Omit<typeof assert, "strict">;
}
export = assert;
}
declare module "node:assert" {
import assert = require("assert");
export = assert;
}
// @filename: index.ts
import { AssertionError } from 'node:assert/strict';
throw new AssertionError({
message: 'Hello',
actual: 3,
expected: 3,
});
from typescript.
The above test crashes even in TS 4.5 (and back even in 4.0 though with a slightly different error). So this most definitely is not a recent regression at all.
from typescript.
This is an interesting one. So the symbol that leads to a crash is a result of combineValueAndTypeSymbols
. That combines a type symbol with a value symbol that is a mapped symbol. Mapped symbols don't have .valueDeclaration
so there is nothing to attach onto the resulting combined symbol here. This leads to a crash.
We could propagate checkFlags
here so getTypeOfSymbol
could call getTypeOfMappedSymbol
instead of getTypeOfVariableOrParameterOrProperty
but that doesn't solve anything on its own. The combined symbol isn't truly a mapped symbol so it lacks properties that getTypeOfMappedSymbol
expects.
I need to think more about it but it seems like more stuff should get propagated onto that combined symbol from the mapped symbol. getTypeOfSymbol
here is interested in the type of the value and the value is typed using a mapped type... so - if I'm not mistaken - the only way to get the correct type is to resolve that mapped type symbol (we just can't do it right now since we lost the information required to do that along the way)
from typescript.
Related Issues (20)
- Make property decorator fabrics share generics with corresponding methods HOT 2
- Generic type parameter not inferring properly HOT 1
- JSDoc `@private` on constructor without parameters is omitted in declaration files
- [API] Ability to check if a parameter is being passed to const type parameter
- Improve support for internal packages by resolving path aliases
- CommonJS globals permitted for ES module builds with no compiler error. HOT 4
- -
- Type predicate doesn't narrow down function overload (but assertion works) HOT 3
- Recursive type strangely resolved to never HOT 3
- [5.5 beta] The `moduleDetection` option is ignored for `verbatimModuleSyntax` error HOT 6
- [NewErrors] 5.5.0-dev.20240526 vs 5.4.5 HOT 63
- [ServerErrors][JavaScript] 5.5.0-dev.20240526 HOT 11
- [ServerErrors][TypeScript] 5.5.0-dev.20240526 HOT 20
- Type Error in Array.includes() method when the array contains only string keys
- Type Error in Array.includes() method when the array contains only string keys HOT 4
- Attribute and Method Visibility depending on generics in form of `private` return type HOT 3
- String template literals as object keys don't get validated correctly HOT 4
- WebWorker NotificationOptions type issue HOT 1
- Type a standard import with jsdoc only
- tsc: "Cannot read properties of undefined (reading 'parent')" HOT 2
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.