Components: Prefix all interfaces/types with `Mat`

Created on 25 Jan 2018  路  3Comments  路  Source: angular/components

Bug, feature request, or proposal:

Maybe a proposal.

What is the expected behavior?

I'd expect all interfaces/types to have the Mat prefix for consistency.

What is the current behavior?

Not sure if it was intentional, but there are some interfaces/types that aren't prefixed by Mat.

Ex.:

https://github.com/angular/material2/blob/a5ca9ceec6cc3bcd4ad0e9f44a63ef5ed2c2144e/src/lib/button-toggle/button-toggle.ts#L34

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

5x.

Is there anything else we should know?

You should already know this, but anyway to find all interfaces/types that aren't prefixed by Mat, you can search using the following regex export (interface|type) [^M].

P4 many feature needs discussion

Most helpful comment

I guess an argument would be that most people would type MatToggleType or read markup with angular code and know the types are specifically based around Material Design. Another good reason for prefixing is less clashing? Also, if many are already prefixed, than doesn't that mean a small percentage that aren't prefixed are essentially going against an implicit or unspoken conventional coding style for this project? (Personally, I don't mind - but i understand the issue raised does serve a purpose for discussion)

All 3 comments

I'm not sure whether this is necessary. Whoever is importing the symbol can figure out that it's from Material by seeing that it comes from @angular/material/*.

I guess an argument would be that most people would type MatToggleType or read markup with angular code and know the types are specifically based around Material Design. Another good reason for prefixing is less clashing? Also, if many are already prefixed, than doesn't that mean a small percentage that aren't prefixed are essentially going against an implicit or unspoken conventional coding style for this project? (Personally, I don't mind - but i understand the issue raised does serve a purpose for discussion)

I let VS Code auto import all of my classes, so I just got used to typing Mat..... and hitting Enter.
This is much faster than scrolling to the top, typing import ..... and looking for the class I need.

So I vote in favor of this change.

Was this page helpful?
0 / 5 - 0 ratings