Skip to content

Crash: Debug Failure. type must be class or interface in getBaseTypes triggered by invalid optional rest parameter in Constructor typeΒ #62921

@na7ure-a

Description

@na7ure-a

πŸ”Ž Search Terms

"Debug Failure. type must be class or interface"

"Rest parameter cannot be optional crash"

"isConstructorAccessible crash strict mode"

"Mixin protected constructor crash"

πŸ•— Version & Regression Information

Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly

Behavior: All tested versions crash when --strict is enabled.

Condition: The crash only occurs when --strict is used. Without --strict, the compiler correctly identifies the syntax error (TS1047) and the semantic error (TS2674).

⏯ Playground Link

https://www.typescriptlang.org/zh/play/?target=7&ts=6.0.0-dev.20251222#code/MYGwhgzhAECCBGEAuAnMwnQN4FgBQ0h0ADigPZICmGlAJtMGQHbIoCuGZKAFAJTb4i0AL75ReUJBgBhZsBSUq0SgA8qTWjASt0mXHnFIAnsUrRZLVByRcAPABVoAXmzCAfM+hNKAd2jcAOiCwFABzCAB+AC5oMCYjAG0AXX4nD3sAbnwAMzYmDABLZmgAWQKVAqYHACFIM1V1TXNmVmsuN25aiEoY+y7Kfn0hBSQ2FCYGcChlNUoNGH6BAiJhLIN8SWmAUQBbYmMl8U2ZNAgAC3sUAtDQyhQZxpgyiqZuXf2jQcEiYjZ4EAKwGgqGutx4X2WQkI3j8FnkikofDWQnEwiAA

πŸ’» Code

class Abstract {
    protected constructor() {
    }
}
class Concrete extends Abstract {
}
type Constructor<T = {}> = new (...args?: any[]) => T;
function Mixin<TBase extends Constructor>(Base: TBase) {
    return class extends Base {
    };
}
class Empty {
}
class CrashTrigger extends Mixin(Empty) {
    public trigger() {
        new Concrete();
    }
}

πŸ™ Actual behavior

.\ts-versions\nightly\node_modules\.bin\tsc.cmd  --ignoreConfig --strict  .\bugfind\2\noCrashOnMixin_m.ts
D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123191
     throw e;
     ^

Error: Debug Failure. type must be class or interface
   at getBaseTypes (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:57088:17)                                                                                                     
   at typeHasProtectedAccessibleBase (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:76955:23)                                                                                   
   at typeHasProtectedAccessibleBase (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:76982:12)                                                                                   
   at typeHasProtectedAccessibleBase (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:76982:12)                                                                                   
   at isConstructorAccessible (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:76999:13)                                                                                          
   at resolveNewExpression (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:76918:12)                                                                                             
   at resolveSignature (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:77323:16)                                                                                                 
   at getResolvedSignature (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:77348:20)                                                                                             
   at checkCallExpression (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:77456:23)                                                                                              
   at checkExpressionWorker (D:\do\tscFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:80921:16)   

.\ts-versions\nightly\node_modules\.bin\tsc.cmd  --ignoreConfig   .\bugfind\2\noCrashOnMixin_m.ts        
bugfind/2/noCrashOnMixin_mutated_17.ts:7:40 - error TS1047: A rest parameter cannot be optional.

7 type Constructor<T = {}> = new (...args?: any[]) => T;
                                        ~                                                                                                                                                               

bugfind/2/noCrashOnMixin_mutated_17.ts:16:9 - error TS2674: Constructor of class 'Abstract' is protected and only accessible within the class declaration.

16         new Concrete();
          ~~~~~~~~~~~~~~                                                                                                                                                                                
Found 2 errors in the same file, starting at: bugfind/2/noCrashOnMixin_mutated_17.ts:7  

πŸ™‚ Expected behavior

The compiler should not crash. It should report the existing errors normally:

error TS1047: A rest parameter cannot be optional.

error TS2674: Constructor of class 'Abstract' is protected and only accessible within the class declaration.

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions