2. Joshua Lawrence
Sr. Software Engineer @LinkedIn
Developer Experience Team
Centralized Release Tool “CRT” - Internal CI/CD UI
Working with Ember for six years
Codemod n00b
6. Life Without Component Argument Type Checking
// ember-mascot usage
<EmberMascot @name={{this.name}} @likes={{this.likes}} />
Are there any other args
that I can/should provide?
Is this a number? Boolean?
An array of strings?
Probably a string
8. JSDoc Basic information for devs, but became
inaccurate over time
Verbose and lacks some features of argument
decorators
Uses modern patterns, is powerful and flexible,
doesn’t distract from component logic
ember-prop-types
ember-decorators/argument
9. Type Checking via “ember-decorators/argument”
// ember-mascot.hbs
<p>{{this.name}}</p>
<p>{{this.likeCount}}</p>
<ul>
{{#each this.likes as |like|}}
<MascotLike @like={{like}} />
{{/each}}
</ul>
// ember-mascot.js
export default class EmberMascot extends Component {
@argument(‘string’)
name = ‘’;
@argument(‘number’)
likeCount = 0;
@argument(shapeOf({
user: ‘string’,
date: Date
}))
likes;
}
20. codemod-cli project
Three transforms are better than one
Map
Decorators
to
JSON
Use JSON
to build
Template
Helpers
Remove
Argument
Decorators
JSON HBS JS
23. // argument-decorators.input.js
class Foo extends Component {
// This is a string arg
@argument(‘string’)
stringArg;
// This is a number arg
@argument(‘number’)
numberArg;
}
Transform 3 - Input/Output
// argument-decorators.output.js
class Foo extends Component {
// This is a string arg
stringArg;
// This is a number arg
numberArg;
}
53. import { argument } from '@ember-
decorators/argument';
class Foo extends Component {
// This is a string arg
@someUnrelatedDecorator
@argument(‘string’)
stringArg;
}
Remove Argument Decorators
class Foo extends Component {
// This is a string arg
@someUnrelatedDecorator
stringArg;
}
54. Putting them all together
Map
Decorators
to
JSON
Use JSON
to build
Template
Helpers
Remove
Argument
Decorators
JSON HBS JS