7.26.7 + ember-animated: Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
NullVoxPopuli opened this issue Β· comments
NullVoxPopuli commented
Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
74 | _inserted = false;
75 |
> 76 | @service('-ea-motion')
| ^
77 | motionService!: MotionService;
78 |
79 | didInsertElement() {
error log
=================================================================================
ENV Summary:
TIME: Wed Dec 15 2021 16:01:31 GMT-0500 (Eastern Standard Time)
TITLE: ember
ARGV:
- π /.volta/tools/image/node/16.13.0/bin/node
- /βοΈ/my-app/node_modules/.bin/ember
- s
EXEC_PATH: π /.volta/tools/image/node/16.13.0/bin/node
TMPDIR: /tmp
SHELL: /bin/bash
PATH:
- π /.volta/tools/image/yarn/1.22.17/bin
- π /.volta/tools/image/node/16.13.0/bin
- π /.volta/bin
- π /.pyenv/plugins/pyenv-virtualenv/shims
- π /.pyenv/shims
- π /.pyenv/bin
- /βοΈ/scripts/
- π /Applications
- π /apps/phantomjs/bin
- π /scripts/system-utils
- π /scripts/git
- π /scripts/rails
- π /scripts
- π /.volta/bin
- π /.local/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin
- π /.fzf/bin
- /usr/lib/go-1.13/bin
- /bin
- π /go/bin
PLATFORM: linux x64
FREEMEM: 1032192000
TOTALMEM: 18851196928
UPTIME: 498146.85
LOADAVG: 6.01,3.28,1.59
CPUS:
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz - 2400
ENDIANNESS: LE
VERSIONS:
- ares: 1.17.2
- brotli: 1.0.9
- cldr: 39.0
- icu: 69.1
- llhttp: 6.0.4
- modules: 93
- napi: 8
- nghttp2: 1.45.1
- nghttp3: 0.1.0-DEV
- ngtcp2: 0.1.0-DEV
- node: 16.13.0
- openssl: 1.1.1l+quic
- tz: 2021a
- unicode: 13.0
- uv: 1.42.0
- v8: 9.4.146.19-node.13
- zlib: 1.2.11
ERROR Summary:
- broccoliBuilderErrorStack: SyntaxError: /βοΈ/my-app/ember-animated/components/animated-beacon.ts: Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
74 | _inserted = false;
75 |
> 76 | @service('-ea-motion')
| ^
77 | motionService!: MotionService;
78 |
79 | didInsertElement() {
at File.buildCodeFrameError (/βοΈ/my-app/node_modules/@babel/core/lib/transformation/file/file.js:249:12)
at NodePath.buildCodeFrameError (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/index.js:139:21)
at Object.field (/βοΈ/my-app/node_modules/ember-animated/node_modules/@babel/plugin-transform-typescript/lib/index.js:69:22)
at /βοΈ/my-app/node_modules/ember-animated/node_modules/@babel/plugin-transform-typescript/lib/index.js:280:33
at Array.forEach (<anonymous>)
at PluginPass.Class (/βοΈ/my-app/node_modules/ember-animated/node_modules/@babel/plugin-transform-typescript/lib/index.js:272:31)
at newFn (/βοΈ/my-app/node_modules/@babel/traverse/lib/visitors.js:177:21)
at NodePath._call (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/context.js:100:31)
- code: [undefined]
- codeFrame: /βοΈ/my-appy/ember-animated/components/animated-beacon.ts: Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
74 | _inserted = false;
75 |
> 76 | @service('-ea-motion')
| ^
77 | motionService!: MotionService;
78 |
79 | didInsertElement() {
- errorMessage: ember-animated/components/animated-beacon.ts: /βοΈ/my-app/ember-animated/components/animated-beacon.ts: Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
74 | _inserted = false;
75 |
> 76 | @service('-ea-motion')
| ^
77 | motionService!: MotionService;
78 |
79 | didInsertElement() {
in /tmp/broccoli-2291805DEFcpumdhqTh/out-0706-analyzer_ember_auto_import_analyzer
at broccoli-persistent-filter:Babel > [Babel: ember-animated] (Babel: ember-animated)
- errorType: Build Error
- location:
- column: [undefined]
- file: ember-animated/components/animated-beacon.ts
- line: [undefined]
- treeDir: /tmp/broccoli-2291805DEFcpumdhqTh/out-0706-analyzer_ember_auto_import_analyzer
- message: ember-animated/components/animated-beacon.ts: /βοΈ/my-app/ember-animated/components/animated-beacon.ts: Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
74 | _inserted = false;
75 |
> 76 | @service('-ea-motion')
| ^
77 | motionService!: MotionService;
78 |
79 | didInsertElement() {
in /tmp/broccoli-2291805DEFcpumdhqTh/out-0706-analyzer_ember_auto_import_analyzer
at broccoli-persistent-filter:Babel > [Babel: ember-animated] (Babel: ember-animated)
- name: Error
- nodeAnnotation: Babel: ember-animated
- nodeName: broccoli-persistent-filter:Babel > [Babel: ember-animated]
- originalErrorMessage: /βοΈ/my-app/ember-animated/components/animated-beacon.ts: Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
74 | _inserted = false;
75 |
> 76 | @service('-ea-motion')
| ^
77 | motionService!: MotionService;
78 |
79 | didInsertElement() {
- stack: SyntaxError: /βοΈ/my-app/ember-animated/components/animated-beacon.ts: Definietly assigned fields and fields with the 'declare' modifier cannot be initialized here, but only in the constructor
74 | _inserted = false;
75 |
> 76 | @service('-ea-motion')
| ^
77 | motionService!: MotionService;
78 |
79 | didInsertElement() {
at File.buildCodeFrameError (/βοΈ/my-app/node_modules/@babel/core/lib/transformation/file/file.js:249:12)
at NodePath.buildCodeFrameError (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/index.js:139:21)
at Object.field (/βοΈ/my-app/node_modules/ember-animated/node_modules/@babel/plugin-transform-typescript/lib/index.js:69:22)
at /βοΈ/my-app/node_modules/ember-animated/node_modules/@babel/plugin-transform-typescript/lib/index.js:280:33
at Array.forEach (<anonymous>)
at PluginPass.Class (/βοΈ/my-app/node_modules/ember-animated/node_modules/@babel/plugin-transform-typescript/lib/index.js:272:31)
at newFn (/βοΈ/my-app/node_modules/@babel/traverse/lib/visitors.js:177:21)
at NodePath._call (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/βοΈ/my-app/node_modules/@babel/traverse/lib/path/context.js:100:31)
=================================================================================
The code that this comes from:
export default class AnimatedBeacon extends Component {
name: string | undefined;
layout: TemplateFactory = layout;
tagName = '';
_inserted = false;
@service('-ea-motion')
motionService!: MotionService;
didInsertElement() {
super.didInsertElement();
I don't see declare π€·
I probably need to figure out some lockfile changes (big monorepo, so I can't just re-roll it)
Kevin Pfefferle commented
I'm seeing this same issue even after upgrading all of my @babel/*
and caniuse-lite
sub-dependencies as suggested in #425 (comment)
NullVoxPopuli commented
same, I've even been trying to minimally reproduce the issue with:
// This file is only tested with Node 12+
/* eslint-disable node/no-unsupported-features/es-syntax */
'use strict';
const fs = require('fs/promises');
const os = require('os');
const path = require('path');
const execa = require('execa');
const root = path.join(__dirname, '..');
async function runTest() {
let tmpDirectory = await fs.mkdtemp(path.join(os.tmpdir(), 'ember-cli-babel-ember-new-test'));
let appName = 'my-app';
let appRoot = path.join(tmpDirectory, appName);
// Must be fully type-valid or else ember-cli crashes
// https://github.com/ember-cli/ember-cli/issues/9584
let decoratorsExample = `
import { inject as service } from '@ember/service';
import type RouterService from '@ember/routing/router-service';
export class A {
@service declare router: RouterService;
@service('router') _router!: RouterService;
get queryParams() {
return this.router.currentRoute.queryParams;
}
}
`
await execa('yarn', ['link'], { cwd: root, stdio: 'inherit' });
await execa('npx', ['ember-cli', 'new', appName, '--yarn', '--skip-git'], { cwd: tmpDirectory, stdio: 'inherit' });
await execa('ember', ['install', 'ember-cli-typescript'], { cwd: appRoot, stdio: 'inherit' });
// await execa('yarn', ['add', '@babel/preset-env@7.16.5'], { cwd: appRoot, stdio: 'inherit' });
// await execa('yarn', ['add', 'caniuse-lite@1.0.30001287'], { cwd: appRoot, stdio: 'inherit' });
await execa('yarn', ['link', 'ember-cli-babel'], { cwd: appRoot, stdio: 'inherit' });
await fs.writeFile(path.join(appRoot, 'app', 'decorators-example.ts'), decoratorsExample);
await execa('ember', ['test'], { cwd: appRoot, stdio: 'inherit' });
}
runTest();
but no dice.
It may be specific to the addon trees π€
NullVoxPopuli commented
resolved
Anthony Pessy commented
Stumbled upon this error today after updating ember-cli-babel to the latest version (7.26.11).
Apparently this is resolved but I'm not sure how.