tsdjs / tsd

Check TypeScript type definitions
MIT License
2.4k stars 67 forks source link

Not catching readonly error #143

Closed brettz9 closed 1 year ago

brettz9 commented 2 years ago

I would expect the "only permits reading" error to be caught by the test framework and not reported when running tsd, but instead I get notified that no error was found and that I was assigning to an index signature only permitting reading:

export type KeysStrictReadonly = {
    readonly [type: string]: readonly string[];
};
import { expectError } from 'tsd';
import { KeysStrictReadonly } from "../lib/index.js";

expectError(() => {
    const erring: KeysStrictReadonly = {
        TestInterface1: ["left", "right"]
    };
    erring.TestInterface1 = ["badAttemptOverwrite"];
});