Direktíva TypeScript '@ts-expect-error' nefunguje v rámci testu Jest
Vytváram aplikáciu Express pomocou nx a axiom. Teraz sa snažím použiť direktívu //@ts-expect-error, ale dostávam chybu Nevyužitá direktíva '@ts-expect-error' ako v termináli, tak aj v editore.
toto je môj test:
describe('apps', () => {
it('should return an error if you return things not in the ts
definition', () => {
expect(() => {
appNotify.get('/v1/notify/healthcheck', ( res) => {
//@ts-expect-error - notExistingProperty shold not be allowed
res.json({
notExistingProperty: true,
message: 'Welcome to notify!'
});
});
}).toThrow();
});
});
toto je môj tsconfig :
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2017", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@notify/logger": ["libs/logger/src/index.ts"],
"@notify/notify-redis-client": ["libs/notify-redis-client/src/index.ts"]
},
"strict": true
},
"exclude": ["node_modules", "tmp"]
}
moja verzia typescriptu je 4.9.5
Skúsil som zapnúť checkJS v tsconfig, ale nič sa nezmenilo.