angular / angular/angular

Type checking for structural directive without parameter

Aberta
#46,749 5 comentários 1 reação 0 responsáveis Ver no GitHub
area: compiler bug compiler: template type-checking P3
Linguagem predominante
TypeScript
Estrelas
101k
Forks
27.5k
Merge médio
1d 19h
PRs com merge (30d)
288

Descrição

### Which @angular/* package(s) are the source of the bug?

Don't known / other

### Is this a regression?

No

### Description

Hello,
not sure if this is an actual issue or just me misunderstanding behaviour of structural directives in Angular.

Let's say we have a simple structural directive (see [repro](https://stackblitz.com/edit/angular-ivy-vbzbnj?file=src%2Fapp%2Funless.directive.ts,src%2Fapp%2Fapp.component.html,tsconfig.json,src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fapp.component.ts)). From my point of view, two declarations below should be equal, however, the first one throws type error, while the second one compiles without any errors. Why is that?

```ts

Test

Test

```

From my point of view, typechecker expects the structural directive without any parameters to be equal to following:

```ts

Test

````

when in reality, it is equal to code above (I tried to change the type of the directive parameter to `boolean | string`, and checked if the input setter will be called - it wasn't).

### Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-vbzbnj?file=src%2Fapp%2Funless.directive.ts,src%2Fapp%2Fapp.component.html,tsconfig.json,src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fapp.component.ts

### Please provide the exception or error you saw

_No response_

### Please provide the environment you discovered this bug in (run `ng version`)

_No response_

### Anything else?

_No response_

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece pela reprodução no StackBlitz, especialmente em src/app/unless.directive.ts, src/app/app.component.html, tsconfig.json, src/app/app.module.ts e src/app/app.component.ts. Reproduza o comportamento diferente de verificação de tipos para *appUnless e para a forma equivalente com ng-template e, em seguida, rastreie a verificação de templates do Angular para diretivas estruturais. A tarefa estará concluída quando o comportamento estiver explicado e as duas formas forem tratadas de maneira consistente, caso o comportamento relatado seja confirmado.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
angular, typescript
Domínio
frontend
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
38/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.