-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[Bug] Result of object rest isn't assignable to symbol index signature #49235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
sounisi5011
added a commit
to sounisi5011/npm-packages
that referenced
this issue
May 25, 2022
sounisi5011
added a commit
to sounisi5011/npm-packages
that referenced
this issue
May 25, 2022
* chore(deps): update dependency typescript to v4.7.2 * chore(check-pid-file): disable type errors due to TypeScript bugs see microsoft/TypeScript#49235 * chore(monorepo-workspace-submodules-finder-action): add the `--transpile-only` flag to avoid errors When using TypeScript 4.7.2 with `@vercel/[email protected]`, I get the following error: Error: Module build failed (from ../../node_modules/.pnpm/@vercel[email protected]/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js): Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself. To suppress this error, I added the `--transpile-only` flag to the build command. Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Sonishi Izuka <[email protected]>
I don't know if this is intentional, but a quick workaround is to write |
Yes. But in the actual code, we may use the spread syntax when we want to exclude some properties. The same error occurs in this case as well. Such code would require a type hack like the one below to set the proper type: const oldErrorProperties = Object.getOwnPropertyDescriptors(oldError);
const { message: _1, stack: _2, ...newErrorProperties } =
oldErrorProperties as (
& typeof oldErrorProperties
& { [x: symbol]: PropertyDescriptor }
);
Object.defineProperties(newError, newErrorProperties); |
Shorter repro: const { ...properties2 } = {};
// Fails, should pass
const t1: { [x: symbol]: unknown } = properties2;
// OK
const t2: { [x: symbol]: unknown } = {}; |
gabritto
pushed a commit
that referenced
this issue
Jun 14, 2022
β¦ned to assignable types. (#49337) * fix issue 49235 * update code with suggested changes Co-authored-by: Benjamin Tong <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
π Search Terms
π Version & Regression Information
β― Playground Link
Playground link with relevant code:
π» Code
π Actual behavior
I get the following error:
But, type
{ [x: string]: PropertyDescriptor; }
is assignable to typePropertyDescriptorMap
. Objects copied with spread syntax cannot be assigned even though they have the same type.π Expected behavior
This type error does not occur. For the same type, it should be consistently assignable / non-assignable anywhere.
The text was updated successfully, but these errors were encountered: