Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type detection when typing out the inputs for components or directives in templates #1800

Open
1 of 2 tasks
sir-captainmorgan21 opened this issue Nov 11, 2022 · 7 comments
Open
1 of 2 tasks
Assignees
Labels

Comments

@sir-captainmorgan21
Copy link

sir-captainmorgan21 commented Nov 11, 2022

馃殌 feature request

Description

Im not sure this is a bug or not, but when providing inputs to a directive or component, the inputs/outputs come up, which is great. However, the type of the input is showed as any, so when I select an input with a custom type as the input, I dont get presented the available options (example of a component below).

export type MyType = 'option1' | 'option2' | 'option3'

@Component({...})
export class MyComponent {
  @Input() myInput: MyType;
}

See video below:
gif

I believe this used to be working, which is why I made the shift to typescript types instead of enums, since we'd get intellisense in the templates without having to define a enum property on the component.

Feature Type

What does this bug affect

  • Angular Language Service VSCode extension
  • Angular Language Service server

Describe the solution you'd like

I'd like to be able to see the list of options once I select an input I want to use that uses custom types like this.

Describe alternatives you've considered

Just working through it for now

Anything else relevant?

Nope

@atscott
Copy link
Collaborator

atscott commented Nov 11, 2022

@sir-captainmorgan21 what does your tsconfig.json look like (specifically the angularCompilerOptions)?

@sir-captainmorgan21
Copy link
Author

@atscott strictTemplates is set to true. I suspected that was it too.

{
  "extends": "../../tsconfig.base.json",
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.lib.json"
    },
    {
      "path": "./tsconfig.spec.json"
    },
    {
      "path": "./.storybook/tsconfig.json"
    }
  ],
  "compilerOptions": {
    "target": "es2020",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

@atscott
Copy link
Collaborator

atscott commented Nov 14, 2022

@sir-captainmorgan21 Ah, looks like I'm able to reproduce this as well. Seems to be an issue with the autocomplete feature that we'll have to investigate.

@sir-captainmorgan21
Copy link
Author

@atscott awesome. Thanks!

@dylhunn dylhunn self-assigned this Nov 28, 2022
@dylhunn
Copy link
Collaborator

dylhunn commented Nov 28, 2022

Thanks for reporting -- I'm planning to debug it this week.

@sir-captainmorgan21
Copy link
Author

@dylhunn awesome. Thanks!

@joeveiga
Copy link

joeveiga commented Feb 6, 2023

Maybe related to #1740 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants