🇧🇷
ts-inferTyping inference for typescript testing units
Motivation
Test the creation of complex generic types.
Installation
npm install ts-infer
yarn add ts-infer
Use
test'Attribute constraint inference',
The infer ()
function checks for compilation errors in the provided callback
and throws an exception if it contains errors. A second argument with the compiler options can be provided. If omitted, the same file as the dependent project will be used.
IMPORTANT: The use of @ ts-ignore
is necessary to avoid errors when compiling the test file. These lines will be removed by infer ()
before inference.
test'Attribute constraint diagnostic',
The diagnose()
is similar to infer()
, but it returns a list of errors instead of throwing an exception.
🇧🇷
Inferência de tipagem para unidades de testes em typescript
Motivação
Testar a criação de tipos genéricos complexos.
Instalação
npm install ts-infer
yarn add ts-infer
Uso
test'Inferência de restrição de atributos',
A função infer()
verifica erros de compilação no callback
fornecido como argumento e lança uma exceção caso a mesma contenha erros. Um segundo argumento com as opções de compilação pode ser fornecido. Se omitido, será usado o mesmo arquivo do projeto dependente.
IMPORTANTE: O uso de @ts-ignore
é necessário para não haver erros na compilação do arquivo de teste. Essas linhas serão removidas por infer()
antes da inferência.
test'Diagnóstico de restrição de atributos',
A função diagnose()
é similar à infer()
, mas retorna uma lista de erros ao invés de lançar uma exceção.