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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imported HTML content incorrectly flagged as non-string for component template. #1768

Open
1 of 2 tasks
KageJittai opened this issue Sep 29, 2022 · 0 comments
Open
1 of 2 tasks
Labels

Comments

@KageJittai
Copy link

🐞 bug report

Is this a regression?

No, ,

Description

When importing html content with an import statement, Angular Language Services generates a typescript. template must be a string\n Value is of type 'undefined'. The error does not affect typescript compiler or webpack, and vscode does not generate the error with ng-language-services disabled.

Example:

import html from "./app.component.html";

@Component({
    selector: 'appComponent',
    template: html
})
class AppComponent { ... }

Bug Type

What does this bug affect

  • Angular Language Service VSCode extension
  • Angular Language Service server

Reproduction

Steps to reproduce the behavior:

  1. Create an empty angular project.
  2. Create an html import typings as such, and register it in the tsconfig.json file
declare module '*.html' {
    const content: string;
    export default content;
}
  1. Create a new component (app.component.ts)
  2. Create an html file containing component's html (app.component.html)
  3. Import the html file created import html from "./app.component.html";, and pass the value as a template parameter to the component.
  4. Build project to confirm no build errors occured.
  5. Enable ng language service, and restart vscode, the intellisense from vscode should show the line of template: html.

Expected behavior

The line should not be shown as an error, because html variable should be identified as type string from the typings file.

Screenshots

image

🌍 Your Environment

Extension Version:


Angular Language Service v14.2.0

VSCode Version:


Version: 1.71.2 (user setup)
Commit: 74b1f979648cc44d385a2286793c226e611f59e7
Date: 2022-09-14T21:03:37.738Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19042
Sandboxed: No

Operating System:


Edition	Windows 10 Enterprise
Version	20H2
Installed on	‎8/‎26/‎2021
OS build	19042.2006
Experience	Windows Feature Experience Pack 120.2212.4180.0
@KageJittai KageJittai added the bug label Sep 29, 2022
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

1 participant