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

propName.toLowerCase is not a function #46936

Closed
Will-at-FreedomDev opened this issue Jul 21, 2022 · 5 comments
Closed

propName.toLowerCase is not a function #46936

Will-at-FreedomDev opened this issue Jul 21, 2022 · 5 comments
Assignees
Labels
area: compiler Issues related to `ngc`, Angular's template compiler bug state: has PR
Milestone

Comments

@Will-at-FreedomDev
Copy link

Will-at-FreedomDev commented Jul 21, 2022

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

compiler

Is this a regression?

No

Description

I think I've narrowed down the reason for this error. I created an @Input() binding with the name valueOf. I think the angular compiler doesn't like this name for some reason, but I can't find any documentation on this being the case. I forked one of the Angular Material examples and updated the example a bit to demonstrate the error.

@Component({
  selector: 'app-value-of',
  template: '{{valueOf("abc")}}'
})
export class ValueOfComponent {
  @Input() valueOf: (s: string) => any = (s: string) => s;
}

@Component({
  selector: 'autocomplete-filter-example',
  template: '<app-value-of [valueOf]="myValueOf"></app-value-of>',
})
export class AutocompleteFilterExample {
  myValueOf = (s: string) => 'something else';
}

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-jyiqdv?file=src%2Fapp%2Fvalue-of.component.ts,src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fautocomplete-filter-example.ts,src%2Fapp%2Fautocomplete-filter-example.css,src%2Fapp%2Fautocomplete-filter-example.html

Please provide the exception or error you saw

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: propName.toLowerCase is not a function
    at eval (/home/projects/angular-jyiqdv/node_modules/@ngtools/webpack/src/ivy/loader.js:81:18)

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: propName.toLowerCase is not a function
    at eval (/home/projects/angular-jyiqdv/node_modules/@ngtools/webpack/src/ivy/loader.js:81:18)

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

This information can be found in the stackblitz reproduction. Looks like version 14.

Anything else?

No response

@alxhub alxhub transferred this issue from angular/angular Jul 22, 2022
@alan-agius4
Copy link
Contributor

@alxhub, this seems to be caused by the compiler.

$ ngc -p tsconfig.app.json
error TS500: TypeError: propName.toLowerCase is not a function
    at DomElementSchemaRegistry.securityContext (file:///xxxxxx/node_modules/@angular/compiler/fesm2015/compiler.mjs:14884:29)
    at file:///xxxxxx/node_modules/@angular/compiler/fesm2015/compiler.mjs:15433:71
    at Array.map (<anonymous>)
    at file:///xxxxxx/node_modules/@angular/compiler/fesm2015/compiler.mjs:15433:43
    at Array.forEach (<anonymous>)
    at calcPossibleSecurityContexts (file:///xxxxxx/node_modules/@angular/compiler/fesm2015/compiler.mjs:15428:33)
    at BindingParser.createBoundElementProperty (file:///xxxxxx/node_modules/@angular/compiler/fesm2015/compiler.mjs:15316:32)
    at file:///xxxxxx/node_modules/@angular/compiler/fesm2015/compiler.mjs:15792:48
    at Array.forEach (<anonymous>)
    at HtmlAstToIvyAst.extractAttributes (file:///xxxxxx/node_modules/@angular/compiler/fesm2015/compiler.mjs:15783:20)```

@alan-agius4 alan-agius4 transferred this issue from angular/angular-cli Jul 22, 2022
@alan-agius4 alan-agius4 added the area: compiler Issues related to `ngc`, Angular's template compiler label Jul 22, 2022
@ngbot ngbot bot added this to the needsTriage milestone Jul 22, 2022
@alan-agius4 alan-agius4 changed the title propName.toLowerCase is not a function in node_modules/@ngtools/webpack/ivy/loader.js propName.toLowerCase is not a function Jul 22, 2022
@noobyogi0010
Copy link

Hey, @alan-agius4
I would like to work on this issue if no one else has already taken it up.
Thanks!

@alan-agius4
Copy link
Contributor

@noobyogi0010 go for it.

@noobyogi0010
Copy link

Okay, thanks!
@alan-agius4

@JoostK JoostK self-assigned this Aug 22, 2022
JoostK added a commit to JoostK/angular that referenced this issue Aug 22, 2022
Using raw objects as a lookup structure will inadvertently find methods defined on
`Object`, where strings are expected. This causes errors downstream when string
operations are applied on functions.

This commit switches over to use `Map`s in the DOM element schema registry to fix
this category of issues.

Fixes angular#46936
JoostK added a commit to JoostK/angular that referenced this issue Aug 22, 2022
Using raw objects as a lookup structure will inadvertently find methods defined on
`Object`, where strings are expected. This causes errors downstream when string
operations are applied on functions.

This commit switches over to use `Map`s in the DOM element schema registry to fix
this category of issues.

Fixes angular#46936
AndrewKushnir pushed a commit that referenced this issue Sep 6, 2022
)

Using raw objects as a lookup structure will inadvertently find methods defined on
`Object`, where strings are expected. This causes errors downstream when string
operations are applied on functions.

This commit switches over to use `Map`s in the DOM element schema registry to fix
this category of issues.

Fixes #46936

PR Close #47220
sbrshkappa pushed a commit to sbrshkappa/angular that referenced this issue Sep 8, 2022
…ular#47220)

Using raw objects as a lookup structure will inadvertently find methods defined on
`Object`, where strings are expected. This causes errors downstream when string
operations are applied on functions.

This commit switches over to use `Map`s in the DOM element schema registry to fix
this category of issues.

Fixes angular#46936

PR Close angular#47220
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler bug state: has PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants