Skip to content

Property initialisation check in TS 3.5 is too strict for ember 3.5 #31682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sandersn opened this issue May 30, 2019 · 1 comment
Open

Property initialisation check in TS 3.5 is too strict for ember 3.5 #31682

sandersn opened this issue May 30, 2019 · 1 comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Milestone

Comments

@sandersn
Copy link
Member

Start reading here: #29395 (comment)

import Component from '@ember/component';
import defaultTo from 'lodash/default-to';

export default class Welcome extends Component {
  greeting: string = defaultTo(this.greeting, "Hello");
}

Briefly, ember 3.5's Components have properties that are initialised by the base to a value, but Typescript doesn't know about this. Users should be able to squash the error by writing greeting!: string = ..., or by turning off strictPropertyInitialization, but can't today.

@sandersn sandersn added this to the Backlog milestone May 30, 2019
@RyanCavanaugh RyanCavanaugh added In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels Jun 13, 2019
@kevinbarabash
Copy link

I've been experimenting with the idea of adding pragmas for each of the strict flags to enabling/disabling on a per file basis. The thinking was that there would be a new flag that disables strict checking of any type in .d.ts files and except for library definitions containing @strict-property-initialization (or other strict pragmas as needed). I think this could address the general problem of people wanting to use various strict flags with their code but not being able to because they break various libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants