2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TypeScriptでクラスを書くとTS1294: This syntax is not allowed when erasableSyntaxOnly is enabled.

2
Posted at

はじめに

  • なんとなくで書いたもので構文エラー。他言語の書き方だったかも

問題

  • この書き方エラー
export class Todo {
  constructor(
    public id: string,
    public title: string,
    public done: boolean,
    public created_at: string,
  ) {}
}

解決

  • こちらではエラーが出ない
export class Todo {
  id: string;
  title: string;
  done: boolean;
  created_at: string;

  constructor(id: string, title: string, done: boolean, created_at: string) {
    this.id = id;
    this.title = title;
    this.done = done;
    this.created_at = created_at;
  }
}

終わりに

2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?