-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Convert packages to TypeScript #4225
Comments
This is great. All JS teams developing any beyond-to-do-list-and-hello-world application should use TypeScript, it's astounding, TypeScript brings JS to the level of feature-rich business application development. |
Refs #4225 IMO this makes the code a little easier to read/write. https://www.typescriptlang.org/docs/handbook/advanced-types.html#string-literal-types
…4287) Refs #4225 IMO this makes the code a little easier to read/write. https://www.typescriptlang.org/docs/handbook/advanced-types.html#string-literal-types
Refs #4225 Removes deprecated package `mdc-icon-toggle` from the all-in-one JS bundle.
How can I help you with this task? |
@gugu we're actually nearing the end of our rewrite. All the components have been written, we're just cleaning up code and putting the finishing touches on everything. Thanks for offering! |
### Goal Make it easier for frameworks to wrap our TypeScript code. Refs #4225 ### How **Isolate framework-specific code from framework-agnostic code.** Specifically, this PR: * Maintains full backward compatibility with existing code * Moves all component definitions from `index.ts` to `component.ts` - `index.ts` is now purely re-exporting other files * Moves component-dependent types from `types.ts` to `component.ts` - Framework-related types are now quarantined in a single file: `component.ts` - All other files are now purely framework-agnostic, and can be safely wrapped by frameworks that don't use our components * Makes `import` paths more specific by switching from `@material/foo/index` to e.g. `@material/foo/foundation` or `@material/foo/types` - The only exception is `component.ts` files: Since they're basically our default "framework", they can safely import _other_ "framework" types via `@material/foo/index` * Updates class & interface export syntax to isolate the `default` export line for future removal if necessary: ```ts export class MDCFooFoundation { // ... } export default MDCFooFoundation; ``` * Combines `typings/custom.d.ts` and `typings/dom.ie.d.ts` into `packages/mdc-dom/externs.d.ts` so the types will be publicly visible * Adds `MDCFooFactory` types for components that need them (e.g., `MDCRipple`, `MDCList`) ### Packages * [x] `animation` * [x] `checkbox` * [x] `chips` * [x] `dialog` * [x] `dom` * [x] `drawer` * [x] `floating-label` * [x] `form-field` * [x] `grid-list` * [x] `icon-button` * [x] `icon-toggle` _(deprecated)_ * [x] `line-ripple` * [x] `linear-progress` * [x] `list` * [x] `menu` * [x] `menu-surface` * [x] `notched-outline` * [x] `radio` * [x] `ripple` * [x] `select` * [x] `selection-control` * [x] `slider` * [x] `snackbar` * [x] `switch` * [x] `tab` * [x] `tab-bar` * [x] `tab-indicator` * [x] `tab-scroller` * [x] `tab-tabs` _(deprecated)_ * [x] `textfield` * [x] `toolbar` _(deprecated)_ * [x] `top-app-bar`
@gugu You rock! 🤜 🤛 Early testing and feedback would be super useful, so if you're able and willing, you could check out the |
I did |
@acdvorak do you plan to continue to use I created packages with |
All `tslint:disable:object-literal-sort-keys` comments now include a description that explains why the linter rule needs to be disabled. For the most part, it's to ensure consistent ordering of methods between adapter interfaces and their implementations in the foundation and component. This PR also reorders a few properties in `MDCCheckbox` and `MDCRadio` for consistency. Refs #4225
Resolves #4225 BREAKING CHANGE: The previously deprecated mdc-icon-toggle package has been removed; use mdc-icon-button instead.
Pre-release version |
All of this work has been done across various PRs (see updates on original description). Some follow-up is being done regarding #4463 as James has begun testing RMWC against the pre-release. |
Overview
One of our Q1 2019 goals is to convert our packages' JS to TypeScript, as an increasing number of our consumers have TypeScript codebases and would benefit from this change.
The primary goal is to convert the packages themselves - converting the unit tests would be a plus (and would likely help test the conversion) but ideally we should be able to first convert packages one-by-one and continue to test them with the existing JS unit tests to confirm no unintended changes.
The intent of this conversion is ideally to involve no breaking changes, and to continue to provide both the ES6 and ES5 formats that we currently distribute in addition to TS.
This is a master issue for tracking all packages during the conversion, rather than creating 20 separate issues. I'm listing the components with JS below in a rough chronological order of approach (generally prioritizing dependencies ahead of dependents).
Packages to convert
base
(dependency of everything) (@moog16, feat(infrastructure): add tsconfig, tslint, and build setup #4241 along with infrastructure)dom
(@acdvorak, feat(dom): Convert JS to TypeScript #4269)animation
(@acdvorak, feat(animation): Convert JS to TypeScript #4271)linear-progress
(@acdvorak, feat(linear-progress): Convert JS to TypeScript #4272)ripple
(@moog16, feat(ripple): convert to ts #4300)menu-surface
(@acdvorak, feat(menu-surface): Convert JS to TypeScript #4273)switch
(@mmalerba)form-field
(@moog16, feat(form-field): ts convert #4327)selection-control
(exists solely for closure annotations; dependency of checkbox/radio) (@moog16, feat(form-field): ts convert #4327)checkbox
(depends onform-field
) (@moog16 and @acdvorak, feat(checkbox): typescript conversion #4319)radio
(@moog16 and @acdvorak, feat(radio): ts conversion #4329)icon-button
(@abhiomkar and @acdvorak, feat(icon-button): Convert to TypeScript #4325)list
(@moog16 and @acdvorak, feat(list): ts conversion #4334)menu
(depends onmenu-surface
andlist
) (@acdvorak, feat(menu): Convert JS to TypeScript #4342)dialog
(note:focus-trap
has its own.d.ts
) (@moog16 and @acdvorak, feat(dialog): ts conversion #4333)chips
(@moog16 and @acdvorak, feat(chips): ts conversion #4332)grid-list
(@moog16 and @acdvorak, feat(grid-list): ts conversion #4337)snackbar
(@acdvorak, feat(snackbar): Convert JS to TypeScript #4363)slider
(@acdvorak, feat(slider): Convert JS to TypeScript #4378)line-ripple
(@acdvorak, feat(line-ripple): Convert JS to TypeScript #4373)floating-label
(@acdvorak, feat(floating-label): Convert JS to TypeScript #4374)notched-outline
(depends onfloating-label
) (@acdvorak, feat(notched-outline): Convert JS to TypeScript #4375)tab-indicator
(@acdvorak, feat(tab-indicator): Convert JS to TypeScript #4391)tab-scroller
(@acdvorak, feat(tab-scroller): Convert JS to TypeScript #4392)tab
(depends ontab-indicator
) (@acdvorak, feat(tab): Convert JS to TypeScript #4393)tab-bar
(depends ontab
andtab-scroller
) (@acdvorak, feat(tab-bar): Convert JS to TypeScript #4394)textfield
(depends online-ripple
,floating-label
, andnotched-outline
) (@acdvorak, feat(text-field): Convert JS to TypeScript #4377)select
(@acdvorak, feat(select): Convert JS to TypeScript #4386)drawer
(note:focus-trap
has its own.d.ts
) (@acdvorak, feat(drawer): Convert JS to TypeScript #4390)top-app-bar
(@acdvorak, feat(top-app-bar): Convert JS to TypeScript #4397)auto-init
(@acdvorak, feat(auto-init): Convert JS to TypeScript #4395)toolbar
(superseded bytop-app-bar
, but keeping due to unique features) (@acdvorak, feat(toolbar): Convert JS to TypeScript #4410)material-components-web
(@acdvorak, feat(package): Convert JS to TypeScript #4396)tabs
(superseded bytab-bar
,tab-scroller
,tab
, andtab-indicator
, but keeping due to unique features) (@acdvorak, feat(tabs): Convert JS to TypeScript #4412)Additional tasks
Object.assign
with spread where possible (@acdvorak, chore: Remove Object.assign from TS files #4389)MDCRippleFactory
) (@acdvorak, refactor: Make TS easier to wrap #4407)index.ts
tocomponent.ts
(@acdvorak, refactor: Make TS easier to wrap #4407)interface
andtype
names (e.g.,Point
,MenuPoint
, orMDCMenuPoint
) (@acdvorak, refactor: Make TS easier to wrap #4407)*EventDetail
interfaces for all custom events that emit adetail
property, and use generic signature ofemit<*EventDetail>()
to prevent accidental type errors (@acdvorak, refactor: Make TS easier to wrap #4407)packages
is TS (@moog16, chore: replace JS for TS #4435)check-imports.js
script and ensure it is still workingPackages to remove
We should consider removing the following deprecated packages rather than spending time converting them:
icon-toggle
(superseded byicon-button
) (@moog16, chore: remove icon-toggle #4415)selection-control
(not used anywhere)(@kfranqueiro, chore(package): Remove selection-control #4442)The text was updated successfully, but these errors were encountered: