Closed JRJurman closed 2 years ago
A lot of the runtime checks can actually be removed now that we verify the return type of Tram-One Components
When playing around in a typescript project, people can use the following syntax to verify the component follows the correct interface:
import { registerHtml, TramOneComponent } from 'tram-one'
const html = registerHtml()
const AppHeader: TramOneComponent = (props, children) => {
return html`
<h1 class="app-header">
${children}
</h1>
`
}
export default AppHeader
Summary
In an effort to get the advantages of type safety, this PR migrates the source code (and most of the tests) to Typescript.
This gives the project more type safety, and allows our consumers to build projects with type safety (if they are using Typescript). If they aren't using Typescript they still will get proper type annotations when working with compatible editors (such as Visual Studio Code).
Changes
All the changes listed below are detailed in the comments, treat these as a high level breakdown.
Bump Major - v11.0.0
In reality, this might not be breaking for JS projects, but there are a significant number of changes (including the removal of some safety checks for JS and addition of checks for TS). Anyone using Typescript would start getting compile time errors / warnings, so for that reason alone really it should be considered a breaking change.
Main Changes
types.ts
file for typescript type definitionsAuxiliary Changes
...args
for more clear parameter definitionsTesting Changes
Artifacts: https://github.com/Tram-One/tram-one/compare/typescript...typescript-artifacts
Note about the artifacts
For some reason, CircleCI slowed down between the last master run and this changeset. This was confirmed with a dummy PR which had similar slowdowns (with no changes).Checklist
Post Merge Checklist