Skip to content
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

new typescript component blueprint gives eslint warning #10427

Open
Polve opened this issue Jan 23, 2024 · 3 comments
Open

new typescript component blueprint gives eslint warning #10427

Polve opened this issue Jan 23, 2024 · 3 comments

Comments

@Polve
Copy link

Polve commented Jan 23, 2024


Output from ember version --verbose && npm --version && yarn --version:

ember-cli: 5.5.0
node: 21.4.0
acorn: 8.11.2
ada: 2.7.4
ares: 1.20.1
base64: 0.5.1
brotli: 1.0.9
cjs_module_lexer: 1.2.2
cldr: 44.0
icu: 74.1
llhttp: 9.1.3
modules: 120
napi: 9
nghttp2: 1.58.0
nghttp3: 0.7.0
ngtcp2: 0.8.1
openssl: 3.0.12+quic
simdutf: 4.0.4
tz: 2023c
undici: 5.28.1
unicode: 15.1
uv: 1.46.0
uvwasi: 0.0.19
v8: 11.8.172.17-node.17
zlib: 1.2.13.1-motley-5daffc7
os: linux x64
10.3.0
1.22.21

I created a new ember TS project using --typescript and when I generate a new component using for example:

ember g component table1

I get this interface definition in the file:

interface Table1Signature {
  // The arguments accepted by the component
  Args: {}
  // Any blocks yielded by the component
  Blocks: {
    default: []
  }
  // The element to which `...attributes` is applied in the component template
  Element: null
}

My ide (vscode) gives me warning on the line Args: {} saying:

Don't use `{}` as a type. `{}` actually means "any non-nullish value".
- If you want a type meaning "any object", you probably want `object` instead.
- If you want a type meaning "any value", you probably want `unknown` instead.
- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.
- If you really want a type meaning "any non-nullish value", you probably want `NonNullable<unknown>` instead.eslint[@typescript-eslint/ban-types](https://typescript-eslint.io/rules/ban-types)

Since I don't know ember internals I'm not sure if it's better to choose "object" or "unknown" (I would guess the former) as type for Args, but I suppose one of the two should be the default.

@bertdeblock
Copy link
Contributor

bertdeblock commented Jan 23, 2024

I think in this case, the solution would be to, either define some argument types, or comment out / remove Args: {} from the signature, indicating that the component does not accept any arguments.

@Polve
Copy link
Author

Polve commented Jan 24, 2024

either way the default blueprint should write this hint in the comments, and use a default that doesn't make linters complain

@bertdeblock
Copy link
Contributor

Feel free to make a PR over in ember-source. The component blueprint is located there, not in the ember-cli repo.

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

No branches or pull requests

2 participants