tsdjs/tsd

expectError strict behaviour

Open

#40 aberto em 30 de set. de 2019

Ver no GitHub
 (4 comments) (0 reactions) (0 assignees)TypeScript (68 forks)user submission
help wantedquestion

Métricas do repositório

Stars
 (2.551 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

I need feedback on the behaviour of the expectError assertion.

The expectType assertion is strict. Which means that expectType<string | number>(concat('a', 'b')) will fail because string | number is defined too wide. See the docs.

I didn't change anything for expectError as I wasn't sure on the exact behaviour.

@cartant asked if it would behave like this (see https://github.com/ReactiveX/rxjs/issues/4871#issuecomment-535725717).

expectError<string | number>(add(1, 2));
//=> no error

The reason behind it could be that because the type is too wide, the assertion is an error and that's what you expect.

I also discussed this with @sindresorhus and he indicated that maybe we should hard fail on that assertion.

I definitely could use feedback on this topic here :).

// @BendingBender

Guia do colaborador