Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Convert packages to TypeScript #4225

Closed
45 tasks done
kfranqueiro opened this issue Jan 4, 2019 · 9 comments
Closed
45 tasks done

Convert packages to TypeScript #4225

kfranqueiro opened this issue Jan 4, 2019 · 9 comments

Comments

@kfranqueiro
Copy link
Contributor

kfranqueiro commented Jan 4, 2019

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

Additional tasks

Packages to remove

We should consider removing the following deprecated packages rather than spending time converting them:

@nemethmik
Copy link

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.

acdvorak added a commit that referenced this issue Jan 18, 2019
acdvorak added a commit that referenced this issue Jan 19, 2019
acdvorak added a commit that referenced this issue Jan 19, 2019
acdvorak added a commit that referenced this issue Jan 19, 2019
acdvorak added a commit that referenced this issue Feb 14, 2019
Refs #4225

Removes deprecated package `mdc-icon-toggle` from the all-in-one JS bundle.
acdvorak added a commit that referenced this issue Feb 15, 2019
@gugu
Copy link
Contributor

gugu commented Feb 20, 2019

How can I help you with this task?

@moog16
Copy link
Contributor

moog16 commented Feb 20, 2019

@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!

acdvorak added a commit that referenced this issue Feb 21, 2019
### 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`
@acdvorak
Copy link
Contributor

@gugu You rock! 🤜 🤛 Early testing and feedback would be super useful, so if you're able and willing, you could check out the feat/typescript branch (currently at 72e8b66), compile it with
npm i && npm run build, and let us know if you see anything unexpected or odd. Thanks! 😀

@gugu
Copy link
Contributor

gugu commented Feb 21, 2019

I did sed s!@material/!@shortcm/! in typescript branch and published them in @Shortcm organization (https://www.npmjs.com/org/shortcm). Tomorrow will start switching react module to the typescript material-web. When this branch will be published I'll try to have a pull request ready

@gugu
Copy link
Contributor

gugu commented Feb 23, 2019

@acdvorak do you plan to continue to use webpack?

I created packages with tsc and instead of 100kB files they are 8kB

https://imgur.com/a/fVCA2sW

@moog16
Copy link
Contributor

moog16 commented Feb 23, 2019

@gugu - did you see changes outlined in #4409? We're also using tsc to achieve smaller file sizes, and allow for tree-shaking. I haven't measured the file sizes, but I'm sure it is smaller than the UMD bundles.

Yes we are not removing webpack from our build.

acdvorak added a commit that referenced this issue Feb 26, 2019
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
acdvorak added a commit that referenced this issue Feb 27, 2019
Resolves #4225

BREAKING CHANGE: The previously deprecated mdc-icon-toggle package has been removed; use mdc-icon-button instead.
@acdvorak acdvorak reopened this Feb 27, 2019
@acdvorak
Copy link
Contributor

Pre-release version 1.0.0-0 has been published on npm 🎉

@kfranqueiro
Copy link
Contributor Author

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.

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

No branches or pull requests

5 participants