I currently have an issue in an addon which I’m trying to convert to an Emberjs addon to the V2 version. It’s a component addon with the co-location layout and typescript in it. Something goes wrong with the compilation of the typescript giving me this error for basically every file: Error without type declaration
The error displayed above is when I disable the declaration of ts files in the rollup config. If I turn it on it’ll give this error: Error with type declaration
I’ve already checked the rollup and babel config may times so far and haven’t been able to find anything particularly wrong. I was wondering if anybody could help with this, I’ve been stuck on it for a few days now. This is the addon rollup.config.js
// @ts-nocheck
import ts from 'rollup-plugin-ts';
import { Addon } from '@embroider/addon-dev/rollup';
import { defineConfig } from 'rollup';
const addon = new Addon({
srcDir: 'src',
destDir: 'dist',
});
export default defineConfig({
output: addon.output(),
plugins: [
addon.publicEntrypoints([
'classes/*.js',
'components/**/*.js',
'helpers/*.js',
'services/*.js',
'transforms/*.js',
]),
addon.appReexports([
'components/**/*.js',
'helpers/*.js',
'services/*.js',
'transforms/*.js',
]),
ts({
transpiler: 'babel',
browserslist: ['last 2 firefox versions', 'last 2 chrome versions'],
tsconfig: {
fileName: 'tsconfig.json',
hook: (config) => ({
...config,
declaration: false,
declarationMap: true,
declarationDir: './dist',
}),
},
}),
addon.dependencies(),
addon.hbs(),
addon.keepAssets(['**/*.css']),
addon.clean(),
],
});
This is the babel.config,js
const { resolve } = require;
module.exports = {
presets: ['@babel/preset-typescript'],
plugins: [
[
resolve('@babel/plugin-transform-typescript'),
{
allowDeclareFields: true,
onlyRemoveTypeImports: true,
// Default enums are IIFEs
optimizeConstEnums: true,
},
],
[
resolve('@babel/plugin-proposal-decorators'),
{
// The stage 1 implementation
legacy: true,
},
],
[
resolve('@babel/plugin-proposal-class-properties'),
{
// Only support browsers that also support class properties...
// If all addons do this, it greatly reduces shipped JS
},
],
// eslint-disable-next-line node/no-missing-require
resolve('@embroider/addon-dev/template-colocation-plugin'),
resolve('@babel/plugin-proposal-private-methods'),
],
assumptions: {
// For legacy decorator support with class fields to work
setPublicClassFields: true,
privateFieldsAsProperties: true,
},
};
this is the tsconfig.json
const { resolve } = require;
module.exports = {
presets: ['@babel/preset-typescript'],
plugins: [
[
resolve('@babel/plugin-transform-typescript'),
{
allowDeclareFields: true,
onlyRemoveTypeImports: true,
// Default enums are IIFEs
optimizeConstEnums: true,
},
],
[
resolve('@babel/plugin-proposal-decorators'),
{
// The stage 1 implementation
legacy: true,
},
],
[
resolve('@babel/plugin-proposal-class-properties'),
{
// Only support browsers that also support class properties...
// If all addons do this, it greatly reduces shipped JS
},
],
// eslint-disable-next-line node/no-missing-require
resolve('@embroider/addon-dev/template-colocation-plugin'),
resolve('@babel/plugin-proposal-private-methods'),
],
assumptions: {
// For legacy decorator support with class fields to work
setPublicClassFields: true,
privateFieldsAsProperties: true,
},
};
The addon is also open source so anything else can be found at: Getflights.com / ember-field-components · GitLab