Skip to content

5.6.3 tsc crash: Error: Debug Failure. False expression. at getOptionalTypeΒ #60390

Closed
@sebcode

Description

@sebcode

πŸ”Ž Search Terms

Error: Debug Failure. False expression. at getOptionalType

πŸ•— Version & Regression Information

Crashes with 5.6.3 and next, but works fine with previous release 5.5.4.

⏯ Playground Link

Couldn't get it to work in the playground. Instead, see below for a repro.

πŸ’» Code

import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";

const slice = createApi({
	reducerPath: "userApi",
	baseQuery: fetchBaseQuery({}),
	endpoints: (builder) => ({
		test: builder.query<any, void>({
			query: () => ({
				url: `/user`,
			}),
		}),
	}),
});

export const { useTestQuery } = slice;

πŸ™ Actual behavior

Crash

Error: Debug Failure. False expression.
    at getOptionalType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:66507:11)
    at Object.canReuseTypeNodeAnnotation (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:50282:28)
    at serializeTypeAnnotationOfDeclaration (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:131464:19)
    at typeFromProperty (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:131687:36)
    at Object.serializeTypeOfDeclaration (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:131519:16)
    at serializeTypeForDeclaration (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:52429:41)
    at addPropertyToElementList (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:51321:43)
    at createTypeNodesFromResolvedType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:51217:11)
    at createTypeNodeFromObjectType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:50984:25)
    at visitAndTransformType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:50907:24)

πŸ™‚ Expected behavior

No crash.

Additional information about the issue

Repro:

$ git clone https://github.com/sebcode/tsccrashbugrepro.git
$ cd tsccrashbugrepro/
$ yarn
$ yarn tsc
yarn run v1.22.21
warning package.json: No license field
$ /home/seb/tmp/1/node_modules/.bin/tsc
/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:121666
      throw e;
      ^

Error: Debug Failure. False expression.
    at getOptionalType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:66507:11)
    at Object.canReuseTypeNodeAnnotation (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:50282:28)
    at serializeTypeAnnotationOfDeclaration (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:131464:19)
    at typeFromProperty (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:131687:36)
    at Object.serializeTypeOfDeclaration (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:131519:16)
    at serializeTypeForDeclaration (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:52429:41)
    at addPropertyToElementList (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:51321:43)
    at createTypeNodesFromResolvedType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:51217:11)
    at createTypeNodeFromObjectType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:50984:25)
    at visitAndTransformType (/home/seb/tmp/1/node_modules/typescript/lib/_tsc.js:50907:24)

Node.js v20.8.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions